Example #1
0
}
$measure->addLayer($layer);
$part->addMeasure($measure);
// 2nd measure
$measure = new Measure($measureOptions);
$layer = new Layer();
foreach ($pitches as $pitch) {
    if (is_array($pitch)) {
        $chord = new Chord();
        foreach ($pitch as $p) {
            $pitch = new Pitch($p);
            $pitch->transpose(-12);
            $note = new Note(array('pitch' => $p, 'duration' => 4, 'type' => 'quarter'));
            $chord->addNote($note);
        }
        $layer->addChord($chord);
    } else {
        $pitch = new Pitch($pitch);
        $pitch->transpose(-12);
        $note = new Note(array('pitch' => $pitch, 'duration' => 4, 'type' => 'quarter'));
        $layer->addNote($note);
    }
}
$measure->addLayer($layer);
$part->addMeasure($measure);
// 3nd measure
$measure = new Measure($measureOptions);
$layer = new Layer();
$note = new Note(array('pitch' => new Pitch('F2'), 'duration' => 8, 'type' => 'half'));
$layer->addNote($note);
$note = new Note(array('pitch' => new Pitch('G2'), 'duration' => 8, 'type' => 'half'));