Pitch Shifting
Dynamically adjust audio pitch.
Introduction
Dynamically adjust audio pitch. This page provides a complete guide to pitch shifting in Appley, covering everything from setup to advanced techniques.
Audio is a core area of Appley. Understanding pitch shifting will help you build better games and use the platform more effectively. This documentation is designed for advanced level users.
Requirements
Before working with pitch shifting, 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
Step-by-Step Guide
Follow these steps to work with pitch shifting in your Appley project:
Prepare audio files
Obtain or create audio files in MP3, WAV, or OGG format for pitch shifting.
Import audio
Upload the audio files through the Asset Browser in Creator Studio.
Configure audio source
Set the audio properties: loop, volume, pitch, 3D spatial, and channel.
Script playback
Use the audio API in Appley Scripting to play and control sounds.
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 pitch shifting:
// Audio — Pitch Shifting
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:
[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
Common Mistakes
Avoid these frequent mistakes when working with pitch shifting:
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 pitch shifting, try these solutions:
No sound plays
Audio is distorted
3D audio has no direction
Audio loops have a gap
Performance Tips
Optimize your use of pitch shifting 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.
Related Pages
Explore these related documentation pages:
Example Project
Download a complete example project demonstrating pitch shifting:
