Author: Pheonix KageDesu
Target: RPG Maker MZ / MV
Website: https://kdworkshop.net/ambient-sound
The PKD Ambient Sound plugin allows you to create dynamic sound points on your maps that will be played at specified intervals and only when the player is within a certain distance. This creates immersive ambient soundscapes that respond to player position.
- Create sound points at specific map coordinates
- Link sound points to events (sounds follow event position)
- Two playback modes: Interval (random timing) and Loop (continuous)
- Distance-based activation (sounds only play when player is nearby)
- Volume control for individual sound points
- Easy-to-use script calls for dynamic sound management
- Create more natural ambient soundscapes with sound variations
- Smooth scene transitions with fade effects
- You can create dynamic day/night cycles using sound groups
- Spatial audio with automatic panning
- You can create complex audio scenarios with batch group operations
- Type: Number
- Default: 100
- Range: 1+
- Description: Global volume multiplier for all ambient sounds in percentage. 100 = 100% volume.
- Type: Boolean
- Default: false
- Options: Clear / Keep
- Description: If enabled, all sound points will be automatically cleared when the player changes maps.
All script calls should be used in Script commands within events or through the console.
setAmbientInterval(ID, FILE_NAME, X, Y, T1, T2, DISTANCE)Creates a sound point that plays at random intervals within a specified time range.
Parameters:
ID- Unique identifier for this sound point (used for deletion)FILE_NAME- Name of the SE sound file (without extension) OR array of file names for random selectionX- Map X coordinateY- Map Y coordinateT1- Minimum time in SECONDS before sound repeatsT2- Maximum time in SECONDS before sound repeatsDISTANCE- Activation distance from player (in tiles)
Example:
setAmbientInterval(1, "Miss", 10, 20, 1, 3, 5);
// Plays "Miss" sound at position (10, 20)
// Random interval between 1-3 seconds
// Activates when player is within 5 tiles
// Using array for variety:
setAmbientInterval(2, ["Bird1", "Bird2", "Bird3"], 15, 25, 2, 5, 7);
// Randomly plays one of three bird sounds at position (15, 25)
// Each time a different bird sound may play
// Random interval between 2-5 secondssetAmbientIntervalEv(ID, FILE_NAME, EVENT_ID, T1, T2, DISTANCE)Creates a sound point linked to an event. The sound moves with the event.
Parameters:
ID- Unique identifier for this sound pointFILE_NAME- Name of the SE sound file OR array of file names for random selectionEVENT_ID- ID of the event to link toT1- Minimum time in SECONDS before sound repeatsT2- Maximum time in SECONDS before sound repeatsDISTANCE- Activation distance from player (in tiles)
Example:
setAmbientIntervalEv(2, "Equip1", 8, 1, 3, 3);
// Links sound to event #8
// Plays "Equip1" sound every 1-3 seconds
// Activates within 3 tiles
// Using array for footstep variety:
setAmbientIntervalEv(3, ["Step1", "Step2", "Step3"], 10, 0.3, 0.6, 2);
// Links to event #10 with varied footstep sounds
// Randomly picks one of three footstep sounds each timesetAmbientLoop(ID, "FILE_NAME", X, Y, DISTANCE, LOOP_REPEAT_TIME)Creates a continuously looping sound point at a fixed position.
Parameters:
ID- Unique identifier for this sound pointFILE_NAME- Name of the SE sound fileX- Map X coordinateY- Map Y coordinateDISTANCE- Activation distance from player (in tiles)LOOP_REPEAT_TIME- Time in MILLISECONDS before sound loops again
Example:
setAmbientLoop(3, "Waterfall", 10, 20, 5, 150);
// Creates looping waterfall sound at (10, 20)
// Loops every 150ms (0.15 seconds)
// Activates within 5 tilessetAmbientLoopEv(ID, "FILE_NAME", EVENT_ID, DISTANCE, LOOP_REPEAT_TIME)Creates a continuously looping sound point linked to an event.
Parameters:
ID- Unique identifier for this sound pointFILE_NAME- Name of the SE sound fileEVENT_ID- ID of the event to link toDISTANCE- Activation distance from player (in tiles)LOOP_REPEAT_TIME- Time in MILLISECONDS before sound loops again
Example:
setAmbientLoopEv(4, "Fire", 12, 4, 200);
// Links looping fire sound to event #12
// Loops every 200ms
// Activates within 4 tilessetAmbientSoundVolumeMod(ID, VOLUME_MOD)Modifies the volume of a specific sound point.
Parameters:
ID- ID of the sound point to modifyVOLUME_MOD- Volume modifier (1.0 = 100%, 0.5 = 50%, etc.)
Example:
setAmbientSoundVolumeMod(1, 0.5);
// Reduces volume of sound point #1 by half
setAmbientSoundVolumeMod(2, 1.5);
// Increases volume of sound point #2 by 50%clearAmbientSound(ID)Removes a sound point from the map.
Parameters:
ID- ID of the sound point to remove
Example:
clearAmbientSound(1);
// Removes sound point with ID 1fadeAmbientSound(ID, TARGET_VOLUME, FADE_TIME)Smoothly changes the volume of a sound point over time.
Parameters:
ID- ID of the sound point to fadeTARGET_VOLUME- Target volume modifier (1.0 = 100%, 0.5 = 50%, etc.)FADE_TIME- Duration of fade in SECONDS
Example:
fadeAmbientSound(1, 0.0, 3);
// Fades sound #1 to silence over 3 seconds (fade out)
fadeAmbientSound(2, 1.0, 2);
// Fades sound #2 to full volume over 2 seconds (fade in)pauseAmbientSound(ID)
resumeAmbientSound(ID)Pauses or resumes playback of a specific sound point.
Parameters:
ID- ID of the sound point to pause/resume
Example:
pauseAmbientSound(1);
// Pauses sound point #1
resumeAmbientSound(1);
// Resumes sound point #1setAmbientSoundPitch(ID, PITCH_MOD)Changes the pitch (playback speed) of a sound point.
Parameters:
ID- ID of the sound point to modifyPITCH_MOD- Pitch modifier (1.0 = normal, 0.5 = lower/slower, 1.5 = higher/faster)
Example:
setAmbientSoundPitch(1, 0.8);
// Makes sound #1 play 20% lower/slower
setAmbientSoundPitch(2, 1.2);
// Makes sound #2 play 20% higher/fastersetAmbientSoundPan(ID, PAN_VALUE)Controls stereo panning for a sound point.
Parameters:
ID- ID of the sound point to modifyPAN_VALUE- Pan value OR auto-pan setting- Number: -100 (full left) to 100 (full right), 0 = center
- Boolean (true): Enable automatic panning based on sound position
- Boolean (false): Disable automatic panning
Example:
setAmbientSoundPan(1, -50);
// Pan sound #1 to the left channel
setAmbientSoundPan(2, true);
// Enable automatic panning for sound #2
// Sound will pan left/right based on its position relative to player
setAmbientSoundPan(3, false);
// Disable automatic panning for sound #3isAmbientSoundActive(ID)
getAmbientSoundInfo(ID)Check if a sound is active or get detailed information about it.
Parameters:
ID- ID of the sound point to check
Returns:
isAmbientSoundActive()- Returnstrueif sound is playing,falseif paused or doesn't existgetAmbientSoundInfo()- Returns object with sound details, ornullif sound doesn't exist
Example:
if (isAmbientSoundActive(1)) {
console.log("Sound 1 is playing");
}
const info = getAmbientSoundInfo(1);
if (info) {
console.log("Volume:", info.volume);
console.log("Pitch:", info.pitch);
console.log("Is Active:", info.isActive);
}Info Object Properties:
id- Sound point IDfileName- Sound file nameisActive- Whether sound is currently playingisInterval- Whether sound uses interval modevolume- Current volume modifierpitch- Current pitch modifierpan- Current pan valueautoPan- Whether auto-pan is enableddistance- Activation distanceposition- Sound position (x, y coordinates or eventId)
Managing multiple sound points together using groups.
addAmbientSoundToGroup(ID, "GROUP_NAME")Adds one or multiple sound points to a named group for easier management.
Parameters:
ID- Sound point ID or array of IDs to add to groupGROUP_NAME- Name of the group (string). Use empty string "" to remove from all groups
Example:
// Add single sound to group
addAmbientSoundToGroup(1, "forest");
// Add multiple sounds to group
addAmbientSoundToGroup([1, 2, 3, 4], "forest");
// Remove sound from all groups
addAmbientSoundToGroup(1, "");clearAmbientSoundsInGroup("GROUP_NAME")Removes all sound points in a group and clears the group itself.
Parameters:
GROUP_NAME- Name of the group to clear
Example:
clearAmbientSoundsInGroup("forest");
// Removes all sounds in "forest" grouppauseAmbientSoundsInGroup("GROUP_NAME")
resumeAmbientSoundsInGroup("GROUP_NAME")Pauses or resumes all sound points in a group.
Parameters:
GROUP_NAME- Name of the group to pause/resume
Example:
pauseAmbientSoundsInGroup("forest");
// Pauses all forest sounds
resumeAmbientSoundsInGroup("forest");
// Resumes all forest soundssetAmbientGroupVolumeMod("GROUP_NAME", VOLUME_MOD)Sets the volume modifier for all sound points in a group.
Parameters:
GROUP_NAME- Name of the groupVOLUME_MOD- Volume modifier (1.0 = 100%, 0.5 = 50%, etc.)
Example:
setAmbientGroupVolumeMod("forest", 0.5);
// Sets all forest sounds to 50% volumeCreate bird chirping sounds at random intervals with variety:
// Using single sound file
setAmbientInterval(101, "Crow", 15, 8, 3, 8, 7);
// Using multiple sound files for more variety
setAmbientInterval(102, ["Bird1", "Bird2", "Bird3"], 25, 12, 4, 9, 7);
setAmbientInterval(103, ["Crow", "Raven"], 18, 20, 5, 10, 7);Create a continuous waterfall sound:
setAmbientLoop(201, "Waterfall", 30, 15, 10, 100);Link varied footstep sounds to a walking NPC:
// Using single footstep sound
setAmbientIntervalEv(301, "Step", 5, 0.5, 0.8, 2);
// Using multiple footstep sounds for realistic variety
setAmbientIntervalEv(302, ["Step1", "Step2", "Step3", "Step4"], 6, 0.4, 0.7, 2);
// Event #6 plays random footstep every 0.4-0.7 secondsCreate fire sound that follows a torch event:
setAmbientLoopEv(401, "Fire1", 10, 3, 250);
setAmbientSoundVolumeMod(401, 0.6);
// Quieter fire sound on event #10Group sounds together for easier control:
// Create forest ambience
setAmbientInterval(101, ["Bird1", "Bird2", "Bird3"], 15, 8, 3, 8, 7);
setAmbientInterval(102, ["Crow", "Raven"], 25, 12, 4, 9, 7);
setAmbientLoop(103, "Wind", 20, 15, 10, 200);
// Add all to "forest" group
addAmbientSoundToGroup([101, 102, 103], "forest");
// Later: fade out all forest sounds
setAmbientGroupVolumeMod("forest", 0.3);
// Or pause all forest sounds during dialogue
pauseAmbientSoundsInGroup("forest");
// Resume after dialogue
resumeAmbientSoundsInGroup("forest");
// Clear all when leaving the forest
clearAmbientSoundsInGroup("forest");Switch between day and night ambience:
// Day sounds
setAmbientInterval(201, ["Bird1", "Bird2"], 10, 10, 2, 5, 10);
setAmbientInterval(202, "Crow", 20, 20, 5, 10, 10);
addAmbientSoundToGroup([201, 202], "day");
// Night sounds
setAmbientInterval(301, ["Cricket1", "Cricket2"], 15, 15, 1, 3, 10);
setAmbientInterval(302, "Owl", 25, 25, 8, 15, 10);
addAmbientSoundToGroup([301, 302], "night");
// When night comes
pauseAmbientSoundsInGroup("day");
resumeAmbientSoundsInGroup("night");
// When day comes
pauseAmbientSoundsInGroup("night");
resumeAmbientSoundsInGroup("day");Always use unique IDs for each sound point to avoid conflicts. Consider using ranges:
- 1-99: Static map sounds
- 100-199: Event-based sounds
- 200+: Temporary sounds
- Close sounds (2-3 tiles): Torches, small objects
- Medium sounds (5-7 tiles): Animals, water features
- Far sounds (10+ tiles): Waterfalls, large ambient effects
- Interval: Random natural sounds (birds, wind, drips)
- Loop: Continuous sounds (waterfalls, fires, machinery)
For interval sounds, use arrays of similar sound files to add natural variety:
// Good: Natural variety in footsteps
setAmbientIntervalEv(1, ["Step1", "Step2", "Step3"], 5, 0.5, 0.7, 2);
// Good: Different bird calls
setAmbientInterval(2, ["Bird1", "Bird2", "Bird3", "Bird4"], 20, 15, 3, 8, 10);
// Tip: Use 3-5 variations for best resultsFor loop sounds, shorter intervals (100-300ms) create smoother continuous effects.
Use volume modifiers to create depth:
- Background sounds: 0.3-0.5
- Mid-ground sounds: 0.6-0.8
- Foreground sounds: 0.9-1.2
- Keep (false): For sounds that should persist across map transitions
- Clear (true): For map-specific ambience that shouldn't carry over
Organize sounds into logical groups for easier management:
// Good: Organized by theme
addAmbientSoundToGroup([1, 2, 3], "forest_birds");
addAmbientSoundToGroup([10, 11], "forest_wind");
addAmbientSoundToGroup([20, 21, 22], "town_crowd");
// Useful for: scenes, time of day, weather conditionsBenefits of using groups:
- Batch operations: Control multiple sounds at once
- Scene management: Easy fade in/out for cutscenes
- Dynamic environment: Quick switches between states (day/night, calm/storm)
- Memory efficiency: Clear entire groups when not needed
- Verify the sound file exists in
audio/se/folder - Check that the player is within the specified distance
- Ensure the ID is unique and not conflicting
- The DISTANCE parameter may be too large
- Verify X, Y coordinates are correct
- Adjust the global Volume Multiplier in plugin parameters
- Use
setAmbientSoundVolumeMod()for individual sound adjustments
- Enable "Auto Clear" in plugin parameters if you want automatic cleanup
- Manually clear sounds with
clearAmbientSound(ID)when needed
If you like this plugin and want more updates, please support the developer:
- Boosty: https://boosty.to/kagedesu
- Patreon: https://www.patreon.com/KageDesu
- YouTube: Pheonix KageDesu Channel
- Website: https://kdworkshop.net/