51
General Discussion / Grace notes with duration
This was referenced in a user tip.
This section allows you to view all Topics made by this member. Note that you can only see Topics made in areas you currently have access to.
/* Notes to Rests by Warren Porter "restStaff.js"
After downloading this file, when setting it up in NWC User Tools create this command line:
wscript "'Browse can insert the path for you' \restStaff.js"
This can help create a new staff when one is needed for layering. First, copy an entire staff to the clipboard, create a new staff,
then cut the clipboard to the new staff. Run this command on that new staff. Clefs, time signatures, and key signatures will be
left alone on the new staff, but all notes, chords, and restchords will be replaced by rests. Bars with "full measures" (the norm,
it has as many beats as the time signature dictates) will be replaced with whole rests, a measure with more or fewer (like a pickup)
will be replaced with rests of the same durations (and order if necessary) or the original notes, rests, chords, or restchords.
The new staff may then be used for layered notes for the original staff. It can be run through the MMR tool with the "LayerHide"
option so unneeded parts won't display.
This is not suited to creating a "tempo" or "conductor" staff. To create a tempo staff which could be layered into all other parts
to print parts, the clef or keys should not be copied while tempos or tempo variences should be.
*/
var rc=0, errMsg=""
function getNoteLength(notelet) { // Returns duration of note , whole = 768
var NoteLengths = { "16th":48, "32nd":24, "4th":192, "64th":12, "8th":96, "Half":384, "Whole":768 }
parts = notelet.split(",");
var noteLength= -1;
noteLength = NoteLengths[parts[0]];
var noteLength = ( NoteLengths[parts[0]] === undefined ) ? -1 : NoteLengths[parts[0]];
if (noteLength == -1)
return -1;
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;
}
function calculate(clip) {
var i, j=0, dsi;
var lines = new Array(), result = new Array(), nlines = new Array, mt=0, measureTab = new Array, beatletCount=0, targetMeasure = 768;
var thisDur, thisNote, durSplit;
lines = clip.split("\r\n");
for (i=0; i < lines.length; i++) {
if (lines[i].slice(1,5) == "Text" || lines[i].slice(1,14) == "TempoVariance")
continue;
if (lines[i].slice(1,5) == "Fake" || lines[i].slice(1,8) == "Context" ) { // For these items, pass them thru and ignore them.
nlines[j++] = lines[i]; continue; }
if ((lines[i].indexOf("TimeSig")) > 0) {
if (beatletCount == targetMeasure) // Measure exactly full
nlines[j++] = "|Rest|Dur:Whole|Visibility:Never"; // Insert whole rest
else {
for (mt = 0; mt < measureTab.length; mt++)
nlines[j++] = "|Rest|Dur:" + measureTab[mt] + "|Visibility:Never";}
beatletCount = 0, measureTab.length = 0; mt=0;
result = lines[i].match(/ture:(\d+)\/(\d+)/); // Read the time signature
if (result == null) //In case it is C or cut time
targetMeasure = 768;
else
targetMeasure = 768 * result[1] / result[2]; // Calculate length of measure
nlines[j++] = lines[i]; continue; }
if (/Grace/.test(lines[i]))
continue;
result = lines[i].match(/Dur:([^\|\r\n]+)/) // Looking for anything with a duration
if (result != null) { // Duration loop
thisDur = result[1];
thisNote = getNoteLength(thisDur);
if (thisNote == -1) {
errMsg += "Invalid duration of " + lines[i] + "\r\n";
rc=1;
continue; }
durSplit = thisDur.split(",");
for (dsi=1; dsi < durSplit.length; dsi++)
if (!(durSplit[dsi].substr(0,9) == "DblDotted" || durSplit[dsi].substr(0,6) == "Dotted" || durSplit[dsi].substr(0,7) == "Triplet")) {
durSplit.length = dsi; break; }
measureTab[mt++] = durSplit.join(",");
if (lines[i].slice(1,15) == "Rest|Dur:Whole") //So existing whole rest in , e.g., 3/4 time won't be treated as having 4 beats.
thisNote = targetMeasure;
beatletCount += thisNote;
continue; } // End duration loop
if (lines[i].slice(1,4) == "Bar" || lines[i].slice(1,5) == "Flow" || lines[i].slice(1,7) == "Ending" || lines[i].slice(0,1) == "!"||
lines[i].slice(1,13) == "RestMultiBar" || lines[i].slice(1,9) == "Boundary" || lines[i].slice(1,11) == "Instrument" ||
lines[i].slice(1,4) == "MPC" || lines[i].slice(1,5) == "Clef" || lines[i].slice(1,4) == "Key" ) { //Bar loop, flow, & spec. endings
if (beatletCount == targetMeasure) // Measure exactly full
nlines[j++] = "|Rest|Dur:Whole|Visibility:Never"; // Insert whole rest
else {
for (mt = 0; mt < measureTab.length; mt++)
nlines[j++] = "|Rest|Dur:" + measureTab[mt] + "|Visibility:Never";}
beatletCount = 0, measureTab.length = 0; mt=0; // Get set up for next measure
if (lines[i].slice(1,6) != "Tempo")
nlines[j++] = lines[i]; } //End bar loop
} //End main processing loop
return nlines;
}
var myLines=calculate(WScript.StdIn.ReadAll()).join("\r\n");
if (rc == 0)
WScript.StdOut.Write(myLines);
else
WScript.StdErr.Write(errMsg);
WScript.quit(rc);
/*
mmr.js by Warren Porter
<PROMPT:MMR?:=|Yes|Undo> <PROMPT:Options:=|HideAll|ShowAll|ShowBar|ShowRst|LayerHide>
Multi Measure Rest Tool
This tool gives the user the ability to convert consecutive measures of whole rests into Multi-Measure Rests. When hidden,
the user can choose to show bars and rests, bars only, rests only, or neither. If a "conductor" or "tempo" staff is being
layered into a part to be printed, the "LayerHide" option will prevent any MMR on that part from being displayed. Boundary
collapse and cancel collapse commands are created around the multi measure rests.
Changes made can be backed out with the "Undo" prompt. All options on the 2nd prompt are ignored. The above boundary commands
are removed and MMRs are replaced by the approprate number of whole rests separated by bar lines.
This tool can operate on ONLY a selected part of a staff, or, if nothing has been selected, the entire staff.
*/
rc=0, errMsg="";
function doProcess(clip) {
var result=new Array(), nlines=new Array(), ii=0, lastBar=-1,cntRest=0,lastRest=0;
var mmrOption = "|PrintOnce:Y";
if (WScript.Arguments.Item(1) == "ShowAll")
mmrOption += "|WhenHidden:ShowBars,ShowRests";
else
if (WScript.Arguments.Item(1) == "ShowBar")
mmrOption += "|WhenHidden:ShowBars";
else
if (WScript.Arguments.Item(1) == "ShowRst")
mmrOption += "|WhenHidden:ShowRests";
else
if (WScript.Arguments.Item(1) == "LayerHide")
mmrOption = "|PrintOnce:N|Visibility:Never"; // Used for hiding tempo or conductor stave.
lines = clip.split("\r\n"); // lines === existing lines; nlines === lines to be created
for (var i=0; i < lines.length; i++) { // Main processing loop
switch (cntRest) {
case 0 :
if (lines[i].slice(0,15) == "|Rest|Dur:Whole") { //Found first rest
cntRest++; lastRest = i; }
else {
nlines[ii++] = lines[i]; } // Didn't find a rest and have no backlog, copy line to OP array.
break;
case 1 : // Have found exactly one whole rest
if (lines[i].slice(0,15) == "|Rest|Dur:Whole") {
cntRest++; lastBar = 0; }
else
if ((lines[i].slice(0,4) == "|Bar") && (lines[i].slice(4,11) != "|Style:")) {
lastBar = i; }
else { // Found whole rest not followed by bar or another rest
if (lastRest) {
for ( ; lastRest <= i; lastRest++) {
nlines[ii++] = lines[lastRest] }
cntRest=0,lastBar=0; } }
break;
default: // cntRest is 2 or more.
if (lines[i].slice(0,15) == "|Rest|Dur:Whole") {
cntRest++; lastBar = 0; }
else
if ((lines[i].slice(0,4) == "|Bar") && (lines[i].slice(4,11) != "|Style:")) {
lastBar = i; }
else { // Found whole rest not followed by bar or another rest, must create MMR
nlines[ii++] = "|Boundary|Style:Collapse";
nlines[ii++] = "|RestMultiBar|NumBars:" + cntRest + mmrOption;
if (lines[i].slice(0,27) != "!NoteWorthyComposerClip-End" || lastBar) {
nlines[ii++] = "|Boundary|Style:EndCollapse"; }
cntRest = 0;
if (lastBar) // If MMR was followed by a barline and something else
nlines[ii++] = lines[lastBar]; // first move the barline over
lastBar = 0;
nlines[ii++] = lines[i] // Move the non-rest non-bar over to OP buffer.
}
} //End of switch
} //End main processing loop
/* Next loop will place the Boundary Collapse BEFORE a bar line and the Cancel Collapse AFTER a bar line. This will stop empty
bars from being displayed when a part begins or ends on a complete system. The loop after that will remove EndCollapse and
Collapse when they are next to each other.
*/
for (i=1; (i+1) < nlines.length; i++) { // Start fixit loop.
if ((nlines[i].slice(0,4) == "|Bar") && (nlines[i+1].slice(0,24) == "|Boundary|Style:Collapse")) {
var tempi = nlines[i];
nlines[i] = nlines[i+1];
nlines[++i] = tempi; }
else
if ((nlines[i].slice(0,27) == "|Boundary|Style:EndCollapse") && (nlines[i+1].slice(0,4) == "|Bar")) {
tempi = nlines[i];
nlines[i] = nlines[i+1];
nlines[++i] = tempi; }
} //End fixup loop
for (i=1; (i+1) < nlines.length; i++) {
if ((nlines[i].slice(0,27) == "|Boundary|Style:EndCollapse") && (nlines[i+1].slice(0,24) == "|Boundary|Style:Collapse")) {
nlines[i] = "#"; //Turn both lines into a comment
nlines[++i] = "#"; }
else
if (WScript.Arguments.Item(1) == "LayerHide" && nlines[i].slice(0,5) =="|Rest" && nlines[i].indexOf("|Visibility:Never") == -1)
nlines[i]+= "|Visibility:Never";
}
return nlines;
}
/*
!NoteWorthyComposerClip(2.51,Single)
|Rest|Dur:Half
|Tempo|Tempo:70|Pos:10
|Rest|Dur:4th|Visibility:Never
|Tempo|Tempo:67|Pos:10
|Rest|Dur:4th
|Bar|Visibility:Never
|Rest|Dur:Whole|Visibility:Never
!NoteWorthyComposerClip-End
*/
function doUndo(clip) {
var result=new Array(), nlines=new Array(), ii=0, lastRest=0,cntRest=0;
var restLit = "|Rest|Dur:Whole", barLit = "|Bar";
lines = clip.split("\r\n"); // lines === existing lines; nlines === lines to be created
for (var i=0; i < lines.length; i++) { // Main processing loop
if (lines[i].match(/Boundary.*Collapse/) != null)
continue;
result = lines[i].match(/(RestMultiBar\|NumBars:)(\d+)(\|PrintOnce)/)
if (result == null) {
nlines[ii++] = lines[i]; }
else {
lastRest = Number(result[2])
for (cntRest=0; cntRest < lastRest; cntRest++) {
nlines[ii++] = restLit;
if ((cntRest + 1) < lastRest)
nlines[ii++] = barLit;
}
}
} //End main processing loop
if (WScript.Arguments.Item(1) == "LayerHide") {
for (i = 0; i < nlines.length; i++)
if (result = nlines[i].match(/Rest.*Never/))
nlines[i] = nlines[i].replace("|Visibility:Never","") }
return nlines;
}
var myLines;
if (WScript.Arguments.length != 2) {
errMsg="NO Prompt read.";
rc=1; }
else {
if (WScript.Arguments.Item(0).slice(0,4) == "Undo")
myLines=doUndo(WScript.StdIn.ReadAll()).join("\r\n");
else
myLines=doProcess(WScript.StdIn.ReadAll()).join("\r\n"); }
if (rc == 0)
WScript.StdOut.Write(myLines);
else
WScript.StdErr.Write(errMsg);
WScript.quit(rc);
/* Dynamic Placement by Warren Porter "dynplace.js"
After downloading this file, when setting it up in NWC User Tools create this command line:
wscript "'Browse can insert the path for you' \dynplace.js" <PROMPT:Enter equal OR +- dd:=*sdd> <PROMPT:Justify Right?:=|N|Y> <PROMPT:Hairpins?:=|Move|Ignore>
A parm of =10 would put ALL dynamic markings above the staff while =-7 would put them just below the staff.
Parms of +3 or -2 would raise or lower all dynamic markings by the specified number of positions.
*/
rc=0, errMsg="";
function calculate(clip) {
var i, OutText = "", relPos=0, absPos=0, goSwitch, dynPrefix, dynPos, dynSuffix;
var lines = new Array(), result = new Array();
if (WScript.Arguments.length != 3) {
errMsg="NO Prompt read. This needs a prompt \"=[-]d[d]\" to place dynamics at a specific position or \"[+-]n[n]\" to move them up or down";
rc=1;
return lines; }
errMsg=WScript.Arguments.Item(0) + "\r\n";
result = WScript.Arguments.Item(0).match(/=(-?\d*)/);
if (result)
absPos=result[1]; //Absolute position specified
else {
result = WScript.Arguments.Item(0).match(/([-+]\d*)\D?/);
if (result)
relPos = Number(result[1]); // Relative position
else { // Neither match worked, abort
errMsg+="Invalid prompt. This needs a prompt \"=[-]d[d]\" to place dynamics at a specific position or \"[+-]n[n]\" to move them up or down";
rc=1;
return lines; } }
var jRight = (WScript.Arguments.Item(1) == "Y")? true : false;
var hairPins = (WScript.Arguments.Item(2) == "Ignore")? true : false;
lines = clip.split("\r\n");
for (i=0; i < lines.length; i++) { // Main processing loop
result=lines[i].match(/(\|Dynamic\|Style.*Pos:)(-?\d*)(.*)/) // Looking for Dynamic, it's position, and the rest of the line
if (result) { //Found dynamic
goSwitch = true; //Setting up look ahead loop
if (hairPins) {
for (var ii=i+1; ii < lines.length; ii++) {
if (lines[ii].slice(0,5) == "|Text") continue; //Ignore text lines
if (lines[ii].slice(0,8) == "|Dynamic") break; //Found another dynamic or dynamic variance, get out of loop.
if (/Crescendo|Diminuendo/.test(lines[ii])) { //Found hairpins before another dynamic, don't mess with it.
goSwitch = false; break; } } // End lookahead loop
} // End if hairPins
if (goSwitch) {
dynPrefix = result[1];
dynPos = Number(result[2]);
dynSuffix = result[3];
if (jRight) {
if (dynSuffix == "")
dynSuffix = "|Wide:N|Justify:Right";
else {
if (!/Justify:Right/.test(dynSuffix))
if (/Justify:/.test(dynSuffix)) {
dynSuffix = dynSuffix.replace("Justify:Left","Justify:Right");
dynSuffix = dynSuffix.replace("Justify:Center","Justify:Right"); }
else
dynSuffix = "|Justify:Right" + dynSuffix; } }
else
dynSuffix = result[3];
if (relPos != 0)
{dynPos += relPos;}
else
{dynPos = absPos;}
lines[i] = dynPrefix + dynPos + dynSuffix; }
} // End dynamic loop
} //End main processing loop
return lines;
}
var myLines=calculate(WScript.StdIn.ReadAll()).join("\r\n");
if (rc == 0)
WScript.StdOut.Write(myLines);
else
WScript.StdErr.Write(errMsg);
WScript.quit(rc);
/*Does anyone have any insight to these lines (they occurred just after the header) or others? The Fake line went away if there was no transposition.
NWC2 User Tool, Ver 1.0 - Rick G. Warren's test version
JScript version of nwswStatisticsReport.php
&Command: WScript Scripts\Stats.js
*/
var i, mark = new Date(), s;
/*
objArgs = WScript.Arguments
WScript.Echo("Argument count = " + WScript.Arguments.Count());
for (i=0; i<objArgs.length; i++)
{
WScript.Echo(objArgs(i))
}
*/
// convert notation clip text to an array of lines
var stdin = WScript.StdIn.ReadAll().split("\r\n");
// init these so they will always report
var d = {"Total Items":0, "Clef":0, "Key":0, "TimeSig":0, "Bar":0, "Note":0, "Chord":0};
// count objects. non-objects are counted as 'undefined'
for (i in stdin){ // i = array index (integer)
s = stdin[i].split("|")[1]; // objType or undefined
if ((s == "Fake") || (s == "Context")) WScript.echo(i + " " + stdin[i]); // new line
d[s] = (0 | d[s]) + 1; // increment, create keys as needed
}
delete d.undefined; s = ""; // cleanup
for (i in d) d["Total Items"] += d[i];
for (i in d) s += (" " + d[i] + " ").slice(-6) + i + "\n";
// report to STDOUT, elapsed time to STDERR
WScript.StdOut.Write("Statistics Report:\n\n" + s);
WScript.StdErr.Write("The STDOUT file contains the report.\n" +
((new Date() - mark) / 1000).toFixed(2) + " seconds\n");
WScript.Quit(99); // show STDOUT page to user
I'm transcribing some Tudor music and, in the original, there are some
"squiggle-like signs" that I think are called signa congruentiae. They seem to
indicate points where all the parts come together.
Just wondering whether anyone has ever encoded these signs in abc. They look a
bit like a mirror image of a question mark, or a distorted S. For the moment,
I'm just annotating an "S" above the stave, but it would be nice to use
something more authentic.
I started with NWC about the same time (1998). I can't take it any more. The upgrade did nothing for my complaints, that I can tell. It's simply too hard to load the extras. Why don't multibar rests exist yet? Why is it so difficult to get rehearsal numbers/letters in? If there's an easy way to do those, and lots of other things, I have never found it. NWC is great for a quick and dirty leadsheet, or a few bars of something, but a full score, in my experience, is way too difficult to maneuver around. I really, really, wanted it to continue working. I finally threw my hands up in disgust about a month ago. It just doesn't do what I want it to do, unless I want to download all the added fonts and other crap that people throw out there. I don't make it a habit of downloading that type of thing from just anyone, and the few times I did try it, the things just didn't work. Both the big boys will do what I want, and much more easily. I just want multibar rests, rehearsal marks, easy lyrics, and easy chord symbols. NWC add-ons haven't made those happen, Finale and Sibelius do it as a basic feature.
NWC now has Multi Measure Rests and collapsable staves. User fonts such as Boxmark2 and FretQwik allow rehearsal symbols and chords to be inserted. These fonts as well as hundreds of transcriptions of classical and originial music are on http://nwc-scriptorium.org/index.html
!NoteWorthyComposerClip(2.0,Single)
|Clef|Type:Treble
|Key|Signature:F#,C#,G#,D#
|TimeSig|Signature:4/4
|Note|Dur:4th|Pos:-9
|Note|Dur:4th|Pos:-7
|Note|Dur:4th|Pos:-4
|Rest|Dur:8th
|Note|Dur:8th|Pos:-7
|Bar
|Note|Dur:8th|Pos:-4|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=End
|Note|Dur:8th|Pos:-4|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=End
|Note|Dur:8th|Pos:-4|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=End
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=End
|Bar
|Note|Dur:8th|Pos:-4|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-5|Opts:Stem=Up,Beam=End
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-7|Opts:Stem=Up,Beam=End
|Note|Dur:4th|Pos:-7
|Rest|Dur:4th
!NoteWorthyComposerClip-End
|Note|Dur:4th|Pos:-7o|Color:0|Visibility:Default
!NoteWorthyComposerClip(2.0,Single)into
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2^|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2^|Opts:Stem=Down,Beam=End
|Note|Dur:4th|Pos:2
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2^|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2^|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2^|Opts:Stem=Down,Beam=End
|Note|Dur:4th|Pos:2
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1^|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:4th|Pos:1
|Note|Dur:Half,Dotted|Pos:0^
|Bar
|Note|Dur:Half,Dotted|Pos:0
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Beam=End
!NoteWorthyComposerClip-End
!NoteWorthyComposerClip(2.0,Single)
|Note|Dur:8th|Pos:2|Opts:Stem=Down
|Note|Dur:4th|Pos:2
|Note|Dur:8th|Pos:2^|Opts:Stem=Down
|Note|Dur:4th|Pos:2
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2^|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:8th|Pos:2|Opts:Stem=Down
|Note|Dur:4th|Pos:1
|Note|Dur:8th|Pos:2^|Opts:Stem=Down
|Note|Dur:4th|Pos:2
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1^|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:4th|Pos:1
|Note|Dur:Half,Dotted|Pos:0^
|Bar
|Note|Dur:Half,Dotted|Pos:0
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Beam=End
!NoteWorthyComposerClip-End
I'm a novice at this but I am trying to work out a way of producing a score that looks and sounds right using different time signatures. Specifically I have a vocal line written in 3/4 with an accompaniment in 9/8. Please advise, in very simple language, how I can get it to look and sound right,
Chris