We used command instrument to implement such design. When Player enter battle ready state, we lower the volume of the BGM by using snapshots(which name in chinese), while play the Battle BGM. But player might quit such state at any time. In that case we want to stop the battle BGM, then turn on the previous BGM.
if we use snapshot instrument instead, the snapshot will stop immediately when the Battle BGM stopped. Since we want a fade in fade out transition, we switch to command instrument implementation.
pic3. we set the condition as event state stopping
In the “Stop Snapshot” command instrument, I did such setup. But when I hit the stop button, the Battle BGM instance stuck in the Stopping state. I looked up related topic in the forum. It is said that, if we uses stopping condition, Fmod will not really stop the event instance and left it to developers.
I wonder, in such case, how should we implement the “Stop”? Of course we can try to use parameter condition. Moreover on the other hand, whats the best practice to implement transition (e.g. crossfade) between different instances?
I found that, if the playback marker leaves the snapshot instrument area, the snapshot stops itself with AHDSR activated. So instead of making snapshot instrument cover all the timeline, we shorten its length since we only need it when the event is looping in the loop region above.
Then, our player may quit the battle intro at anytime, so when they quit, we use a parameter to activate the transition region(mark in the picture). We may jump to a kind of escaping sound effect with a fade out. And at the same time, the snapshot, which controll the volume of another group, stops with a decay, allowing the volume raise slowly.
This seem to work just fine. But I’m still looking forward to your replay, about the “stopping” question.
BTW, I try to call the EventInstance.stop() and pass the allow_fade_out, but the event seems to stop immediately. And it doesn’t trigger the stopsnapshot instrument (in my first post).
A brief summary about how to apply AHDSR of a snapshot:
When using snapshot instrument, the AHDSR will be applied when playback position leave the snapshot area.
When using Command Instrument to start a snapshot event, the AHDSR will be applied as long as you add another Command Instrument which “stop snapshot event” by “stopping conditon”. (Make sure you enter stopping state successfully).
After looking up the forum and the documentation. When using “Stopping Codition” in the event, calling “Stop” will let the event enter “Stopping State”. In that state, AHDSR will be applied and the event won’t stop till it reach the “natural end”. The “natural end,” in my understanding, refers to when the playback position reaches the end of all tracks.
But what if the “Stop” is called in a loop region? Well I tried it and the event stucks in that loop region and never ends. To break this loop, I add a codition to the loop region, showed in the picture below.
Yes, we may take both two approaches in our project. Some general snapshots might be triggered through code, while for certain events where the triggering of snapshots is strongly related to the timeline, we attempt to use snapshots directly within the event to reduce the number of calls. Actually this practice was also observed in the Celeste project.