Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d7dec7
Switch all Jamulus audio sample processing to use floats instead of
hselasky Aug 20, 2020
d5ea08e
Merge pull request #535 from hselasky/floating_point
corrados Sep 26, 2020
7e3fb6a
variable renaming, fixes
corrados Sep 26, 2020
e0540e0
fix compilation error on Linux
corrados Sep 26, 2020
4c77ceb
bug fix
corrados Sep 26, 2020
17ef7cb
update
corrados Sep 26, 2020
3f1640d
fixes
corrados Sep 26, 2020
31650af
code style changes
corrados Sep 26, 2020
94ca039
fix clipping indicator for the client (does not yet work for the serv…
corrados Sep 26, 2020
349db41
clipping in the server seems to work (I tested again)
corrados Sep 26, 2020
a858fa1
a lot of code was from HPS, add him to the header
corrados Sep 26, 2020
be56f6c
Merge branch 'master' into integrate_float
corrados Sep 26, 2020
6c0796c
Merge branch 'master' into integrate_float
corrados Sep 26, 2020
d98f172
Merge branch 'master' into integrate_float
corrados Sep 27, 2020
47b0ae9
merge fix
corrados Sep 27, 2020
e9a1b9f
fixed compilation error
corrados Sep 27, 2020
d106c4d
Merge branch 'master' into integrate_float
corrados Sep 27, 2020
bb5cc54
bug fix: the meter fly back did not work correctly with the float type
corrados Sep 27, 2020
8a45af3
Minor scaling factor fixes
bflamig Sep 29, 2020
32026bd
Merge pull request #645 from bflamig/integrate_float
corrados Sep 30, 2020
615c52a
Merge branch 'master' into integrate_float
corrados Oct 1, 2020
3f64a91
Merge branch 'master' into integrate_float
corrados Oct 4, 2020
67aba98
merge fix: fix the changelog
corrados Oct 4, 2020
815e6c1
Merge branch 'master' into integrate_float
corrados Oct 4, 2020
6a2605c
small fixes
corrados Oct 4, 2020
287ca7d
the type for the CConvBuf is not always float but a template -> renam…
corrados Oct 4, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

3.5.12git <- NOTE: the release version number will be 3.5.13

- switched all audio sample processing to use floats, coded by hselasky (#544)

- bug fix: reduced server list is displayed instead of the normal list (#657)


Expand Down
22 changes: 10 additions & 12 deletions android/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/* Implementation *************************************************************/

CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<float>& pfData, void* arg ),
void* arg,
const int iCtrlMIDIChannel,
const bool ,
Expand Down Expand Up @@ -193,7 +193,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
iOpenSLBufferSizeStereo = 2 * iOpenSLBufferSizeMono;

// create memory for intermediate audio buffer
vecsTmpAudioSndCrdStereo.Init ( iOpenSLBufferSizeStereo );
vecfTmpAudioSndCrdStereo.Init ( iOpenSLBufferSizeStereo );

// TEST
#if ( SYSTEM_SAMPLE_RATE_HZ != 48000 )
Expand All @@ -205,7 +205,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
// 48 kHz / 16 kHz = factor 3 (note that the buffer size mono might
// be divisible by three, therefore we will get a lot of drop outs)
iModifiedInBufSize = iOpenSLBufferSizeMono / 3;
vecsTmpAudioInSndCrd.Init ( iModifiedInBufSize );
vecfTmpAudioInSndCrd.Init ( iModifiedInBufSize );

return iOpenSLBufferSizeMono;
}
Expand Down Expand Up @@ -238,19 +238,17 @@ oboe::DataCallbackResult CSound::onAudioReady ( oboe::AudioStream* oboeStream, v
memset ( audioData, 0, sizeof(float) * numFrames * oboeStream->getChannelCount() );

// Only copy data if we have data to copy, otherwise fill with silence
if ( !pSound->vecsTmpAudioSndCrdStereo.empty() )
if ( !pSound->vecfTmpAudioSndCrdStereo.empty() )
{
for ( int frmNum = 0; frmNum < numFrames; ++frmNum )
{
for ( int channelNum = 0; channelNum < oboeStream->getChannelCount(); channelNum++ )
{
// copy sample received from server into output buffer
const float fCurSam =
pSound->vecfTmpAudioSndCrdStereo[frmNum * oboeStream->getChannelCount() + channelNum];

// convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> (
pSound->vecsTmpAudioSndCrdStereo [frmNum * oboeStream->getChannelCount() + channelNum] );

floatData[frmNum * oboeStream->getChannelCount() + channelNum] = (float) iCurSam / _MAXSHORT;
floatData[frmNum * oboeStream->getChannelCount() + channelNum] = fCurSam;
}
}
}
Expand Down Expand Up @@ -282,13 +280,13 @@ oboe::DataCallbackResult CSound::onAudioReady ( oboe::AudioStream* oboeStream, v
{
for ( int channelNum = 0; channelNum < oboeStream->getChannelCount(); channelNum++ )
{
pSound->vecsTmpAudioSndCrdStereo[frmNum * oboeStream->getChannelCount() + channelNum] =
(short) floatData[frmNum * oboeStream->getChannelCount() + channelNum] * _MAXSHORT;
pSound->vecfTmpAudioSndCrdStereo [frmNum * oboeStream->getChannelCount() + channelNum] =
floatData[frmNum * oboeStream->getChannelCount() + channelNum];
}
}

// Tell parent class that we've put some data ready to send to the server
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
pSound->ProcessCallback ( pSound->vecfTmpAudioSndCrdStereo );
}

// locker.unlock();
Expand Down
6 changes: 3 additions & 3 deletions android/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class CSound : public CSoundBase, public oboe::AudioStreamCallback//, public IRenderableAudio, public IRestartable
{
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
CSound ( void (*fpNewProcessCallback) ( CVector<float>& pfData, void* arg ),
void* arg,
const int iCtrlMIDIChannel,
const bool ,
Expand All @@ -54,7 +54,7 @@ class CSound : public CSoundBase, public oboe::AudioStreamCallback//, public IRe

// these variables should be protected but cannot since we want
// to access them from the callback function
CVector<short> vecsTmpAudioSndCrdStereo;
CVector<float> vecfTmpAudioSndCrdStereo;

static void android_message_handler ( QtMsgType type,
const QMessageLogContext& context,
Expand All @@ -74,7 +74,7 @@ class CSound : public CSoundBase, public oboe::AudioStreamCallback//, public IRe
};

// TEST
CVector<short> vecsTmpAudioInSndCrd;
CVector<float> vecfTmpAudioInSndCrd;
int iModifiedInBufSize;

int iOpenSLBufferSizeMono;
Expand Down
15 changes: 6 additions & 9 deletions linux/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int CSound::Init ( const int /* iNewPrefMonoBufferSize */ )
iJACKBufferSizeStero = 2 * iJACKBufferSizeMono;

// create memory for intermediate audio buffer
vecsTmpAudioSndCrdStereo.Init ( iJACKBufferSizeStero );
vecfTmpAudioSndCrdStereo.Init ( iJACKBufferSizeStero );

return iJACKBufferSizeMono;
}
Expand Down Expand Up @@ -259,16 +259,13 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
{
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
{
pSound->vecsTmpAudioSndCrdStereo[2 * i] =
(short) ( in_left[i] * _MAXSHORT );

pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] =
(short) ( in_right[i] * _MAXSHORT );
pSound->vecfTmpAudioSndCrdStereo[2 * i] = in_left[i];
pSound->vecfTmpAudioSndCrdStereo[2 * i + 1] = in_right[i];
}
}

// call processing callback function
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
pSound->ProcessCallback ( pSound->vecfTmpAudioSndCrdStereo );

// get output data pointer
jack_default_audio_sample_t* out_left =
Expand All @@ -285,10 +282,10 @@ int CSound::process ( jack_nframes_t nframes, void* arg )
for ( i = 0; i < pSound->iJACKBufferSizeMono; i++ )
{
out_left[i] = (jack_default_audio_sample_t)
pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT;
pSound->vecfTmpAudioSndCrdStereo[2 * i];

out_right[i] = (jack_default_audio_sample_t)
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT;
pSound->vecfTmpAudioSndCrdStereo[2 * i + 1];
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions linux/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
class CSound : public CSoundBase
{
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
CSound ( void (*fpNewProcessCallback) ( CVector<float>& pfData, void* arg ),
void* arg,
const int iCtrlMIDIChannel,
const bool bNoAutoJackConnect,
Expand All @@ -78,7 +78,7 @@ class CSound : public CSoundBase

// these variables should be protected but cannot since we want
// to access them from the callback function
CVector<short> vecsTmpAudioSndCrdStereo;
CVector<float> vecfTmpAudioSndCrdStereo;
int iJACKBufferSizeMono;
int iJACKBufferSizeStero;
bool bJackWasShutDown;
Expand Down Expand Up @@ -111,7 +111,7 @@ class CSound : public CSoundBase
Q_OBJECT

public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* pParg ),
CSound ( void (*fpNewProcessCallback) ( CVector<float>& pfData, void* pParg ),
void* pParg,
const int iCtrlMIDIChannel,
const bool ,
Expand All @@ -122,12 +122,12 @@ class CSound : public CSoundBase
this, &CSound::OnTimer ); }
virtual ~CSound() {}
virtual int Init ( const int iNewPrefMonoBufferSize ) { CSoundBase::Init ( iNewPrefMonoBufferSize );
vecsTemp.Init ( 2 * iNewPrefMonoBufferSize );
vecfTemp.Init ( 2 * iNewPrefMonoBufferSize );
return iNewPrefMonoBufferSize; }
CHighPrecisionTimer HighPrecisionTimer;
CVector<short> vecsTemp;
CVector<float> vecfTemp;

public slots:
void OnTimer() { vecsTemp.Reset ( 0 ); if ( IsRunning() ) { ProcessCallback ( vecsTemp ); } }
void OnTimer() { vecfTemp.Reset ( 0 ); if ( IsRunning() ) { ProcessCallback ( vecfTemp ); } }
};
#endif // WITH_SOUND
24 changes: 12 additions & 12 deletions mac/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


/* Implementation *************************************************************/
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
CSound::CSound ( void (*fpNewProcessCallback) ( CVector<float>& pfData, void* arg ),
void* arg,
const int iCtrlMIDIChannel,
const bool ,
Expand Down Expand Up @@ -848,7 +848,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
iCoreAudioBufferSizeStereo = 2 * iCoreAudioBufferSizeMono;

// create memory for intermediate audio buffer
vecsTmpAudioSndCrdStereo.Init ( iCoreAudioBufferSizeStereo );
vecfTmpAudioSndCrdStereo.Init ( iCoreAudioBufferSizeStereo );

return iCoreAudioBufferSizeMono;
}
Expand Down Expand Up @@ -970,8 +970,8 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice,
for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ )
{
// copy left and right channels separately
pSound->vecsTmpAudioSndCrdStereo[2 * i] = (short) ( pLeftData[iNumChanPerFrameLeft * i + iSelInInterlChLeft] * _MAXSHORT );
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = (short) ( pRightData[iNumChanPerFrameRight * i + iSelInInterlChRight] * _MAXSHORT );
pSound->vecfTmpAudioSndCrdStereo[2 * i] = pLeftData[iNumChanPerFrameLeft * i + iSelInInterlChLeft];
pSound->vecfTmpAudioSndCrdStereo[2 * i + 1] = pRightData[iNumChanPerFrameRight * i + iSelInInterlChRight];
}

