I am developing a music player with managed code and I am using Microsoft.DirectX.DirectSound. I am getting this error "Value does not fall within the expected range" when I calling play method. So, The problem is only for 24 bit WAV files. That was the reason for the exception. For 16 bit files is working fine. Any Ideas how to make it work for 24 bit files too?
Thank you!
using Microsoft.DirectX.DirectSound;
using DS = Microsoft.DirectX.DirectSound;
.......
private DS.Device sounddevice;
private DevicesCollection AuioDevList;
//Create buffer
private SecondaryBuffer secondaryBuffer;
private BufferDescription d = new BufferDescription();
private void initializeSound()
{
// List all Audio Cards
AuioDevList = new DevicesCollection();
// Populate cmbAudioCards
cmbAudioCards.Items.Clear();
for (int i = 0; i < AuioDevList.Count; i++)
{
cmbAudioCards.Items.Add(AuioDevList[i].Description);
}
cmbAudioCards.SelectedIndex = 0;
sounddevice = new DS.Device(AuioDevList[0].DriverGuid);
sounddevice.SetCooperativeLevel(this.Handle, CooperativeLevel.Normal);
// Set descriptor’s flags
d.ControlPan = true;
d.ControlVolume = true;
d.ControlFrequency = true;
d.ControlEffects = true;
}
private void prepareSound(string file)
{
playing = false;
//secondaryBuffer.Stop();
secondaryBuffer = new SecondaryBuffer(file, d, sounddevice);
secondaryBuffer.Volume = trkVolume.Value;
}
private void btnPlay_Click(object sender, EventArgs e)
{
//Here is throwing exception
secondaryBuffer.Play(0, BufferPlayFlags.Default);//
}
play
method. No question. – spender Mar 14 '13 at 13:19