function createGenome($scale, $octaves = 1, $length = 16, $phraseLength = 8) { //global $scale; $genome = array(); $degrees = array(1,4,5); for($i = 0; $i < $length; $i++) { //$genome[] = getNoteFromDegrees($scale, $octaves, $degrees); //$genome[$i] = rand(1,16); if (!($i % $phraseLength)) //if beginning of phrase { //get a nice note from the triad $genome[] = getNoteFromTriad($scale, $octaves); //getNoteOnScale($scale); } elseif (!(($i+($phraseLength+1)) % $phraseLength)) { //if this is the last note of the phrase $genome[] = getNoteOnNativeChord($scale, $octaves, 1); } else { //get any note on scale $genome[] = getNoteOnScale($scale, $octaves); } } var_dump($genome); return $genome; }
function createGenome($scale, $octaves = 1, $length = 16, $phraseLength = 8) { //eval(globals()); // get all the probability objects global $pFirstPhraseNoteOnTriad, $pNoteOnScale, $pLastPhraseNoteOnTriad, $pLastNoteOnTriad, $pLastNoteOnTonic; $genome = array(); for($i = 0; $i < $length; $i++) { //$genome[$i] = rand(1,16); if (!($i % $phraseLength)) //if beginning of phrase { //get a nice note from the triad if ($pFirstPhraseNoteOnTriad->get()) $genome[] = getNoteFromTriad($scale, $octaves); elseif ($pNoteOnScale->get()) $genome[] = getNoteOnScale($scale, $octaves); else $genome[] = getNoteRandom($scale, $octaves); } elseif (!(($i+($phraseLength+1)) % $phraseLength)) { //if this is the last note of the phrase //get a nice note from 'I' if ($pLastPhraseNoteOnTriad->get()) $genome[] = getNoteFromTriad($scale, $octaves); elseif ($pNoteOnScale->get()) $genome[] = getNoteOnScale($scale, $octaves); else $genome[] = getNoteRandom($scale, $octaves); } elseif ($i == ($length - 1)) { //if this is the last note of the melody if ($pLastNoteOnTriad->get()) { // need to change this to an actual tonic, not just a note from the tonic chord (or add another level) if ($pLastNoteOnTonic->get()) $genome[] = getNoteOnNativeChord($scale, $octaves, 1); else $genome[] = getNoteFromTriad($scale, $octaves); } elseif ($pNoteOnScale->get()) $genome[] = getNoteOnScale($scale, $octaves); else $genome[] = getNoteRandom($scale, $octaves); } else { //get any note on scale if ($pNoteOnScale->get()) $genome[] = getNoteOnScale($scale, $octaves); else $genome[] = getNoteRandom($scale, $octaves); //echo getNoteOnScale($scale, $octaves).' - '; } } //var_dump($genome); return $genome; }