AppleyAppley Docs
Docs/Audio

Audio Fading

Smooth fade in and out transitions.

8 min read Intermediate Updated 2026-07-01 v2.0 ~23 min to complete

Introduction

Smooth fade in and out transitions. This page provides a complete guide to audio fading in Appley, covering everything from setup to advanced techniques.

Audio is a core area of Appley. Understanding audio fading will help you build better games and use the platform more effectively. This documentation is designed for intermediate level users.

Requirements

Before working with audio fading, ensure you have the following:

  • Audio files (MP3, WAV, OGG)
  • An Appley project
  • Basic understanding of game audio
  • Optional: Freesound API key for sound search

Estimated Completion Time

This guide takes approximately 23 minutes to complete. The estimated reading time is 8 minutes. Difficulty level: Intermediate.

Step-by-Step Guide

Follow these steps to work with audio fading in your Appley project:

1

Prepare audio files

Obtain or create audio files in MP3, WAV, or OGG format for audio fading.

2

Import audio

Upload the audio files through the Asset Browser in Creator Studio.

3

Configure audio source

Set the audio properties: loop, volume, pitch, 3D spatial, and channel.

4

Script playback

Use the audio API in Appley Scripting to play and control sounds.

5

Mix and test

Adjust volume levels and test the audio mix. Use the Audio Manager.

FluxScript Example

Below is an Appley Scripting (Flux Scripting) code example demonstrating audio fading:

Audio Fading — Appley Scripting
// Audio — Audio Fading
on start {
  audio.playLoop("ambient_wind")
  audio.setVolume("ambient_wind", 0.3)
  bgm = audio.play("bgm", { volume: 0.7, loop: true })
}

on collision(other) {
  if other.type == "coin" {
    audio.play("collect", { pitch: 1.0 + math.random(0.2) })
  }
  if other.type == "enemy" {
    audio.play("hit", { volume: 0.9 })
    audio.setPitch("hit", 0.8)
  }
}

on event("gameOver") {
  audio.fadeOut("bgm", 1.5)
}

Node Script Example

The same logic can be implemented using Node Scripting. Here is the equivalent node graph:

Audio Fading — Node Graph
[On Collision] ──► [Branch: type]
            ├─ "coin" ──► [Play: "collect", random pitch]
            └─ "enemy" ──► [Play: "hit", volume 0.9]

[On Event "gameOver"] ──► [Fade Out: "bgm", 1.5s]

Interchangeable Systems

FluxScript and Node Scripting compile to the same runtime. You can mix both in a single project — use whichever is best for each task.

Common Mistakes

Avoid these frequent mistakes when working with audio fading:

Using uncompressed WAV files for long music

Use MP3 or OGG for background music to reduce file size.

Playing too many simultaneous audio sources

Limit to 8-10 concurrent sounds. Use audio channels for grouping.

Not setting 3D audio properties

Enable spatial audio for positional sounds like footsteps and gunfire.

Loading all audio at startup

Stream long audio files instead of loading them into memory.

Troubleshooting

If you encounter issues with audio fading, try these solutions:

No sound plays
Check that audio is not muted. Verify the file loaded. Ensure volume is above 0.
Audio is distorted
Reduce the volume. Check for overlapping sources. Lower the master mixer level.
3D audio has no direction
Ensure the listener is attached to the camera. Enable spatial audio.
Audio loops have a gap
Use seamless loop files. Check for silence at start/end of the clip.

Performance Tips

Optimize your use of audio fading with these performance tips:

  • Use audio channels to group sounds (music, sfx, voice) for independent volume control.
  • Randomize pitch slightly (0.9-1.1) on repeated sound effects to avoid monotony.
  • Use audio occlusion for realistic sound blocking behind walls.
  • Pre-load frequently used short sounds; stream long music tracks.

Explore these related documentation pages:

Example Project

Download a complete example project demonstrating audio fading: