} // THE MAIN ACTION STARTS HERE foreach ($argv as $arg) { if ($arg == "help") { print_help_and_exit(); } elseif ($arg == "separate") { $writeasseparate = 1; } } $clip = new NWC2Clip('php://stdin'); // 1. Scan each line foreach ($clip->Items as $item) { $o = new NWC2ClipItem($item); $oType = $o->GetObjType(); if ($oType == "Note") { CheckExtremes($o->GetTaggedOpt("Pos")); } elseif ($oType == "RestChord") { CheckExtremes($o->GetTaggedOpt("Pos2")); } elseif ($oType == "Chord") { CheckExtremes($o->GetTaggedOpt("Pos")); CheckExtremes($o->GetTaggedOpt("Pos2")); } unset($o); } // 2. Check if we scanned any notes if ($maximum == -999) { // Bail out if no notes or chords or restchords abort("No notes found!"); } if ($maximum == $minimum) { abort("This selection has a range of a single note!");
$bar = 0; $nothingToDo = TRUE; // 2. Load and scan the stream... output is group by group $clip = new NWC2Clip('php://stdin'); echo $clip->GetClipHeader() . "\n"; foreach ($clip->Items as $item) { $nothingToDo = FALSE; $o = new NWC2ClipItem($item); $oType = $o->GetObjType(); if ($oType == "TimeSig") { // better flush anything in the buffer while ($go = array_shift($currentGroup)) { echo $go->ReconstructClipText() . "\n"; } // now flush the current group $timeSig = $o->GetTaggedOpt("Signature"); if (isset($groupingsTable[$timeSig])) { $currentGroupTimes = $groupingsTable[$timeSig]; } else { unset($currentGroupTimes); } // this isn't $groupNum = 0; $placeInTime = 0; } if ($oType == "Bar" && !$o->GetTaggedOpt("Color")) { $bar++; while ($go = array_shift($currentGroup)) { echo $go->ReconstructClipText() . "\n"; } // now flush the current group
} } } $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"); switch ($ARPEGGIO_SEQUENCE) { case "up": // do nothing break; case "down": $chordnotes = array_reverse($chordnotes); break; case "random": shuffle($chordnotes); break; } // The last item does not need a tied in grace note array_pop($chordnotes); foreach ($chordnotes as $i => $notepitchtxt) {
$font = $m[1]; } else { abort("Unknown parameter \"{$arg}\". Use \"help\" for more details."); } } if (!isset($transposeValue) || $transposeValue < -11 || $transposeValue > 11) { abort("Must provide an integer between -11 and 11 as transposition"); } if ($transposeValue != 0 && !isset($transposeKey)) { $transposeKey = "C"; } $clip = new NWC2Clip('php://stdin'); // 1. Scan each line echo $clip->GetClipHeader() . "\n"; $nothingToDo = TRUE; foreach ($clip->Items as $item) { $nothingToDo = FALSE; $o = new NWC2ClipItem($item); if ($o->GetObjType() == "Text" && ($t =& $o->GetTaggedOpt("Text")) && rootChordValue($t) && (isset($font) ? $o->GetTaggedOpt("Font") == $font : true)) { transpose($t); echo $o->ReconstructClipText() . "\n"; } else { echo $item; } unset($o); } echo NWC2_ENDCLIP . "\n"; if ($nothingToDo) { abort("This tool requires a selection.\nPlease select something on the staff before invoking transpose_chords."); } exit(NWC2RC_SUCCESS);
echo $clip->GetClipHeader() . "\n"; $PlayContext = new NWC2PlayContext(); foreach ($clip->Items as $item) { $o = new NWC2ClipItem($item, true); if ($o->IsContextInfo()) { $PlayContext->UpdateContext($o); continue; } $isChanged = false; if (in_array($o->GetObjType(), array('Note', 'Chord', 'RestChord'))) { $o_new = new NWC2ClipItem($item, true); for ($loop = 0; $loop < 2; $loop++) { $Opt_inc = $loop ? "2" : ""; $OptName_Pos = "Pos" . $Opt_inc; $OptName_Dur = "Dur" . $Opt_inc; $pitchpos =& $o_new->GetTaggedOpt($OptName_Pos); if (is_string($pitchpos)) { ProcessNote($pitchpos); } else { if (is_array($pitchpos)) { foreach ($pitchpos as &$notepitchTxt) { ProcessNote($notepitchTxt); } } } } if ($isChanged) { echo $o_new->ReconstructClipText() . "\n"; } } if (!$isChanged) {