Skip to content

Commit ef3e599

Browse files
committed
bugfix with fretboard fretted note calculation
1 parent 57a5f8b commit ef3e599

File tree

16 files changed

+17
-355
lines changed

16 files changed

+17
-355
lines changed
18.1 KB
Binary file not shown.
-93.7 KB
Binary file not shown.

apps/notation_kb/src/theory/scale.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,20 @@ impl ScalePage {
9797
);
9898
let mut entries = vec![];
9999
let duration = Duration::_1_4;
100-
let mut add_note = |syllable: &Syllable, semitones: Option<Semitones>| {
101-
let octave = if self.scale.calc_do_offset() > 0 {
102-
Octave::P3
103-
} else {
104-
Octave::P4
105-
};
106-
let note = Note::from(
107-
Semitones::from(octave)
108-
+ Semitones::from(self.key.clone())
109-
+ Semitones::from(self.scale.calc_syllable_for_sort(syllable))
110-
+ semitones.unwrap_or(Semitones(0))
111-
);
100+
let mut add_note = |syllable: &Syllable, add_octave| {
101+
let octave = if add_octave { Octave::P5 } else { Octave::P4 };
102+
let note = self.scale.calc_note_from_syllable(&self.key, syllable, &octave);
112103
entries.push(ProtoEntry::from(CoreEntry::from((Tone::from(note), duration))));
113104
};
114105
let mut syllables = self.scale.get_syllables();
115106
for syllable in syllables.iter() {
116-
add_note(syllable, None);
107+
add_note(syllable, false);
117108
}
118-
add_note(&self.scale.calc_root_syllable(), Some(Semitones(12)));
119-
add_note(&self.scale.calc_root_syllable(), Some(Semitones(12)));
109+
add_note(&self.scale.calc_root_syllable(), true);
110+
add_note(&self.scale.calc_root_syllable(), true);
120111
syllables.reverse();
121112
for syllable in syllables.iter() {
122-
add_note(syllable, None);
113+
add_note(syllable, false);
123114
}
124115
let new_bar = |index: usize| {
125116
ProtoBar::new(
18.1 KB
Binary file not shown.
-93.7 KB
Binary file not shown.

crates/notation_bevy/src/notation/assets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct NotationAssets {
2929
pub trait ExtraAssets : AssetCollection {
3030
fn get_assets(&self) -> Vec<HandleUntyped>;
3131
fn get_syllable_font(_settings: &NotationSettings) -> &'static str {
32-
"fonts/uchiyama.ttf"
32+
"fonts/Sofia_Handwritten.otf"
3333
}
3434
fn get_fret_font(_settings: &NotationSettings) -> &'static str {
3535
"fonts/Bitter-Bold.ttf"

crates/notation_fretted/src/fretboard.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,15 @@ macro_rules! impl_fretboard {
4040
pub fn fretted_note(&self, scale: &Scale, key: &Key, string: u8, fret: u8) -> Option<Note> {
4141
if fret as usize >= self.fret_num() {
4242
None
43-
} else {
43+
} else if fret == 0 {
4444
self.open_note(scale, key, string)
45+
} else {
46+
if string == 0 || string as usize > self.string_notes.len() {
47+
None
48+
} else {
49+
let semitones = self.string_notes[(string - 1) as usize];
50+
Some(self.get_capo_note(scale, key, semitones + Semitones(fret as i8)))
51+
}
4552
}
4653
}
4754
pub fn string_num(&self) -> usize {

fonts/Sofia/README.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://www.dafont.com/sofia-handwritten.font

fonts/Sofia/Sofia_Handwritten.otf

18.1 KB
Binary file not shown.
-946 KB
Binary file not shown.

0 commit comments

Comments
 (0)