From a2377e09873aeef22dc47faba7874aab9a342b38 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Sun, 21 Apr 2024 13:15:42 -0700 Subject: [PATCH] make it an int so its easier to read --- musical-leptos/src/components/dancing_lights.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/musical-leptos/src/components/dancing_lights.rs b/musical-leptos/src/components/dancing_lights.rs index 486cfda..7670faa 100644 --- a/musical-leptos/src/components/dancing_lights.rs +++ b/musical-leptos/src/components/dancing_lights.rs @@ -44,7 +44,7 @@ pub fn DancingLights() -> impl IntoView { // TODO: do this on button click let (listen, set_listen) = create_signal(false); - let (audio, set_audio) = create_signal(0.0); + let (audio, set_audio) = create_signal(0); // TODO: this is wrong. this runs immediatly, not on first click. why? let start_listening = create_resource(listen, move |x| async move { @@ -62,8 +62,9 @@ pub fn DancingLights() -> impl IntoView { let onmessage_callback = Closure::new(move |x: MessageEvent| { // TODO: this seems fragile. how do we be sure of the data type + // TODO: actual audio processing // TODO: this will actually be a vec of 120 f32s when we are done - let data = x.data().as_f64().unwrap().abs(); + let data = (x.data().as_f64().unwrap().abs() * 10000.0) as u32; set_audio(data); });