Audio Programming with NAudio

A thorough tutorial in the use of NAudio, an open source audio library for .NET.
Course info
Rating
(65)
Level
Intermediate
Updated
Nov 4, 2013
Duration
6h 59m
Table of contents
Introducing NAudio
Audio File Playback
Working with Files
Changing Audio Formats
Working with Codecs
Recording Audio
Visualizations
Mixing and Effects
Audio Streaming
Description
Course info
Rating
(65)
Level
Intermediate
Updated
Nov 4, 2013
Duration
6h 59m
Description

This course teaches you how to use all the major features of NAudio, and open source audio library for .NET. It includes plenty of code examples for playback, recording, working with files and codecs, streaming and visualising. You'll also learn about what underlying system APIs are being used by NAudio, so you can ensure your application runs as expected on all target operating systems.

About the author
About the author

Mark Heath is a software developer based in Southampton, England, working for NICE Systems as a software architect creating cloud based digital evidence management systems for the police. He is the creator of NAudio, an open source audio framework for .NET.

More from the author
More courses by Mark Heath
Section Introduction Transcripts
Section Introduction Transcripts

Audio File Playback
Hi, my name's Mark Heath and in this module we'll be looking at audio file playback with an audio. Let's have a quick look at the things we'll be covering in this module. Well, I'm going to start off by showing, that you might not actually need NAudio, to play audio files, in a. net application. And that's because although the. net framework hasn't got very much audio support, it does a couple of classes that let you play audio. And they might be sufficient for your needs. So I'll show you what they are. Then we'll look at the most basic possible example of audio playback with NAudio. We'll see how you can take an audio file, and start playing it. And then we'll see how you can reposition within that audio file, while you're playing, and how you can stop playback. And we'll look at some of the considerations you need to take into account when you're doing those things. One of the things that might be confusing if you're new to an audio is deciding which implementation of iWave player you're going to use to play back audio. Which of the various output models is the most appropriate. So I'll be discussing what the main choices are. WaveOut and WaveOutEvent, DirectSoundOut, WasapiOut and AsioOut. And we'll talk about the advantages and disadvantages of these as well as looking at how you can configure them. Finally, we'll look at how you can change the volume while you're playing back. Obviously, this is something that you quite often want to be able to do from within your application, but unfortunately, it's not always as simple as you might hope, and there's a variety of different ways you can go about doing it. So we'll look at some different strategies for adjusting the volume.

Working with Files
Hi, my name's Mark Heath. And in this module, we'll be looking at how you can work with audio files using NAudio. Obviously the main two things you're going to want to do with audio files are read them and create them. So we'll start off by looking at how you can read audio files with NAudio. We'll look in a bit more detail at the various different file reader classes that NAudio provides. Now when you're reading an audio file, there's three things that you're going to want to read out of it. Obviously first of all, there's the audio data, the sound that's contained within the file. But also you need to know what the WAVE format is, what format that audio data is stored in. So I'll be showing how you can use the WaveFormat property to find out what format the audio's in. And also, many types of audio files provide a way for metadata to be stored. And so, I'll be showing the ways that NAudio can, and in some cases can't, help you to access that metadata. We'll also look at creating audio files using NAudio. We'll go through the different types of file writer classes that NAudio provides, and we'll focus in particularly on the WaveFileWriter. The WaveFileWriter is very important, because wave files are very often used when you're recording or producing any sort of audio, even you plan later to convert it to another format. But I will also be touching on some MP3 file manipulation in this module.

Recording Audio
Hi, my name's Mark Heath, and in this module, we'll be looking at how you can record audio using NAudio. Let's have a quick look at what we'll be covering in this module. We're going to start off by looking at the IWaveIn interface. This is the base interface that's implemented by several classes in Naudio that gives you access to the recording capabilities of various Windows recording API's. Then we'll move on to look in a bit more detail at some of the various classes in naudio, the support recording. We'll start by looking at recording using the WaveIn API. Although this is a legacy API, it's actually one of the most flexible and easiest API's to use for recording. We'll then move on to look at how you can record using WASAPI. And in addition to regular recording, where you're recording the inputs from your sound card. We'll also see how WASAPI can allow you to do what's called Loopback Capture where you record the audio that's being played in your sound card. And finally we'll have a look at using the ASIO API for recording. And for each of these techniques of recording I'll be showing some code demos to show you what you need to do to use this in your own applications. Along the way, we'll be looking at how you can implement some common recording tasks, such as selecting the device to record from, or monitoring the input level, or configuring the recording level for your microphone, or see how you can save the audio that you captured to a WAV file. And also we look at some ways that you can monitor the recorded audio which is where you listen to it while you're recording it.

Visualizations
Hi, my name's Mark Heath, and in this module we'll be looking at various ways you can add audio visualizations to your. NET applications. Now, providing GUI components for audio visualizations isn't actually one of the project goals of NAudio. But it is something, that a lot of users of NAudio, want to do. And so in the demo applications, I have included a number of examples, showing how you can use NAudio, to do audio visualizations. And in this module, we're going to be looking at three of the most common audio visualizations, that you might want to add to your application. The first is a Peak Meter. Which is a simple way of viewing the signal level at a point in time. The second is showing Audio Wave Forms. And the third, is Spectrum Analyzers, showing the frequency components in a signal. And for each of these visualizations we'll be looking at the audio analysis you need to do in order to provide the data that drives the visualization. For the Peak Meter and WaveForm we need to detect the peaks in the audio signal. And for the Spectrum Analyzer we need to get the frequency components using something called the Fast Fourier Transform. We'll also have a look at a few different rendering techniques, so we'll see how you can draw wave forms in Windows Forms, as well as in WPF. And we'll also see how, if you want to save those waveforms to a PNG for example,. Maybe you want to show them on a web page, we'll see how you can do that as well.