Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by 1911_Dev · Aug 07, 2013 at 01:50 AM · audioimportaudiosourceimportingmp3

How to Import .mp3 and use it as AudioClip

Hi all,

I need to let the user choose the .mp3 audio file to play at runtime (using a Dialog).

I've done a solution with WWW but it doesn't support .mp3 (in my app I have no time to convert from ogg or wav to mp3s).

Works using NAudio but with that I'm losing all Audioclip's properties (I absolutely need them).

What's the best way to achieve this result?

Thank you

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DaveA · Aug 07, 2013 at 02:06 AM 0
Share

Have you looked in the Asset Store?

avatar image DryTear · Aug 07, 2013 at 03:12 AM 0
Share

http://docs.unity3d.com/Documentation/ScriptReference/Asset.html

avatar image 1911_Dev · Aug 07, 2013 at 08:52 AM 0
Share

Assets doesn't fit my needs...my user has to choose between any of his .mp3 on his hard drive.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by gregzo · Aug 07, 2013 at 09:17 AM

NAudio will allow you to get access to decompressed data, which you can then convert to floats and set in a clip.

I'm not familiar from NAudio, but a quick google yielded this mp3 to wav conversion example.

-Convert to wav -Ditch the header, grab the data ( ints, most often int16 -Convert to float -Create AudioClip of appropriate size, channels etc... -Set data in clip

Much more elegant would be to stream small chunks to a looped AudioClip, would save lots of ram and having to write to disk first.

Hope it helps.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image 1911_Dev · Aug 07, 2013 at 10:53 AM 0
Share

I've tried using the $$anonymous$$p3ToWav(string mp3File, string outputFile) function in my scripts and passing it hard path but it doesn't seem to convert anything.

Anyway thank you for your support

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

16 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unspecified Error during Audio Import 0 Answers

Loading Audio Files at Runtime for Playback and Processing 1 Answer

Play MPEG from web options 0 Answers

Android play mp3 file 0 Answers

Best Audio File Format Practices? iOS/Unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges