$arr)
{
$total += 1/$arr[3];
$newvalue1 .= $arr[0]." ".$arr[1]." ".$arr[2]." ".$arr[3];
//echo $i." ".$total."
";
if ($total >= $measureval)
{
$total -= $measureval;
//add a bar and a measure number to the display
$measure++;
$newvalue1 .= "-------$measure-------\n";
}
}
//exit;
$measure = 1;
$total = 0;
foreach ($c2_data as $i => $arr)
{
$total += 1/$arr[3];
$newvalue2 .= $arr[0]." ".$arr[1]." ".$arr[2]." ".$arr[3];
if ($total >= $measureval)
{
$total -= $measureval;
//add a bar and a measure number to the display
$measure++;
$newvalue2 .= "-------$measure-------\n";
}
}
}
$dir = opendir("midi");
$note_array = array("square"=>array(),"lead"=>array(),"saw"=>array(),"bass"=>array());
while (($file = readdir($dir)) != null)
{
//format: distortion_atari note index_note name_octave_freq_error_MIDI note index_pitch bend left bits_pitch bend right bits
if (strpos($file,".ogg"))
{
$info = explode("_",$file);
$info[2] = str_replace("+","#",$info[2]);
$info[count($info)-1] = substr($info[count($info)-1],0,strpos($info[count($info)-1],".ogg"));
if (!isset($note_array[$info[0]][$info[1]]))
$note_array[$info[0]][$info[1]] = array();
array_push($note_array[$info[0]][$info[1]],$file);
for ($i = 2; $i < count($info); $i++)
array_push($note_array[$info[0]][$info[1]],$info[$i]);
$red = str_pad(dechex(100+2*$note_array[$info[0]][$info[1]][4]),2,"0",STR_PAD_LEFT);
$green = str_pad(dechex(150),2,"0",STR_PAD_LEFT);
$blue = str_pad(dechex(100-2*$note_array[$info[0]][$info[1]][4]),2,"0",STR_PAD_LEFT);
$color = $red.$green.$blue;
$note_array[$info[0]][$info[1]][8] = '#' . $color;
}
}
require ("createmidi.php");
?>
Click anywhere inside it.Who? | What? | When? | Where? | Why?
Tommy Montgomery | Atari 2600 Music Composing Utility | January, 2007 | On the internet | Why notHow?
An unholy union of PHP, Javascript and the HTML DOM. The MIDI files used to play the sounds were created using Java because I didn't know PHP could write to binary files at the time. 15 years later in April 2022 I converted them to OGG.Why is this useful?
Writing music for the 2600 is difficult, because of the variations in pitch. The frequencies don't conform to any sort of useful or intelligible scale, so we have to approximate to get what we want. This utility makes that process easier, by supplying a visual and aural cue of the (musical) limitations of the 2600.Why are there four keyboards?
The four keyboards correspond to the four "melodic" distortions (meaning the ones that don't sound like noise). They are labeled for your convenience. The grayed keys are notes whose frequencies are unavailable in that distortion. Middle C is outlined in red.What about the other distortions?
The primary reason I didn't include them is because there aren't any MIDI voices that can approximate them. The secondary reason is because this utility is for making music, not noise, which is generally what the other distortions are used for; making noise is generally much easier and doesn't need a fancy tool.How do I write songs?
The Atari 2600 has two sound channels available (or so I've heard). The two textareas at the bottom of the screen correspond to each channel. They are labeled for your convenience. When you click on a key, you will hear its sound and the data will be written to the channel's textarea (that data can also be typed in manually). To listen to your song, press "Listen." The best way to learn how to use this is to experiment. Use the "Format" and "Listen" buttons liberally.What does "Format" do?
Pressing this button formats each channel's data into something more comprehensible. It groups all the data into measures (this is dependent on the time signature).How do I change the note value/channel/tempo/time signature?
Find the labels and/or pictures and click something until it does what you want.How do I insert a rest in my song?
See above.What does "Dotted" do?
Checking this elongates the note by 50%.What do all the numbers in the textareas mean?
I know stuff about some stuff. How do I look at this stuff?
- The first thing is the note name and octave (e.g.
E3
).- The second thing is the distortion (
0
= square,1
= lead,2
= saw,3
= bass. Note that these do not correspond to the distortion numbers in the text file linked to below).- The third thing is the pitch index, mentioned below.
- The last thing is the note value (
1
= whole note,2
= half note,4
= quarter note, etc.).
Right click on a key to view info about that note (doesn't work in Opera).What does "Exchange" mean?Pitch
is the Atari 2600 pitch index (see here for details);Freq
is the note's frequency;Error
is the distance in cents from "perfect" pitch. If you don't know what that means, the closer to 0 is better. Unless you're doing something weird and/or painful, you'll want all the notes in your song to have approximately the same error.
Some notes have more than one frequency that approximates that note. Clicking on "Exchange" toggles between the two. Such notes are generally in the lower half of the keyboard.What does "Color Me Blind" do?
Checking this color codes all the keys. Keys with the same color are in tune with each other. Keys that are different colors probably shouldn't be used in succession.Dude, seriously. Using the mouse is a bother. Are there any keyboard shortcuts?
Glad you asked. If you hover the cursor over various objects on the page, you'll notice a single character in square brackets in the tooltip for some of them (try one of the note value buttons, for example). Check here to see your access key combination (generallyALT
orALT+SHIFT
).