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 Xifajk · Feb 17, 2014 at 12:43 AM · timeaudioclipsynchronizationtwo

Synchronise the Time for Two or More Audio Clips

Hey guys,

The game that we're working on has to do with sound and music mostly. Now what we're having trouble with is trying to synchronise the Music Track. Basically, we have three instruments, and these will be picked up by the character. Once picked up, the music of that instrument starts playing. However, these need to be FULLY synchronised, which at the moment can't seem to find a correct answer.

So basically I need an answer in JAVASCRIPT to this scenario, if possible:

  1. Character picks up instrument

  2. Music of that instrument starts playing

  3. After 30 seconds, character picks up second instrument

  4. Second instrument track needs to start playing at its 30 seconds interval as well, not at 0 so it will be fully synced with the previous instrument. Music of First instrument still playing.

  5. After 1 minute, character picks up third instrument

  6. Third instrument tracks needs to start playing at its 1 minute interval as well, not at 0 so it will be fully synced with the previous instruments. Music of First & Second instruments still playing.

PLEASE NOTE THE FOLLOWING

  1. Each instrument track is set as an AUDIOCLIP variable and cannot be different. Audio Source is definitely out of the question as it won't work of what we intend to do (already tried it)

  2. The times aren't fixed, as one user might be faster/slower than another.

Thanks!

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 MakeCodeNow · Feb 17, 2014 at 02:30 AM

Check out AudioSource.timeSamples. If you have an audio source per track and set the timeSamples correctly before calling AudioSource.Play() then it will start at exactly the right part. I use this currently and it works well. This doesn't guarantee that they will stay in sync forever, but usually it's good enough.

The most correct solution is to use a multitrack (i.e. > 2 track) wav and then fade tracks in or out as they are needed, but I'm not sure if this is possible to do in Unity.

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

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

19 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

Related Questions

InGame Time out of synch with cooldown if resting (time goes faster). 2 Answers

How to define the number of times of an event? 1 Answer

How to synchronize Datetime from server to client? 0 Answers

Texts Highlighted at certain time (Karaoke like for spelling storytelling) 0 Answers

two projects in the same time 4 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