Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tversteeg/usfx
🎼 Realtime procedurally generated sound effects
https://github.com/tversteeg/usfx
audio procedural-generation rust sfx sfxr
Last synced: 6 days ago
JSON representation
🎼 Realtime procedurally generated sound effects
- Host: GitHub
- URL: https://github.com/tversteeg/usfx
- Owner: tversteeg
- License: agpl-3.0
- Created: 2020-03-29T10:37:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-12T16:26:19.000Z (about 1 month ago)
- Last Synced: 2024-10-28T22:15:20.227Z (18 days ago)
- Topics: audio, procedural-generation, rust, sfx, sfxr
- Language: Rust
- Homepage:
- Size: 88.9 KB
- Stars: 53
- Watchers: 5
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
μsfx
Generate sound effects for your game in realtime.
## Example
```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.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`](examples/cpal.rs) & [`sdl`](examples/sdl2.rs) examples illustrate how to use it with different audio libraries. The [`music`](examples/music.rs) 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`](examples/cpal.rs) & [`music`](examples/music.rs) examples on Linux you will need to have the alsa development libraries:
```bash
sudo apt install libasound2-dev
```### SDL Example
To build the [`sdl`](examples/sdl2.rs) you will need the SDL2 development libraries, on Linux:
```bash
sudo apt install libsdl2-dev
```## Tools
- [usfx-test](https://github.com/emmabritton/uxfs-test) - pretty GUI program for playing with the parameters by @emmabritton
## Special Thanks
- [sfxr-rs](https://github.com/bzar/sfxr-rs) - inspiration
- [amsynth](https://github.com/amsynth/amsynth) - distortion algorithm