Search Unity

NAudio library

Discussion in 'Editor & General Support' started by Dark-Protocol, Jul 17, 2012.

  1. Dark-Protocol

    Dark-Protocol

    Joined:
    Nov 19, 2011
    Posts:
    279
    I am trying to import the NAudio library into my Unity project so I will be able to open MP3 files during runtime. However when I import the NAudio.dll file into Unity and then I write

    import NAudio;
    import Naudio.Wave;

    I get the following error:

    The class NAudio.Gui.TrackView.Clip could not be loaded, used in NAudio, Version=1.5Assets/MuseWarrior/GUI/MainMenu.js(3,8): BCE0021: Namespace 'NAudio.Wave' not found, maybe you forgot to add an assembly reference?


    I've seen that other people have this assembly reference error when trying to use a certain library but I never saw a solution to this problem.

    What do I need to do to import successfuly this library ?

    Thanks in advance :) !
     
    reefwirrax likes this.
  2. Dark-Protocol

    Dark-Protocol

    Joined:
    Nov 19, 2011
    Posts:
    279
    Still can't get it to work and have no clue why isn't it working. Is it possible that NAudio needs a higher version of .NET ?
     
    reefwirrax likes this.
  3. Dark-Protocol

    Dark-Protocol

    Joined:
    Nov 19, 2011
    Posts:
    279
    Well if not with NAudio, is there at least another library I can use to read MP3 files ? A kind member of the community once gave me the mp3Sharp library but I couldn't get it to work. Actually I had the same isse I'm having now with NAudio.
     
    reefwirrax likes this.
  4. skalev

    skalev

    Joined:
    Feb 16, 2012
    Posts:
    264
    reefwirrax likes this.
  5. tree1891

    tree1891

    Joined:
    Apr 8, 2010
    Posts:
    6
    I can play mp3 with NAudio, but can not close app.
     
    reefwirrax likes this.
  6. reefwirrax

    reefwirrax

    Joined:
    Sep 20, 2013
    Posts:
    137
    can not close app? unity app?

    Thanks i tried the DLL, i am having trouble loading wavs with it, i have to perhaps use a namespace or something?

    i've written using NAudio at the top, and tested this:
    Code (csharp):
    1.  
    2.       using (WaveFileReader reader = new WaveFileReader("myfile.wav"))
    3.      {
    4.          Assert.AreEqual(16, reader.WaveFormat.BitsPerSample, "Only works with 16 bit audio");
    5.          byte[] bytesBuffer = new byte[reader.Length];
    6.           int read = reader.Read(bytesBuffer, 0, buffer.Length);
    7.          // HOW TO GET AS double ARRAY
    8.      }
    9.  
    and i checked other variants but i couldnt get it to compile.
     
    Last edited: May 2, 2016
  7. reefwirrax

    reefwirrax

    Joined:
    Sep 20, 2013
    Posts:
    137
    found more infos googline "using NAudio" monobehaviour but no joy
     
  8. MMOERPG

    MMOERPG

    Joined:
    Mar 21, 2014
    Posts:
    50
    Check out this video it may help.