This project has moved and is read-only. For the latest updates, please go here.

Weird slowing down of audio, when i use Mp3StreamingDemo

Jan 28, 2016 at 1:41 PM
Edited Jan 28, 2016 at 2:08 PM
Sorry for my bad english.
When i am using NAudioDemo -> Mp3StreamingDemo and want to play some music from
for example, i get a weird audio slowing down. What the matter of this?
(I ve tried to use DMO frame decompressor and I ve got "System.NullReferenceException" in NAudio.dll) exception)
About 95% audios from same website is playing successfully (TEXT, for example). But with another 5% I get a 50% speed, if i use Acm frame decompressor
Jan 28, 2016 at 2:58 PM
Edited Jan 28, 2016 at 3:08 PM
Ok, I found the problem, but still can't solve it.
private static IMp3FrameDecompressor CreateFrameDecompressor(Mp3Frame frame)
            WaveFormat waveFormat = new Mp3WaveFormat(frame.SampleRate, frame.ChannelMode == ChannelMode.Mono ? 1 : 2,
               frame.FrameLength, frame.BitRate);
            return new DmoMp3FrameDecompressor(waveFormat);
frame has a wrong SampleRate property in some audios.
this song has 44100 Hz sample rate, but frame.SampleRate is 32000 Hz.
How can i solve this problem?

Also Dmo decompressor started work when I set argument sampleRate of Mp3WaveFormat constructor in true sample rate value of song manually
Jan 28, 2016 at 3:09 PM
I think this is caused by junk (album art?) at the start of MP3 files getting mis-recognised as valid MP3 frames. One way to work around this is to keep reading frames until you've had a certain number in a row with the same format, and ignoring any before that.
Jan 28, 2016 at 3:58 PM
Edited Jan 28, 2016 at 6:15 PM
Ok, I solved the problem. thx