This feature allows you to add audio sources on a map with a particular BGM/BGS or SE having varying volume and panning depending on the player's position to the audio source(s). There can be multiple audio sources for a single BGM/BGS, the volume and panning will be calculated according to the player's position to ALL audio sources. Beware of performance if you have TONS of audio sources, especially if they are dynamic (more on that below).
Audio Sources are created via events. Basically, you assign a BGM/BGS to a channel number and you attach audio sources to the channel number. So if you add the River BGS in channel 5, you can create an audio source for that River BGS by creating an event and adding this tag in the note box:
<bgs_source: 5>. This will make that event an audio source for the BGS in channel 5. Here's the code to be put in the note box of an event for spatial BGM and BGS:
- For BGM:
<bgm_source: channel>, replace channel with the actual channel number.
- For BGS:
<bgs_source: channel>, replace channel with the actual channel number.
That takes care of the part about audio sources, but you need to actually add the spatial BGM/BGS to the audio channel. You can do so with plugin commands, just run it an auto event which erases itself after running the plugin commands. Use one of these plugin commands:
- For BGM:
Add Spacial BGM
- For BGS:
Add Spacial BGS
Here's how the window will look for a spatial BGM, but spatial BGS are essentially the same:
The filename, pitch and channel arguments are pretty straightforward. The other arguments can be a bit confusing so I'll go through each one of them.
The
Max Volume is simply the maximum possible volume of the audio. Basically, the closer you are to a source, the closer to the max volume you'll be.
The
Radius refers to a radius around an audio source inside which the audio can be heard. When outside the radius, the player can't hear the audio attached to the audio source. Inside the radius, the closer the player is to the source, the higher the volume.
The
Strength refers to the curve of the volume variation INSIDE the radius. This does not affect the radius at all. Basically, how do you want the volume to increase or decrease based on position? If strength is 100, this will equal a linear function, meaning that if the radius is 10 and the max volume is 100, each 1 distance away from the source will result in -10 volume. If the strength is higher than 100, the volume will decrease slower (imagine a root function), if the strength is smaller than 100, the volume will decrease faster (imagine a parabolic function).
The
Pan Type allows you to control how the panning will work if you want that feature (there's an option to deactivate it). There are at the moment only 2 pan types:
- Origin Expand: the closer to the source, the less panning there will be. The further away from the source, the more the panning starts to kick in. The Pan Start Distance is the distance from the source before the audio starts panning, and the Pan Length Distance is the distance it takes for the pan to hit 100% (distance from when it starts panning, not from the source).
- Linear Scaling: the pan is simply calculated with the X and Y position of the player to the source. This is more appropriate for side view like the Mario Bros games because if the player 1 tile left from the source and at the same Y position the panning will be 100 (meaning 100% playing from the right speaker). The Pan Start Distance and Pan Length Distance are not used at all with this algorithm.
The
Dynamic argument is very important as it will affect the game performance. This should be TRUE if any of the audio sources associated with this channel can move, meaning that their position can change. If all the audio sources associated with this channel will remain at the same position then this argument should be set to FALSE to save performance. Basically if this argument is false, the game will only check if the player has moved to update the audio. If set to TRUE, the game will check if either the player moved or ANY of the audio sources associated with the channel has moved.
The Cross Fade argument is unique to spatial BGMs. Basically if set to true, it will cross fade the volume of the main BGM (the map BGM) and the spatial BGM the closer the player gets to the audio source. It will be just like this:
For spatial SE, it's pretty similar except for a few things. First of all, the SE will update when the player moves. The volume and pitch are calculated depending on the player's position to a single source when it starts playing. This is because SE are usually short and don't loop. A second difference is that there is no channel, the source is simply determined by the event ID (so it's using the event's position to the player).
With this method, you can also decide to turn ON or OFF the pitch and volume variance feature. This will override the general variance setting from the plugin. You can just leave them to "default" if you want it to follow the general variance setting from the plugin.