-
Notifications
You must be signed in to change notification settings - Fork 241
Switch all Jamulus audio sample processing to use floats instead of a mix of double and int16_t #535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch all Jamulus audio sample processing to use floats instead of a mix of double and int16_t #535
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ | |
|
|
||
| /* Implementation *************************************************************/ | ||
|
|
||
| CSound::CSound ( void (*fpNewProcessCallback) ( CVector<short>& psData, void* arg ), | ||
| CSound::CSound ( void (*fpNewProcessCallback) ( CVector<float>& psData, void* arg ), | ||
| void* arg, | ||
| const int iCtrlMIDIChannel, | ||
| const bool , | ||
|
|
@@ -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 ) | ||
|
|
@@ -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; | ||
| } | ||
|
|
@@ -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 | ||
|
|
||
| // 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; | ||
| const float fCurSam = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you compiled and run the Android code to check that it works with your modifications? Or did you just change the code and have not compiled or tested it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I haven't check Android. Need some help here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, I cannot compile Jamulus for Android. The Android development was done mainly by Simon. But as far as I know, he still had issues on the Android platform. So maybe we can live with the fact that the changes in the Android interface are very small. So I think it is ok to take your changes untested. |
||
| pSound->vecfTmpAudioSndCrdStereo [frmNum * oboeStream->getChannelCount() + channelNum]; | ||
| floatData[frmNum * oboeStream->getChannelCount() + channelNum] = fCurSam; | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -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(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.