Answered
0
0

Greetings,

I am currently working on a game on Unity3D and I have seen the tutorials on how to create interactive music system. These videos all use just one “track”.

On the game I’m working, the soundtrack has several music tracks. I have been searching around but I still haven’t found how to make a music system with multiple tracks.

  1. How can I cycle through the entire OST?
  2. Do I simply play the corresponding events?
  3. What is the best way to store the list of events to play?

Thank you for your time.

  • You must to post comments
Best Answer
1
0

If you want to have multiple pieces of music triggered by the game, it is probably be easiest to keep them in separate events. If you need to enumerate these events in game, you can use Studio.Bank.getEventCount and Studio.Bank.getEventList (http://www.fmod.org/documentation/#content/generated/FMOD_Studio_Bank_GetEventList.html). You will then likely want to filter for certain events based on a path prefix (e.g. event paths starting with “event:/Music/”). You can do this using the accessor function Studio.EventDescription.getPath (http://www.fmod.org/documentation/#content/generated/FMOD_Studio_EventDescription_GetPath.html).

A more advanced way of selecting switching between different events would be to make a ‘container event’, that has event sounds referencing each of the music events. You could arrange the event sounds on a parameter that switches between different pieces of music based on the parameter value.

  • João Serina

    Thank you for your reply! On a related note is there a way to get the output level from an event? In my events there are some transitions to silence so that the music isn’t playing at all times and I would like to know if there is a way to get the output volume of an event. The only thing I could find was the Studio.EventInstance.getVolume (http://www.fmod.org/documentation/#content/generated/FMOD_Studio_EventInstance_GetVolume.html) but from what I gathered that returns the volume set in FMOD Studio and not the output level.

  • Cameron Baron

    Using metering you can get the current volume per channel.
    Basically get the tail dsp (before any panning or volume control), enable metering and get the metering info whenever you need the latest data.
    Here is a short example:

    [FMODUnity.EventRef] public string eventRef;
    FMOD.Studio.EventInstance instance;
    FMOD.ChannelGroup channelGroup;
    FMOD.DSP metering;
    FMOD.DSP_METERING_INFO dspInfo = new FMOD.DSP_METERING_INFO();

    /* Start */
    instance = FMODUnity.RuntimeManager.CreateInstance(eventRef);
    instance.start();

    instance.getChannelGroup(out channelGroup);
    channelGroup.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.TAIL, out metering);
    metering.setMeteringEnabled(false, true);

    /* Call this before checking the data */
    metering.getMeteringInfo(null, dspInfo);

    From there you can use the dspInfo to get the volume of each channel.

  • João Serina

    Thanks a lot for the reply!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.