I'm writing a game and I'd like to use NAudio to add sound to it. I followed a few examples and was rather pleased with NAudio's API and performance.
I ran into the following issue: NAudio will not play short audio files. I've used WaveChannel32.Length to get the following numbers.
Files with length 755712 or less will not play.
Files with length 5935104 do play.
I'm not sure where the exact limit is. There are no exceptions thrown. I was hoping to use NAudio to play files of about 1 second long. Is anyone else having this issue? Is there a fix? Do I need to find a different library?
Comments: Setting Position = 0; before re-adding the AudioFileReader to the MixingSampleProvider doesn't fix it. I already did that in my original code. I can only play an AudioFileReader once. Additionally, I peeked at the WaveFormat that creating a MixingSampleProvider with a sample creates and produced one in code. Like this: WaveFormat format = WaveFormat.CreateIeeeFloatWaveFormat(44100, 2); And then I fed format to the MixingSampleProvider constructor. The result is no sound at all. I've inspected the WaveFormat made with the sample and compared it to the WaveFormat made with CreateIeeeFloatWaveFormat. They appear identical. I am at a loss on both points. Do you have any ideas?
I ran into the following issue: NAudio will not play short audio files. I've used WaveChannel32.Length to get the following numbers.
Files with length 755712 or less will not play.
Files with length 5935104 do play.
I'm not sure where the exact limit is. There are no exceptions thrown. I was hoping to use NAudio to play files of about 1 second long. Is anyone else having this issue? Is there a fix? Do I need to find a different library?
Comments: Setting Position = 0; before re-adding the AudioFileReader to the MixingSampleProvider doesn't fix it. I already did that in my original code. I can only play an AudioFileReader once. Additionally, I peeked at the WaveFormat that creating a MixingSampleProvider with a sample creates and produced one in code. Like this: WaveFormat format = WaveFormat.CreateIeeeFloatWaveFormat(44100, 2); And then I fed format to the MixingSampleProvider constructor. The result is no sound at all. I've inspected the WaveFormat made with the sample and compared it to the WaveFormat made with CreateIeeeFloatWaveFormat. They appear identical. I am at a loss on both points. Do you have any ideas?