0
0

I’m just starting to use FMOD library and I have one problem.

I’m trying to record a sound form microphone and play it. My cod looks like below:

[code:3qqw2dyr]
FMOD_SYSTEM *system;
FMOD_RESULT result;
FMOD_CHANNEL *channel = 0;
FMOD_SOUND *sound;

result = FMOD_System_Create(&system); // Create the main system object.
ERRCHECK( result);

result=FMOD_System_Init(system, 100,FMOD_INIT_NORMAL, 0);
ERRCHECK( result);

result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_WINMM);

int numdr;

result = FMOD_System_GetNumDrivers(system,&numdr);

Memo1->Lines->Add("Number of used device");
Memo1->Lines->Add(numdr);

int recorddriver;

result = FMOD_System_GetRecordNumDrivers(system,&recorddriver); 

    Memo1->Lines->Add("Number of device used for recording");
    Memo1->Lines->Add(recorddriver);

char name[256];
int count;
for (count=0; count < numdr; count++)
{
char name[256];

        result = FMOD_System_GetDriverInfo(system, count, name, 256, 0);
        ERRCHECK(result);
            Memo1-&gt;Lines-&gt;Add(&quot;Device Name&quot;);
            Memo1-&gt;Lines-&gt;Add(name);
        }

FMOD_CREATESOUNDEXINFO exinfo;

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

exinfo.cbsize           = sizeof(FMOD_CREATESOUNDEXINFO);
exinfo.numchannels      = 2;
exinfo.format           = FMOD_SOUND_FORMAT_PCM16;
exinfo.defaultfrequency = 44100;
exinfo.length           = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5;

result = FMOD_System_CreateSound(system, 0, FMOD_OPENUSER , &exinfo, &sound);
ERRCHECK(result);

result = FMOD_System_RecordStart(system, recorddriver, sound, 0);
ERRCHECK(result);

result = FMOD_System_PlaySound(system, FMOD_CHANNEL_REUSE, sound, 0, &channel);
ERRCHECK( result);[/code:3qqw2dyr]

Function for chcecking errors ERRCHECK:

[code:3qqw2dyr]void TForm1::ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
Memo1->Lines->Add("FMOD error! Błąd: "+*FMOD_ErrorString(result));
exit(0);
}
}
[/code:3qqw2dyr]

Problem occures when program reaches the line:

result = FMOD_System_RecordStart(system, recorddriver, sound, 0);
ERRCHECK(result);

then ERRCHECK returns error FMOD_ERR_INVALID_PARAM

but I have no idea which parameter could be invalid.

Readings from Memo1 are as follows:

Number of device used 1
Number of device used for recording 1
Device Name SoundMAX Digital Audio

What I’m doing wrong, please help me.

  • You must to post comments
0
0

You are getting an error from record start because you are passing in "recorddriver" which is the number of drivers available. So if you only have 1 record driver, it will be index 0, passing in 1 in this case is outside the valid range.

Changing your code to the following should work (it will use the default recording device):

[code:mlqzjswa]result = FMOD_System_RecordStart(system, 0, sound, 0); [/code:mlqzjswa]

  • You must to post comments
0
0

now is ok, thanks for help :)

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.