0
0

I am making double-buffered input with FMODEX, with 16-bits stereo 44.1khz samples/sec (is that too much ?).

Due to latency, I have flickering difficulties.
Is there any way other than FMOD_SYSTEM_IsRecording or FMOD_GetRecordPosition to know whether the recording for a buffer is complete ? Is there a callback system ?

Thanx

  • You must to post comments
0
0

System::getRecordPosition is very accurate, so i’m not sure what else you could use. Thinks like directsound recording api dont give you a callback so if we added one ourselves it would just be doing what you would be doing. The 2 recording examples show how to use the getposition to read data as fast as possible.

  • You must to post comments
0
0

ok, I think it should work.
I was disapointed because the WinMM API give us a callback after a record.
thanks again

  • You must to post comments
0
0

It does not work at all.
I can’t rid off with these ‘click’

I record and play in the same time to use EAX reverb. The buffers are
my code looks like that :

FMOD_SOUND buf[2];
int current = 0;
FMOD_CHANNEL channel = 0;
FMOD_SYSTEM system;
const int REPEAT = 0;
const int SAMPLES = 4096; // for example

void swapbuffers() { // suppose that that stuff works as it should work
current = 1-current;
system->Stoprecord();
channel->Stop();
system->play(FMOD_CHANNEL_REUSE, buf[current],false, channel);
system->Startrecord(buf[1-current],REPEAT);
}

[…init…]
while(1) {
int position;
bool isrecording;
while (1) {
system->getRecordposition(&position);
system->isRecording(&isrecording);
if (! isrecording) || (( abs( position – SAMPLES ) < 30 ))
{
break;
}
}
swapbuffers;
}
[…deinit…]

I cannot play and record at the same time a buffer, that’s why I have two buffers.
Changing the size of the sound is useless.
I am always checking system:getRecordPosition() and even then there is a ‘clic’ on swapping.

please help !

  • You must to post comments
0
0

The record example already does this, you just need to start playing a bit after you start recording. You cant play data that is still being recorded to, that will click.

You shouldnt be ‘swapping buffers’. Just call playSound on the record sound.

  • You must to post comments
0
0

Hi,

I have a similar problem. I want to do some real-time signal processing, so basically I want to record it, process it, then output it as fast as possible (I’d like to try to simulate a guitar amp).
I think that the problem might be that if I record at 44100 Hz for example, the recording pointer writes data to the buffer every 441 samples… but that’s only 0.002 seconds and shouldn’t be audible.
My problem is that there’s too much delay between the recorded sound and the played one (believe me, you can’t play guitar like that 😉 ). This delay seems longer than 0.02 seconds…

Also, this works with FMOD_HARDWARE on FMOD Ex 0.4.3.2 but not on 0.4.4.0 anymore (where only FMOD_SOFTWARE works)… any idea why? (BTW, the delay seems shorter with FMOD_HARDWARE)

This is on win32 with a SB card (tested on a live player and an audigy 2 zs)

Here’s the relevant part of my code, where I’m just trying to output what’s recorded:

[code:2e2f95sw]int main(int argc, char *argv[])
{
InitSoundSystem();

FMOD_CREATESOUNDEXINFO exinfo;
FMOD_SOUND *pSound;
FMOD_CHANNEL *pChannel;

memset(&amp;exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));

exinfo.cbsize           = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels      = 1;
exinfo.format           = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = 44100;
exinfo.decodebuffersize = 0;
exinfo.length           = unsigned int(exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5);

FMOD_System_CreateSound(pSystem, 0, FMOD_2D | FMOD_HARDWARE | FMOD_OPENUSER, &amp;exinfo, &amp;pSound);

FMOD_System_RecordStart(pSystem, pSound, true);


unsigned int uiPos;
do
{
    FMOD_System_GetRecordPosition(pSystem, &amp;uiPos);
    FMOD_System_Update(pSystem);
} while( uiPos &lt; 10 );

printf(&quot;%6d\n&quot;, uiPos); // Displays 882 or 441 sometimes

FMOD_System_PlaySound(pSystem, FMOD_CHANNEL_REUSE, pSound, true, &amp;pChannel);
FMOD_Channel_SetMode(pChannel, FMOD_LOOP_NORMAL);
FMOD_Channel_SetPaused(pChannel, false);
FMOD_Channel_SetPosition(pChannel, 0, FMOD_TIMEUNIT_PCM);
FMOD_System_Update(pSystem);

int key = 0;

do
{
    if( _kbhit() )
    {
        key = _getch();
    }
    FMOD_System_Update(pSystem);
} while(key != 27);

if( pChannel )
    FMOD_Channel_Stop(pChannel);
FMOD_System_RecordStop(pSystem);
FMOD_Sound_Release(pSound);

ShutdownSoundSystem();

return 0;

}
[/code:2e2f95sw]

  • You must to post comments
0
0

Hi,
Ok, well your delay of 10 is too small, because recording and playback is processed in much larger chunks than that.
For directsound/win32 you have to use around a 40-100ms delay (experiment a bit), which you might as well just do with a Sleep(40 to 100) rather than polling the position.

Seriously, if you want low latency, you have to use ASIO. Waveout/Directsound are not built for this, and all you can do is minimize a latency which is going to be probably up to 100ms.

With ASIO FMOD uses its simultaneous record/playback feature right in the
mixer so you don’t have to do any delay at all, and the latency is really reallly low. I’ve had the record to play latency as low as a few ms.

  • You must to post comments
0
0

Thank you very much!! :)

I guess I missed it in the doc 😳

I’ll take a closer look at this.

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.