[solved] Problem with DirectSound capturing input [solved]

Started by
1 comment, last by Omega147 18 years ago
Hey all, Working on a program which needs to process live audio, and I am using managed DirectSound with C#. I've adapted my code from the CaptureSound example in the DX9 SDK, but I've found a bizarre bug which I cannot for the life of me track down, I don't know enough about how it all works. The program involves beat detection, but that is not important to this query. What I'm doing (as I understand the code) is filling a CaptureBuffer with the audio, and a notification thread calls a BufferFullDo() function whenever it reaches a notification position. Using 44100Hz, 8bit, mono, that gives (by default, from the MS code) a notification size of 5512 samples, so the CaptureBuffer is 2 times that, i.e. 11024 samples. There are two notification positions in it, one at 5512 and one at 11024. What should happen, then, is that every time the buffer reaches one of these positions (i.e. 5512 samples of audio), it calls BufferFullDo() and writes these 5512 samples to disk (giving a raw PCM file). It works - sort of - but testing it, something odd is happening - only every other full buffer is being written, i.e. it'll write 5512 samples then the next 5512 samples are skipped - I've tested this with an input of 5512 samples at one frequency, 5512 at another - you only get one of them in the output. I'm pretty sure the problem is that BufferFullDo() is never getting called for the second 5512 samples in the buffer, but I've been trying for hours to figure out where I've gone wrong and hit something of a brick wall. I'm sure it's trivial, so if anyone could take a look at the code and advise me on what I've done wrong, I'd be eternally greatful. The code (or the relevant sections) are at: http://pastebin.com/628293 (I've chopped bits out, so it might not compile as it is there). Please save me ;) Cheers, Tom [Edited by - authortitle on March 29, 2006 11:38:31 AM]
Advertisement
Ignore me, another night of my life wasted... just copied the code back from the MS version and then altered it to have all my beat detection stuff and it worked again. Could've sworn I didn't change it but can't be bothered checking one against the other to see how stupid I was lol.
Change the topic to include "Solved" if you can, so people glancing by at this thread know it's been resolved.

This topic is closed to new replies.

Advertisement