var segment = curScore.firstSegment(); while (segment) { var aCount = 0; var annotation = segment.annotations[aCount]; while (annotation) { if (annotation.type == Element.HARMONY) { var harmony = annotation; var str = harmony.text; console.log ("harmony = ", str) if (str != "") str = correctCase(str); var r = str.indexOf("Maj"); if(str.substr(str.length-3,3)== "Maj"){ str = str.substr(0,str.length-3) //console.log('Maj string = ' + str); } if (str != ""){ harmonies.push(str); htick.push(segment.tick + gTick); } } annotation = segment.annotations[++aCount]; } segment = segment.next; }