Direct Sound vs Multi Media API
How much faster is using Direct Audio of the Direct X library versus using API functions like ''waveOutWrite()''? I need real-time performance since the sounds are time critical.
Is there a Direct X analog for recording? It appears that Direct X only has playback options.
Any knowledge about these guys will be greatly appreciated! Sound analysis (both in and out) is the essential core of this application. Everything else just makes it look pretty!
Brian Reinhold
Brian Reinhold
direct audio will be much faster than the win32 API functions since it accesses the hardware directly.
Also, direct audio does have support for both recording and playback.
digital radiation
Also, direct audio does have support for both recording and playback.
digital radiation
Directrix,
Do you have any idea how quickly I can send a data buffer to the sound card via Direct X? When using the API like ''waveOutWrite()'', it seems like once a buffer is finished and ''waveOutWrite()'' with the other buffer has already been called, that it takes a fair amount of time to get the impending buffer started once the other has finished.
At a 44 Khz sampling rate you have 44 K data words being fed to the card per second. When buffer A finishes, buffer B needs to start and to be "continuous", it should have it''s first word out to the sound card 1/44,000 th of a second after the last data word from buffer A was sent.
I take it that ''waveOutWrite()'' can''t do that.
(I am hoping Direct X can so it''s worth the sweat of doing it!)
Brian Reinhold
Do you have any idea how quickly I can send a data buffer to the sound card via Direct X? When using the API like ''waveOutWrite()'', it seems like once a buffer is finished and ''waveOutWrite()'' with the other buffer has already been called, that it takes a fair amount of time to get the impending buffer started once the other has finished.
At a 44 Khz sampling rate you have 44 K data words being fed to the card per second. When buffer A finishes, buffer B needs to start and to be "continuous", it should have it''s first word out to the sound card 1/44,000 th of a second after the last data word from buffer A was sent.
I take it that ''waveOutWrite()'' can''t do that.
(I am hoping Direct X can so it''s worth the sweat of doing it!)
Brian Reinhold
Brian Reinhold
March 04, 2003 03:23 PM
waveOut calls can be queued; you don''t have to wait for one block to be finished to send the next. I wrote many games with waveOut API (pre DX time) and used it even then DSound become available. waveOut is fine if you need something simple, but most games should use DSound/DMusic.
"waveOut calls can be queued; you don''t have to wait for one block to be finished to send the next."
I don''t. Using a double buffering approach I call the waveOut function back to back with the two buffers. And then in the callback function when the MM_WOM_DONE message appears, i fill the emptied buffer with more data and call waveOut.
However, doing such has a delay. If I am sending audio tones at a rate of 100 baud (the tones represent bit values of data to be sent over radio and are pure sinusiods) and make the buffer a size such that it holds but 1 baud pulse, the time it takes to send 1000 bits is longer than a second! And at every baud pulse the is noise. One can slow the operation down and one hears noise at the rate of the buffer switching.
For music with one or more seconds of data this is probably not a problem, but since these tones are synchronous encoded data the timeing is critical.
Am I doing something wrong using ''waveOutWrite()''?
If my sound card sampling rate is 44 K, will the time between the last data word of buffer A sent and the first data word of buffer B be fast enough that the sound card gets it 1/44,000 th of a second later?
Brian Reinhold
March 04, 2003 04:35 PM
I see. Well, waveOut was not designed for this kind of use. You will have to go with DSound. Use single looping buffer and fill it in continuously. Use separate thread if necessary.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement