Thanks to Giawa, the latest NAudio source code (to be released with NAudio 1.5) has an AIFF File Reader. This makes it very easy to convert from AIFF files to WAV (or simply into PCM format for inputs to other NAudio streams). Here’s how to do it:

public static void ConvertAiffToWav(string aiffFile, string wavFile)
    using (AiffFileReader reader = new AiffFileReader(aiffFile))
        using (WaveFileWriter writer = new WaveFileWriter(wavFile, reader.WaveFormat))
            byte[] buffer = new byte[4096];
            int bytesRead = 0;
                bytesRead = reader.Read(buffer, 0, buffer.Length);
                writer.Write(buffer, 0, bytesRead);
            } while (bytesRead > 0);
Want to get up to speed with the the fundamentals principles of digital audio and how to got about writing audio applications with NAudio? Be sure to check out my Pluralsight courses, Digital Audio Fundamentals, and Audio Programming with NAudio.
Vote on HN


Comment by TriFu

Hi there,

I apologize I don't know where to send you this question,

but I was trying to build a web based music visualizer and needed a way to read the mp3 data so I can analyze the volumn and frequency so I can visualize on it. I've been searching your blog and also googling online but haven't found a tutorial on how to use NAudio to read the sound values?

Do you think you could post up a example of how one could do this? Thank you so much for your time.

Comment by Anonymous

great article!

Comment by Anonymous

Can you show an article on how to read sound from an mp3?

Specifically, how to read volume so that one can make visualizations based on the change in volume of the music playing?

Comment by Mark H

@Anonymous, with the NAudio source code there is an NAudio demo app that will show you how to play MP3 and show waveform.

comments powered by Disqus