Skip to main content
Topic: Unjazzify Note Pairs (Read 20818 times) previous topic - next topic

Unjazzify Note Pairs

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.

Code: [Select · Download]
<?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

Re: Unjazzify Beamed, Dotted Note Pairs

Reply #1
Thanks Eric. Of course, a tool offered is a tool to be expanded upon.

Do you see a way to make an extension as follows: modify pairs of (Dotted 8th rest,16th note) and pairs of (Dotted 8th note,16th rest) to straight eighths as well?

/Wilm
Wilm Boerhout

Re: Unjazzify Note Pairs

Reply #2
Added in version 1.1.

 

Re: Unjazzify Note Pairs

Reply #3
[shadow=red,left]Wow![/shadow]
Wilm Boerhout

Re: Unjazzify Note Pairs

Reply #4
This script is now included in the NWC2 User Tool Starter Kit.

Re: Unjazzify Note Pairs

Reply #5
Hi, I just come to install the v.2 and when I unjazz it works, but the duration change to the notes he'd change... ex:  I do the unjazz on a dotted eight and an 16, it change to two 8 but now it play exactely two eights not swing at all.

Greetings

Ganta

Re: Unjazzify Note Pairs

Reply #6
G'day Ganta,
welcome to the forum.

Hi, I just come to install the v.2 and when I unjazz it works, but the duration change to the notes he'd change... ex:  I do the unjazz on a dotted eight and an 16, it change to two 8 but now it play exactely two eights not swing at all.

Umm, yup - that's what it's supposed to do.  To enable swing playback you need a tempo/conductor staff with tempo directives on it.  there are several ways of doing this, but rather than going into it here, I'll point you to some good threads on the subject:

https://forum.noteworthycomposer.com/?topic=2335.msg12893#msg12893
https://forum.noteworthycomposer.com/?topic=6032.0
https://forum.noteworthycomposer.com/?topic=5806
https://forum.noteworthycomposer.com/?topic=5590

The unjazzify tool allows you to import a jazz MIDI to NWC and then alter it to appear as a normal jazz chart.  The appearance is important for musicians who will be playing your charts.  Of course, if you also want to listen to it, it will will sound odd - hence the tempo or conductor staff to make the swing work...
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: Unjazzify Note Pairs

Reply #7
Thank you a lot Lawrie, this will help me a lot to better understand how to do it... it's that normally I'm working with the program Finale but its far too expansive.  So I got noteworthy in 2006 but I didn't even know that the version two were out  and when I've seen that the swing is now in the program I said to myself: I'll probably work with it more.

Greetings

Ganta