// add an additional optional channel
Expand All @@ -982,8 +982,8 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice,

for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ )
{
pSound->vecsTmpAudioSndCrdStereo[2 * i] = Double2Short (
pSound->vecsTmpAudioSndCrdStereo[2 * i] + pLeftData[iNumChanPerFrameLeft * i + iSelAddInInterlChLeft] * _MAXSHORT );
pSound->vecfTmpAudioSndCrdStereo[2 * i] = ClipFloat (
pSound->vecfTmpAudioSndCrdStereo[2 * i] + pLeftData[iNumChanPerFrameLeft * i + iSelAddInInterlChLeft] );
}
}

Expand All @@ -994,19 +994,19 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice,

for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ )
{
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] = Double2Short (
pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] + pRightData[iNumChanPerFrameRight * i + iSelAddInInterlChRight] * _MAXSHORT );
pSound->vecfTmpAudioSndCrdStereo[2 * i + 1] = ClipFloat (
pSound->vecfTmpAudioSndCrdStereo[2 * i + 1] + pRightData[iNumChanPerFrameRight * i + iSelAddInInterlChRight] );
}
}
}
else
{
// incompatible sizes, clear work buffer
pSound->vecsTmpAudioSndCrdStereo.Reset ( 0 );
pSound->vecfTmpAudioSndCrdStereo.Reset ( 0 );
}

