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 Agoston Torok · Jan 19, 2012 at 04:00 PM · audiotimesynchronizationandorid

Audio start time uncertainty

Hi,

I'm trying to write a game for my project, I'm doing it on Unity Android. My problem is that I want to play an audio in every second, but when I recorded the sound and analyzed it I found that there is some uncertainty in every audio's start time (stdev: 0.035 sec). My main purpose is to give a pulse sound at the exact start of the game, this repeated sound is just a control for me that I can do it.

  • I used Fixedupdate function to play the sound in every 20th update

  • I used a very short .wav file (should I use mp3 instead?)

  • I recorded the framerate too, but have no found any statistical connection between the uncertanty and the framerate

  • If I adjust the fixed time step form 0.05 to 0.01 the deviation remains

  • I set the audio priority to max

I'm not sure that whether the time handling or the play causes this uncertainty. Any clue or advise?

Comment
Add comment · Show 1
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 Kryptos · Jan 19, 2012 at 06:02 PM 1
Share

Do not use FixedUpdate for that purpose. FixedUpdate is meant to be used for Physics interactions. Even fixed update are not 'fixed'.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by luizgpa · Jan 19, 2012 at 06:49 PM

This happens because the way Unity uses FixedUpdate (see more here)

You could make the clip length exactly 1 second and play it looped. This way you won't have play it again.

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

Answer by Agoston Torok · Jan 20, 2012 at 09:43 PM

I tried several ways:

  • Using the method you suggested (to play a 1sec long file in loop) - better results, because time doesn't change for 5-6 cycles, but then it does

  • Used Update instead of FixedUpdate and saved deltatimes between commands (audio.Play()) to a text file, I can't find out why but the values based on time.time did not match with the recorded sound

Any ideas?

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 Kryptos · Jan 20, 2012 at 10:27 PM 0
Share

Windows, $$anonymous$$ac, even linux are not realtime OS. There is no way to guarantee the kind of synchro you're looking for.

avatar image Agoston Torok · Jan 21, 2012 at 09:28 AM 0
Share

It's true:( The thing that I don't understand is that how could it be possible, that even if I log the update times the time interval between the sounds has fairly any relation with them. Here is my code:

var ins : float = 1;

function Update () {if (Time.time > ins ) {audio.Play(); print(Time.time); ins = ins +1; }}

But on the recorded soundfile the interval is 0.98 or 1.02 sec

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

Problem using AudioSource.timeSamples 1 Answer

Calculating reverberation time in Resonance Audio for Unity,Reverberation time in Resonance Audio (Unity) 0 Answers

How to synchronize Datetime from server to client? 0 Answers

Is there a way to wait a certain amount of time before the audio plays again 0 Answers

Synchronise the Time for Two or More Audio Clips 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