It sounds as if you want to solve it by 'the hard coded way', but if you haven't thought about or heard of, here's another elegant way for doing this :
fmod.dll (or bass.dll although, I think, but there's a PB-Import for fmod.) does this job very well and comfortable. One advantage is, that you can use this buffer with any outputdriver (DSound, WinMM, ALSA, etc.) on Windows, Linux, ....
And I
think it uses double buffer: while one buffer (~25 ms by default) is played by the soundcard, the other one passes through the whole mixer- and DSP-routines and may be filled somewhere there with your data.
There are different ways to fill the buffer, an easy one is to create a stream 'on scratch' with a callback-function of type:
Code: Select all
Procedure.l Buffercallback(*hStream.l, *BufferPointer.l, length.l, param.l)
This procedure is called each time when the new buffer requests further data. So you can easily fill the buffer with raw 16Bit-stereo-data now.
Using a stream-callback for this allows your data to pass the whole mixer and DSP-chain before being copied to the soundcard, so you can do anything that you want with it (pitching, volume, DSP-FX, FFT,...)
Other possibilities are:
- Using a Sample with Sample-Upload.
- Using a DSP-unit
You might have a look at SineMouse or Realtime-Keys at
http://fmod.2mal2mal.de
But keep in mind that fmod / bass are not free for non-free software.