Why do some wav files play in my C # directsound application, but some not?

I have a C # application that plays simple wav files through directsound. With the test data that I had, the code worked fine. However, when I used real-world data, it created a very useless error when creating a secondary buffer: "ArgumentException: value does not fall into the expected range."

The wavs test had a data transfer rate of 512 kbps, a sample size of 16 bits and a sampling frequency of 32 kHz. The new wavs are 1152 kbit / s, 24 bit and 48 kHz respectively. How can I get directsound to handle these larger values, or if not, how can I programmatically determine these values ​​before trying to play the file?

it was running DirectX v9.00.1126 I am using and I have included the sample code below:

using DS = Microsoft.DirectX.DirectSound;  
...  
DS.Device device = new DS.Device();
device.SetCooperativeLevel(this, CooperativeLevel.Normal);  
...
BufferDescription bufferDesc = new BufferDescription();
bufferDesc.ControlEffects = false;  
...
try
{
    SecondaryBuffer sound = new SecondaryBuffer(path, bufferDesc, device);
    sound.Play(0, BufferPlayFlags.Default);
}
...

Additional information: real-world wav files will not play in Windows Media Player, telling me that a codec is required to play the file, while they play winamp perfectly.

2: , , RIFF "bext", , , , fmt. / fmt chunk , , fmt. , beuge beuge , - , .

+3
2

24 , , . . 44,1 , 48 .

.NET NAudio, , WAV . (, Wav... API) resampler DMO.

+6

WAV - , ( , AVI - ). , GSpot, , WAV . Winamp , , WMP, , Winamp , WMP - .

+4

Source: https://habr.com/ru/post/1697195/


All Articles