Author Topic: [Feature Suggestion/Request] Default Music/Ambience option in room properties.  (Read 276 times)


  • Zzz...
    • I can help with making music
    • I can help with story design
Not sure if this has been mentioned before but I thought it may be nice to add an option to the room's settings in the editor to select an ambient/music track to play for that room only and stop playing when exiting. It's not a major thing just a suggestion :)

Like somewhere here:
Spoiler: ShowHide
Follow me on twitter:

Crimson Wizard

  • Local Moderator
    • Lifetime Achievement Award Winner
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    • Crimson Wizard worked on one or more games that won an AGS Award!
    • Crimson Wizard worked on one or more games that was nominated for an AGS Award!
There have been such setting before, in the older versions of AGS, called "Play music on room load", but it has been removed in favor of using script commands.

Anything automatic (sound start/stop) in the current audio system tends to increase chances of unintended behavior conflicting with script, because it's unclear how to track such sound.
- If there are multiple music channels, how do you find the one where this "room music" is played on?
- If the "room music" was interrupted by something else (another music, e.g. played during an event), should it restart from beginning / restart from the same position / not restart at all?
- If the "room music" was stopped by a script command, then run again by a script command, should it be considered "same" music or a different one that engine should not stop on room exit now?

If there were a concept of "sound instances", where a playback is an object, that is explicit, may be addressed and tracked, that perhaps would be simplier to handle.

Note that it's relatively simple to script such system for your own game case. Imagine you add a custom property to rooms, called "RoomMusic", you may then use on_event in a global script to catch room enter/leave events and handle this "room music", for example:
Code: Adventure Game Studio
  1. AudioChannel *roomMusic;
  3. function on_event (EventType event, int data) {
  4.     if (event == eEventEnterRoomBeforeFadein) {
  5.         int music = Room.GetProperty("RoomMusic");
  6.         if (music >= 0) {
  7.              roomMusic = Game.AudioClips[music].Play();
  8.         }
  9.     } else if (event == eEventLeaveRoom) {
  10.         int music = Room.GetProperty("RoomMusic");
  11.         if (music >= 0) {
  12.              Game.AudioClips[music].Stop();
  13.         }
  14.     }
  15. }
« Last Edit: 30 Nov 2021, 12:07 by Crimson Wizard »


  • Zzz...
    • I can help with making music
    • I can help with story design
Thanks for the tip CW! I'll definitely put it to good use :)
Follow me on twitter: