Example #1
0
function initPopulation()
{
	$population = array();
	for($i = 0; $i < 4; $i++) {
		$population[$i] = createGenome();
	}
	return $population;
}
Example #2
0
        }
        return $pitchesAllowed[array_rand($pitchesAllowed)];
}

function createGenome()
{
	global $scale;
	$genome = array();
	for($i = 0; $i < 16; $i++) {
		//$genome[$i] = rand(1,16);
		$genome[] = getNoteOnScale($scale['major']);
	}
	return $genome;
}

$genome = array(createGenome(), createGenome());
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Genetic Music Evolution Interface</title>
<link rel="stylesheet" type="text/css" href="css/style2.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script> 
window.onload = function() {
	MIDI.connect();
	//MIDI.start();
	notesWorking = notes.slice();
};
 
Example #3
0
<?php

// probability of the following is higher:
// - that the note after is close in pitch to the note before
// - that the note is in scale, rather than being sharp or flat
// - that the beat notes are on triad

$scale['major']['notes'] = array(0,2,4,5,7,9,11);
$scale['major']['length'] = 12;
$scale['major']['triad'] = array(1,4,5);
//$scale['major']['I'] = array(1,3,5)

$genome = array(createGenome($scale['major'], 2), createGenome($scale['major']));

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);
		}
		
Example #4
0
<?php

require_once (__DIR__.'/functions.php');
ini_set(display_errors, 1);
$genome = array(createGenome($scales['major'], 2, 16, 8), createGenome($scales['major']));

$files = array();
foreach ($genome as $k => $pitches)
{
	//echo 'hello<br/>';
	$files[$k] = generateOgg($pitches);
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Genetic Music Evolution Interface</title>
<link rel="stylesheet" type="text/css" href="css/style2.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script> 
window.onload = function() {
	MIDI.connect();
};
 
window.onbeforeunload = function() { 
	if(MIDIPlugin) { 
		MIDIPlugin.closePlugin();
	}
};