tuning for recorder
This commit is contained in:
parent
4945b4d777
commit
63bb5b8fea
1 changed files with 11 additions and 4 deletions
|
@ -20,7 +20,7 @@ fn main() -> Result<()> {
|
||||||
let (sender, notes) = mpsc::channel();
|
let (sender, notes) = mpsc::channel();
|
||||||
|
|
||||||
const POWER_THRESHOLD: f32 = 5.0;
|
const POWER_THRESHOLD: f32 = 5.0;
|
||||||
const CLARITY_THRESHOLD: f32 = 0.7;
|
const CLARITY_THRESHOLD: f32 = 0.85;
|
||||||
const PACKET_LEN: usize = 2204;
|
const PACKET_LEN: usize = 2204;
|
||||||
|
|
||||||
let stream = device.build_input_stream(&config.into(),
|
let stream = device.build_input_stream(&config.into(),
|
||||||
|
@ -42,8 +42,8 @@ fn main() -> Result<()> {
|
||||||
for (note,vol) in notes {
|
for (note,vol) in notes {
|
||||||
if let Some(note) = note {
|
if let Some(note) = note {
|
||||||
//dbg!(note.frequency);
|
//dbg!(note.frequency);
|
||||||
dbg!(note.clarity);
|
//dbg!(note.clarity);
|
||||||
dbg!(vol);
|
//dbg!(vol);
|
||||||
let note = Note::from_freq(note.frequency, Tuning::EqualTemperament);
|
let note = Note::from_freq(note.frequency, Tuning::EqualTemperament);
|
||||||
match note.pitch {
|
match note.pitch {
|
||||||
Pitch { letter: NoteLetter::A, accidental: 0} => {
|
Pitch { letter: NoteLetter::A, accidental: 0} => {
|
||||||
|
@ -61,8 +61,15 @@ fn main() -> Result<()> {
|
||||||
Pitch { letter: NoteLetter::G, accidental: 0} => {
|
Pitch { letter: NoteLetter::G, accidental: 0} => {
|
||||||
println!("fire");
|
println!("fire");
|
||||||
}
|
}
|
||||||
|
Pitch { letter: NoteLetter::E, accidental: 0} => {
|
||||||
|
println!("fire");
|
||||||
|
}
|
||||||
pitch => {
|
pitch => {
|
||||||
dbg!(pitch);
|
if vol > 3000. {
|
||||||
|
println!("fire");
|
||||||
|
} else {
|
||||||
|
//dbg!(pitch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue