Hi Minimeme100, NAudio.dll is the class library I am using for interfacing with the audio hardware on the computer. The class library must be loaded as a reference to your project for the code to compile. Cheers, Giawa
Dude, me and my dad went out for a drink. After many laughs I started talking about my friend Montana and how friggen brilliant he is. Then I showed him this video. Then we were like, "It's like watchin a friggen wizard." Hope all is well buddy..
@briancks Hi Briancks, you're right. I should have been clearer. A limitation of the current WaveFileReader is that it cannot be used as a source directly. This may be due to buffer allocation, or some other factor that the author of NAudio did not make immediately clear to me. It is interesting, so I'll probably take a look through the code to confirm. In the mean time, you will still need the WaveChannel32 intermediary. I believe this will be fixed in a future version of NAudio. Cheers!
Extremely good tutorial. TY so much for putting this up. I always have problems looking for the right functions and usually waste hours just doing that so again ty so much.
Hi Ram, I suggest you check out the NAudio project homepage which is on codeplex. You can search for it easily using Google. The license and terms of use are all available there. Since I am not the author of the NAudio project I cannot give you explicit permission to use it. Cheers!
Hi cSharpIndonesia! I've replied to this via a personal message, since I exceeded the character limit. Long story short - you need to access the MP3/WAV byte stream (which NAudio can do) and then pass that to a FLAC encoder. You can do this by calling the FLAC encoder directly (interop) or using a managed C# encoder (check google, there is an open source port of the FLAC encoder to C#). Best of luck.
Thanks for your tutorial I really learned a lot. Can you create a tutorial showing how to change audio source on for your application using C#. e.g. In Tutorial 11 you are recording a WAV file, can you show how to add a combo box that show all audio sources available on your machine
You helped me in a way you didn't wanted but because your tutorialproject had an exeption by using my own .wav I realized that theres a difference between 16 and 32 bit files :D So now my irrKlang.dll Projekt will work too :D:D
At 6:25, you said a WaveFileReader is a WaveStream, but not an IWaveProvider, but it seems WaveStream inherits IWaveProvider. However, if I skip wrapping the wave with WaveChannel32, I cannot play. Can you please confirm? Thanks.
Hi cSharpIndonesia! Unfortunately, NAudio relies on a number of Windows classes and uses interop to access these classes and functionality. Metro/Silverlight/WP7 do not have these classes, and thus NAudio will not work on these platforms. The creator of NAudio (Mark Heath) has expressed his intentions to work towards a Metro friendly solution in the future. Until then, NAudio is limited to Windows desktop apps.
Great tutorial. Great resource. Question: Can I create sinewaves that are modulated with slider UI control and output in real time? I've written single sine wave data into wave file but never output dynamically. Thank you
Sorry, your website semes a bit broken at the time. I searched for a tutorial like this for days an finally found one and now my code ist not working and i dont know why.
I realise it's been 6 years since you made this video, but I have to ask. Do you think you could make a tutorial series for setting up a discord bot to play music from a url or download a video mp3 then play it? I've got one working on my own, from using libvideo, mediatoolkit and NAudio (this is what brought me here), but I still have some kinks, like bad audio quality and sometimes not being able to download certain videos. Oh and btw, awesome video I've learned a lot about NAudio from watching this series. :)
Hey, how do i take the intput(Microphone) and create 2 outputs in 1: like one high pitched output and 1 low pitched. And then gettung the output of those 2 in one microphone that can be used anywere like ts3.
Hey, Giawa, I tried running the program but I got the following two error messages: Error 1 The type or namespace name 'WaveFileReader' does not exist in the namespace 'NAudio' (are you missing an assembly reference?) Error 2 The name 'pauseButton' does not exist in the current context Is there any way to fix this?
Okay, I am trying this with VS 2013 Express and I have 17 errors. Mostly they have to do with the keyword output. All of the instances of the name "output" are underlined in red and I get this error message... " Error 13 The name 'output' does not exist in the current context... " I have typed out the code exactly as you did and I even added the NAudio.dll file. Am I missing a Using library maybe?
I realize this is REALLY old but, it's because you never initialized a variable named "output". You named the output "wave" probably a copy/paste overlook. private NAudio.Wave.DirectSoundOut wave = null; ------------------------------------------------------------output = null;
Program runs fine (no errors) but I'm hearing no audio. I verified the .wav file works when opened directly. I also tried downloading the code and the result is the same. Any ideas?
You'll need to access the underlying PCM data and then add the two together. Make sure you add it in such a way that you don't saturate the output. It might be best to take 0.5*wave1+0.5*wave2, just to be sure. You can then write this back out to a wave file. Tutorial 7 shows how to record to wave, tutorials 8-11 all deal with accessing and manipulating the PCM data. Hopefully this helps!
Hi Giawa awesome video! I can't seem to get the audio to sound out coding this in .net core on my raspberry pi 3B+ but it works fine on my windows laptop. Any idea why?
Hey there. Sorry, I wish I could help. However, I have no experience with the Raspberry Pi :( I also haven't tried using NAudio with Linux. There are a few stack overflow questions addressing NAudio+Linux, for example here: stackoverflow.com/questions/13793514/monodevelop-naudio-ubuntu-linux-tells-me-winmm-dll-not-found Wish I could be more help. Good luck!
hello bro i like your video. i want to make a project on guitar effect, tuning, and chord finding of a song can you please help me .?? Thanks in advance .. :)
Awsome Tutorial! Thanks for this Divine Tut! ---------------------------------------------------------------------------------------------------------------------- Hey! What's Sephiroth's doing back there? eehhehehe! FFVII Rulez! By the way. Recentlt i found some coincidences with that character name and the game itself. Cloud goes into Astral Projections; Sephiroth is related to Kabalah; etc... The whole game is like a reproduction of some of our own spiritual history.
Can't believe I got Rick Rolled on a C# tutorial
I just got rick rolled by a c# tutorial. What am I doing with my life?
Hi Minimeme100,
NAudio.dll is the class library I am using for interfacing with the audio hardware on the computer. The class library must be loaded as a reference to your project for the code to compile. Cheers,
Giawa
The fact that you played Never Gonna Give You Up makes me so happy :D
Haha I'm glad you enjoyed it! I had to sneak it in there somewhere
Great tutorial, informative! You're also an insanely fast coder. On point.
+Michael Manley Thanks!
You should continue doing Tutorials. You have a gift for explaining things. Use it.
I appreciate the comment! I'd love to keep making tutorials, I just can't find the time in the day to get them done right now. Hopefully soon!
8:48 he got us damn
;)
Dude, me and my dad went out for a drink. After many laughs I started talking about my friend Montana and how friggen brilliant he is. Then I showed him this video. Then we were like, "It's like watchin a friggen wizard." Hope all is well buddy..
@briancks Hi Briancks, you're right. I should have been clearer. A limitation of the current WaveFileReader is that it cannot be used as a source directly. This may be due to buffer allocation, or some other factor that the author of NAudio did not make immediately clear to me. It is interesting, so I'll probably take a look through the code to confirm. In the mean time, you will still need the WaveChannel32 intermediary. I believe this will be fixed in a future version of NAudio. Cheers!
A good source to learn the usage of NAudio. Nice work!
Extremely good tutorial. TY so much for putting this up. I always have problems looking for the right functions and usually waste hours just doing that so again ty so much.
His "It is" sounds exactly like he was about to say "Wednesday, my dudes"
I'm watching it in 2021 and this video is still helpful =) Thanks !
Glad it helped!
Worked first try. Thanks a ton!
Awesome, glad to hear it!
Any idea on how to use NAudio in Metro App?
Here in 2018 and seeing VS2008(?) brings back good memories. I'm following along using the VS2019 preview and WPF instead of WinForms
Ya, it's wild to think that I made these videos 7+ years ago. I remember it clearly, seems like it wasn't so long ago. Have fun coding!
It's a great testament to yourself and the guys behind NAudio (and the .GiawaFX ;) ) that these tutorials and code are still valid today.
Hi Ram,
I suggest you check out the NAudio project homepage which is on codeplex. You can search for it easily using Google. The license and terms of use are all available there. Since I am not the author of the NAudio project I cannot give you explicit permission to use it. Cheers!
Does NAudio support conversion from WAV/MP3/M4A into FLAC?
Hi cSharpIndonesia! I've replied to this via a personal message, since I exceeded the character limit. Long story short - you need to access the MP3/WAV byte stream (which NAudio can do) and then pass that to a FLAC encoder. You can do this by calling the FLAC encoder directly (interop) or using a managed C# encoder (check google, there is an open source port of the FLAC encoder to C#). Best of luck.
Thanks for your tutorial I really learned a lot. Can you create a tutorial showing how to change audio source on for your application using C#. e.g. In Tutorial 11 you are recording a WAV file, can you show how to add a combo box that show all audio sources available on your machine
You helped me in a way you didn't wanted but because your tutorialproject had an exeption by using my own .wav I realized that theres a difference between 16 and 32 bit files :D So now my irrKlang.dll Projekt will work too :D:D
i saw ur all the tutorial. its alll are awesome work but why dont u use timer for record a audio file.
At 6:25, you said a WaveFileReader is a WaveStream, but not an IWaveProvider, but it seems WaveStream inherits IWaveProvider. However, if I skip wrapping the wave with WaveChannel32, I cannot play. Can you please confirm?
Thanks.
Hi cSharpIndonesia! Unfortunately, NAudio relies on a number of Windows classes and uses interop to access these classes and functionality. Metro/Silverlight/WP7 do not have these classes, and thus NAudio will not work on these platforms. The creator of NAudio (Mark Heath) has expressed his intentions to work towards a Metro friendly solution in the future. Until then, NAudio is limited to Windows desktop apps.
No way this dude made a tutorial 3 days before I was born 💀💀
Haha way to make me feel old XD
@@GiawaVideos yeah I'm 12 and I'm having trouble with a project maybe you can help me
Thanks. This sounds like a new fun endeavor.
Dude this is just what I was looking for
Thanks a bunch
Great tutorial. Great resource. Question: Can I create sinewaves that are modulated with slider UI control and output in real time? I've written single sine wave data into wave file but never output dynamically. Thank you
Sorry, your website semes a bit broken at the time. I searched for a tutorial like this for days an finally found one and now my code ist not working and i dont know why.
You don't need to go in any website. Simply consider using inbuilt NuGet Package Manager in Visual Studio to deploy the library.
Can I include naudio in my game engine? My game engine licence is LGPL
Hello!
Is it possible to detect a fingerprint audio on a file ? then edit ?
Thank You!
This is indeed a great tutorial sir. Really time saving and efficient. Thanks!
I want to develop a single application to record live announcements based on voice detection. Any further suggestions ? Thanks In Advance.
hello sir;
how can i binary/digitized the wave/mp3 or any other type of sound file in c#?
plz answer ASAP....
thankx...
nice tutorial,
i have a question.
How do i play two or more sounds at the same time?
lol, nice video. Can NAudio process audio's tone such parametric equalization?
Very useful, saved me tons of time! Appreciate it!
I realise it's been 6 years since you made this video, but I have to ask. Do you think you could make a tutorial series for setting up a discord bot to play music from a url or download a video mp3 then play it? I've got one working on my own, from using libvideo, mediatoolkit and NAudio (this is what brought me here), but I still have some kinks, like bad audio quality and sometimes not being able to download certain videos.
Oh and btw, awesome video I've learned a lot about NAudio from watching this series. :)
Hey, how do i take the intput(Microphone) and create 2 outputs in 1:
like one high pitched output and 1 low pitched.
And then gettung the output of those 2 in one microphone that can be used anywere like ts3.
straight forward explaining. very good series.
Had some questions regarding the tutorial. How do I contact you?
Hey, Giawa, I tried running the program but I got the following two error messages: Error 1 The type or namespace name 'WaveFileReader' does not exist in the namespace 'NAudio' (are you missing an assembly reference?)
Error 2 The name 'pauseButton' does not exist in the current context
Is there any way to fix this?
Okay, I am trying this with VS 2013 Express and I have 17 errors. Mostly they have to do with the keyword output. All of the instances of the name "output" are underlined in red and I get this error message...
" Error 13 The name 'output' does not exist in the current context... "
I have typed out the code exactly as you did and I even added the NAudio.dll file. Am I missing a Using library maybe?
using System;
using System.Windows.Forms;
namespace Naudio_Tutorial
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private NAudio.Wave.WaveFileReader wave = null;
private NAudio.Wave.DirectSoundOut wave = null;
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Wave File (*.wav)|*.wav;";
if (open.ShowDialog() != DialogResult.OK) return;
DisposeWave();
wave = new NAudio.Wave.WaveFileReader(open.FileName);
Output = new NAudio.Wave.DirectSoundOut();
Output.Init(new NAudio.Wave.WaveChannel32(wave));
Output.Play();
pauseButton.Enabled = true;
}
private void button2_Click(object sender, EventArgs e)
{
if (output != null)
{
if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) output.Pause();
else if (output.PlaybackState == NAudio.Wave.PlaybackState.Paused) output.Play();
}
}
private void DisposeWave()
{
if (output != null)
{
if (output.PlaybackState == NAudio.Wave.PlaybackState.Playing) output.Stop();
output.Dispose();
output = null;
}
if (wave != null)
{
wave.Dispose();
wave = null;
}
}
private void Form1_Closing(object sender, FormClosingEventArgs e)
{
DisposeWave();
}
}
}
I realize this is REALLY old but, it's because you never initialized a variable named "output". You named the output "wave" probably a copy/paste overlook.
private NAudio.Wave.DirectSoundOut wave = null;
------------------------------------------------------------output = null;
Haha! That makes more sense now. I will have to try the code again soon.
Program runs fine (no errors) but I'm hearing no audio. I verified the .wav file works when opened directly. I also tried downloading the code and the result is the same. Any ideas?
Hmm why did he/u put that NAudio.dll file in visual studio?
Thanks for the excellent tutorial! This made the learning process very easy!
Thanks for share your knowledge.
Great tutorial! Very easy to follow.
How can you merge 2 Wave files on top of each other?
You'll need to access the underlying PCM data and then add the two together. Make sure you add it in such a way that you don't saturate the output. It might be best to take 0.5*wave1+0.5*wave2, just to be sure. You can then write this back out to a wave file. Tutorial 7 shows how to record to wave, tutorials 8-11 all deal with accessing and manipulating the PCM data. Hopefully this helps!
@@GiawaVideos And what for multiple wav files? Like 5/6, is it the same way?
@@maartengregoor6705 Yup, it should do the trick!
@@GiawaVideos your videos really helped out a lot, but I still don't really understand how to merge them together
Hi Giawa awesome video! I can't seem to get the audio to sound out coding this in .net core on my raspberry pi 3B+ but it works fine on my windows laptop. Any idea why?
Hey there. Sorry, I wish I could help. However, I have no experience with the Raspberry Pi :( I also haven't tried using NAudio with Linux. There are a few stack overflow questions addressing NAudio+Linux, for example here: stackoverflow.com/questions/13793514/monodevelop-naudio-ubuntu-linux-tells-me-winmm-dll-not-found Wish I could be more help. Good luck!
Thanks for your response! I’ll look into the link and hopefully find a solution.
I like your work bro this awesome
Thanks a lot for the video! It helps with with my project!
Lol am i the only one that loves this video cause he rickrolled us?
The best way i was Rick Rolled ever
thanks for sharing!!!!
good video!!
BTW what's this song name of this video?
8:49 Best part of the video!
sir can u chek this code plz and remove my errors
Hey there, did you try checking out the tutorials hosted on the website? giawa.com/tutorials/src/
brilliant my good friend
Thanks man ! It's working really well :-)
You are my hero!
Rick Rolled - via Audio .... I like it.... :-)
*Dat Rick Roll tho!*
You're a smart dude.
hello bro i like your video. i want to make a project on guitar effect, tuning, and chord finding of a song can you please help me .?? Thanks in advance .. :)
скинь код пж
awesome video! i love the music hahahaha
Thank you !!!
Awsome Tutorial! Thanks for this Divine Tut!
----------------------------------------------------------------------------------------------------------------------
Hey! What's Sephiroth's doing back there? eehhehehe! FFVII Rulez!
By the way. Recentlt i found some coincidences with that character name and the game itself.
Cloud goes into Astral Projections; Sephiroth is related to Kabalah; etc...
The whole game is like a reproduction of some of our own spiritual history.
I am learning to work with audio...
...and I got rickrolled.
Great!
Спасибо чувак , очень помогло !!!
Я рад!
haha got rickrolled.
another person who hasent bought winrar XD
love it!
edit: aaaaaaaaaaaaaaaaand i got rick rolled... GG dude!!
Thank you so much sir :D
Genius !
Anyone here in 10 years later?
Yup, I am! Hopefully you found the video useful!
Odisee boys
that fast writing...
You look like the guy who sings that song.
Thanks for the tutorial. It really helpe...............aw i just got rick roll'd :/
Damn he's typing too fast
rikrol