I am trying to modify a version of the existing arpeggiate script to hide the tied grace notes (I have "up" and "16th" as constants w/o prompts). My question is around line 58 in the following. TIA
<?php
/*******************************************************************************
nwsw_ArpeggiateChord.php Version 1.21
This script will arpeggiate selected chords by adding grace notes that tie into the chord.
Prompting can be added with the following command line:
"/duration=<PROMPT:Select a grace note duration:=|8th|16th|32nd>" "/sequence=<PROMPT:Select an arpeggio order:=|up|down|random>"
Copyright © 2007 by NoteWorthy Software, Inc.
All Rights Reserved
HISTORY:
================================================================================
[2010-07-25] Testing hidden arpeggios and inserting the vertical wavy line symbol from Boxmark2
[2007-06-19] Version 1.21: Support prompting
[2007-06-16] Version 1.20: Add grace note duration constant, sequencing scheme, and ignore last note in chord sequence
[2006-05-12] Version 1.01: Code format cleanup
[2004-10-28] Version 1.00: Initial release
*******************************************************************************/
require_once("lib/nwc2clips.inc");
// ARPEGGIO_DURATION can be one of 8th, 16th, 32nd, 64th
$ARPEGGIO_DURATION = "16th";
//
// Const_ARPEGGIO_SEQUENCE can be one of up, down, or random
$ARPEGGIO_SEQUENCE = "up";
//foreach ($argv as $k => $v) {
// if (preg_match('/^\/duration\=(.*)$/i',$v,$m)) $ARPEGGIO_DURATION = $m[1];
// else if (preg_match('/^\/sequence\=(.*)$/i',$v,$m)) $ARPEGGIO_SEQUENCE = $m[1];
// }
$clip = new NWC2Clip('php://stdin');
if (count($clip->Items) < 1) trigger_error("Please select at least one chord",E_USER_ERROR);
echo $clip->GetClipHeader()."\n";
$priorNoteObj = false;
foreach ($clip->Items as $item) {
$o = new NWC2ClipItem($item);
//
// If this is a non-grace chord and is not preceded by a grace note,
// and it is larger than an 8th note in duration, then add a grace note arpeggio
if (($o->GetObjType() == "Chord") &&
!isset($o->Opts["Dur"]["Grace"]) &&
(count(array_intersect(array_keys($o->Opts["Dur"]),array("Whole","Half","4th"))) > 0) &&
!isset($priorNoteObj->Opts["Dur"]["Grace"])) {
$chordnotes = $o->GetTaggedOpt("Pos");
$chorddur = $o->GetTaggedOpt("Dur");
// The last item does not need a tied in grace note
array_pop($chordnotes);
/* This is where my question starts. I would like to get the position of the bottom note of the chord,
* add 3 to it and use it to echo a |Text| line with the calculated Pos either here or in the next foreach loop when $i == 0.
* My first question is how to read it, strip off the accent (if any), and calculate a $TextPos value to use in the echo; and the second
* is where should the statement go. TIA
*/
foreach ($chordnotes as $i => $notepitchtxt) {
$notepitchObj = new NWC2NotePitchPos($notepitchtxt);
$notepitchObj->Tied = '^';
$new_notepitchtxt = $notepitchObj->ReconstructClipText();
//
$beamOpt = ($i ? "" : "=First");
if ($i == (count($chordnotes)-1)) $beamOpt = "=End";
//
$o = new NWC2ClipItem($item);
echo "|Note|Dur:$ARPEGGIO_DURATION,Grace|Pos:$new_notepitchtxt|Opts:Stem=Up,Beam$beamOpt|Visibility:Never\n";
}
}
/* Sample data:
!NoteWorthyComposerClip(2.0,Single)
|Text|Text:"c "|Font:User1|Pos:-3|Wide:Y
|Note|Dur:16th,Grace|Pos:#-6^|Opts:Stem=Up,Beam=First|Visibility:Never
|Note|Dur:16th,Grace|Pos:-4^|Opts:Stem=Up,Beam|Visibility:Never
|Note|Dur:16th,Grace|Pos:-2^|Opts:Stem=Up,Beam=End|Visibility:Never
|Chord|Dur:4th|Pos:#-6,-4,-2,#1
!NoteWorthyComposerClip-End
*/
echo $item;
if (in_array($o->GetObjType(),array('Note','Chord','Rest','RestChord'))) $priorNoteObj = $o;
else if ($o->GetObjType() == "Bar") unset($priorNoteObj);
unset($o);
}
echo NWC2_ENDCLIP."\n";
exit(NWC2RC_SUCCESS);
?>