"; wc = window.open("","nocren","width=750,height=650,left=250,top=200") wc.document.write(html); wc.document.close(); } function startup() { document.penta.DeBugging.checked=false; var dloc = document.location.toString(); var DeBugging = document.getElementById("DeBugging") if (dloc.slice(0,4) != "file") { DeBugging.style.visibility = 'hidden'; } } function carg(arg) { return (arg == null)? "" : arg;} // So will be compatible on all browsers. function noteTable(thisLine) { if (thisLine == "--") { this.dur = Number.POSITIVE_INFINITY this.begPos = Number.POSITIVE_INFINITY; this.endPos = Number.POSITIVE_INFINITY; } else { this.dur = 0; this.begPos = sumMeasure * 50000 + sumBatch; result=thisLine.match(/Dur:([^\|]*)/); if ((result != null) && (!/Grace/.test(thisLine))) { // Has duration but is not grace. var durVal = result[1]; var durLen = getNoteLength(durVal); this.dur = durLen; if (durLen == -1) { alert("Illegal length: " + thisLine); return 1; } else { sumBatch += durLen; } // Keeping a running total of note durations in 768th notes } // End of object with "Dur:" not a grace note else { if (thisLine.slice(0,4) == "|Bar") { sumBatch=0; sumMeasure++; } else { result = thisLine.match(/RestMultiBar\|NumBars:(\d+)/); if (result != null) { var multRest = Number(result[1]); sumMeasure += multRest - 1; // Counting number of bars, one less than number of rests sumBatch=0; } } } } this.endPos = 50000 * sumMeasure + sumBatch; this.begGroup = this.begPos; this.endGroup = this.endPos; if (thisLine.slice(0,5) == "|Rest") this.dur = 0; } function doMove() { var result=new Array(), lineL = new Array(), lineU = new Array(), lineUarr=new Array(), lineLarr=new Array(), PosU, PosL, offset; var aNote = /\|Note\|Dur:.*(Grace)?.*Pos:([x#nbv]?)(-?\d+)([\^]?).*Stem=(Up|Down)(.*)/ tempField=document.penta.UPstaff.value; tempField=tempField.replace(/\r/g,""); var lineU=tempField.split("\n"); // Upper staff tempField=document.penta.DNstaff.value; tempField=tempField.replace(/\r/g,""); var lineL=tempField.split("\n"); // Lower staff sumMeasure = 0, sumBatch = 0; for (var iU=0; iU < lineU.length; iU++) { // Initial processing loop on upper staff. lineUarr[iU] = new noteTable(lineU[iU]); } //End of initial processing of upper staff. sumMeasure = 0, sumBatch = 0; for (var iL=0; iL < lineL.length; iL++) { // Initial processing loop on lower staff. lineLarr[iL] = new noteTable(lineL[iL]); } //End of initial processing of lower staff. lineLarr[iL] = new noteTable("--"); // Prevents crash if there are fewer notes downstairs iL = 1; // Code to match parts and modify if necessary for (iU=1; iU < lineUarr.length; iU++) { //First line is NWC header Look for |Note| with Stem=Up specfied, not Grace, no Space= result = lineU[iU].match(aNote); if ((result != null) && (lineUarr[iU].dur) && (!/Space=/.test(lineU[iU]))) { // Has duration, space not overridden. while ((lineLarr[iL].dur == 0) || (lineUarr[iU].begPos > lineLarr[iL].begPos)) iL++; // Advance lower subscript until find same place in score if (lineLarr[iL].begPos == Number.POSITIVE_INFINITY) // Ran out of notes downstairs break; if (lineUarr[iU].begPos < lineLarr[iL].begPos) // If went past it (syncopation?) try next line continue; resultL = lineL[iL].match(aNote); if ((resultL == null) || /Space=/.test(lineL[iL])) // No match for note or space overridden continue; //////// At this point both staves are pointing the the same place in the score. ///////////// PosU = Number(result[3]); PosL = Number(resultL[3]); offset = PosU - PosL; // offset is needed in all methods if ((result[5] == "Up") && (resultL[5] == "Down")) // Last test, stem directions must be specified for original usage { if ((offset == 1) || (offset < 0)) // Offset by 1, higher note needs more space OR parts crossover each other. lineU[iU]+= ",XNoteSpace=1"; if ((result[2].length == 1) && (resultL[2].length == 1) && (offset > 0) && (offset <= 5)) //Both have accidentals and are too close lineL[iL]+= ",XAccSpace=1"; // Lower note needs more space for the accidental if ((result[2].length == 1) && (resultL[2].length == 1) && (offset < 0) && (offset >= -5)) //Both have accidentals and are too close lineU[iU]+= ",XAccSpace=1"; // "Upper" note needs more space for the accidental (the one on the botton because of crossover). } else { //Implementing new feature of page if (offset < 1) { // No crossover, no same note var posText = Number(result[3]) + 7; lineU[iU-1]+= '\n|Text|Text:"*"|Font:PageTitleText|Pos:' + posText + '|Color:1'; continue; } if (lineUarr[iU].dur != lineLarr[iL].dur) // Durations of both notes must be equal for new parts { continue; } else { if ((result[5] == "Up") && (resultL[5] == "Up")) { //New features, both stem up tResult = lineU[iU].match(/(\|Note[^,]*).*(\|Pos:[^\|,]*)/); if (tResult == null) { alert("251 match fail on " + lineU[iU]); break} lineU[iU] = lineU[iU].replace(/\|Opts.*/,""); lineU[iU] = tResult[1] + tResult[2] + "|Opts:Stem=Up,StemLength=0" lineU[iU] += (offset == 1)? ",XNoteSpace=1" : ""; if ((/\^/.test(lineU[iU])) && (!/Tie=Upward/.test(lineU[iU]))) { lineU[iU] += ",Tie=Upward"; } tline = "|Note|Dur:Whole,Grace|Pos:" + result[2] + result[3] + "^|Opts:Stem=Up,Tie=Upward,Muted|Visibility:Never\n" tResult = lineL[iL].match(/\|Note\|Dur:(.*)\|Pos:([x#nbv]?)(-?\d*)(\^?)(\|Opts:.*)/) if (tResult == null) { alert("257 match fail on " + lineL[iL]); break} lineL[iL] = tline + "|Chord|Dur:" + tResult[1] + "|Pos:" + tResult[2] + tResult[3] + tResult[4] + "," + result[2] + result[3] + result[4] + tResult[5]; lineL[iL] = lineL[iL].replace("^^","^"); // if (result[2] && tResult[2]) lineU[iU]+= ",XAccSpace=1"; // line may not be needed } // End of stem up features else if ((result[5] == "Down") && (resultL[5] == "Down")) { //New features, both stem down result = lineL[iL].match(aNote); tResult = lineL[iL].match(/(\|Note[^,]*).*(\|Pos:[^\|,]*)/); if (tResult == null) { alert("251 match fail on " + lineL[iL]); break} lineL[iL] = lineL[iL].replace(/\|Opts.*/,""); // lineL[iL] = tResult[1] + tResult[2] + "|Opts:Stem=Down,StemLength=0" lineL[iL] += (offset == 1)? ",XNoteSpace=1" : ""; if ((/\^/.test(lineL[iL])) && (!/Tie=Downward/.test(lineL[iL]))) { lineL[iL] += ",Tie=Downward"; } tline = "|Note|Dur:Whole,Grace|Pos:" + result[2] + result[3] + "^|Opts:Stem=Down,Tie=Downward,Muted|Visibility:Never\n" tResult = lineU[iU].match(/\|Note\|Dur:(.*)\|Pos:([x#nbv]?)(-?\d*)(\^?)(\|Opts:.*)/) if (tResult == null) { alert("257 match fail on " + lineU[iU]); break} lineU[iU] = tline + "|Chord|Dur:" + tResult[1] + "|Pos:" + result[2] + result[3] + result[4] + "," + tResult[2] + tResult[3] + tResult[4] tResult[5]; lineU[iU] = lineU[iU].replace("^^","^"); // if (result[2] && tResult[2]) lineL[iL]+= ",XAccSpace=1"; // line may not be needed /* ************** Stem down code goes here ********************** */ } // End of new stem down features } // End of equal duration bracket } // End of new features } //End of found note in upper staff to match } //End of matching loop document.penta.UPstaff.value=""; //Build data in top window for (i=0; i < lineU.length; i++) { document.penta.UPstaff.value+= lineU[i]; if ((i + 1) < lineU.length) document.penta.UPstaff.value+= "\n"; } document.penta.UPstaff.select(); document.penta.DNstaff.value=""; //Build data in bottom window for (i=0; i < lineL.length; i++) { document.penta.DNstaff.value+= lineL[i]; if ((i + 1) < lineL.length) document.penta.DNstaff.value+= "\n"; } return 0; }

Space Layered Notes

 

To move slurs, ties, and articulations click here.

       Save your file first!!

Cut Section of upper staff into here.  

 

Cut Section of lower staff into here.         It's a little easier if you load the bottom first.

 

 

This Web Page Created with PageBreeze Free HTML Editor

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License 2013 by Warren Porter