Handle shaprs in s2v_i32_note_formatter()
This commit is contained in:
parent
230ed90745
commit
c947d6c232
|
@ -255,11 +255,19 @@ pub fn s2v_i32_note_formatter() -> Arc<dyn Fn(&str) -> Option<i32> + Send + Sync
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A valid trimmed string will either be be two characters (we already checked the length),
|
// A valid trimmed string will either be be at least two characters (we already checked the
|
||||||
// or two characters separated by spaces
|
// length) or at least three characters if the second character is a hash, and there may be
|
||||||
|
// spaces in between the note name and the octave number
|
||||||
let (note_name, octave) = string
|
let (note_name, octave) = string
|
||||||
.split_once(|c: char| c.is_whitespace())
|
.split_once(|c: char| c.is_whitespace())
|
||||||
.unwrap_or_else(|| (&string[..1], &string[1..]));
|
.unwrap_or_else(|| {
|
||||||
|
// Sharps need to be handled separately
|
||||||
|
if string.len() > 2 && &string[1..2] == "#" {
|
||||||
|
(&string[..2], &string[2..])
|
||||||
|
} else {
|
||||||
|
(&string[..1], &string[1..])
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let note_id = util::NOTES
|
let note_id = util::NOTES
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in a new issue