Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion neothesia/src/scene/freeplay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ impl Scene for FreeplayScene {
mod chords {
/// Get chord name based on notes, eg. Cmaj7
pub fn deduce_name(midi_notes: &[u8]) -> String {
if midi_notes.is_empty() {
return "No notes".to_string();
}

if midi_notes.len() == 1 {
return note_name(midi_notes[0]).to_string();
}
Expand Down Expand Up @@ -343,7 +347,7 @@ mod chords {
#[test]
fn test_edge_cases() {
assert_eq!(deduce_name(&[]), "No notes");
assert_eq!(deduce_name(&[60]), "single");
assert_eq!(deduce_name(&[60]), "C");
// Multiple octaves should normalize
assert_eq!(deduce_name(&[48, 64, 67, 72]), "CM");
}
Expand Down