• 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 DKMode · Jun 23, 2014 at 08:57 PM · audiotimesoundmusic

Unmuted sounds playing off-beat

This is going to take some explanation, so please bear with me.

I'm creating a game wherein the player triggers timed sound loops by running into objects. For example, if a player runs into the corresponding object, it creates a sound on beat 1, while running into the object that comes directly after it will create a sound on beat 2, and so on.

To do this, I've created all the sounds in Reason first, and exported each note within a single-bar loop individually. So for the beat 1 sound, I deleted all of the notes in the one bar EXCEPT for beat 1, then exported that bar as an audio file - so the audio file is just the hit on beat 1, then silence for the remainder of the bar. I then do this for every note in the bar, and attach each individual beat to an individual object. The sounds are set to play on awake, and loop, but they're muted. I then use this piece of code to unmute the sound when the player runs into the object:

 function OnTriggerEnter (col: Collider) {
     if (col.gameObject.name == "SnakeHead1")
         audio.mute = false;
         renderer.enabled = false;}


The problem I'm having currently is that when I actually play the game, the sounds are not playing on their specified beats. I've checked the individual audio files, and it seems that everything should be in order, so the problem must be coming from something within Unity.

Any help here would be greatly appreciated. Thanks!

Comment
Add comment · Show 6
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 meat5000 ♦ · Jun 23, 2014 at 08:58 PM 0
Share

Are you building for Android, per-chance?

avatar image AlucardJay · Jun 23, 2014 at 10:40 PM 0
Share

What file format are your audio loops in?

Edit : you want to use .wav as mp3s have a silent portion and therefore not loopable (assumed for ID tag and other info)

avatar image DKMode · Jun 24, 2014 at 04:21 PM 0
Share

I am not building for Android, no. Not specifically, at least.

The audio loops are in .wav format. Would that be a problem?

avatar image DKMode · Jun 24, 2014 at 04:49 PM 0
Share

I've also noticed that if I make the sounds unmuted from the start, they are not playing on-time. I can see from the waveforms of the audio that they are definitely set up how I bounced them out originally, though.

avatar image AlucardJay · Jun 24, 2014 at 04:59 PM 0
Share

I would suggest a test where you don't use PlayOnAwake, but store all the AudioSources in an array one one script. At Start, loop through each AudioSource in the array and tell it to play. Hopefully this will get all the AudioSources to start playing at the same instant.

eg :

 var audioLoops : AudioSource[];
 
 function Start()
 {
     for ( var audioLoop : AudioSource in audioLoops )
     {
         audioLoop.Play();
     }
 }

You could also test if mute is the problem, by changing mute to volume = 0;

Show more comments

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why is my backtrack's volume getting lower? 0 Answers

Getting beats from a song using frequency range 1 Answer

audio different in game than preview? 1 Answer

Problem with seamless music looping in Unity 5 1 Answer

Why Doesn't My Music Loop? 5 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