public function getByName($name, $type, $transpose = 0) { $this->name = Strings::ucfirst($name); $this->type = Strings::sanitize_u($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->chord[] = $notes[$current]; foreach ($this->config[$this->type] as $num) { $current += $num; if ($current > $note_sum) { $current -= $note_sum + 1; } $this->chord[] = $notes[$current]; } return $this->chord; } } }
public function testUcfirstEmpty() { $expected = ''; $string = new Strings(''); $result = $string->ucfirst(); $this->assertEmpty($result); }
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; }