Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

8 Commits

Repository files navigation

oscy

Crates.ioDocs.rsLicense: MITChangelog

A Rust library for audio oscillators, waveform generation, and noise.

Sound sources

SourceDescription
NaiveOscSimple oscillator without anti-aliasing. Fast but produces aliasing at higher frequencies.
PolyBlepOscBand-limited oscillator using polyBLEP for reduced aliasing.
NoiseGenNoise generator with white, pink, and brown noise. Requires noise feature.

Usage

Filling an audio buffer

use oscy::{poly_blep::PolyBlepOsc,Oscillator,Waveform};letmut osc = PolyBlepOsc::new(44100.0,440.0,Waveform::Saw);letmut buffer = [0.0f32;512];
osc.fill(&mut buffer);

Using as an iterator

use oscy::{poly_blep::PolyBlepOsc,Waveform};let osc = PolyBlepOsc::new(44100.0,440.0,Waveform::Square);let samples:Vec<f32> = osc.take(1024).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 oscy::{naive::NaiveOsc, poly_blep::PolyBlepOsc,Oscillator,Waveform};// Naive: simple and fast, but aliasesletmut naive = NaiveOsc::new(44100.0,2000.0,Waveform::Saw);// PolyBLEP: smooths discontinuities to reduce aliasingletmut blep = PolyBlepOsc::new(44100.0,2000.0,Waveform::Saw);

Noise generator

Enable the noise feature in your Cargo.toml:

oscy = { version = "0.1", features = ["noise"] }
use oscy::noise::NoiseGen;letmut noise = NoiseGen::pink();let samples:Vec<f32> = noise.take(1024).collect();

Available types: white(), pink(), brown().

Supported waveforms

  • Sine
  • Saw
  • Square
  • Triangle

License

MIT License - see LICENSE for details.

About

A Rust library for audio oscillators and waveform generation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages