Original Post
Ok. I'm using C#. I'm trying to create a basic secondary buffer. I don't want to open a wav file or anything. I'm doing this because I want to be able to mix all my sounds myself. This is what I use
BufferDescription desc = new BufferDescription(); priv_Buffer = new SecondaryBuffer(desc,priv_Device);and I get a lovely:
quote:It's just a guess but I'm thinkign it's because I don't set any of the BufferDescriptions properties or it's wave format. But I don't know what I should set them to(the Managed docs are terrible). Basically I want a good quality single channel buffer. Thanks for your help. UPDATE: I changed it to this:
An unhandled exception of type 'System.ArgumentException' occurred in microsoft.directx.directsound.dll Additional information: Value does not fall within the expected range.
// Create a wave format object
WaveFormat format = new WaveFormat();
format.BitsPerSample = 16;
format.BlockAlign = 4;
format.Channels = 2;
format.FormatTag = WaveFormatTag.Pcm;
format.SamplesPerSecond = 22050;
format.AverageBytesPerSecond = format.SamplesPerSecond * format.BlockAlign;
// Create a buffer description
BufferDescription desc = new BufferDescription(format);
desc.BufferBytes = 3 * format.AverageBytesPerSecond;
// Actually create the buffer
priv_Buffer = new SecondaryBuffer(desc,priv_Device);
// Play the buffer
priv_Buffer.Play(0,BufferPlayFlags.Default);
and I believe it works as I want it to. I get the error if I change it to only 1 channel. Any suggestions?
[edited by - cilcoder on November 22, 2003 2:36:35 AM]
[edited by - cilcoder on November 22, 2003 2:38:52 AM]