A new webpage will add to a note (not an existing chord) the same note an octave higher, replicating any accidental and keeping all other attributes of the original note intact.
octaveup.html (http://www.wjporter.com/nwc/octaveup.htm). It is on the page: nwc (http://www.wjporter.com/nwc).
That page also will replicate a tie for the new note if there was one on the original note. I've also changed the Do It Yourself.txt (http://www.wjporter.com/nwc/diy.txt) page.
Typical problem from cut & paste: <title>Modify Tempos</title>
It should have been "Octave Up".
Good catch. Fixed and uploaded.
I have converted this to a user tool. The new note will be an octave up or octave down depending upon the prompt. See code for installation instructions.
Modified to ignore "Fake" input when the selection starts in the middle of a measure./*
doOctave.js by Warren Porter
<PROMPT:Dir?:=|Up|Down>
Octave Tool
This tool will convert a note to an octave chord, replicating accidentals and tie status. The new note will be higher or lower
than the original note depending on the prompt.
This tool can operate on ONLY a selected part of a staff, or, if nothing has been selected, the entire staff.
To install:
1) Save this file with the name doOctave.js on your computer and remember its location.
2) Start NWC and press Alt/F8. Pick new
3) After choosing a name and group, browse for this file and click "Open".
4) Insert "wscript " at the beginning of the command and " <PROMPT:Dir?:=|Up|Down>" at the end.
5) Clip text should be selected and check no options.
*/
rc=0, errMsg="";
function doUp(clip) {
var displ=0, upDispl=0;
var result = new Array();
var lines = clip.split("\r\n");
for (i = 1; i < lines.length; i++) { // Main processing loop
if (/Fake/.test(lines[i]))
lines[i] = "#";
else {
result = lines[i].match(/(\|Note.*Pos:)([n#bvx]?)(-?\d+)(\^?)(.*)$/) // 1. Note thru Pos 2. Accidental 3. Position 4. Ties 5. To end of line
if (result != null) {
var note_lit = result[1];
var acc_lit = result[2]
displ = parseInt(result[3]);
var a_tie = result[4]
var eol = result[5]
note_lit = note_lit.replace("Note","Chord")
upDispl = displ + 7;
lines[i] = note_lit + acc_lit + displ + a_tie + "," + acc_lit + upDispl + a_tie + eol; }
} } // End main loop
return lines;
}
function doDown(clip) {
var displ=0, dnDispl=0;
var result = new Array();
var lines = clip.split("\r\n");
for (i = 1; i < lines.length; i++) { // Main processing loop
if (/Fake/.test(lines[i]))
lines[i] = "#";
else {
result = lines[i].match(/(\|Note.*Pos:)([n#bvx]?)(-?\d+)(\^?)(.*)$/) // 1. Note thru Pos 2. Accidental 3. Position 4. Ties 5. To end of line
if (result != null) {
var note_lit = result[1];
var acc_lit = result[2]
displ = parseInt(result[3]);
var a_tie = result[4]
var eol = result[5]
note_lit = note_lit.replace("Note","Chord")
dnDispl = displ - 7;
lines[i] = note_lit + acc_lit + dnDispl + a_tie + "," + acc_lit + displ + a_tie + eol; }
} } // End main loop
return lines;
}
var myLines;
if (WScript.Arguments.length != 1) {
errMsg="NO Prompt read.";
rc=1; }
else {
if (WScript.Arguments.Item(0).slice(0,2) == "Up")
myLines=doUp(WScript.StdIn.ReadAll()).join("\r\n");
else
myLines=doDown(WScript.StdIn.ReadAll()).join("\r\n"); }
if (rc == 0)
WScript.StdOut.Write(myLines);
else
WScript.StdErr.Write(errMsg);
WScript.quit(rc);
Or you could use either of my "MakeChord" tools with no parameters ;)
https://forum.noteworthycomposer.com/?topic=5738.0
If NWC's User Tool implementation is inspired, a simple task should not need a lot of code.
As evidence, I present this:
<?php
# rg_AddOctave.php ver 1.1 NWC User Tool
# Ref: http://my.noteworthysoftware.com/?topic=7901.0
$dir = in_array('Up', $argv)? 7: -7;
$io = file('php://stdin');
foreach(preg_grep('/^\|Note\|/', $io) as $k=>$v) {
preg_match('/^.Note(.*?Pos:(.*?)(-?\d+)(.*?))([|\s].*)$/', $v, $m);
$io[$k] = '|Chord'.$m[1].','.$m[2].($dir + $m[3]).$m[4].$m[5]."\n";
if (in_array('-t', $argv)) fwrite(STDERR, print_r($m, true));
}
echo join($io);
?>
and submit that the hypothesis is not disproved by the task of adding octaves to notes.
For those interested in how this works, add '-t' to the command line, as in: <PROMPT:Dir?:=|Up|Down>
-t