I use Visual C++6.0 and Windows XP (SP1) and write on a tool,
where high time-precision audio-output is very important.
But it doesn’t work in any way.
I think, there is no problem with setTimerEvent(), because when I use
for example the PC-Speaker “Beep-Output”, the delays between
the beeps are the same.
But when I play a sample-sound thru DirectSound,
I can clearly hear the different delays between the sample-outputs.

And it doesn’t play a role, if I use my SoundBlaster Live or the
onboard-sound, also with different drivers or deactivated HW-acceleration… It’s still the same problem.

Same issues under Win98, where I have used a little test-program, too.
And before I forget it: Actual audio-sequencer-software, which i have
tested, doesn’t have such timing-problems on my system.

Because I haven’t any idea to solve this problem, I post my test-program

You can see, I use fmod-library for audio-output, but that’s not the
problem, because typical directsound-programming with primary/secondary buffers have the same issue, too.
It’s a console-application with some mfc-stuff you can ignore.

// Audiotests2.cpp

include “stdafx.h”

include “Audiotests2.h”

include <mmsystem.h>

include “fmod.h”

include “conio.h”

void CALLBACK CBPlaySample(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1,
DWORD dw2);

CWinApp theApp;
using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
int nRetCode = 0;

// MFC init
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
cerr << _T(“Fatal Error: MFC initialization failed”) << endl;
nRetCode = 1;
// Timer init
MMRESULT timerevent;
bool ok=true;
TIMECAPS timecaps;
UINT mintimer=5;
int systime=timeGetTime();



// Sound-System init


printf(“<Key for break>”);

return nRetCode;

// Callback-Funktion for Timer
void CALLBACK CBPlaySample(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1,
DWORD dw2)
//printf(“#### “);

You can see, a simple primitive code, but I cannot use it for a precision

Is there anyone, who can tell me, what’s wrong with the timing?
It’s a kind of mystery.

Perhaps I can’t do that what I like (multichannel-playback of different samples like a sequencer) in fmod or directsound in this kind of way.

Thanks for any help.

Robbson. :(

  • You must to post comments

But that’s not the problem!

In the Windows SDK, you can read, that this kind of timer-programming is a very good solution for applications like sequencers, where high precision is very important.
But I cannot use it on the shown (easy) way: Simple play
of a sound (you can do it with DirectSound without fmod, it’s the same problem) in the timer-callback-function.

That’s nothing with the 25ms mixer of fmod, or are your
MOD-Songs playing with FMusic in any way inaccurate in timing?
I think not.

So, how can I exactly time my sounds for a sequencer-like application?
Is the only way, the programming of an own buffer in form of a stream?
But I cannot see any examples with streams (without reading from a disk) that I can use for my issue.
The sample-program in the fmod-package “stream2” is a little
bit too complicated to understand all the callbacks in short time.

Only if I can master this timing-problem, I can step deep into the interesting fmod-programming for my audio-application.

Greetings from Germany,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.