From 7bd9dd418ac6215094feb87087fcb59499c3aa69 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Wed, 27 Oct 2021 22:24:23 -0400 Subject: Fix pitch in rust code and limit to 3 second duration --- klangfarbrs/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'klangfarbrs/src') diff --git a/klangfarbrs/src/lib.rs b/klangfarbrs/src/lib.rs index 9bf1ded..9638690 100644 --- a/klangfarbrs/src/lib.rs +++ b/klangfarbrs/src/lib.rs @@ -10,13 +10,13 @@ pub struct MonoBuffer { } pub fn fill_frames() -> TypedArray { - let tau = std::f32::consts::FRAC_PI_2; let frequency = 440.0; - let sample_rate = 8000.0; + let sample_rate = 44100.0; + let duration = sample_rate * 3.0; let mut frames = TypedArray::new(); - for i in 0..512 { - frames.push(f32::sin(tau * frequency * i as f32/sample_rate)); + for i in 0..duration as i32 { + frames.push(f32::sin(std::f32::consts::TAU * frequency * i as f32/sample_rate)); } return frames -- cgit v1.2.3