Beispiel #1
0
 /**
  * accepts the scale object in the form of an array structure
  * @param  [type] $scale [description]
  * @return [type]        [description]
  */
 public static function constructFromArray($props)
 {
     if (isset($props['root'])) {
         if ($props['root'] instanceof Pitch) {
             $root = $props['root'];
         } else {
             $root = Pitch::constructFromArray($props['root']);
         }
     }
     return new Scale($props['scale'], $root, $props['direction']);
 }
 public function getPitchByIdAjax($id)
 {
     return Response::json(Pitch::find($id));
 }
Beispiel #3
0
 function toXML()
 {
     $out = '';
     $out .= '<note';
     if (isset($this->defaultX)) {
         $out .= ' default-x="' . $this->defaultX . '"';
     }
     if (isset($this->defaultY)) {
         $out .= ' default-y="' . $this->defaultY . '"';
     }
     $out .= '>';
     if (!empty($this->rest)) {
         $out .= '<rest/>';
     }
     if (!empty($this->chord)) {
         $out .= '<chord/>';
     }
     if (!empty($this->pitch)) {
         if ($this->pitch instanceof Pitch) {
             $pitch = $this->pitch;
         } else {
             // we'll presume it's a string then
             $pitch = new Pitch($this->pitch);
         }
         $out .= $pitch->toXML();
     }
     if (!empty($this->duration)) {
         $out .= '<duration>' . $this->duration . '</duration>';
     }
     if (!empty($this->voice)) {
         $out .= '<voice>' . $this->voice . '</voice>';
     }
     if (!empty($this->type)) {
         $out .= '<type>' . $this->type . '</type>';
     }
     if (!empty($this->dot)) {
         $out .= '<dot/>';
     }
     if (!empty($this->tie)) {
         $out .= '<tie style="' . $this->tie . '">';
         $this->notations['tie'] = $this->tie;
     }
     if (!empty($this->staccato)) {
         $this->notations['staccato'] = $this->properties['staccato'];
     }
     if (!empty($this->stem)) {
         $out .= $this->stem->toXml();
     }
     if (!empty($this->staff)) {
         $out .= '<staff>' . $this->staff . '</staff>';
     }
     if (!empty($this->beam)) {
         if (!is_array($this->beam)) {
             $this->beam = array($this->beam);
         }
         foreach ($this->beam as $beam) {
             $out .= $beam->toXml();
         }
     }
     if (!empty($this->notations) || !empty($this->articulations)) {
         $out .= '<notations>';
         // Slur, Tie, Tuplet, Arpeggiate
         foreach ($this->notations as $notation) {
             $out .= $notation->toXml();
         }
         // staccato
         if (!empty($this->articulations)) {
             $out .= '<articulations>';
             foreach ($this->articulations as $articulation) {
                 $out .= $articulation->toXml();
             }
             $out .= '</articulations>';
         }
         $out .= '</notations>';
     }
     $out .= '</note>';
     return $out;
 }
Beispiel #4
0
 function toXML()
 {
     $out = '';
     $out .= '<note';
     if (isset($this->properties['default-x'])) {
         $out .= ' default-x="' . $this->properties['default-x'] . '"';
     }
     if (isset($this->properties['default-y'])) {
         $out .= ' default-y="' . $this->properties['default-y'] . '"';
     }
     $out .= '>';
     if (!empty($this->properties['rest'])) {
         $out .= '<rest/>';
     }
     if (!empty($this->properties['chord'])) {
         $out .= '<chord/>';
     }
     if (!empty($this->properties['pitch'])) {
         if ($this->properties['pitch'] instanceof Pitch) {
             $pitch = $this->properties['pitch'];
         } else {
             // we'll presume it's a string then
             $pitch = new Pitch($this->properties['pitch']);
         }
         $out .= $pitch->toXML();
     }
     if (!empty($this->properties['duration'])) {
         $out .= '<duration>' . $this->properties['duration'] . '</duration>';
     }
     if (!empty($this->properties['voice'])) {
         $out .= '<voice>' . $this->properties['voice'] . '</voice>';
     }
     if (!empty($this->properties['type'])) {
         $out .= '<type>' . $this->properties['type'] . '</type>';
     }
     if (!empty($this->properties['dot'])) {
         $out .= '<dot/>';
     }
     if (!empty($this->properties['tie'])) {
         $out .= '<tie style="' . $this->properties['tie'] . '">';
         $this->notations['tie'] = $this->properties['tie'];
     }
     if (!empty($this->properties['staccato'])) {
         $this->notations['staccato'] = $this->properties['staccato'];
     }
     if (!empty($this->properties['stem'])) {
         $out .= '<stem';
         if (isset($this->properties['stem']['default-x'])) {
             $out .= ' default-x="' . $this->properties['stem']['default-x'] . '"';
         }
         if (isset($this->properties['stem']['default-y'])) {
             $out .= ' default-y="' . $this->properties['stem']['default-y'] . '"';
         }
         $out .= '>';
         if (isset($this->properties['stem']['direction'])) {
             $out .= $this->properties['stem']['direction'];
         }
         $out .= '</stem>';
     }
     if (!empty($this->properties['staff'])) {
         $out .= '<staff>' . $this->properties['staff'] . '</staff>';
     }
     if (!empty($this->properties['beam'])) {
         if (!is_array($this->properties['beam'])) {
             $this->properties['beam'] = array($this->properties['beam']);
         }
         foreach ($this->properties['beam'] as $beam) {
             $out .= '<beam';
             if (isset($beam['beam']['number'])) {
                 $out .= ' number="' . $beam['beam']['number'] . '"';
             }
             $out .= '>';
             if (!empty($beam['beam']['type'])) {
                 $out .= $beam['beam']['type'];
             }
             $out .= '</beam>';
         }
     }
     if (!empty($this->notations) || !empty($this->articulations)) {
         $out .= '<notations>';
         foreach ($this->notations as $notationType => $n) {
             switch ($notationType) {
                 case 'slur':
                     $out .= '<slur';
                     $out .= ' number="' . $n['number'] . '"';
                     $out .= ' placement="' . $n['placement'] . '"';
                     $out .= ' type="' . $n['type'] . '"';
                     $out .= ' bezier-x="' . $n['bezier-x'] . '"';
                     $out .= ' bezier-y="' . $n['bezier-y'] . '"';
                     $out .= ' default-x="' . $n['default-x'] . '"';
                     $out .= ' default-y="' . $n['default-y'] . '"';
                     $out .= '/>';
                     break;
                 case 'tie':
                     $out .= '<tied type="' . $n . '"/>';
                     break;
                 case 'tuplet':
                     $out .= '<tuplet';
                     $out .= ' bracket="' . $n['bracket'] . '"';
                     $out .= ' number="' . $n['number'] . '"';
                     $out .= ' placement="' . $n['placement'] . '"';
                     $out .= ' type="' . $n['type'] . '"';
                     $out .= '/>';
                     break;
                 case 'arpeggiate':
                     $out .= '<arpeggiate';
                     $out .= ' default-x="' . $n['default-x'] . '"';
                     $out .= ' number="' . $n['number'] . '"';
                     $out .= '/>';
                     break;
             }
         }
         if (!empty($this->articulations)) {
             $out .= '<articulations>';
             foreach ($this->articulations as $articulation => $value) {
                 switch ($articulation) {
                     case 'staccato':
                         $out .= $value ? '<staccato/>' : '';
                 }
             }
             $out .= '</articulations>';
         }
         $out .= '</notations>';
     }
     $out .= '</note>';
     return $out;
 }
