Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Import Mp3 files at runtime

Discussion in 'Assets and Asset Store' started by HelloMeow, Sep 15, 2014.

  1. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    167
    Here is a free package that lets you import mp3 files at runtime.

    http://hellomeow.net/#unity-assets (Download link on website)

    The package contains a simple file browser:


    There are three different importers:
    1. MobileImporter, which is for mobile platforms only. It uses Unity's WWW / UnityWebRequest class, that can stream mp3 files on mobile platforms only.
    2. NAudioImporter, which uses NAudio, which is licensed under the Ms-PL. It might require licensing for using MP3 technology.
    3. BassImporter, which uses Bass.dll and Bass.net, that require separate licenses for commercial projects. This importer can use the OS's mp3 decoder, so no MP3 license is needed.
    MP3 technology is patented. More information about MP3 licensing can be found here https://en.wikipedia.org/wiki/MP3#Licensing.2C_ownership_and_legislation

    In order for some of the decoders to work properly, the API compatibility level needs to be set to ".NET 2.0" in player settings. Otherwise it will only work in the editor, if at all.

    For Android, Write Permission has to be set to External.

    Some assets have external dependencies. These are optional and can be removed:
    • BassImporter requires bass.dll and bass.dll.net
    • VisualizerDemo requires RhythmTool
    Importing bass.dll and bass.net.dll:
    1. Get bass.dll from http://www.un4seen.com/ and place the required libraries (based on the editor platform and the project's build target) in a Plugins folder.
    2. Get bass.net.dll from http://www.un4seen.com/ and place it somewhere your project's assets folder. Bass.Net comes with a number of versions. Unity needs the one from the "V2.0" folder. You can register Bass.Net on http://bass.radio42.com/bass_register.html and by editing line 17 of BassImporter.cs.
     
    Last edited: Jul 31, 2017
  2. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    167
    A small update. This now includes an importer that uses Bass.dll and the importers are now derived from MonoBehaviour.
     
  3. RickyTB

    RickyTB

    Joined:
    Dec 13, 2014
    Posts:
    3
    Wow thankyou very much, this is going to help me a lot in a future project. Can't believe nobody has given you a thanks in all this time.
     
  4. F0RG0TTEN

    F0RG0TTEN

    Joined:
    Sep 20, 2015
    Posts:
    1
    Thank you for sharing this for free! I don't understand why didn't you get more attention for such useful tool like that one.
     
  5. jister

    jister

    Joined:
    Oct 9, 2009
    Posts:
    1,636
  6. Ocram1989

    Ocram1989

    Joined:
    Jul 15, 2016
    Posts:
    1
    Is free this??
     
  7. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    167
    Yes. One of the importers uses Bass.dll, which is not free for commercial projects, but every importer is optional.
     
  8. ikemen_blueD

    ikemen_blueD

    Joined:
    Jan 19, 2013
    Posts:
    286
    @HelloMeow this is supppperrr useful, so many thanks. I emailed u before, can't wait for new update from RhythmTool, no memory allocations every frame plz :)
     
    Last edited: Jan 8, 2017
  9. jalemanyf

    jalemanyf

    Joined:
    Jun 16, 2013
    Posts:
    10
    Hello,

    It seems very interesting but I still can't do it Works...

    I'm using Unity 5.3.3f1 on a Windows 8.1 to test it.

    I have also downloaded the rythmtool sample: it opens, navigate for the folders but nothing sounds after select an mp3...

    Any idea about what I'm doing wrong?

    It seems easy to follow when I read but anyone has any step by step guide to be sure I have done everything correct?

    Thanks!
     
  10. Allthebees

    Allthebees

    Joined:
    Apr 22, 2017
    Posts:
    3
    Hey there. So I've been working on a game using your rhythm tool as well as these .mp3 importer.

    I was coming up against an issue where some mp3 files would not be able to load. After a bit of messing around, I found that the while loop in FillBuffer() in the DecoderImporter class would get stuck.

    Read would return 0, and therefore index would not increase. I am not 100% sure why the issue happens but a simple solution is to check if index + read is equal to index, and break out of the while loop if the condition is met.

    Hopefully this can help anyone else that might be running into this issue
     
  11. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    167
    Thanks for reporting this issue, I'm going to look into it.