=|help|Treble|Bass|Alto|Tenor|Percussion| =|None|Octave Up|Octave Down| Notes are defined in Noteworthy by their position on the stave. If the Clef is changed, the notes remain in the same position and hence represent different note values. This User Tool changes the Clef and adjusts the positions of the notes to keep the same note values. The first clef symbol in the selection (or the whole tune if no selection is made) is changed and all subsequent notes are adjusted up to the next clef symbol or the end of the tune, whichver comes first." ; exit(NWC2RC_REPORT) ; } $noteTypes = array ("Note", "Chord", "RestChord"); $clefShift = array ("Treble" => -6, "Alto" => 0, "Tenor" => 2, "Bass" => 6, "Percussion" => 6); $octaveShift = array ("None" => 0 , "Octave Up" => -7 , "Octave Down" => 7); $clip = new NWC2Clip('php://stdin'); $arg = array('clef' => 'Treble','octave' => 'None'); foreach ($argv as $k => $v) { if (!$k) continue; if (preg_match('/^\/([a-z]+)\=(.*)$/',$v,$m)) { $argname = $m[1]; $argvalue = $m[2]; $arg[strtolower($argname)] = $argvalue; } } if ($arg["clef"] == "help") help_msg_and_exit() ; echo $clip->GetClipHeader()."\n"; // $firstClefFound=FALSE; $secondClefFound=FALSE; foreach ($clip->Items as $item) { $o = new NWC2ClipItem($item); $oType = $o->GetObjType(); if ($secondClefFound) { echo $item; continue; } if ($oType=="Clef") { if ($firstClefFound) { echo $item; $secondClefFound=TRUE; } else { $startPos = $clefShift[$o->Opts['Type']]; $endPos = $clefShift[$arg['clef']]; if (isset($o->Opts['OctaveShift'])) { $startOctave = $octaveShift[$o->Opts['OctaveShift']]; } else { $startOctave = 0; } $endOctave = $octaveShift[$arg['octave']]; $shiftPos = $endPos - $startPos + $endOctave - $startOctave; $o->Opts['Type'] = $arg['clef']; $o->Opts['OctaveShift'] = $arg['octave']; echo $o->ReconstructClipText()."\n"; $firstClefFound=TRUE; } } else { if ($firstClefFound) { if (in_array($oType, $noteTypes)) { if ($oType=="Note") { $notepitchObj = new NWC2NotePitchPos($o->Opts["Pos"]); $notepitchObj->Position += $shiftPos; $o->Opts["Pos"] = $notepitchObj->ReconstructClipText(); echo $o->ReconstructClipText()."\n"; } else { if (isset($o->Opts["Pos"])) { $c=count($o->Opts["Pos"]); for ($i = 0; $i < $c; $i++) { $notepitchObj = new NWC2NotePitchPos($o->Opts["Pos"][$i]); $notepitchObj->Position += $shiftPos; $o->Opts["Pos"][$i] = $notepitchObj->ReconstructClipText(); } } if (isset($o->Opts["Pos2"])) { $c=count($o->Opts["Pos2"]); for ($i = 0; $i < $c; $i++) { $notepitchObj = new NWC2NotePitchPos($o->Opts["Pos2"][$i]); $notepitchObj->Position += $shiftPos; $o->Opts["Pos2"][$i] = $notepitchObj->ReconstructClipText(); } } echo $o->ReconstructClipText()."\n"; } } else { echo $item; } } else { echo $item; } } } echo NWC2_ENDCLIP."\n"; exit(NWC2RC_SUCCESS); ?>