0
votes

I have a question regarding the synchronization of 2 Directsound streams.

To record and play sound I currently use Portaudio to open 2 Directsound streams. There are 2 callback functions which are called every time the input buffer is filled and the output buffer needs data.

Now here`s my problem...

The input stream is running at 48kHz samplerate (@1024 samples). The output stream is running at 192kHz samplerate (@4096 samples). Every time the input buffer is filled and the callback is called I do some DSP and after that I convert the result to 192kHz. The output stream takes the result and outputs the data. Now the 2 streams are running completely out of sync.

I have looked through the entire Portaudio API but I cant`t find a sync option to lock the 2 streams together.

Is there any way to lock 2 Directsound streams? I really need 48kHz input and 192kHz output.

Br,

Vincent Bruinink.

1
You might have better luck with some API other than directsound.Bjorn Roche
Understood but Directsound and ASIO are the only ones that support 192kHz samplerate. ASIO can only open one stream instantly.Vincent Bruinink

1 Answers

1
votes

The thing is that you can't really open two streams "at the same time", nor can you open two devices (or even one device at two different sample rates) and expect them to stay truly in sync, even if they were, at one time, in sync. To understand why, you may want to read something about how audio works on a computer. You may also want to read this document, which is specific to PortAudio.

As an alternative, you may want to consider opening a single device in a single stream and using software sample-rate conversion.