C# Audio Tutorial 1 - Wave File with NAudio

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ธ.ค. 2024

ความคิดเห็น • 116

  • @razmigavedis9377
    @razmigavedis9377 2 ปีที่แล้ว +6

    Can't believe I got Rick Rolled on a C# tutorial

  • @hvrjstn
    @hvrjstn 8 ปีที่แล้ว +41

    I just got rick rolled by a c# tutorial. What am I doing with my life?

  • @GiawaVideos
    @GiawaVideos  12 ปีที่แล้ว +1

    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

  • @stuckurface
    @stuckurface 10 ปีที่แล้ว +18

    The fact that you played Never Gonna Give You Up makes me so happy :D

    • @GiawaVideos
      @GiawaVideos  10 ปีที่แล้ว +4

      Haha I'm glad you enjoyed it! I had to sneak it in there somewhere

  • @michaelmanley9066
    @michaelmanley9066 8 ปีที่แล้ว +17

    Great tutorial, informative! You're also an insanely fast coder. On point.

    • @GiawaVideos
      @GiawaVideos  8 ปีที่แล้ว +1

      +Michael Manley Thanks!

  • @CreepyFosta
    @CreepyFosta 5 ปีที่แล้ว

    You should continue doing Tutorials. You have a gift for explaining things. Use it.

    • @GiawaVideos
      @GiawaVideos  5 ปีที่แล้ว

      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!

  • @Beyluta
    @Beyluta 6 ปีที่แล้ว +2

    8:48 he got us damn

  • @RenSylvain23
    @RenSylvain23 10 ปีที่แล้ว

    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..

  • @GiawaVideos
    @GiawaVideos  13 ปีที่แล้ว

    @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!

  • @centosys
    @centosys 4 ปีที่แล้ว +1

    A good source to learn the usage of NAudio. Nice work!

  • @Nekros4442
    @Nekros4442 12 ปีที่แล้ว

    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.

  • @mrfashionguy1
    @mrfashionguy1 3 ปีที่แล้ว +1

    His "It is" sounds exactly like he was about to say "Wednesday, my dudes"

  • @michaelkashkov4337
    @michaelkashkov4337 3 ปีที่แล้ว

    I'm watching it in 2021 and this video is still helpful =) Thanks !

  • @ultima_maxima
    @ultima_maxima 9 วันที่ผ่านมา

    Worked first try. Thanks a ton!

    • @GiawaVideos
      @GiawaVideos  6 วันที่ผ่านมา

      Awesome, glad to hear it!

  • @cSharpIndonesia
    @cSharpIndonesia 12 ปีที่แล้ว

    Any idea on how to use NAudio in Metro App?

  • @MrSmokyFly
    @MrSmokyFly 6 ปีที่แล้ว

    Here in 2018 and seeing VS2008(?) brings back good memories. I'm following along using the VS2019 preview and WPF instead of WinForms

    • @GiawaVideos
      @GiawaVideos  6 ปีที่แล้ว +1

      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!

    • @MrSmokyFly
      @MrSmokyFly 6 ปีที่แล้ว

      It's a great testament to yourself and the guys behind NAudio (and the .GiawaFX ;) ) that these tutorials and code are still valid today.

  • @GiawaVideos
    @GiawaVideos  12 ปีที่แล้ว

    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!

  • @cSharpIndonesia
    @cSharpIndonesia 12 ปีที่แล้ว

    Does NAudio support conversion from WAV/MP3/M4A into FLAC?

  • @GiawaVideos
    @GiawaVideos  12 ปีที่แล้ว

    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.

  • @NABUKENAEZER
    @NABUKENAEZER 12 ปีที่แล้ว

    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

  • @eliaszimmermann3864
    @eliaszimmermann3864 7 ปีที่แล้ว

    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

  • @rejeeshnair5877
    @rejeeshnair5877 8 ปีที่แล้ว

    i saw ur all the tutorial. its alll are awesome work but why dont u use timer for record a audio file.

  • @briancks
    @briancks 13 ปีที่แล้ว

    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.

  • @GiawaVideos
    @GiawaVideos  12 ปีที่แล้ว

    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.

  • @Sir_Tom21
    @Sir_Tom21 8 หลายเดือนก่อน

    No way this dude made a tutorial 3 days before I was born 💀💀

    • @GiawaVideos
      @GiawaVideos  8 หลายเดือนก่อน

      Haha way to make me feel old XD

    • @Sir_Tom21
      @Sir_Tom21 8 หลายเดือนก่อน

      @@GiawaVideos yeah I'm 12 and I'm having trouble with a project maybe you can help me

  • @lizravenwood5317
    @lizravenwood5317 8 ปีที่แล้ว

    Thanks. This sounds like a new fun endeavor.

  • @Dexxxxxxxxx
    @Dexxxxxxxxx 11 ปีที่แล้ว

    Dude this is just what I was looking for
    Thanks a bunch

  • @BassJaco71
    @BassJaco71 12 ปีที่แล้ว

    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

  • @dustsucker4704
    @dustsucker4704 4 ปีที่แล้ว +1

    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.

    • @centosys
      @centosys 4 ปีที่แล้ว

      You don't need to go in any website. Simply consider using inbuilt NuGet Package Manager in Visual Studio to deploy the library.

  • @SriHarshaChilakapati
    @SriHarshaChilakapati 12 ปีที่แล้ว

    Can I include naudio in my game engine? My game engine licence is LGPL

  • @mcbublick
    @mcbublick 8 ปีที่แล้ว

    Hello!
    Is it possible to detect a fingerprint audio on a file ? then edit ?
    Thank You!

  • @AshishVerma-gg3tt
    @AshishVerma-gg3tt 8 ปีที่แล้ว

    This is indeed a great tutorial sir. Really time saving and efficient. Thanks!

  • @jeanfernandeseng
    @jeanfernandeseng 2 ปีที่แล้ว

    I want to develop a single application to record live announcements based on voice detection. Any further suggestions ? Thanks In Advance.

  • @abrarsiddique3939
    @abrarsiddique3939 11 ปีที่แล้ว

    hello sir;
    how can i binary/digitized the wave/mp3 or any other type of sound file in c#?
    plz answer ASAP....
    thankx...

  • @raphaelvolta
    @raphaelvolta 11 ปีที่แล้ว

    nice tutorial,
    i have a question.
    How do i play two or more sounds at the same time?

  • @FortyTwoAnswerToEverything
    @FortyTwoAnswerToEverything 9 ปีที่แล้ว

    lol, nice video. Can NAudio process audio's tone such parametric equalization?

  • @nekorbin
    @nekorbin 8 ปีที่แล้ว

    Very useful, saved me tons of time! Appreciate it!

  • @Tavor57
    @Tavor57 7 ปีที่แล้ว

    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. :)

  • @stew9671
    @stew9671 8 ปีที่แล้ว

    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.

  • @GonzoGonschi
    @GonzoGonschi 13 ปีที่แล้ว

    straight forward explaining. very good series.

  • @prajaktachari9393
    @prajaktachari9393 7 ปีที่แล้ว

    Had some questions regarding the tutorial. How do I contact you?

  • @CreativityInProgress
    @CreativityInProgress 10 ปีที่แล้ว

    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?

  • @rwxstudio7173
    @rwxstudio7173 10 ปีที่แล้ว +1

    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?

    • @rwxstudio7173
      @rwxstudio7173 10 ปีที่แล้ว

      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();
      }
      }
      }

    • @JonCarrNet
      @JonCarrNet 8 ปีที่แล้ว +2

      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;

    • @rwxstudio7173
      @rwxstudio7173 8 ปีที่แล้ว +2

      Haha! That makes more sense now. I will have to try the code again soon.

  • @martinvigesaa878
    @martinvigesaa878 11 ปีที่แล้ว

    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?

  • @Minimeme100
    @Minimeme100 12 ปีที่แล้ว

    Hmm why did he/u put that NAudio.dll file in visual studio?

  • @tonyasch5265
    @tonyasch5265 11 ปีที่แล้ว

    Thanks for the excellent tutorial! This made the learning process very easy!

  • @adrha058
    @adrha058 4 ปีที่แล้ว

    Thanks for share your knowledge.

  • @briancks
    @briancks 13 ปีที่แล้ว

    Great tutorial! Very easy to follow.

  • @maartengregoor6705
    @maartengregoor6705 3 ปีที่แล้ว

    How can you merge 2 Wave files on top of each other?

    • @GiawaVideos
      @GiawaVideos  3 ปีที่แล้ว +2

      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!

    • @maartengregoor6705
      @maartengregoor6705 3 ปีที่แล้ว

      @@GiawaVideos And what for multiple wav files? Like 5/6, is it the same way?

    • @GiawaVideos
      @GiawaVideos  3 ปีที่แล้ว +1

      @@maartengregoor6705 Yup, it should do the trick!

    • @maartengregoor6705
      @maartengregoor6705 3 ปีที่แล้ว

      @@GiawaVideos your videos really helped out a lot, but I still don't really understand how to merge them together

  • @markogilo5332
    @markogilo5332 6 ปีที่แล้ว

    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?

    • @GiawaVideos
      @GiawaVideos  6 ปีที่แล้ว

      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!

    • @markogilo5332
      @markogilo5332 6 ปีที่แล้ว

      Thanks for your response! I’ll look into the link and hopefully find a solution.

  • @MohamedAhmed-jc5fs
    @MohamedAhmed-jc5fs 10 ปีที่แล้ว

    I like your work bro this awesome

  • @TuanLeMau
    @TuanLeMau 12 ปีที่แล้ว

    Thanks a lot for the video! It helps with with my project!

  • @captncoderyankee9953
    @captncoderyankee9953 8 ปีที่แล้ว +2

    Lol am i the only one that loves this video cause he rickrolled us?

  • @komunx_3170
    @komunx_3170 3 ปีที่แล้ว +1

    The best way i was Rick Rolled ever

  • @justaurant
    @justaurant 8 ปีที่แล้ว

    thanks for sharing!!!!
    good video!!

    • @justaurant
      @justaurant 8 ปีที่แล้ว

      BTW what's this song name of this video?

  • @theman13300
    @theman13300 12 ปีที่แล้ว

    8:49 Best part of the video!

  • @willsmith8593
    @willsmith8593 7 ปีที่แล้ว

    sir can u chek this code plz and remove my errors

    • @GiawaVideos
      @GiawaVideos  7 ปีที่แล้ว

      Hey there, did you try checking out the tutorials hosted on the website? giawa.com/tutorials/src/

  • @richcasella
    @richcasella 10 ปีที่แล้ว

    brilliant my good friend

  • @axelvdk
    @axelvdk 9 ปีที่แล้ว

    Thanks man ! It's working really well :-)

  • @brostahl6435
    @brostahl6435 8 ปีที่แล้ว

    You are my hero!

  • @shawty_ds
    @shawty_ds 9 ปีที่แล้ว +7

    Rick Rolled - via Audio .... I like it.... :-)

  • @Ali107
    @Ali107 4 ปีที่แล้ว +1

    *Dat Rick Roll tho!*

  • @garrettrudolph6545
    @garrettrudolph6545 9 ปีที่แล้ว

    You're a smart dude.

  • @abduttawabbinrashid3966
    @abduttawabbinrashid3966 9 ปีที่แล้ว

    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 .. :)

  • @vofkanchik
    @vofkanchik 8 หลายเดือนก่อน

    скинь код пж

  • @darrenleeyx
    @darrenleeyx 9 ปีที่แล้ว

    awesome video! i love the music hahahaha

  • @siberiancoder9327
    @siberiancoder9327 7 ปีที่แล้ว

    Thank you !!!

  • @ricardog.374
    @ricardog.374 11 ปีที่แล้ว

    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.

  • @jastrobaron
    @jastrobaron 4 ปีที่แล้ว

    I am learning to work with audio...
    ...and I got rickrolled.

  • @RaoulWB
    @RaoulWB 8 ปีที่แล้ว

    Great!

  • @siberiancoder9327
    @siberiancoder9327 7 ปีที่แล้ว

    Спасибо чувак , очень помогло !!!

  • @aiman_yt
    @aiman_yt 9 ปีที่แล้ว +9

    haha got rickrolled.

  • @platinumlagg
    @platinumlagg 7 ปีที่แล้ว +2

    another person who hasent bought winrar XD
    love it!
    edit: aaaaaaaaaaaaaaaaand i got rick rolled... GG dude!!

  • @zBloodelfz
    @zBloodelfz 11 ปีที่แล้ว

    Thank you so much sir :D

  • @ivodonckers25
    @ivodonckers25 8 ปีที่แล้ว

    Genius !

  • @that_bean1793
    @that_bean1793 3 ปีที่แล้ว +1

    Anyone here in 10 years later?

    • @GiawaVideos
      @GiawaVideos  3 ปีที่แล้ว +3

      Yup, I am! Hopefully you found the video useful!

  • @Pico_444
    @Pico_444 8 ปีที่แล้ว

    Odisee boys

  • @netwar123
    @netwar123 11 ปีที่แล้ว

  • @ebubekircagrsen7824
    @ebubekircagrsen7824 7 ปีที่แล้ว

    that fast writing...

  • @Platerpus7
    @Platerpus7 8 ปีที่แล้ว

    You look like the guy who sings that song.

  • @CoolGuyPCGamer
    @CoolGuyPCGamer 12 ปีที่แล้ว

    Thanks for the tutorial. It really helpe...............aw i just got rick roll'd :/

  • @polamin
    @polamin 12 ปีที่แล้ว

    Damn he's typing too fast

  • @MunaAlaneme
    @MunaAlaneme 11 หลายเดือนก่อน

    rikrol