Crate usfx

Source
Expand description

Generate sound effects for your game in realtime.

§Example

// Create a simple blip sound
let mut sample = usfx::Sample::default();
sample.volume(0.5);

// Use a sine wave oscillator at 500 hz
sample.osc_type(usfx::OscillatorType::Sine);
sample.osc_frequency(500);

// Set the envelope
sample.env_attack(0.02);
sample.env_decay(0.05);
sample.env_sustain(0.2);
sample.env_release(0.5);

// Add some distortion
sample.dis_crunch(0.5);
sample.dis_drive(0.9);

// Create a mixer so we can play the sound
let mut mixer = usfx::Mixer::default();

// Play our sample
mixer.play(sample);

// Plug our mixer into the audio device loop
// ...
mixer.generate(&mut audio_device_buffer);

Structs§

Mixer
Manage samples and mix the volume output of each.
Sample
Audio sample that procedurally generates it’s sound.

Enums§

DutyCycle
Possible values for the duty cycle of the square wave.
OscillatorType
Wave form generation type.