Example
// Create a simple blip sound
let mut sample = default;
sample.volume;
// Use a sine wave oscillator at 500 hz
sample.osc_type;
sample.osc_frequency;
// Set the envelope
sample.env_attack;
sample.env_decay;
sample.env_sustain;
sample.env_release;
// Add some distortion
sample.dis_crunch;
sample.dis_drive;
// Create a mixer so we can play the sound
let mut mixer = default;
// Play our sample
mixer.play;
// Plug our mixer into the audio device loop
// ...
mixer.generate;
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).
CPAL Example
To build the cpal
& music
examples on Linux you will need to have the alsa development libraries:
SDL Example
To build the sdl
you will need the SDL2 development libraries, on Linux: