A Few of My Favorite Sigmoids (2018)(raphlinus.github.io)
raphlinus.github.io
A Few of My Favorite Sigmoids (2018)
https://raphlinus.github.io/audio/2018/09/05/sigmoid.html
7 comments
How does the function map to sound? I didn't see any discussion of that on the site.
You take a damped sine wave, where its amplitude gradually moves towards zero, of some frequency and you pass it through the particular sigmoid function. Just like you can play a sine wave, you can play the resulting tone.
If you look at his code, you can see how he wrote it:
If you look at his code, you can see how he wrote it:
fn gen_audio(len: usize) -> Vec<f32> {
//(0..len).map(|i| ((i as f32).powi(2) * 1e-7).sin()).collect()
let f = 440.0;
let d = f / 44_100.0 * 2.0 * std::f64::consts::PI;
(0..len).map(|i| {
let i = i as f64;
let amp = 100.0 * (i * -4e-5).exp();
let tone = (i * d).sin() * amp;
tone.max(-1.0).min(1.0) as f32
//erf7(tone as f32)
//(tone / (1.0 + tone * tone).sqrt()) as f32
//tone.tanh() as f32
}).collect()
}[deleted]
Turn down the volume before playing the samples. Especially when wearing headphones.
I've always loved sigmoids, a really simple beauty to them.
$$ g(x) = a e^{-b e^{-cx} } $$
[1]: https://en.wikipedia.org/wiki/Gompertz_function