Hi,
Does anyone have a simple example of FMOD simply taking in the audio input and routing into a callback loop for output?
My platform is iOS, with other mobile devices planned. At the moment I only need access to the input buffer from within a single for loop type custom callback buffer. I’m not intending on using any of the fx or soudfile playback functions.
I’m chomping at the bit to get started with my project and any advice would be greatly appreciated.
Thanks,
Casey
- caseyjames asked 5 years ago
- You must login to post comments
More simply, can someone post just the code that will allow audio input from the device, without recording it.
Is this not possible?
I have been searching both the forum and google and have found nothing.
- caseyjames answered 5 years ago
- You must login to post comments
[quote="caseyjames":26itmd49]More simply, can someone post just the code that will allow audio input from the device, without recording it.
Is this not possible?
I have been searching both the forum and google and have found nothing.[/quote:26itmd49]
Is this what you are looking for?
[code:26itmd49]
memset(&ExInfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));
ExInfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO);
ExInfo.numchannels = 1;
ExInfo.format = FMOD_SOUND_FORMAT_PCM16;
ExInfo.defaultfrequency = Freq;
ExInfo.length = BufferSize;
Result = _Data.System->createSound(0, FMOD_2D | FMOD_SOFTWARE | FMOD_OPENUSER, &ExInfo, &_Data.Sound);
Result = _Data.Sound->getLength(&SoundLength, FMOD_TIMEUNIT_PCM);
/********************durring the update loop********************************/
Result = _Data.System->getRecordPosition(_Data.DriverId, &CurrentPosition);
if(Result)
{
return ;
}
CurrentPosition *= _Data.BytesPerSample;
BytesInBuffer = CurrentPosition - _Data.LastRecordPosition;
if (BytesInBuffer < 0)
{
BytesInBuffer += _Data.BufferSize;
}
/**** and to retrieve the data ***********/
static int _ProcessBytesInBuffer(int BytesToProcess)
{
FMOD_RESULT Result;
void *Ptr1, *Ptr2;
unsigned int Length1, Length2;
int NextByte;
NextByte = 0;
Result = _Data.Sound->lock(_Data.LastRecordPosition,
BytesToProcess, &Ptr1, &Ptr2, &Length1, &Length2); /* * ExInfo.numchannels * 2 = stereo 16bit. 1 sample = 4 bytes. */
if(Result)
{
return 0;
}
if (Ptr1 && Length1)
{
_CopyToBuf(&_Data.TranserBuffer[NextByte],Ptr1,Length1);
NextByte += Length1;
}
if (Ptr2 && Length2)
{
_CopyToBuf(&_Data.TranserBuffer[NextByte],Ptr2,Length2);
NextByte += Length2;
}
_Data.Sound->unlock(Ptr1, Ptr2, Length1, Length2);
_Data.LastRecordPosition += BytesToProcess;
_Data.LastRecordPosition %= _Data.BufferSize;
_ProcessMicData(_Data.TranserBuffer,BytesToProcess);
_Data.TransmitTime += (float)BytesToProcess /_Data.Freq * 0.5f;
return 0;
}
[/code:26itmd49]
- HiTech answered 5 years ago
- You must login to post comments
Please login first to submit.