"; wc = window.open("","nocren","width=720,height=730,left=250,top=200") wc.document.write(html); wc.document.close(); } function getNoteLength(notelet) { var NoteLengths = [ [48,"16th"], [24,"32nd"], [192,"4th"], [12,"64th"], [96,"8th"], [384,"Half"], [768,"Whole"] ] parts = notelet.split(","); var min=0, max=NoteLengths.length - 1, mid, noteLength= -1; while (max >= min) { mid = Math.floor((max + min) / 2); if (parts[0] == NoteLengths[mid][1]) {noteLength = NoteLengths[mid][0]; break;} if (parts[0] < NoteLengths[mid][1]) max = mid - 1; else min = mid + 1; } //End while loop if (noteLength == -1) return noteLength; for (var i = 1; i < parts.length; i++) { if (parts[i].substr(0,9) == "DblDotted") { noteLength = noteLength * 7 / 4; } else if (parts[i].substr(0,6) == "Dotted") { noteLength = noteLength * 3 / 2; } else if (parts[i].substr(0,7) == "Triplet") { noteLength = noteLength * 2 / 3; } } return noteLength; } var i, lines= new Array(); function startup() { document.penta.OptionList[1].checked=true; document.penta.DeBugging.checked=false; var dloc = document.location.toString(); if (dloc.slice(0,4) != "file") { document.penta.DeBugging.style.visibility = 'hidden'; } } // |Spacer|Width:0 |Text|Text:"Dur=16th"|Font:StaffItalic|Pos:2|Wide:N|Justify:Left|Placement:BestFit|Color:0|Visibility:Default function doProcess() { var awidth=13, result=new Array(); var tempField=document.penta.IOField.value; var splitOnBar = new Array, splitOnComma = new Array; var newLine = (this.navigator.appName.slice(0,8) == "Netscape")? "\n" : "\r\n"; tempField=tempField.replace(/\r/g,"") var lines=tempField.split("\n"); // Insert new tempo after NWC Clip Header. if (document.penta.OptionList[0].checked) { // Insert minimum spacer after everything for (i = 0; (i+1) < lines.length; i++) { if ((lines[i].charAt(0) == "|") && (lines[i].slice(1,7) != "Spacer") && (lines[i+1].slice(1,7) != "Spacer")) lines[i] += newLine+"|Spacer|Width:0"; }} else if (document.penta.OptionList[1].checked) { // Insert after things with a duration for (var i = 0; (i+1) < lines.length; i++) { result=lines[i].match(/Dur:([^\|]*)/); if ((lines[i].charAt(0) == "|") && (lines[i].slice(1,5) != "Text") && (result != null) && (lines[i+1].slice(1,7) != "Spacer") && (!/Grace/.test(lines[i]))) { var durVal = result[1]; var durLen = getNoteLength(durVal); if (durLen >= 192) { // Quarter note or longer, spacing depends on duration var logDur = Math.log(durLen) // Thanks to http://www.idomaths.com/simeq.php for the following line: var wSpace = Math.round(4.162737782 * logDur * logDur - 29.344198583 * logDur + 47.213680944); } else { // Flagged note, depends on stem direction result=lines[i].match(/Stem=(U|D)/); // Explicit stem direction? if (result != null) // If yes, var stemDir = result[1]; // read it. else //Check to see if it is a rest if (/Rest/.test(lines[i])) stemDir = "D"; else { // If not, determine stem direction from the position of the note. splitOnBar = lines[i].split("|"); if (splitOnBar.length < 4) alert("i = " + i + " ->" + lines[i]); splitOnComma = splitOnBar[3].split(",") splitOnComma[0] = splitOnComma[0].replace("Pos:","") var notePos = Number(splitOnComma[0]) + Number(splitOnComma[splitOnComma.length-1]); stemDir = (notePos < 0)? "U" : "D"; } wSpace = (stemDir == "U")? 7:4; } // Less space on stem down since flags share horizontal space with the note. lines[i] += newLine+"|Spacer|Width:" + (wSpace * 25); }}} else if (document.penta.OptionList[2].checked) { // Remove all spacers for (var i = 0; i < lines.length; i++) { if (lines[i].slice(0,7) == "|Spacer") lines[i] = "#"; // Replace spacer with a comment }} else for (var i = 0; i < lines.length; i++) { // Add or subtract from spacer value if (lines[i].slice(0,7) == "|Spacer") { result=lines[i].match(/\|Spacer\|Width:(\d+)\D?.*$/); if (result != null) { awidth=Number(result[1]); awidth += (document.penta.OptionList[3].checked)? 25: -25; // Wider checked--if not, must be Narrower awidth = (awidth > -1)? awidth: 0; lines[i] = "|Spacer|Width:" + awidth; }}} document.penta.IOField.value=""; for (i=0; i < lines.length; i++) { document.penta.IOField.value+= lines[i]; if ((i + 1) < lines.length) document.penta.IOField.value+= newLine; } document.penta.IOField.select(); } function demo() { var txtArray = [ ['!NoteWorthyComposerClip(2.5,Single)'], ['|Clef|Type:Treble'], ['|Bar'], ['|Key|Signature:F#,C#,G#|Tonic:A'], ['|Bar'], ['|TimeSig|Signature:Common'], ['|Bar'], ['|TimeSig|Signature:4/4'], ['|Bar'], ['|Note|Dur:8th,Dotted|Pos:5'], ['|Bar'], ['|Note|Dur:4th|Pos:5|Color:6'], ['|Chord|Dur:4th|Pos:0,5|Opts:Slur=Downward,Lyric=Never,ArticulationsOnStem,Tie=Upward|Color:6|Visibility:Default'], ['|Bar|Color:6'], ['|Note|Dur:Half|Pos:5|Color:6'], ['|Chord|Dur:Half|Pos:-5,0,5|Color:6'], ['|Rest|Dur:4th'], ['|Bar'], ['|Note|Dur:Whole|Pos:5'], ['|Bar'], ['|Clef|Type:Treble'], ['|Spacer|Width:0'], ['|Bar'], ['|Key|Signature:F#,C#,G#|Tonic:A'], ['|Spacer|Width:0'], ['|Bar'], ['|TimeSig|Signature:Common'], ['|Spacer|Width:0'], ['|Bar'], ['|TimeSig|Signature:4/4'], ['|Spacer|Width:0'], ['|Bar'], ['|Spacer|Width:0'], ['|Note|Dur:8th,Dotted|Pos:5'], ['|Spacer|Width:0'], ['|Bar'], ['|Spacer|Width:0'], ['|Note|Dur:4th|Pos:5'], ['|Spacer|Width:0'], ['|Bar'], ['|Spacer|Width:0'], ['|Note|Dur:Half|Pos:5'], ['|Spacer|Width:0'], ['|Bar'], ['|Spacer|Width:0'], ['|Note|Dur:Whole|Pos:5'], ['|Spacer|Width:0'], ['|Bar'], ['|Note|Dur:8th|Pos:1'], ['|Spacer|Width:50'], ['|Note|Dur:8th|Pos:1'], ['|Spacer|Width:50'], ['|Note|Dur:8th|Pos:1'], ['|Spacer|Width:50'], ['|Note|Dur:4th|Pos:1'], ['|Spacer|Width:75'], ['|Note|Dur:4th|Pos:1'], ['|Spacer|Width:100'], ['|Note|Dur:4th|Pos:1'], ['|Spacer|Width:125'], ['|Note|Dur:Half|Pos:1'], ['|Spacer|Width:125'], ['|Note|Dur:Half|Pos:1'], ['|Spacer|Width:150'], ['|Note|Dur:Half|Pos:1'], ['|Spacer|Width:125'], ["!NoteWorthyComposerClip-End"] ] document.penta.IOField.value=""; for (var i = 0; i < txtArray.length; i++) { document.penta.IOField.value+=txtArray[i]; if ((i+1) < txtArray.length) {document.penta.IOField.value+="\n";} } }

Spacer Assistant

 

Insert minimum spacers after all objects    Insert starting spacers after notes, rests, & chords only

Remove     Wider     Narrower    

 

Cut Section of NWC file into here.

 

 

To use this page, cut the staff (or part of the staff) from a NWC file into the above box. Choose the appropriate option at the top and click on Submit. The output is pre-selected so do Cntl/C (copies to clipboard), Alt/Tab (gets back to NWC w/o moving the cursor), and Cntl/V to paste back into your score. When using the Wider or Narrower options, you may click on Submit more than once without taking the output back to NWC. The spacer width will not be allowed to go negative. Created or modified spacers have no special attributes.

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 2012 by Warren Porter