oscy
A Rust library for audio oscillators, waveform generation, and noise.
Sound sources
| Source | Description |
|---|---|
NaiveOsc |
Simple oscillator without anti-aliasing. Fast but produces aliasing at higher frequencies. |
PolyBlepOsc |
Band-limited oscillator using polyBLEP for reduced aliasing. |
NoiseGen |
Noise generator with white, pink, and brown noise. Requires noise feature. |
Usage
Filling an audio buffer
use ;
let mut osc = new;
let mut buffer = ;
osc.fill;
Using as an iterator
use ;
let osc = new;
let samples: = osc.take.collect;
Naive vs PolyBLEP
Use NaiveOsc when performance is critical and aliasing is acceptable (e.g., low frequencies, or when followed by filtering). Use PolyBlepOsc for cleaner sound at higher frequencies.
use ;
// Naive: simple and fast, but aliases
let mut naive = new;
// PolyBLEP: smooths discontinuities to reduce aliasing
let mut blep = new;
Noise generator
Enable the noise feature in your Cargo.toml:
= { = "0.1", = ["noise"] }
use NoiseGen;
let mut noise = pink;
let samples: = noise.take.collect;
Available types: white(), pink(), brown().
Supported waveforms
- Sine
- Saw
- Square
- Triangle
License
MIT License - see LICENSE for details.