Exemple #1
0
    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;
            }
            //
Exemple #2
0
    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!");
}
// 3. Commence output...
echo $clip->GetClipHeader() . "\n";
foreach ($clip->Items as $item) {
    if (!$printedRange) {
        $o = new NWC2ClipItem($item);
        if (in_array($o->GetObjType(), array("Note", "Chord", "RestChord"))) {
            $printedRange = 1;
            // ...and then precede it with our range
            if ($writeasseparate) {
                echo "|Note|Dur:Whole|Pos:{$minimum}\n|Note|Dur:Whole|Pos:{$maximum}\n";
            } else {
                echo "|Chord|Dur:Whole|Pos:{$minimum},{$maximum}\n";
            }
            echo "|Bar|Style:Double\n";
        }
        unset($o);
    }
    echo $item;
}
echo NWC2_ENDCLIP . "\n";
exit(NWC2RC_SUCCESS);
Exemple #3
0
}
// process other optional arguments, in no particular order
foreach ($argv as $arg) {
    if (preg_match("/^nosingle\$/", $arg)) {
        $single = 0;
    } else {
        abort("Unrecognised parameter '{$arg}'");
    }
}
$clip = new NWC2Clip('php://stdin');
echo $clip->GetClipHeader() . "\n";
$nothingToDo = TRUE;
foreach ($clip->Items as $item) {
    $nothingToDo = FALSE;
    $o = new NWC2ClipItem($item);
    $oType = $o->GetObjType();
    if (!in_array($oType, array("Note", "Chord", "Rest", "RestChord"))) {
        // not an item of interest, pass it thru
        echo $item;
    } elseif ($gobbleTime > 0) {
        // run down the gobble clock, don't print the item
        $gobbleTime -= timeTaken($o);
    } elseif ($passTime > 0) {
        $passTime -= timeTaken($o);
        echo $item;
    } elseif ($oType == "Rest" || !timeTaken($o)) {
        // don't filter on rests or grace notes
        echo $item;
    } else {
        $o =& filterPart($action, $part, $o);
        echo $o->ReconstructClipText() . "\n";
        $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);
                shuffle($chordnotes);
                break;
        }
        // The last item does not need a tied in grace note
        array_pop($chordnotes);
        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|Opts:Stem=Up,Beam{$beamOpt}|Pos:{$new_notepitchtxt}\n";
        }
    }
    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);
Exemple #6
0
        $optname = $m[1];
        $optvalue = $m[2];
        $opts[strtolower($optname)] = $optvalue;
    }
}
$opts['skip'] = strtolower($opts['skip']);
$skiplist = explode(',', $opts['skip']);
echo $clip->GetClipHeader() . "\n";
//
foreach ($clip->Items as $item) {
    $o = new NWC2ClipItem($item);
    //
    $skipit = false;
    //
    if ($opts['skip'] == 'all') {
        $skipit = true;
    } else {
        if ($opts['skip'] != 'none') {
            $skipit = in_array(strtolower($o->GetObjType()), $skiplist);
        }
    }
    //
    if ($skipit) {
        echo $item;
        continue;
    }
    $o->Opts['Visibility'] = $opts['visibility'];
    echo $o->ReconstructClipText() . "\n";
}
echo NWC2_ENDCLIP . "\n";
exit(NWC2RC_SUCCESS);