Creating audio assets on the fly

I want to let the user specify an audio file during runtime, then load that audio and play it back as an audioclip. Is there a way to create audioclips from audio files(.wav, .mp3, etc.) during runtime?

A related question: Can I create assetbundles during runtime?

Unity only has support for .ogg audio files. If you're not in the webplayer you can build an FFMpeg DLL (http://ffmpeg.org/) and load the audio with that. If you are in the webplayer, you can do the hack-ey solution I did when I had this same problem. Put a flash swf on your page that just plays audio and have unity control it through the javascript interface.

You can use the WWW class to get an audio clip from a location on disk, and that will even let you play the audio clip while it is still streaming that off the disk, which is particularly helpful. It's ogg-only, though -- from the documentation I'm not even certain that wav files are supported with that particular function.

Evidently you could also look into Resources.Load, but I have not messed with that myself. You can set it up to load all sorts of raw files off the disk at runtime via WWW (for streaming), or via StreamReader, etc, in System.IO (for immediate read), depending on what your needs are. But bear in mind that each copy of WWW leads to a new thread being spawned, and there is a limit to how many of those you can have going at once. So for my dynamic loading of a few hundred assets, I have it queue up the requests and only run around 4 graphics and 4 sound effect WWWs at a time.

I'm not sure if you can dynamically create AssetBundles at runtime, but I also don't think there's a compelling reason to; you can easily load individual files instead.