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 /
avatar image
0
Question by MarkD · Oct 29, 2014 at 04:02 PM · 3daudiosoundaudiosourceclip

Set audio clip to 3D in script

Hi, I have been breaking my head over this one for a couple of day's now and I can't seem to find a direct answer on the wiki/questions/forums to my problem.

It is about the following piece of code. audio.clip = Microphone.Start(selectedDevice, true, 10, maxFreq);

As you can see it is an audio clip created directly in script. What I need is that this audio clip gets imported as a 3D sound, which can not be done in the editor, since there is not physical clip in my asset folder (because I create it live in my script).

Is there anyway I can set it's audio type manually without using the AssetImporter class (because this would require a datapath to a clip inside the asset folder).

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by smoggach · Oct 29, 2014 at 04:36 PM

There's no way to set it directly. As with sprites (and their importer settings) You have to set them via the Create function.

http://docs.unity3d.com/ScriptReference/AudioClip.Create.html

Create a new audio clip with the settings you want, GetData from your microphone recording and SetData on your new audio clip.

Comment
Add comment · Show 5 · 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 MarkD · Oct 29, 2014 at 04:45 PM 0
Share

Ok thanks, this gives a better insight, I will try a workaround through an editor script. If that fails, I will give your approach a sway.

thx

avatar image MarkD · Oct 29, 2014 at 07:20 PM 0
Share

Unfortunately it does not seem to be possible to use a GetData function from the microphone en then feed it with SetData to an audio clip. After some research it seems that the $$anonymous$$icrophone interface (scripting) only supports 2D audio, which is a shame.

avatar image smoggach · Oct 29, 2014 at 07:55 PM 1
Share

That's pretty lame but not entirely impossible. There are many more ways to get the audio data than just with Unity. If you're still serious I'd look into that, otherwise you're better off just modifying the volume by yourself.

avatar image MarkD · Oct 29, 2014 at 08:10 PM 1
Share

Well I have created my own workaround, Unity creates the 3D effect by changing it's volume, this gave me the idea to calculate the distance between the AudioSource(wich carry's my clip) and the audio listener, this is the algorithm I came up with audio.volume = (sourceVolume/100/(ListenerDistance*VolumeFallOff));

This creates exactly the effect I wanted, without having the hassle of GetData and SetData.

Thx for your support, without your reply I would have never come up with this solution!.

avatar image smoggach · Oct 29, 2014 at 08:11 PM 0
Share

nice one!

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

27 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Playing a sound clip from another object 1 Answer

Help with sound clips [C#] 0 Answers

Get audio from device... -1 Answers

Random, 3d sound. 1 Answer

Audio not coming out of speakers 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