Skip to main content

Overview

Finewave provides real-time audio effects that can be applied to individual audio sources. These effects enhance realism and immersion by simulating acoustic environments and adding creative sound design.

Available Effects

Finewave includes three built-in audio effects:
  • Reverb: Simulates acoustic reflections in a space
  • Echo: Creates delayed repetitions of sound
  • Distortion: Adds harmonic distortion for gritty sounds

Reverb Effect

Reverb simulates how sound reflects off surfaces in an environment, creating a sense of space.

Basic Usage

#include "finewave/effect.h"

// Create reverb effect
Reverb reverb;

// Apply to audio source
audioSource.applyEffect(reverb);

Reverb Parameters

Reverb cathedralReverb;

// Room size (0.0 to 1.0)
// Larger values create bigger, more spacious reverb
cathedralReverb.setRoomSize(0.9f);

// Damping (0.0 to 1.0)
// Lower values create brighter, longer reflections
cathedralReverb.setDamping(0.3f);

// Wet level (0.0 to 1.0)
// Amount of reverb effect
cathedralReverb.setWetLevel(0.6f);

// Dry level (0.0 to 1.0)
// Amount of original signal
cathedralReverb.setDryLevel(0.4f);

// Stereo width (0.0 to 1.0)
// Width of the stereo field
cathedralReverb.setWidth(1.0f);

// Apply to source
audioSource.applyEffect(cathedralReverb);

Environment Presets

Small Room

Reverb smallRoom;
smallRoom.setRoomSize(0.3f);
smallRoom.setDamping(0.5f);
smallRoom.setWetLevel(0.3f);
smallRoom.setDryLevel(0.7f);
smallRoom.setWidth(0.8f);

Cathedral

Reverb cathedral;
cathedral.setRoomSize(0.9f);
cathedral.setDamping(0.3f);
cathedral.setWetLevel(0.6f);
cathedral.setDryLevel(0.4f);
cathedral.setWidth(1.0f);

Cave

Reverb cave;
cave.setRoomSize(0.8f);
cave.setDamping(0.2f);
cave.setWetLevel(0.7f);
cave.setDryLevel(0.3f);
cave.setWidth(0.9f);

Footsteps Example

class FootstepSound : public Component {
    AudioSource footstep;
    Reverb hallReverb;
    
public:
    void init() override {
        // Load footstep sound
        footstep.fromFile(
            Workspace::get().getResource("footstep")
        );
        
        // Configure reverb for hallway
        hallReverb.setRoomSize(0.6f);
        hallReverb.setDamping(0.4f);
        hallReverb.setWetLevel(0.5f);
        hallReverb.setDryLevel(0.5f);
        
        // Apply effect
        footstep.applyEffect(hallReverb);
        
        // Enable spatial audio
        footstep.useSpatialization();
    }
    
    void update(float deltaTime) override {
        // Play on footstep event
        if (shouldPlayFootstep()) {
            footstep.play();
        }
    }
};

Echo Effect

Echo creates distinct delayed repetitions of the original sound, perfect for canyons or large open spaces.

Basic Usage

Echo echo;
echo.setDelay(0.5f);      // 500ms delay
echo.setDecay(0.4f);      // 40% volume per repetition
echo.setWetLevel(0.5f);   // 50% echo
echo.setDryLevel(0.7f);   // 70% original

audioSource.applyEffect(echo);

Echo Parameters

Echo canyonEcho;

// Delay time in seconds
// Time between repetitions
canyonEcho.setDelay(0.5f);

// Decay rate (0.0 to 1.0)
// How much quieter each repetition becomes
canyonEcho.setDecay(0.4f);

// Wet level (0.0 to 1.0)
// Amount of echo effect
canyonEcho.setWetLevel(0.5f);

// Dry level (0.0 to 1.0)
// Amount of original signal
canyonEcho.setDryLevel(0.7f);

audioSource.applyEffect(canyonEcho);

Voice Line Example

class VoiceSystem : public Component {
    AudioSource voiceLine;
    Echo echo;
    
public:
    void init() override {
        // Load voice audio
        voiceLine.fromFile(
            Workspace::get().getResource("dialogue_01")
        );
        
        // Configure echo for dramatic effect
        echo.setDelay(0.3f);
        echo.setDecay(0.5f);
        echo.setWetLevel(0.4f);
        echo.setDryLevel(0.8f);
        
        voiceLine.applyEffect(echo);
    }
    
    void playDialogue() {
        voiceLine.play();
    }
};

Distortion Effect

Distortion adds harmonic overtones and can create gritty, aggressive sounds for engines, weapons, or electronic effects.

Basic Usage

Distortion distortion;
distortion.setEdge(0.7f);
distortion.setGain(3.0f);
distortion.setLowpassCutoff(4000.0f);

audioSource.applyEffect(distortion);

Distortion Parameters

