Forum rules - please read before posting.

Audio intro+loop

Hi everyone,
Is someone uses music tracks with an intro and a loop?
I tried a system with 2 audio objects, one for the intro, one for the loop.
With ActionList in parallel at the beginning of each scene, I run the intro and then the loop, but not in a good way. I use the "pause game" action, I indicate precisely the number of seconds (equal to the intro), and then the loop starts. But strangely this is not very accurate.
Is it expected to have "Wait until finish" with "play sound" action, or is there a better method than the one I use?

thanks

Comments

  • A custom Action could be written to "wait" for the old music to finish before playing the new, but otherwise I'd say this is the right way.  Not accurate - too soon or late?

    Just so you're aware, if you Play or Fade In the new music, the old one will fade out, allowing for a crossfade effect to ease the transition.
  • With my method it's often too late, and you hear a cut. So I try to decrease the number of milliseconds.
    It works in an approximate way (it was better in unity 4, my previous settings are still too "long" in unity 5)
    The two tracks are created to be played without a fade in, but I will test with a crossfade effect,
    Thank you Chris!
  • edited March 2015
    Maybe a custom action is what is needed here...

    You could take the "play sound" action, and make something like a "play intro+music" action or "play sounds playlist" action using audiosource.PlayScheduled with the audioclips.length of your clips.

    Remember to preload you clip (it needs time to buffering and stuff :P) and use AudioSettings.dspTime+nextclip.lenght for your scheduled starting time.

    ref: http://docs.unity3d.com/ScriptReference/AudioSource.PlayScheduled.html
  • Thanks! I was looking yesteray night to improve the play sound action with audioclips.length but I'm terrible coder. And I missed this doc, so I should be able to find the solution now. If it works, I'll give you the code I used :)
  • Well, I could create a playlist, but the cut is still listenable. My files are played without a cut in my daw, I export to ogg and the loop works well in unity (mp3 format is very bad for loops, but that's normal).
    For now, I'll keep with my first solution.
  • Hello! I have made a Unity plugin called Introloop which you can guess what it does : play music with intro which then goes into endless looping. You don't need to cut music into 2 files physically, and because of this the cut is very clean. You just give it 2 boundary points and play it.

    I also implemented this internally with multiple AudioObjects like you said, but I uses 4, not 2. Since it supports cross-fading between intro-included audio it means at some point you can hear both playing at the same time, hence the double amount of AudioSource pair.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.