@@ -157,27 +157,27 @@ MuseScore {
157157
158158 " Maj" : {
159159 " symb" : " " ,
160- " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 11 ]
160+ " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 11 , 12 ]
161161 },
162162 " Min" : {
163163 " symb" : " -" ,
164- " scale" : [0 , 2 , 3 , 5 , 7 , 8 , 10 ]
164+ " scale" : [0 , 2 , 3 , 5 , 7 , 8 , 10 , 12 ]
165165 },
166166 " Maj7" : {
167167 " symb" : " t7" ,
168- " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 11 ]
168+ " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 11 , 12 ]
169169 },
170170 " Dom7" : {
171171 " symb" : " 7" ,
172- " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 10 ]
172+ " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 10 , 12 ]
173173 },
174174 " Min7" : {
175175 " symb" : " -7" ,
176- " scale" : [0 , 2 , 3 , 5 , 7 , 8 , 10 ]
176+ " scale" : [0 , 2 , 3 , 5 , 7 , 8 , 10 , 12 ]
177177 },
178178 " Bepop" : {
179179 " symb" : " -7" ,
180- " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 10 , 11 ]
180+ " scale" : [0 , 2 , 4 , 5 , 7 , 9 , 10 , 11 , 12 ]
181181 },
182182 }
183183
@@ -190,18 +190,18 @@ MuseScore {
190190
191191 property var _chords: [{
192192 " root" : ' C' ,
193- " major" : false , // we consider C as a flat scale, sothat a m7 is displayed as Bb instead of A#
193+ " major" : false , // we consider C as a flat scale, sothat a m7 is displayed as B♭ instead of A♯
194194 " minor" : false
195195 }, {
196- " root" : ' Db/C# ' ,
196+ " root" : ' D♭/C♯ ' ,
197197 " major" : false ,
198198 " minor" : true
199199 }, {
200200 " root" : ' D' ,
201201 " major" : true ,
202202 " minor" : false
203203 }, {
204- " root" : ' Eb/D# ' ,
204+ " root" : ' E♭/D♯ ' ,
205205 " major" : false ,
206206 " minor" : true
207207 }, {
@@ -213,23 +213,23 @@ MuseScore {
213213 " major" : false ,
214214 " minor" : false
215215 }, {
216- " root" : ' F#/Gb ' ,
216+ " root" : ' F♯/G♭ ' ,
217217 " major" : true ,
218218 " minor" : true
219219 }, {
220220 " root" : ' G' ,
221221 " major" : true ,
222222 " minor" : false
223223 }, {
224- " root" : ' Ab/G# ' ,
224+ " root" : ' A♭/G♯ ' ,
225225 " major" : false ,
226226 " minor" : true
227227 }, {
228228 " root" : ' A' ,
229229 " major" : true ,
230230 " minor" : true
231231 }, {
232- " root" : ' Bb/A# ' ,
232+ " root" : ' B♭/A♯ ' ,
233233 " major" : false ,
234234 " minor" : false
235235 }, {
@@ -861,29 +861,36 @@ MuseScore {
861861 // 2) Scale loopAt mode, we decline the pattern along the scale (up/down, by degree/Triad)
862862 var shift = loopAt .shift ; // Math.abs(loopAt) * (-1);
863863 console .log (" Looping patterns : scale mode (" + shift + " )" );
864+ // We clear all the patterns because will be restarting from the last step
865+ extpattern[" subpatterns" ] = [];
866+
867+ // Building the other ones
868+ var counter = 0 ;
869+ var dia = [];
870+ var delta = Math .abs (shift);
871+ // we compute the degree to have III V VII
872+ for (var i = 0 ; i < scale .length ; i += delta) {
873+ console .log (" Adding " + i + " (" + scale[i] + " )" );
874+ dia .push (i);
875+ }
876+
877+ // if we have a scale ending on a tonic (I - 12), and our steps have stopped before (ex the next triad after the VII is the II, not the I)
878+ // we add it explicitely
879+ if ((scale[scale .length - 1 ] == 12 ) && (dia[dia .length - 1 ] < (scale .length - 1 ))) {
880+ dia .push (scale .length - 1 ); // the repetition must end with the last step of the scale (the one that holds "12")
881+ }
864882 if (shift > 0 ) {
865- for (var i = shift; i < scale .length ; i += shift) {
866- console .log (" Looping patterns : scale mode at " + i);
867- var shifted = shiftPattern (basesteps, scale, i);
883+ // we loop it
884+ for (var i = 0 ; i < dia .length ; i++ ) {
885+ counter++ ;
886+ console .log (" Looping patterns : scale mode at " + dia[i]);
887+ var shifted = shiftPattern (basesteps, scale, dia[i]);
868888 extpattern[" subpatterns" ].push (shifted);
889+ if (counter > 99 ) // security
890+ break ;
869891 }
870892 } else {
871- // We are decresing, so we'll tweak the original pattern one actave up
872- var octaveup = [];
873- for (var i = 0 ; i < basesteps .length ; i++ ) {
874- octaveup[i] = basesteps[i] + 12 ;
875- }
876- extpattern[" subpatterns" ][0 ] = octaveup;
877893
878- // Building the other ones
879- var counter = 0 ;
880- var dia = [];
881- shift = Math .abs (shift);
882- // we compute III V VII
883- for (var i = shift; i < scale .length ; i += shift) {
884- console .log (" Adding " + i + " (" + scale[i] + " )" );
885- dia .push (i);
886- }
887894 // we loop it in reverse
888895 for (var i = (dia .length - 1 ); i >= 0 ; i-- ) {
889896 counter++ ;
@@ -941,26 +948,33 @@ MuseScore {
941948 }
942949
943950 pdia .push (d);
944- // console.log("1)[" + ip + "]" + p + "->" + debugDia(d));
951+ console .log (" [shift " + step + " ] 1)[" + ip + " ]" + p + " ->" + debugDia (d));
945952 }
946953
947954 // 2) shift the diatonic pattern by the amount of steps
948955 for (var ip = 0 ; ip < pdia .length ; ip++ ) {
949956 var d = pdia[ip];
950957 d .degree += step;
951- d .octave += Math .floor (d .degree / scale .length );
952- d .degree = d .degree % scale .length ;
958+ d .octave += Math .floor (d .degree / 7 ); // degrees are ranging from 0->6, 7 is 0 at the nexy octave // scale.length);
959+ d .degree = d .degree % 7 ; // scale.length;
953960 pdia[ip] = d;
954- // console.log("2)[" + ip + "]->" + debugDia(d));
961+ console .log (" [shift " + step + " ] 2)[" + ip + " ]->" + debugDia (d));
955962 }
956963
957964 // 3) Convert back to a chromatic scale
958965 var pshift = [];
959966 for (var ip = 0 ; ip < pdia .length ; ip++ ) {
960967 var d = pdia[ip];
968+ if (d .degree >= scale .length ) {
969+ // We are beyond the scale, let's propose some value
970+ d .semi += (d .degree - scale .length + 1 ) * 1 ; // 1 semi-tone by missing degree
971+ d .degree = scale .length - 1 ;
972+ if ((scale[d .degree ] + d .semi ) >= 12 )
973+ d .semi = 11 ;
974+ }
961975 var s = scale[d .degree ] + 12 * d .octave + d .semi ;
962976 pshift .push (s);
963- // console.log("3)[" + ip + "]" + debugDia(d) + "->" + s);
977+ console .log (" [shift " + step + " ] 3)[" + ip + " ]" + debugDia (d) + " ->" + s);
964978 }
965979
966980 return pshift;
@@ -1863,7 +1877,7 @@ MuseScore {
18631877 model: _ddRoots
18641878 currentIndex: find (steproots[rootIndex], Qt .MatchExactly )
18651879 Layout .preferredHeight : 30
1866- implicitWidth: 80
1880+ implicitWidth: 90
18671881 onCurrentIndexChanged: {
18681882 steproots[rootIndex] = model[currentIndex]
18691883 console .log (" Root " + rootIndex + " : " + steproots[rootIndex]);
0 commit comments