This tool will allow you to move all or selected dynamics up or down by the amount you specify or place these dynamics at a specific position above, on, or below the staff. Installation instructions are in comments. An argument of +3 or -4 would move dynamics up or down while =-7 would put all dynamics below the staff.
This could be adapted to move other objects such as pedal commands.
Please note the first eight lines of this code:/* 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);
The comments (between the /* and the */ near the top of the program) show how the command line should look. I don't know where you will create the js file, but browse will create a path and name for it. It still needs the wscript in front and the prompt (at the end of the line) to make it fly.
Am away from my regular computer now. Will look at enhancements and a new mmr (including undo) when I get back.
Jan 24, 2013 10:00 am
I replaced the code in the first message. May add prompts for justification and lookahead in a few days. This version right justifies dynamics and won't move one when a hairpin follows.
BTW, is there a way to put a real = in the prompt? I didn't find a way to escape it.
!NoteWorthyComposerClip(2.5,Single)
|Boundary|Style:Collapse
|Clef|Type:Bass
|Key|Signature:F#|Tonic:C
|TimeSig|Signature:4/4
|RestMultiBar|NumBars:9|PrintOnce:Y|WhenHidden:ShowBars,ShowRests
|Dynamic|Style:p|Opts:Volume=23|Pos:10|Visibility:Never
|Bar
|Note|Dur:Half|Pos:3|Opts:Lyric=Never
|Rest|Dur:8th
|Dynamic|Style:mf|Opts:Volume=38|Pos:10|Justify:Right
|Note|Dur:8th|Pos:3|Opts:Lyric=Never
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam=End
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Note|Dur:8th|Pos:1|Opts:Lyric=Never
|Note|Dur:4th,Dotted|Pos:2^|Opts:Lyric=Never
|Note|Dur:4th|Pos:2|Opts:Lyric=Never
|Rest|Dur:4th
|Bar
|Rest|Dur:Whole
|Bar
|Rest|Dur:Half
|Rest|Dur:4th
|Rest|Dur:8th
|Note|Dur:8th|Pos:3|Opts:Lyric=Never
|Bar
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Lyric=Never,Beam=End
|Note|Dur:8th|Pos:4|Opts:Lyric=Never
|Note|Dur:4th|Pos:4|Opts:Lyric=Never
|Note|Dur:8th|Pos:3|Opts:Lyric=Never
|Bar
|Boundary|Style:EndCollapse
|Note|Dur:8th|Pos:1|Opts:Lyric=Never
|Note|Dur:4th,Dotted|Pos:0|Opts:Lyric=Never
|Rest|Dur:8th
|Note|Dur:8th|Pos:1|Opts:Lyric=Never
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam=End
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam
|Note|Dur:8th|Pos:-3|Opts:Stem=Up,Lyric=Never,Beam=End
|Bar
|Note|Dur:4th|Pos:0|Opts:Lyric=Never
|Note|Dur:4th|Pos:1|Opts:Lyric=Never
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:-2|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:-1|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:-2|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Boundary|Style:Collapse
|Dynamic|Style:mf|Opts:Volume=38|Pos:-10|Justify:Right
|Note|Dur:4th|Pos:0|Opts:Lyric=Never
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam=End
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Rest|Dur:8th
|Note|Dur:4th|Pos:5|Opts:Lyric=Never
|Note|Dur:8th|Pos:3|Opts:Lyric=Never
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Note|Dur:4th|Pos:6|Opts:Lyric=Never
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Lyric=Never,Beam=End
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:#0|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Lyric=Never,Beam
|Note|Dur:8th|Pos:-1|Opts:Stem=Down,Lyric=Never,Beam=End
|Bar
|Note|Dur:Half|Pos:-2|Opts:Stem=Down,Lyric=Never
|Rest|Dur:8th
|Note|Dur:8th|Pos:-2|Opts:Lyric=Never
|Note|Dur:8th|Pos:-1|Opts:Stem=Up,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Lyric=Never,Beam=End
|Bar
|Boundary|Style:EndCollapse
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Lyric=Never,Beam=End
|Rest|Dur:8th|Opts:Crescendo
|Note|Dur:8th|Pos:3|Opts:Crescendo,Lyric=Never
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Lyric=Never,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Lyric=Never,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Lyric=Never,Beam=End
|Bar
|Rest|Dur:8th|Opts:Crescendo
|Note|Dur:4th|Pos:n2|Opts:Crescendo,Lyric=Never
|Note|Dur:8th|Pos:2|Opts:Crescendo,Lyric=Never
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Crescendo,Lyric=Never,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Crescendo,Lyric=Never,Beam
|Note|Dur:8th|Pos:#0|Opts:Stem=Down,Crescendo,Lyric=Never,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Crescendo,Lyric=Never,Beam=End
|Bar
|Note|Dur:8th|Pos:n3|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=End
|Rest|Dur:4th|Opts:Crescendo
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=End
|Rest|Dur:4th|Opts:Crescendo
|Bar
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=End
|Rest|Dur:4th|Opts:Crescendo
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Crescendo,Beam=End
|Rest|Dur:4th|Opts:Crescendo
|Bar
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Beam=End
|Rest|Dur:4th|Opts:Crescendo
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Beam=End
|Rest|Dur:4th|Opts:Crescendo
|Bar
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Crescendo,Beam=End
|Note|Dur:4th|Pos:2|Opts:Crescendo
|Note|Dur:4th|Pos:0|Opts:Crescendo
|Note|Dur:4th|Pos:0|Opts:Crescendo
|Bar
|Note|Dur:Whole|Pos:3|Opts:Crescendo
|Bar
|Boundary|Style:Collapse
|Rest|Dur:Half
|Rest|Dur:8th
|Dynamic|Style:f|Opts:Volume=46|Pos:10|Justify:Right
|Note|Dur:8th|Pos:-1
|Note|Dur:8th|Pos:b0|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-1|Opts:Stem=Up,Beam=End
|Bar|Style:Double
|Key|Signature:Bb,Eb,Ab,Db|Tonic:C
|Note|Dur:4th|Pos:1
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Bar
|Rest|Dur:8th
|Note|Dur:4th|Pos:6
|Note|Dur:8th|Pos:4
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:4th|Pos:7
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Beam=End
|Note|Dur:4th|Pos:1
|Note|Dur:4th|Pos:5
|Bar
|Note|Dur:Half|Pos:4
|Rest|Dur:8th
|Note|Dur:8th|Pos:-1
|Note|Dur:8th|Pos:0|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-1|Opts:Stem=Up,Beam=End
|Bar
|Note|Dur:4th|Pos:1
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam=End
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam=End
|Bar
|Rest|Dur:8th
|Note|Dur:4th|Pos:6
|Note|Dur:8th|Pos:4
|Note|Dur:8th|Pos:2|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Up,Beam=End
|Bar
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:6|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:7|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:Half|Pos:4|Opts:Stem=Down
|Rest|Dur:8th
|Note|Dur:8th|Pos:4
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:8th|Pos:2
|Note|Dur:4th,Dotted|Pos:3^
|Note|Dur:4th|Pos:3
|Rest|Dur:4th
|Bar
|Rest|Dur:Whole
|Bar
|Rest|Dur:Half
|Rest|Dur:4th
|Rest|Dur:8th
|Note|Dur:8th|Pos:3
|Bar
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:5|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:5
|Note|Dur:4th|Pos:5
|Note|Dur:8th|Pos:4
|Bar
|Boundary|Style:EndCollapse
|Note|Dur:8th|Pos:2
|Note|Dur:4th,Dotted|Pos:1
|Rest|Dur:8th
|Note|Dur:8th|Pos:2
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam=End
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam=First
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam
|Note|Dur:8th|Pos:-2|Opts:Stem=Up,Beam=End
|Bar
|Note|Dur:4th|Pos:1
|Note|Dur:4th|Pos:2
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:-1|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:0|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:-1|Opts:Stem=Down,Beam=End
|Bar
|Boundary|Style:Collapse
|Note|Dur:4th|Pos:1
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Bar
|Rest|Dur:8th
|Note|Dur:4th|Pos:6
|Note|Dur:8th|Pos:4|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th|Pos:1|Opts:Stem=Down,Beam=End
|Bar
!NoteWorthyComposerClip-End