Distortion guitarDistortion;

// Edge sharpness
// Controls the character of the distortion
guitarDistortion.setEdge(0.7f);

// Gain multiplier
// How much the signal is amplified before distortion
guitarDistortion.setGain(3.0f);

// Lowpass filter cutoff (Hz)
// Removes harsh high frequencies
guitarDistortion.setLowpassCutoff(4000.0f);

audioSource.applyEffect(guitarDistortion);

Engine Sound Example

class Engine : public Component {
    AudioSource engineSound;
    Distortion engineDistortion;
    
public:
    void init() override {
        // Load engine audio
        engineSound.fromFile(
            Workspace::get().getResource("engine_idle")
        );
        
        // Configure distortion
        engineDistortion.setEdge(0.5f);
        engineDistortion.setGain(2.5f);
        engineDistortion.setLowpassCutoff(3500.0f);
        
        engineSound.applyEffect(engineDistortion);
        engineSound.setLooping(true);
        engineSound.useSpatialization();
        engineSound.play();
    }
    
    void update(float deltaTime) override {
        // Vary pitch based on speed
        float speed = getCurrentSpeed();
        float pitch = 0.8f + (speed / 100.0f) * 0.7f;
        engineSound.setPitch(pitch);
    }
};

Combining Effects

You can apply multiple effects to a single audio source:
// Create effects
Reverb reverb;
reverb.setRoomSize(0.7f);
reverb.setWetLevel(0.4f);

Distortion distortion;
distortion.setEdge(0.3f);
distortion.setGain(1.5f);

// Apply both effects
audioSource.applyEffect(reverb);
audioSource.applyEffect(distortion);

Dynamic Environment Effects

Change effects based on player location:
class AdaptiveAudio : public Component {
    AudioSource ambientSound;
    Reverb currentReverb;
    
public:
    void init() override {
        ambientSound.fromFile(
            Workspace::get().getResource("ambient")
        );
        ambientSound.setLooping(true);
        updateEnvironment("outdoor");
        ambientSound.play();
    }
    
    void updateEnvironment(const std::string& environment) {
        if (environment == "outdoor") {
            // Minimal reverb for outdoor
            currentReverb.setRoomSize(0.2f);
            currentReverb.setWetLevel(0.1f);
        } else if (environment == "cave") {
            // Heavy reverb for cave
            currentReverb.setRoomSize(0.9f);
            currentReverb.setWetLevel(0.7f);
        } else if (environment == "indoor") {
            // Medium reverb for indoor
            currentReverb.setRoomSize(0.5f);
            currentReverb.setWetLevel(0.4f);
        }
        
        ambientSound.applyEffect(currentReverb);
    }
    
    void update(float deltaTime) override {
        // Detect environment changes and update effects
        std::string newEnv = detectEnvironment();
        updateEnvironment(newEnv);
    }
};

Complete Example: Spatial Audio with Effects

class Torch : public CompoundObject {
    CoreObject torchModel;
    
public:
    void init() override {
        // Create visual torch
        torchModel = createModel("torch.obj");
        torchModel.setPosition({5.0f, 1.0f, 0.0f});
        torchModel.initialize();
        this->addObject(&torchModel);
        
        // Add crackling sound with reverb
        auto audioPlayer = torchModel.addComponent<AudioPlayer>();
        audioPlayer->setSource(
            Workspace::get().createResource(
                "torch_crackle.wav",
                "TorchSound",
                ResourceType::Audio
            )
        );
        
        // Enable spatial audio
        audioPlayer->useSpatialization();
        audioPlayer->source->setLooping(true);
        audioPlayer->source->setVolume(0.6f);
        
        // Add subtle reverb
        Reverb torchReverb;
        torchReverb.setRoomSize(0.4f);
        torchReverb.setDamping(0.6f);
        torchReverb.setWetLevel(0.3f);
        torchReverb.setDryLevel(0.7f);
        audioPlayer->source->applyEffect(torchReverb);
        
        audioPlayer->play();
    }
};

Performance Considerations

Audio effects are processed in real-time:
  • Effects have minimal CPU overhead for a few sources
  • For many sources, consider:
    • Applying effects only to important/close sounds
    • Disabling effects for distant sources
    • Using simpler effects (echo vs reverb)

Best Practices

Choose effect parameters that match your acoustic environment. Large rooms need bigger reverb, canyons need longer echo delays.
Keep dry level high enough to preserve clarity. Too much wet signal can make audio muddy. A 40% wet / 60% dry ratio is often a good starting point.
Effects should enhance, not overwhelm. Start with conservative settings and adjust to taste.
Effects work great with spatial audio. Apply reverb to 3D positioned sources for realistic environment simulation.

Next Steps

Audio API Reference

Complete API documentation for Finewave

Physics Overview

Add physics interactions to your audio sources

Build docs developers (and LLMs) love