NoteWorthy Composer Forum

Forums => Tips & Tricks => User Tools => Topic started by: NoteWorthy Online on 2006-05-09 01:55 pm

Title: Unjazzify Note Pairs
Post by: NoteWorthy Online on 2006-05-09 01:55 pm
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:

Title: Re: Unjazzify Beamed, Dotted Note Pairs
Post by: Wilm Boerhout on 2006-05-09 03:37 pm
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
Title: Re: Unjazzify Note Pairs
Post by: NoteWorthy Online on 2006-05-09 05:05 pm
Added in version 1.1.
Title: Re: Unjazzify Note Pairs
Post by: Wilm Boerhout on 2006-05-10 06:32 am
[shadow=red,left]Wow![/shadow]
Title: Re: Unjazzify Note Pairs
Post by: NoteWorthy Online on 2006-05-13 12:36 pm
This script is now included in the NWC2 User Tool Starter Kit.
Title: Re: Unjazzify Note Pairs
Post by: Gantafistor on 2009-01-23 04:16 am
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
Title: Re: Unjazzify Note Pairs
Post by: Lawrie Pardy on 2009-01-23 06:26 am
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...
Title: Re: Unjazzify Note Pairs
Post by: Gantafistor on 2009-01-23 09:47 pm
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