Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
1
Question by TYUYT · Aug 11, 2017 at 07:33 AM · audiosourceaudioclipstartmicrophoneend

Microphone.start(), need lengthsec unfixed value, is possible?

Hi,

Unity advise me microphone.start use like this audio.clip = Microphone.Start(null, false, 7, 44100);

But I don't want to fixed value, I have two button, start recording and stop recording.

So i want detect user click the button for stop recording.(<- this is ok.)

how can i use unfixed_value at microphone.(Microphone.Start(null, false, unfixed_value, 44100); )

I don't know total recording times. Please help me. give me any advise plz.

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
0

Answer by robot55 · Aug 11, 2017 at 06:51 AM

I had similar issues - as you mentioned, having a "stop" button that executes Microphone.End(null); will stop the recording.

so what you need to od, IMO, is set the lengthSec in Microphone.Start to be very long (180 would mean 3 minutes for instance). Any length that would be larger than what user would need (1800 would give you 30 minutes, 18000 = 300 minutes or whatever you think is enough) Note that when user play the stop butoon - the clip length would be from Microphone.Start to Microphone.End (stop button clicked) and not the initial value you entered.

I am asusming Unity decided you must enter a length in order to avoid performance, file-size and (maybe) privacy issues - so there will never be a recording that lasts forever. (Note that legthSec is an INT. If it was a float - you could set it to MathF.Infinity)

TL;DR: Just set legthSec to something bigger than what user will ever need - and all your clips legth would be set to when the stop button is clicked. This should give you what you need.

hope that helps. Robot55

Comment
Add comment · Show 2 · 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 robot55 · Aug 23, 2017 at 05:11 PM 1
Share

Hi, correcting mistake - what I wrote above is no longer accurate. In order to shorten the clip.length to the actual recording you need to create some "EndRecording" function - involves copying the actual recorded data to a new AudioClip. See here

avatar image liuyang61 robot55 · Aug 11, 2020 at 11:48 PM 0
Share

Thanks for following this up

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

6 People are following this question.

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

Related Questions

Trying to use derive pitch and db from realtime microphone input 0 Answers

Trying to use derive pitch and db from realtime microphone input 0 Answers

Newbie with OnTriggerEnter & Audio Files 0 Answers

how do i destroy object on trigger with sound in unity 5.2.2? 1 Answer

I want the audio to play when the player nears the object, but fade away when they walk away. 0 Answers


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