// call processing callback function
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
pSound->ProcessCallback ( pSound->vecfTmpAudioSndCrdStereo );
}

if ( ( inDevice == pSound->CurrentAudioOutputDeviceID ) && outOutputData )
Expand All @@ -1028,8 +1028,8 @@ OSStatus CSound::callbackIO ( AudioDeviceID inDevice,
for ( int i = 0; i < iCoreAudioBufferSizeMono; i++ )
{
// copy left and right channels separately
pLeftData[iNumChanPerFrameLeft * i + iSelOutInterlChLeft] = (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i] / _MAXSHORT;
pRightData[iNumChanPerFrameRight * i + iSelOutInterlChRight] = (Float32) pSound->vecsTmpAudioSndCrdStereo[2 * i + 1] / _MAXSHORT;
pLeftData[iNumChanPerFrameLeft * i + iSelOutInterlChLeft] = (Float32) pSound->vecfTmpAudioSndCrdStereo[2 * i];
pRightData[iNumChanPerFrameRight * i + iSelOutInterlChRight] = (Float32) pSound->vecfTmpAudioSndCrdStereo[2 * i + 1];
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions mac/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class CSound : public CSoundBase
{
public:
CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ),
CSound ( void (*fpNewProcessCallback) ( CVector<float>& pfData, void* arg ),
void* arg,
const int iCtrlMIDIChannel,
const bool ,
Expand All @@ -63,7 +63,7 @@ class CSound : public CSoundBase

// these variables should be protected but cannot since we want
// to access them from the callback function
CVector<short> vecsTmpAudioSndCrdStereo;
CVector<float> vecfTmpAudioSndCrdStereo;
int iCoreAudioBufferSizeMono;
int iCoreAudioBufferSizeStereo;
AudioDeviceID CurrentAudioInputDeviceID;
Expand Down
20 changes: 10 additions & 10 deletions src/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,16 @@ template<class TData> class CConvBuf
}
}

void PutAll ( const CVector<TData>& vecsData )
void PutAll ( const CVector<TData>& vecData )
{
iGetPos = 0;

std::copy ( vecsData.begin(),
vecsData.begin() + iBufferSize, // note that input vector might be larger then memory size
std::copy ( vecData.begin(),
vecData.begin() + iBufferSize, // note that input vector might be larger then memory size
vecMemory.begin() );
}

bool Put ( const CVector<TData>& vecsData,
bool Put ( const CVector<TData>& vecData,
const int iVecSize )
{
// calculate the input size and the end position after copying
Expand All @@ -519,8 +519,8 @@ template<class TData> class CConvBuf
if ( iEnd <= iBufferSize )
{
// copy new data in internal buffer
std::copy ( vecsData.begin(),
vecsData.begin() + iVecSize,
std::copy ( vecData.begin(),
vecData.begin() + iVecSize,
vecMemory.begin() + iPutPos );

// set buffer pointer one block further
Expand All @@ -540,18 +540,18 @@ template<class TData> class CConvBuf
return vecMemory;
}

void GetAll ( CVector<TData>& vecsData,
void GetAll ( CVector<TData>& vecData,
const int iVecSize )
{
iPutPos = 0;

// copy data from internal buffer in given buffer
std::copy ( vecMemory.begin(),
vecMemory.begin() + iVecSize,
vecsData.begin() );
vecData.begin() );
}

bool Get ( CVector<TData>& vecsData,
bool Get ( CVector<TData>& vecData,
const int iVecSize )
{
// calculate the input size and the end position after copying
Expand All @@ -563,7 +563,7 @@ template<class TData> class CConvBuf
// copy new data from internal buffer
std::copy ( vecMemory.begin() + iGetPos,
vecMemory.begin() + iGetPos + iVecSize,
vecsData.begin() );
vecData.begin() );

// set buffer pointer one block further
iGetPos = iEnd;
Expand Down
Loading