rg_ForceAccidentals.php - Force Accidentals on a selection
Quite easy. Figuring out how easy took several hours.
<?php
# rg_ForceAccidentals.php ver 1.0
# Ref: http://my.noteworthysoftware.com/?topic=8445.0
require_once ('lib/nwc2clips.inc');
$clip = new NWC2Clip(); // Input Type: Clip Text
echo $clip->GetClipHeader(), PHP_EOL; // Returns Clip Text
$PlayContext = new NWC2PlayContext();
foreach ($clip->Items as $item) {
$o = new NWC2ClipItemWithPitchPos($item, true);
foreach (array('Pos', 'Pos2') as $pos_tag)
foreach ($o->PitchPos[$pos_tag] as $npp)
$npp->Accidental = $PlayContext->GetNotePitchAccidental($npp);
$PlayContext->UpdateContext($o);
$o->ReconstructPosOpts();
echo $o->ReconstructClipText(), PHP_EOL;
}
echo NWC2_ENDCLIP, PHP_EOL;
?>
Comments and criticisms welcome.