Crate twang[−][src]
A sound synthesis crate.
extern crate twang; // for sound generation / effects extern crate adi; // for speaker use twang as t; fn main() { let mut speaker = adi::speaker::Speaker::new(0, false).unwrap(); let mut gen = t::Generator::new(440.0, 1.0); loop { let x = gen.next(); // Play synthesized voice. speaker.update(&mut || { // Do synthesis t::out(t::mul(&[ t::dst(t::sin(x), 2), t::dst(t::saw(x), 2) ])) }); } }
Structs
Generator |
An audio wave generator. |
PnkGenerator |
Pink Noise Generator. |
WhtGenerator |
White Noise Generator. |
Functions
acs |
Arcosine of a sound wave. |
add |
Add sound waves together. (Add sound waves ontop of eachother), may introduce clipping. |
asn |
Arcsine of a sound wave. |
atn |
Arctangent of a sound wave. |
crt |
Cube root of sound wave. |
dst |
Discrete step conversion of sound wave. |
hrd |
Distort sound wave with hard clipping. Volume should be more than 1 to have any effect. |
inv |
Invert sound wave (-x). |
mix |
Mix sound waves together. (Add soundwaves together, then divide by len) |
mul |
Multiply sound waves together, avoiding octave jump. |
neg |
Only the negative part of the wave. |
out |
Convert an f64 sample and volume to an i16 sample. |
ovr |
Generate sound from fundamental and overtones. For reverse FFT use twang::sin for the generator |
pnk |
Pink noise |
pos |
Only the positve part of the wave. |
saw |
A Saw wave |
sft |
Distort sound wave with soft clipping. Volume should be more than 1 to have any effect. |
sgn |
Signum of sound wave (-1 or 1) |
sin |
A Sine wave |
sqr |
A square wave |
srt |
Square root of sound wave. |
tri |
A triangle wave |
wht |
White noise |