Generate sound effects for your game in realtime.
```rust // Create a simple blip sound let mut sample = usfx::Sample::default(); sample.volume(0.5);
// Use a sine wave oscillator at 500 hz sample.osctype(usfx::OscillatorType::Sine); sample.oscfrequency(500);
// Set the envelope sample.envattack(0.02); sample.envdecay(0.05); sample.envsustain(0.2); sample.envrelease(0.5);
// Add some distortion sample.discrunch(0.5); sample.disdrive(0.9);
// Create a mixer so we can play the sound let mixer = usfx::Mixer::default();
// Play our sample mixer.play(sample);
// Plug our mixer into the audio device loop // ... mixer.generate(&mut audiodevicebuffer); ```
The cpal
& sdl
examples illustrate how to use it with different audio libraries. The music
example shows how to create procedurally generated music with it (don't expect a masterpiece though, it's obvious I'm not a musician).