C# 值不在Microsoft.DirectX.DirectSound中的预期范围内;
我正在使用托管代码开发音乐播放器,我正在使用Microsoft.DirectX.DirectSound。当我调用play方法时,我得到了这个错误“值不在预期范围内”。因此,问题仅限于24位WAV文件。这就是例外的原因。对于16位文件,它可以正常工作。有没有办法让它也适用于24位文件 谢谢大家!C# 值不在Microsoft.DirectX.DirectSound中的预期范围内;,c#,directx,directsound,C#,Directx,Directsound,我正在使用托管代码开发音乐播放器,我正在使用Microsoft.DirectX.DirectSound。当我调用play方法时,我得到了这个错误“值不在预期范围内”。因此,问题仅限于24位WAV文件。这就是例外的原因。对于16位文件,它可以正常工作。有没有办法让它也适用于24位文件 谢谢大家! using Microsoft.DirectX.DirectSound; using DS = Microsoft.DirectX.DirectSound; .......
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);//
}
使用Microsoft.DirectX.DirectSound;
使用DS=Microsoft.DirectX.DirectSound;
.......
专用DS设备、声音设备;
私有设备集合AuioDevList;
//创建缓冲区
私有二级缓冲区二级缓冲区;
private BufferDescription d=新的BufferDescription();
private void initializeSound()
{
//列出所有声卡
AuioDevList=新设备集合();
//填充音频卡
CMB声卡.项目.清除();
for(int i=0;i
Noplay
method。没问题。@spender谢谢你的评论。但请下次带着答案来,怎么可能回答一个不完整的问题呢?你的编辑更有意义,但你还是什么都没问。@spender我在问。。出于某些原因,你不喜欢我的问题。