public function indexAction() { if ($this->getRequest()->isPost() && $this->getRequest()->getParam('name')) { $species = new Nandu_Species(); $species->name = strip_tags($this->getRequest()->getParam('name')); $species->tempo = $this->getRequest()->getParam('tempo'); $species->instrument = $this->getRequest()->getParam('instrument'); $species->reference_note = $this->getRequest()->getParam('reference_note'); $species->scale_type = $this->getRequest()->getParam('scale_type'); $species->save(); $this->_manager->initPopulation($species); $this->_helper->redirector->gotoRoute(array('speciesId' => $species->id), 'evolve', true); } //$species = $this->_manager->getSpecies(1); //$this->view->species = $species; $this->view->allSpecies = $this->_manager->getSpeciesTable()->findAll();; $this->view->evolving = false; }
public function initPopulation(Nandu_Species $species = null, $count = 8) { if (null == $species) { $species = new Nandu_Species(); $species->save(); } $music = new Nandu_Music_Theory(); for($i = 0; $i < $count; $i++) { $melody = new Nandu_Melody(); $melody->species_id = $species->id; $melody->save(); $notes = $music->melodyGen(Nandu_Music_MusicScales::Major(), 2, 8, 16); $melody->setNotesFromArray($notes); } return $species; }