@@ -12,6 +12,7 @@ pub struct ScalePage {
1212 pub path : & ' static str ,
1313 pub scale : Scale ,
1414 pub key : notation_bevy:: prelude:: Key ,
15+ pub transpose : i8 ,
1516}
1617
1718impl KbPage for ScalePage {
@@ -53,12 +54,15 @@ impl KbPage for ScalePage {
5354 } ) ;
5455 } ) ;
5556 ui. separator ( ) ;
56- NotesPage :: notes_ui ( ui, texts, assets, state, theme, link_evts, self . scale , self . key ) ;
57+ NotesPage :: notes_ui ( ui, texts, assets, state, theme, link_evts, self . scale , self . key , self . transpose ) ;
5758 ui. separator ( ) ;
5859 ui. horizontal ( |ui| {
5960 if ui. button ( "play" ) . clicked ( ) {
6061 link_evts. send ( EasyLinkEvent :: from ( IndexPanel :: LINK_MIDI_PLAY ) ) ;
6162 }
63+ if ui. button ( "stop" ) . clicked ( ) {
64+ link_evts. send ( EasyLinkEvent :: from ( IndexPanel :: LINK_MIDI_STOP ) ) ;
65+ }
6266 } ) ;
6367 }
6468}
@@ -82,6 +86,7 @@ impl ScalePage {
8286 path,
8387 scale : Default :: default ( ) ,
8488 key : Default :: default ( ) ,
89+ transpose : 0 ,
8590 }
8691 }
8792 pub fn make_tab ( & self ) -> ProtoTab {
@@ -91,28 +96,40 @@ impl ScalePage {
9196 ) ;
9297 let mut entries = vec ! [ ] ;
9398 let duration = Duration :: _1_4;
94- for syllable in self . scale . get_syllables ( ) . iter ( ) {
95- let note = Note :: from ( Semitones :: from ( Octave :: CENTER ) + Semitones :: from ( self . scale . calc_syllable_for_sort ( syllable) ) ) ;
99+ let mut add_note = |syllable : & Syllable , semitones : Option < Semitones > | {
100+ let note = Note :: from (
101+ Semitones :: from ( Octave :: CENTER )
102+ + Semitones :: from ( self . key . clone ( ) )
103+ + Semitones :: from ( self . scale . calc_syllable_for_sort ( syllable) )
104+ + semitones. unwrap_or ( Semitones ( 0 ) )
105+ ) ;
96106 entries. push ( ProtoEntry :: from ( CoreEntry :: from ( ( Tone :: from ( note) , duration) ) ) ) ;
107+ } ;
108+ let mut syllables = self . scale . get_syllables ( ) ;
109+ for syllable in syllables. iter ( ) {
110+ add_note ( syllable, None ) ;
97111 }
98- let note = Note :: from ( Semitones ( 12 ) + Semitones :: from ( Octave :: CENTER ) + Semitones :: from ( self . scale . calc_syllable_for_sort ( & self . scale . calc_root_syllable ( ) ) ) ) ;
99- entries. push ( ProtoEntry :: from ( CoreEntry :: from ( ( Tone :: from ( note) , duration) ) ) ) ;
100- let track = ProtoTrack :: new ( "notes" . to_owned ( ) , TrackKind :: Vocal , entries) ;
101- let bars = vec ! [
112+ add_note ( & self . scale . calc_root_syllable ( ) , Some ( Semitones ( 12 ) ) ) ;
113+ add_note ( & self . scale . calc_root_syllable ( ) , Some ( Semitones ( 12 ) ) ) ;
114+ syllables. reverse ( ) ;
115+ for syllable in syllables. iter ( ) {
116+ add_note ( syllable, None ) ;
117+ }
118+ let new_bar = |index : usize | {
102119 ProtoBar :: new (
103120 vec ! [
104121 ProtoBarLayer :: new( "notes" . to_owned( ) , vec![
105- Slice :: new( SliceBegin :: Index ( 0 ) , SliceEnd :: Count ( 4 ) , None ) ,
122+ Slice :: new( SliceBegin :: Index ( index ) , SliceEnd :: Count ( 4 ) , None ) ,
106123 ] )
107124 ] ,
108- ) ,
109- ProtoBar :: new (
110- vec! [
111- ProtoBarLayer :: new ( "notes" . to_owned ( ) , vec![
112- Slice :: new ( SliceBegin :: Index ( 4 ) , SliceEnd :: Count ( 4 ) , None ) ,
113- ] )
114- ]
115- ) ,
125+ )
126+ } ;
127+ let track = ProtoTrack :: new ( "notes" . to_owned ( ) , TrackKind :: Vocal , entries ) ;
128+ let bars = vec ! [
129+ new_bar ( 0 ) ,
130+ new_bar ( 4 ) ,
131+ new_bar ( 8 ) ,
132+ new_bar ( 12 ) ,
116133 ] ;
117134 let section = ProtoSection :: new ( "notes" . to_owned ( ) , SectionKind :: Rest , bars) ;
118135 ProtoTab :: new (
0 commit comments