Ejemplo n.º 1
0
 public function getByName($name, $type, $transpose = 0)
 {
     $this->name = Strings::strtoupper($name);
     $this->type = Strings::underscore($type);
     $notes = $this->getNotes();
     if (in_array($this->type, array_keys($this->config))) {
         $start = array_keys($notes, $this->name);
         $note_sum = sizeof($notes) - 1;
         if (count($start) > 0) {
             if ($start[0] + $transpose < 0) {
                 $current = $start[0] + $transpose + $note_sum + 1;
             } else {
                 if ($start[0] + $transpose > $note_sum) {
                     $current = $start[0] + $transpose - $note_sum - 1;
                 } else {
                     $current = $start[0] + $transpose;
                 }
             }
             $this->scale[] = $notes[$current];
             foreach ($this->config[$this->type] as $num) {
                 $current += $num;
                 if ($current > $note_sum) {
                     $current -= $note_sum + 1;
                 }
                 $this->scale[] = $notes[$current];
             }
             return $this->scale;
         }
     }
 }
Ejemplo n.º 2
0
 public function getByScale($name, $type)
 {
     $scale = new Scale();
     $name = Strings::strtoupper($name);
     $type = Strings::underscore($type);
     $scale->getByName($name, $type);
     $scale_notes = $scale->notes;
     if (isset($scale_notes) && count($scale_notes) > 0) {
         $this->possible = array();
         $chords = $this->getTypes();
         for ($i = 0; $i < 12; $i++) {
             foreach ($chords as $chord) {
                 $this->chord = null;
                 $this->getByName("C", $chord, $i);
                 if ($this->containsNotes($this->chord, $scale_notes)) {
                     array_push($this->possible, array("name" => current($this->chord), "type" => $chord));
                 }
             }
         }
         return $this->possible;
     }
 }