usfx

Crates.iousfx
lib.rsusfx
version0.1.5
sourcesrc
created_at2020-04-03 12:40:26.04571
updated_at2023-12-21 09:27:58.904549
descriptionRealtime procedurally generated sound effects
homepage
repositoryhttps://github.com/tversteeg/usfx
max_upload_size
id225903
size119,731
Thomas Versteeg (tversteeg)

documentation

https://docs.rs/usfx

README

μsfx

CI Version Rust Documentation License

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);

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:

sudo apt install libasound2-dev

SDL Example

To build the sdl you will need the SDL2 development libraries, on Linux:

sudo apt install libsdl2-dev

Tools

  • usfx-test - pretty GUI program for playing with the parameters by @emmabritton

Special Thanks

Commit count: 54

cargo fmt