Beispiel #5
0
$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'));
$layer->addNote($note);
$measure->addLayer($layer);
 public function run()
 {
     // $faker = Faker::create();
     // foreach(range(1, 10) as $index)
     // {
     // 	Pitch::create([
     // 	]);
     // }
     $pitch = new Pitch();
     $pitch->user_id = 1;
     $pitch->brewery_id = 1;
     $pitch->title = "Alamomode";
     $pitch->campaign = "This is a beer for beer and ice cream fans.  We have some great ideas to make this happen.  Keep updated here for further info.";
     $pitch->goal = "5000";
     $pitch->deadline = "2016-02-29";
     $pitch->video = "https://www.youtube.com/embed/aV36ytSgC3o";
     $pitch->recipe = "100 lbs of hops and 50 lbs of wheat";
     $pitch->save();
     $pitch = new Pitch();
     $pitch->user_id = 2;
     $pitch->brewery_id = 2;
     $pitch->title = "UPA";
     $pitch->campaign = "This is an unusual pale ale.  Lets get started. ";
     $pitch->goal = "4000";
     $pitch->deadline = "2016-03-28";
     $pitch->video = "https://www.youtube.com/embed/aV36ytSgC3o";
     $pitch->recipe = "200 lbs of hops and 50 lbs of barley";
     $pitch->save();
     $pitch = new Pitch();
     $pitch->user_id = 3;
     $pitch->brewery_id = 3;
     $pitch->title = "Tropical Fruit Shandy";
     $pitch->campaign = "This is an unusual pale ale.  Lets get started. ";
     $pitch->goal = "3000";
     $pitch->deadline = "2016-04-11";
     $pitch->video = "https://www.youtube.com/embed/aV36ytSgC3o";
     $pitch->recipe = "200 lbs of hops and 50 lbs of barley";
     $pitch->save();
     $pitch = new Pitch();
     $pitch->user_id = 4;
     $pitch->brewery_id = 4;
     $pitch->title = "Bourbon infused Stout";
     $pitch->campaign = "This is an unusual pale ale.  Lets get started. ";
     $pitch->goal = "10000";
     $pitch->deadline = "2016-05-25";
     $pitch->video = "https://www.youtube.com/embed/aV36ytSgC3o";
     $pitch->recipe = "200 lbs of hops and 50 lbs of barley";
     $pitch->save();
     $pitch = new Pitch();
     $pitch->user_id = 5;
     $pitch->brewery_id = 5;
     $pitch->title = "Saison Pale Ale with notes of Coconut";
     $pitch->campaign = "This is an unusual pale ale.  Lets get started. ";
     $pitch->goal = "8000";
     $pitch->deadline = "2016-03-03";
     $pitch->video = "https://www.youtube.com/embed/aV36ytSgC3o";
     $pitch->recipe = "200 lbs of hops and 50 lbs of barley";
     $pitch->save();
     $pitch = new Pitch();
     $pitch->user_id = 6;
     $pitch->brewery_id = 6;
     $pitch->title = "Thanksgiving Holiday Beer";
     $pitch->campaign = "This is an unusual pale ale.  Lets get started. ";
     $pitch->goal = "9000";
     $pitch->deadline = "2016-11-28";
     $pitch->video = "https://www.youtube.com/embed/aV36ytSgC3o";
     $pitch->recipe = "200 lbs of hops and 50 lbs of barley";
     $pitch->save();
 }