DirectSound Secondary Buffer problem
-
Hi, I want to create an application that plays the sound recorded from the microphone. I succeeded in capturing the sound from the mic using CaptureBuffer....my problem is when using the data from this buffer to play it with SecondaryBuffer. I'm using a memory stream to get the data from the capture buffer to a stream. When I capture the data from the mic I use the following code. CaptureData is a byte array.
memStream.Write(CaptureData, 0, CaptureData.Length); secBuffer = new SecondaryBuffer(memStream, appDevice); secBuffer.Play(0, BufferPlayFlags.Default);
When i run my application it gives me System.ArgumentException was unhandled - Value does not fall within the expected range. Even if I use a different constructor, it always gives me this exception. I think it' because of the device object...This object is instantiated like this:appDevice = new Device(); appDevice.SetCooperativeLevel(this, CooperativeLevel.Priority);
If any of you have a suggestion it will be most welcomed because I ran out of ideas. Thanks.Do your best to be the best
-
Hi, I want to create an application that plays the sound recorded from the microphone. I succeeded in capturing the sound from the mic using CaptureBuffer....my problem is when using the data from this buffer to play it with SecondaryBuffer. I'm using a memory stream to get the data from the capture buffer to a stream. When I capture the data from the mic I use the following code. CaptureData is a byte array.
memStream.Write(CaptureData, 0, CaptureData.Length); secBuffer = new SecondaryBuffer(memStream, appDevice); secBuffer.Play(0, BufferPlayFlags.Default);
When i run my application it gives me System.ArgumentException was unhandled - Value does not fall within the expected range. Even if I use a different constructor, it always gives me this exception. I think it' because of the device object...This object is instantiated like this:appDevice = new Device(); appDevice.SetCooperativeLevel(this, CooperativeLevel.Priority);
If any of you have a suggestion it will be most welcomed because I ran out of ideas. Thanks.Do your best to be the best
Maybe you should use the constructor where you pass in a
BufferDescription
object to describe the format you're using. This is just a guess, but I think that since you got your stream for a capture buffer that it's not going to have the headers at the beginning that a stream loaded directly from a wave file would have. Thus you need to provide that info with theBufferDescription
object. But don't quote me on that...