3 ms·
How does the function map to sound? I didn't see any discussion of that on the site.
by montecarl 8y ago
How does the function map to sound? I didn't see any discussion of that on the site.
- eindiran 8y agoYou 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: 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 8y ago[deleted]