Archived

This topic is now archived and is closed to further replies.

Gyannea

Delays in sound output

Recommended Posts

THough I am not writing a game program, I need real time response to sound. The program sends data over radios. The data bits are coded as tones of a specific frequency and duration. So, I create the digitized sine wave. To send the sounds I use the classic double buffering technique (under Windows). Buffer A is filled, Buffer B is filled and then two calls to ''waveOutWrite()'' are made. In the callback function, when the buffer is sent, one gets the MM_WOM_DONE message which also tells which buffer was just finished. So one loads that buffer and calls ''waveOutWrite()''. Now in theory, the other buffer should be sending at that time, so the flow should be continuous. However, there is a clear delay and a ''crack'' is heard at the rate of the buffer switching. How bad is it? Pretty bad. If I send some data signal at 1200 baud and make each buffer only large enough to hold two baud pulses, each buffer (should) last only 1/600th of a second. But if I send 600 of these items, the message takes SEVERAL seconds to send whereas it should take but one second. If I make the buffer large enough to hold one second''s worth of data, the message takes but a second to run. But no matter what I do, I lose some time EVERY time the buffer is switched. Am I doing something wrong or is it a fact that every call to ''waveOutWrite()'' takes a few milliseconds (maybe quite a few) to start the sending? (Not so with DOS32.) Does anyone know how I can send a continuous stream of data with NO loss of continuity in Windows? I''ve got a new 2.4 GHz Pentium with a soundblaster Live, so it''s not a hardware deficiency! Will Direct X solve this problem? From my understanding of game programmers, if they can''t do it, it can''t be done! Brian Reinhold

Share this post


Link to post
Share on other sites
I''ve got it perfect with DirectX but it is possible with WaveOut too because at least WinUAE does it. I know nothing of Waveout but In directX I use one looping buffer and write data ahead of the play position in blocks. It takes a bit of care because you can''t write over what hasn''t been played and you can''t play what hasn''t been written but when it works, it works.

Mark
Cornutopia Games
http://www.cornutopia.net
Bytten Independent Games Magazine
http://www.bytten.com

Share this post


Link to post
Share on other sites