0
0

Hello,

First I’d like to thanks the dev. team for their hard work.

I’m trying to make a very simple application in order mimic a dsp card, so I can record a voice and apply real time effects.

Here’s my main function to demonstrate what I’m trying to do :

[code:1cmkail7]

int main(int argc, char *argv[])
{
FMOD_SYSTEM *system = 0;
FMOD_SOUND *sound = 0;
FMOD_CHANNEL *channel = 0;
FMOD_RESULT result;
FMOD_CREATESOUNDEXINFO exinfo;
int key, driver, numdrivers, count, bin;
unsigned int version;

/*
    Create a System object and initialize.
*/
result = FMOD_System_Create(&system);
ERRCHECK(result);

result = FMOD_System_GetVersion(system, &version);
ERRCHECK(result);

if (version < FMOD_VERSION)
{
    printf("Error!  You are using an old version of FMOD %08x.  This program requires %08x\n", version, FMOD_VERSION);
    return 0;
}

/*
    System initialization
*/
printf("---------------------------------------------------------\n");
printf("Select OUTPUT type\n");
printf("---------------------------------------------------------\n");
printf("1 :  DirectSound\n");
printf("2 :  Windows Multimedia WaveOut\n");
printf("3 :  ASIO\n");
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");

do
{
    key = getch();
} while (key != 27 && key < '1' && key > '5');

switch (key)
{
    case '1' :  result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_DSOUND);
                break;
    case '2' :  result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_WINMM);
                break;
    case '3' :  result = FMOD_System_SetOutput(system, FMOD_OUTPUTTYPE_ASIO);
                break;
    default  :  return 1;
}
ERRCHECK(result);

/*
    Enumerate playback devices
*/

result = FMOD_System_GetNumDrivers(system, &numdrivers);
ERRCHECK(result);

printf("---------------------------------------------------------\n");
printf("Choose a PLAYBACK driver\n");
printf("---------------------------------------------------------\n");
for (count=0; count < numdrivers; count++)
{
    char name[256];

    result = FMOD_System_GetDriverInfo(system, count, name, 256, 0);
    ERRCHECK(result);

    printf("%d : %s\n", count + 1, name);
}
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");

do
{
    key = getch();
    if (key == 27)
    {
        return 0;
    }
    driver = key - '1';
} while (driver < 0 || driver >= numdrivers);

result = FMOD_System_SetDriver(system, driver);
ERRCHECK(result);

/*
    Enumerate record devices
*/

result = FMOD_System_GetRecordNumDrivers(system, &numdrivers);
ERRCHECK(result);

printf("---------------------------------------------------------\n");
printf("Choose a RECORD driver\n");
printf("---------------------------------------------------------\n");
for (count=0; count < numdrivers; count++)
{
    char name[256];

    result = FMOD_System_GetRecordDriverInfo(system, count, name, 256, 0);
    ERRCHECK(result);

    printf("%d : %s\n", count + 1, name);
}
printf("---------------------------------------------------------\n");
printf("Press a corresponding number or ESC to quit\n");

do
{
    key = getch();
    if (key == 27)
    {
        return 0;
    }
    driver = key - '1';
} while (driver < 0 || driver >= numdrivers);

printf("\n");

result = FMOD_System_SetRecordDriver(system, driver);
ERRCHECK(result);

result = FMOD_System_SetSoftwareFormat(system, OUTPUTRATE, FMOD_SOUND_FORMAT_PCM16, 1, 0, FMOD_DSP_RESAMPLER_LINEAR);
ERRCHECK(result);

result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);

/*
    Create a sound to record to.
*/
memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO));

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

result = FMOD_System_CreateSound(system, 0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &sound);
ERRCHECK(result);

/*
    Start the interface
*/
printf("=========================================================================\n");
printf("Pitch detection example.  Copyright (c) Firelight Technologies 2004-2008.\n");
printf("=========================================================================\n");
printf("\n");
printf("Record something through the selected recording device and FMOD will\n");
printf("Determine the pitch.  Sustain the tone for at least a second to get an\n");
printf("accurate reading.\n");
printf("Press 'Esc' to quit\n");
printf("\n");

result = FMOD_System_RecordStart(system, sound, TRUE);
ERRCHECK(result);

Sleep(200);                         /* Give it some time to record something */

result = FMOD_System_PlaySound(system, FMOD_CHANNEL_REUSE, sound, FALSE, &channel);
ERRCHECK(result);

bin = 0;

FMOD_DSP        *dspecho       = 0;
FMOD_DSP        *dspdistortion = 0;
FMOD_DSP        *dsppitch = 0;
FMOD_DSP        *dspreverb = 0;

result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_REVERB, &dspreverb);
ERRCHECK(result);
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_PITCHSHIFT, &dsppitch);
ERRCHECK(result);

result = FMOD_System_AddDSP(system, dsppitch, 0);
ERRCHECK(result);
result = FMOD_System_AddDSP(system, dspreverb, 0);
ERRCHECK(result);

result = FMOD_DSP_SetParameter(dsppitch, FMOD_DSP_PITCHSHIFT_PITCH, 1.5f);
ERRCHECK(result);
result = FMOD_DSP_SetParameter(dsppitch, FMOD_DSP_PITCHSHIFT_FFTSIZE, 4096);
ERRCHECK(result);

/*
    Main loop.
*/
do
{
    static float spectrum[SPECTRUMSIZE];
    float        dominanthz = 0;
    float        max;
    int          dominantnote = 0;
    float        binsize = BINSIZE;

    if (kbhit())
    {
        key = getch();
    }

    FMOD_System_Update(system);

    Sleep(10);

} while (key != 27);

printf("\n");

result = FMOD_Sound_Release(sound);
ERRCHECK(result);

result = FMOD_System_Release(system);
ERRCHECK(result);

return 0;

}
[/code:1cmkail7]

My question is about ASIO and especially the latency. As I can see in some threads, it should be about XXms. Running my program, it give me a latency around 2-3 second and sometime more, so direct sound is much faster but not enough for my needs.

I’m using :
* a quite new laptop
* an external sound blaster live card
* a pre-amplifier for the microphone
* asio drivers "ASIO4ALL v2.8"

I’ve really no idea how I can bypass this problem, is it the throughput which is too low, or a problem with my sound card ?

Thanks for your help in advance !

[/quote]

  • You must to post comments
0
0

ASIO4ALL is a wrapper for directsound, not a real asio driver for your hardware. You will have to find a native ASIO driver for your sound device.

  • You must to post comments
0
0

If you have an x-fi card, try to use 96kHz sampling and to reduce the buffer size. I can get 7ms with ASIO4ALL and my x-fi card on my laptop in such a configuration.

BTW, creative drivers are worthless.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.