Forum rules - please read before posting.

Audio Mixer Groups, 3D Sounds and synchronizing audio tracks

Dear all,

Our game has several puzzles wherein the scene's music is synchronized with another audio track that provides a complimentary melody when the player solves a puzzle. For example, the player fixes the organ grinder's broken machine, and it plays a little melody alongside the normal music for the scene. These additional audio tracks are often localised to a certain place - so in the example above, if you walk to the far side of the scene you should now be out of earshot of the organ and only hear the normal theme.

I'm attempting to implement this by having both tracks playing simultaneously all the time, with the additional track at zero volume until the player solves the puzzle.

In order for the synchronisation to work, the two tracks (which are the exact same length) need to start simultaneously. I've set up Unity audio mixer groups for the game, and having both tracks as sound objects in the scene with Play on Awake ticked allows me to assign mixer groups to them, set one to zero and then turn it up later by transitioning to a different Snapshot when the puzzle is solved.

However, this smashes me headlong into the bug this user encountered:
https://adventurecreator.org/forum/discussion/7022/parent-sound-object-triggering wherein the action that changes the mixer snapshot occurs a fraction of a second after Play on Awake, resulting in a blast of sound at the beginning of the scene.

As an alternative, I've tried both (a) having one track as a AC music track and the other as an AC ambience track and (b) having both as ambience tracks. The two sync up just fine, but without a sound object in the scene, I'm unable to assign a specific mixer group to them, meaning that turning down my additional track also turns down all other SFX in the entire game. This problem occurs if both tracks are set as ambience. Is there a menu somewhere where I can assign a specific child mixer group to a track that I've just not spotted?

A further problem with using ACs ambience/music players to control the additional tracks is that I can't seem to set 3D audio information for them, or link them to a corresponding sound object in the scene to do so - is this possible, or am I going about it the wrong way?

Comments

  • You don't need to begin both tracks at the same time - through script, you can set the starting point of a track to match that of the current music.

    Is that the reason you're looking for it to be in 3D? The music/ambience system is assumed to be "scene wide", and so are played in 2D.

    Seems to me that you have a couple of options, depending on preference:

    1. Have a Sound object of the type Music to fade in the additional track when the player gets close enough.

    You can get the current timeSamples of the main music with:

    int timeSamples = AC.KickStarter.music.audioSource.timeSamples;
    

    And then start playing the Sound from that point:

    GetComponent <AC.Sound>().FadeIn (0.5f, true, FadeIn, timeSamples);
    
    1. Don't have a separate "organ grinder" track, but instead create a new track with both the "original" and "organ grinder" variations into one - and then crossfade to that from your original track when the player gets close enough.

      AC.KickStarter.music.Play (trackID, true, false, 0.5f, false, timeSamples);

    Where "trackID" is the ID number of the combined track.

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.