Exemple #1
0
 public function __construct($name, $type)
 {
     $this->name = $name;
     $this->type = $type;
     $this->scale = new Scale();
     $this->scale = $this->scale->getByName($name, $type);
     if (isset($this->scale) && count($this->scale)) {
         foreach ($this->scale as $note) {
             $chord = new Chord();
             $chord->getByName($note, $this->config[$type][count($this->chords)]);
             array_push($this->chords, $chord);
         }
     }
 }
Exemple #2
0
 public function getByChords($chords)
 {
     $_chord = new Chord();
     $notes = array();
     foreach ($chords as $chord) {
         $name = Strings::ucfirst($chord["name"]);
         $type = Strings::sanitize_u($chord["type"]);
         $_chord->getByName($name, $type);
         $notes = array_merge($notes, $_chord->notes);
     }
     $notes = array_unique($notes);
     $this->possible = array();
     $scales = $this->getTypes();
     for ($i = 0; $i < 12; $i++) {
         foreach ($scales as $scale) {
             $this->scale = null;
             $this->getByName("C", $scale, $i);
             if ($this->containsNotes($notes, $this->scale)) {
                 array_push($this->possible, array("name" => current($this->scale), "type" => $scale));
             }
         }
     }
     return $this->possible;
 }
Exemple #3
0
 function addNote($note)
 {
     $chord = new Chord();
     $chord->addNote($note);
     $this->addChord($chord);
 }
Exemple #4
0
 /**
  * Clone current Chord
  * @return Chord clone
  */
 public function __clone()
 {
     $chord = new Chord(count($this->strings));
     $chord->setName($this->getName());
     $chord->setFirstFret($this->getFirstFret());
     for ($i = 0; $i < count($chord->strings); $i++) {
         $chord->strings[$i] = $this->strings[$i];
     }
     return $chord;
 }
Exemple #5
0
function encloseChord($matches)
{
    global $mosConfig_live_site, $chordsToAdd;
    $chord = $matches[2];
    if (trim($chord) == "") {
        return "<td>&nbsp;</td>";
    }
    $chordObj = new Chord($chord);
    if ($chordObj->getBassNote() != "") {
        $bassNote = $chordObj->getNote($chordObj->getBassNote());
    } else {
        $bassNote = $chordObj->getNote($chordObj->getMainNote());
    }
    $chord = $chordObj->getChordAsString();
    $chordHTML = $chordObj->getChordAsHTML();
    if (!in_array($chordObj->getChordAsHTML(), $chordsToAdd)) {
        $chordsToAdd[$chordObj->getChordAsHTML()] = $chordObj;
    }
    return "<td><a class=\"choproChord\" href=\"\" onclick=\"javascript: playChordMidi(this.innerHTML); return false;\" onMouseOver=\"return overlib(getChordHint(this.innerHTML), WIDTH, 100, ABOVE);\" onMouseOut=\"return nd();\">{$chordHTML}</a>&nbsp;</td>";
}
Exemple #6
0
        }
        $layer->addChord($chord);
    } else {
        $note = new Note(array('pitch' => $pitch, 'duration' => 4, 'type' => 'quarter'));
        $layer->addNote($note);
        // this essentially adds a chord with only one note in it.
    }
}
$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);