Last active
August 15, 2020 08:50
-
-
Save justanotherdot/1b992813978344a54a9922795be04bcf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn sine_wave_oscillator (w : f32) -> impl Iterator<Item=f32> { | |
let mut x0 = w.sin(); | |
let mut x1 = 0.0; | |
let b = 2.0 * w.cos(); | |
std::iter::repeat_with(move || { | |
let xn = b * x0 - x1; | |
x1 = x0; | |
x0 = xn; | |
xn | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment