Here is a free package that lets you import mp3 files at runtime.
AudioImporter enables you to import audio files at runtime in Unity. It loads an audio file into an AudioClip. The package includes a simple file browser that can be used to select a file.
An optional importer using BASS dll and BASS net is included as a separate package. This importer needs additional licenses and steps to use. See Using Bass Importer for more information.
@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
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
Version 3.0 is ready. I’ve decided to put it up on the Asset Store and Github to make it easier to add to a project. It should be available on the asset store soon.
Hi, I’m using the importer (and rhythm tool) to play audio clips from local storage (Android).
It loads and plays the first song fine, but the Loaded event is not triggered a second time.
the second run gives this error:
07-09 14:01:25.680 7832 7846 E Unity : ArgumentNullException: Value cannot be null.
07-09 14:01:25.680 7832 7846 E Unity : Parameter name: _unity_self
07-09 14:01:25.680 7832 7846 E Unity : at (wrapper managed-to-native) UnityEngine.Networking.UnityWebRequest.Abort(UnityEngine.Networking.UnityWebRequest)
07-09 14:01:25.680 7832 7846 E Unity : at MobileImporter.Abort () [0x00008] in :0
07-09 14:01:25.680 7832 7846 E Unity : at AudioImporter.Import (System.String uri) [0x00000] in :0
07-09 14:01:25.680 7832 7846 E Unity : at SpawnScript.loadSong () [0x00047] in :0
My current workaround is to comment out the Abort() call in Import(string uri) (AudioImporter.cs:50)
This solves the issue, but I wonder if I’m doing something wrong… or it is a bug
By the way, in loadSong() you appear to subscribe to the AudioImporter.Loaded event every time. You’d only want to subscribe to this once. In Awake for example. Otherwise it will invoke songLoaded() an increasing number of times, every time you use loadSong().
I was doing tests with the event subscription (deregistering in songLoaded(), or one time register at Start()), as I first thought the problem was related to the event handling (on second trigger). But thanks for commenting the potential issue
Hello, excuse me, i want to use your asset in my work. But i have some troubles. On the first screenshot you can see the path to file i want to read (it is mp3 file).
On the second screenshot there is code.
On the third screenshot there is file i want to read. (Расположение = Path)
Could you help me out?
I do all like in example. But there is no changes.
I try perform that script with AudioImporter and with NAudioImporter to. Anyway it writes: “is null”.
Hi, very clean interface for the importer. However, using mobile importer my whole game freezes on android (for about 1-2 seconds) while the import is happening. My code is straight from the example - with Coroutine and all that. Any advice? Thanks