The specification for how this tool was created can be found at:
https://forum.noteworthycomposer.com/?topic=5563.0
This script will find note pairs where the first note is a dotted note, and the second is half the notehead duration of the first and is not dotted. It will convert the pair into two notes of the same duration. Version 1.1 now works on rests, non-beamed notes, and quarter note duration.
<?php
/*******************************************************************************
nwsw_Unjazzify Version 1.1
This script will find note pairs where the first note is a dotted note,
and the second is half the notehead duration of the first and is not dotted.
It will convert the pair into two notes of equal duration.
Copyright © 2006 by NoteWorthy Software, Inc.
All Rights Reserved
History:
2006-05-09: Version 1.1
- Changed detection to allow rests, non-beamed notes, and quarter note duration
2006-05-09: Initial release (1.0)
*******************************************************************************/
require_once("lib/nwc2clips.inc");
$clip = new NWC2Clip('php://stdin');
//
$validPairs = array(
"4th" => "8th",
"8th" => "16th",
"16th" => "32nd",
"32nd" => "64th"
);
//
// Track the number of conversions
$numConvertedPairs = 0;
//
// Track the previous note if it is eligible for conversion
$priorNoteObj = false;
$targetEndingDuration = false;
//
// Track any items that fall between the two notes in the group
$NonNoteQ = "";
//
function FlushTheGroupingQ()
{
global $NonNoteQ,$priorNoteObj;
if ($priorNoteObj) echo $priorNoteObj->ReconstructClipText()."\n";
if ($NonNoteQ) echo $NonNoteQ;
$NonNoteQ = "";
$priorNoteObj = false;
}
echo $clip->GetClipHeader()."\n";
//
foreach ($clip->Items as $item) {
$o = new NWC2ClipItem($item);
//
$is_note = in_array($o->GetObjType(), array("Chord","Note","Rest"));
$is_rest = ($o->GetObjType() == "Rest");
$is_grace = isset($o->Opts["Dur"]["Grace"]);
$is_dotted = isset($o->Opts["Dur"]["Dotted"]);
$is_dbldotted = isset($o->Opts["Dur"]["DblDotted"]);
$is_beamed = isset($o->Opts["Opts"]["Beam"]);
$is_beamstart = $is_beamed && ($o->Opts["Opts"]["Beam"] == "First");
if ($is_note) {
if (!$priorNoteObj) {
$starterDuration = array_intersect(array_keys($o->Opts["Dur"]),array_keys($validPairs));
if (count($starterDuration)) $starterDuration = array_shift($starterDuration);
else $starterDuration = false;
//
if ($is_dotted && !$is_grace && $starterDuration && (!$is_beamed || ($is_beamed && $is_beamstart))) {
$targetEndingDuration = $validPairs[$starterDuration];
$priorNoteObj = $o;
continue;
}
//
echo $item;
}
else if (in_array($targetEndingDuration, array_keys($o->Opts["Dur"])) && !$is_beamstart && !$is_dotted && !$is_dbldotted) {
$numConvertedPairs++;
unset($priorNoteObj->Opts["Dur"]["Dotted"]);
unset($o->Opts["Dur"][$targetEndingDuration]);
$o->Opts["Dur"][$starterDuration] = "";
FlushTheGroupingQ();
echo $o->ReconstructClipText()."\n";
}
else {
FlushTheGroupingQ();
echo $item;
}
continue;
}
if (in_array($o->GetObjType(),array("Bar","TimeSig"))) {
FlushTheGroupingQ();
echo $item;
continue;
}
if ($priorNoteObj) $NonNoteQ .= $item;
else echo $item;
}
FlushTheGroupingQ();
echo NWC2_ENDCLIP."\n";
if (!$numConvertedPairs) {
fputs(STDERR,"No valid note pairs were found within the selection");
exit(NWC2RC_ERROR);
}
exit(NWC2RC_SUCCESS);
?>
In order to install this script, you need to do the following:
- Install the NWC2 User Tool Starter Kit
- Select all of the script text that appears above this bulleted list and press Ctrl+C to copy it
- Open a Notepad window
- Paste the contents of the script into the Notepad window
- In Notepad, select File, Save As, and navigate to the Scripts are of your NWC2 installation, which is usually at "C:\Program Files\NoteWorthy Composer 2\Scripts"
- Enter the File name as nwsw_Unjazzify.php and press enter
- Close Notepad
- In NWC2, press Alt+F8, then click the New button
- For Name, enter Unjazzify (nwsw)
- For Command, use the Browse button to navigate to to your nwsw_Unjazzify.php script and press Open
- Press OK to complete your addition of this script to your tool library