mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-17 15:15:17 +00:00
much better fidelity
This commit is contained in:
1 parent
73afdc7a98
commit
71c0edf0e8
1 file changed
+28
-1
+28
-1
@@ -13,11 +13,38 @@ use std::collections::VecDeque;
|
||||
|
||||
fn main() {
|
||||
println!("Run");
|
||||
record().unwrap();
|
||||
//record().unwrap();
|
||||
record2().unwrap();
|
||||
}
|
||||
|
||||
const THRESHOLD : i16 = 1500;
|
||||
|
||||
fn record2() -> Result<(), AudioError> {
|
||||
println!("Opening microphone system");
|
||||
let mut mic = MicrophoneSystem::new(SampleRate::Studio)?;
|
||||
|
||||
println!("Opening speaker system");
|
||||
let mut speaker = SpeakerSystem::new(SampleRate::Studio)?;
|
||||
|
||||
println!("Done");
|
||||
|
||||
let mut buffer = VecDeque::new();
|
||||
|
||||
loop {
|
||||
mic.record(&mut |_index, l, r| {
|
||||
buffer.push_back((l, l));
|
||||
});
|
||||
|
||||
speaker.play(&mut || {
|
||||
if let Some((lsample, rsample)) = buffer.pop_front() {
|
||||
AudioSample::stereo(lsample, rsample)
|
||||
} else {
|
||||
AudioSample::stereo(0, 0)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn record() -> Result<(), AudioError> {
|
||||
// Connect to the speaker and microphone systems.
|
||||
let mut mic = MicrophoneSystem::new(SampleRate::Studio)?;
|
||||
|
||||
Reference in new issue
Block a user