Skip to content

Commit a2dce3d

Browse files
committed
Base functionality for separate audio thread and audio being read in realtime by another thread
1 parent 062bbaa commit a2dce3d

File tree

3 files changed

+3
-238
lines changed

3 files changed

+3
-238
lines changed

Cargo.lock

-226
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@ edition = "2021"
55

66
[dependencies]
77
cpal = "0.13"
8-
dasp = { version = "0.11.0", features = ["signal"] }
98
env_logger = "0.11.5"
109
log = "0.4.22"
11-
portaudio = "0.7.0"
12-
rustfft = "6.2.0"

src/main.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,23 @@ mod audio_modifiers;
22
mod realtime_playback;
33

44
use crate::realtime_playback::playback;
5-
use log::info;
5+
use std::io::{self};
66
use std::sync::{Arc, LazyLock, Mutex};
77
use std::thread;
88
use std::time::Duration;
99

1010
static AUDIO_DATA: LazyLock<Arc<Mutex<Vec<f32>>>> =
1111
LazyLock::new(|| Arc::new(Mutex::new(Vec::new())));
1212

13-
fn main() {
13+
fn main() -> Result<(), io::Error> {
1414
env_logger::init();
15-
1615
let _ = thread::spawn(move || {
1716
let _ = playback(Arc::clone(&AUDIO_DATA));
1817
});
1918

2019
loop {
2120
thread::sleep(Duration::from_millis(1));
2221
let audio = AUDIO_DATA.lock().unwrap().clone();
23-
match audio.get(600) {
24-
Some(value) => {
25-
info!("{}", value);
26-
}
27-
None => {}
28-
}
22+
println!("{}", audio.get(600).unwrap_or(&0.0f32));
2923
}
3024
}

0 commit comments

Comments
 (0)