0
0

Hi,
I have a problem with sound latency. I have made a program where different sounds are played when typing different keys, either on a regular pc keyboard or on a music keyboard. There is one sound file of about 10 seconds length used within each octave, and the sound file is transposed to different frequencies when pressing different keys. The problem is that there often is a delay before the sound occurs when pressing a key, which doesn’t work, and sometimes the system even breaks down and I don’t get any sound at all. I wonder therefore if these problems could be solved, and the program could work as an ordinary keyboard instrument. I am working in C for Windows and the code I’m using is something like this:

[code:eogay1st]
result = FMOD_System_CreateSound(systemx, "soundfile.wav", FMOD_CREATESAMPLE | FMOD_HARDWARE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound[0]);

case WM_KEYDOWN:

switch (wParam)
{
case ‘D’: keynumber = 0; break;
case ‘F’: keynumber = 1; break;
case ‘G’: keynumber = 2; break;
case ‘H’: keynumber = 3; break;
case ‘J’: keynumber = 4; break;

//etc.
}

if (keyflag){
FMOD_Channel_SetPaused(channel[0], 1);
FMOD_System_Update(systemx);
result = FMOD_System_PlaySound(systemx, FMOD_CHANNEL_FREE, sound[0], 1, &channel[0]);
frequency = scale[keynumber];
FMOD_Channel_SetFrequency(channel[0], frequency);
FMOD_Channel_SetPaused(channel[0], 0);
}

keyflag = 0;
return 0;

case WM_KEYUP :

FMOD_Channel_SetPaused(channel[0], 1);
keyflag = 1;

[/code:eogay1st]

I also wonder what would be the best strategy if I want more than one key sound to sound simultaneously. Should I then for instance play each sound in a different channel.

It would be greatly appreciated if someone could help me with this. Thanks in advance.

Keitel

  • You must to post comments
0
0

End-to-end latency on a PC is a complicated topic, and there are a lot of places that delay can be introduced: keyboard hardware, operating system input drivers, FMOD itself, audio drivers, audio hardware.

You can try calling FMOD_System_SetDSPBufferSize() before initialising the system. Smaller and fewer mixblocks will improve the internal latency of FMOD. Also using FMOD_System_SetOutput(FMOD_OUTPUTTYPE_ASIO) to switch to an ASIO audio driver might help.

If you’re not getting any sound at all, what return codes are you getting from PlaySound? If you’re trying to hold down multiple keys to play a chord you need to look into keyboard ghosting issues http://www.microsoft.com/appliedscience … ained.mspx

  • You must to post comments
0
0

Hi,

Thank you very much , that was useful. I have tried using ASIO and it helps. I have also tried using the different ferquencies of the same sound in seperate channels and only use setpause to start and stop the sounds, and I don’t have the problem of sounds stopping anymore. I just hope this approach doesn’t require to much resources. I will also experiment with buffersize later. However, I have one question that I wonder if you maybe could answer. If I wanted to make the program into an embedded system with Windows CE to use for a keyboard instrument, could I then use basically the same program or is there other things I would have to consider?

Best regards
Keitel

  • You must to post comments
0
0

FMOD Ex doesn’t support Windows CE.

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.