The Music Computer One (MUC-I) was a music composing and playing machine I designed and built in my Junior year in high school, in 1965. I’ve recently revised the design using an Arduino Uno, which I will describe fully later in this post. But the history really begins with the GENIAC, what was said to be the first personal, home computer which came out in 1955. https://en.wikipedia.org/wiki/Geniac
History — GENIAC Music Composer
The GENIAC performed combinatorial logic using six programmable rotary switches for input and row of ten small lightbulbs for output. It was lots of fun for a young boy (I got mine in 1958 at age 9), but most of the programs were quite simple. Even though “GEN” stood for Genius, it wasn’t much of one!
However there was one program that stood out, the music composer. This one their prize for the best design in a competition the manufacturer had in 1956. The designer, John F. Sowa https://en.wikipedia.org/wiki/John_F._Sowa, was 16 years old when he submitted his design. The combinatorial logic implemented a state machine for the notes to be played. Although not explicitly described as a state machine, the lights held the state (the note to play) and the user had to set a switch representing this value as the state machine’s storage element, and flip a coin (randomizer) for the machine to calculate the next note to play.
While the designer made a table of probabilities for the next note for any current note for each beat in the measure, this had to be vastly simplified to run on the GENIAC, with only the two most common next notes being available and selected via a coin toss.
The machine could select from five notes, C through G, and “hold the previous note” and would compose four beats/notes per measure. For instance, if the first note were D and the solid line path were followed, the first measure would be D G G, with the last G held for two beats.

The paper describing the Machine to Compose Music can be downloaded at https://almy.us/files/Geniac_Machine-Compose-Music.pdf.
History — The MUC-I
My design in 1965, the MUC-I, used diode logic to calculate the next state, had what I called an unstable vibrator to generate the random selection, a drum switch made mostly of Erector Set parts to keep time, and an organ circuit to generate the music that would play through a speaker.
Because the state machine was 100% electronic, it would run without human intervention. And because of the organ circuit it would be able to play the music it composed in “real time”.
The specifications were:

The cost would be over $700 in today’s dollars. Integrated circuits being way too expensive at the time, diode logic was used along with transistor amplifiers to restore the signal levels and provide an inverter circuit, as well as the few flip-flops needed for the state registers. Because all the semiconductors were surplus (1N34A diodes and CK722 transistors) I had to hand test and sort for gain and leakage. A Vector Board held the components that were point-to-point wired. This was tedious, and I said it took about 200 hours of work.
The MUC – II, 60 years later
I thought about redesigning the computer over the years, and finally did so. It is now a program that runs in an Arduino Uno R3, although any Arduino board will do, and I didn’t use anything but standard Arduino library functions. A push button is connected to the board to provide a push-to-start/push-to-stop control, and a Keyestudio “passive speaker” is attached for sound output.
The MUC-I was able to increase the volume of the first beat in a measure for emphasis. Without adding some more circuitry (which would probably have doubled my total design time), I settled on lighting the on-board LED with the first beat. This took less than a minute to implement!
The Arduino “sketch” file can be downloaded at https://almy.us/files/MusicComputer.zip. But it is short enough that I will explain it all in this blog. The description here reorganizes the program by function performed to make it easier to understand.
First we define some constants. beatTime is the time in milliseconds of a single beat. I went with 88 beats per minute. The start/stop pushbutton will connect from pin 2 to ground, and the buzzer will connect to pin 4. The notes array contains the frequencies of the notes C, D, E, F, and G.
const long beatTime = 1000L * 60 / 88; // 88 BPM
const int BUTTONPIN = 2;
const int BUZZERPIN = 4;
const uint16_t notes[5] = { 523, 587, 659, 698, 784 };
The probability table that John Sowa created was easily converted into a three dimensional array. There were some errors in the table, all the next note probabilities for each current note and beat must add to 100%, but that wasn’t always the case, so I had to make some adjustments. Note that in the AVR based Arduino boards, the data is stored in RAM (copied at boot from ROM) making it wasteful of space unless extra steps are taken. Because there was sufficient RAM for this project, I left it as is.
// indices are beat current next,
// where current and next are C D E F G and O (hold)
const uint8_t table[][6][6] = {
{ { 32, 14, 7, 0, 4, 41 }, /* Example, first beat, C played,
next note is ... */
{ 5, 3, 32, 14, 27, 19 },
{ 22, 22, 9, 19, 3, 25 },
{ 0, 50, 50, 0, 0, 0 },
{ 0, 2, 21, 16, 0, 61 },
{ 0, 0, 0, 0, 0, 0 } },
{ /* Second Beat */
{ 11, 89, 0, 0, 0, 0 },
{ 43, 7, 29, 14, 7, 0 },
{ 9, 22, 0, 61, 8, 0 },
{ 0, 0, 57, 0, 43, 0 },
{ 17, 0, 25, 0, 42, 17 },
{ 15, 13, 15, 5, 10, 42 } },
{ /* Third Beat */
{ 0, 11, 22, 0, 0, 67 },
{ 10, 10, 24, 14, 10, 32 },
{ 80, 0, 0, 7, 0, 13 },
{ 0, 56, 17, 0, 17, 10 },
{ 0, 0, 33, 22, 0, 45 },
{ 6, 6, 12, 12, 6, 58 } },
{ /* Fourth Beat */
{ 0, 94, 6, 0, 0, 0 },
{ 9, 0, 61, 0, 30, 0 },
{ 25, 38, 4, 8, 25, 0 },
{ 12, 0, 63, 0, 25, 0 },
{ 0, 15, 80, 0, 5, 0 },
{ 21, 33, 21, 5, 21, 0 } }
};
The procedure for starting a new song wasn’t accurately described in the original GENIAC design, so I created an array, startNote, to pick the first note. We will also need a few variables.
const uint8_t startNote[6] = { 25, 23, 29, 7, 16, 0 };
const uint8_t *choiceRow; // Table row to use
uint8_t currentBeat, currentNote; // essentially the current state
unsigned long lastTime, thisTime; // measuring the time between beats
bool lastButton, thisButton; // debouncing the start/stop button
The setup function seeds the random number generator, but it gets reseeded later. It also configures the pins. Note that the pushbutton uses the internal pullup and is active low.
void setup() {
randomSeed(1);
pinMode(BUTTONPIN, INPUT_PULLUP);
pinMode(BUZZERPIN, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
Several things need to happen in the loop function, so I’m separating them out here for clarity. The first thing is to handle the start/stop button. We loop until the button is pressed, calling the random number generator to randomize the seed. Then we play until the button is pressed again. At that point we turn off the tone generator, silencing the “organ.”
void loop() {
// Wait for start to be signaled
do {
random(100); // advance the random number generator
delay(10); // Yeah, I know.
lastButton = thisButton;
thisButton = !digitalRead(BUTTONPIN); // Sample the button
} while (!(thisButton && !lastButton));
/* CODE TO SET UP FOR PLAYING WILL GO HERE */
//while stop is not being signaled (button press), play
do {
/* VARIABLES FOR PLAYING WILL BE DECLARED HERE */
delay(10); // Yeah, I know
lastButton = thisButton;
thisButton = !digitalRead(BUTTONPIN); // Sample the button
// CODE TO DO THE PLAYING WILL GO HERE
} while (!(thisButton && !lastButton));
noTone(BUZZERPIN); // Turn off the tone generator
}
The delay is to slow the button sampling to make a low pass filter that rejects switch contact bounce.
The CODE TO SET UP FOR PLAYING makes it time for a new beat, and the next note to be played, advancing the state machine. The initial state forces the startNote array to be used for the first note.
thisTime = millis();
lastTime = thisTime - beatTime; // Force a new beat,
// so start playing without delay
currentBeat = 3; // Start at last beat of a measure to calculate
// the note of the first beat
currentNote = 6; // Out of range value signals starting note
The VARIABLES FOR PLAYING are:
uint8_t nextNote; // what we want to calculate
uint8_t accum;
uint8_t randnum;
The CODE FOR PLAYING is:
thisTime = millis();
// Note that if currentBeat is 3, the next beat
// will be the first beat of the measure.
// We calculate the tone for the next beat
if (thisTime - lastTime >= beatTime) { // Time for a new note
digitalWrite(LED_BUILTIN, currentBeat == 3); // Emphasis
// Figure out the next note, first get the correct table row
if (currentNote == 6) { // First note of song
choiceRow = startNote;
} else {
choiceRow = table[currentBeat][currentNote];
}
randnum = random(100); // Find the next note from the table row
for (nextNote = 0, accum = 0; nextNote < 6; nextNote++) {
accum += choiceRow[nextNote];
if (accum >= randnum) break;
}
if (nextNote == 6) nextNote = 5; // Should never happen
/* output the new note, unless holdover (value 5)*/
if (nextNote < 5) {
noTone(BUZZERPIN); // Need a small rest between notes
delay(40);
tone(BUZZERPIN, notes[nextNote]);
}
// Advance the state machine
lastTime = thisTime;
currentNote = nextNote;
currentBeat = (currentBeat + 1) % 4;
The order of the indices in the table is critical because I dereference the beat and current note to get a single row of probabilities for the next note. This I put in choiceRow. The for loop finds the correct note based on the random number set in randnum. If a new note is to be played, the tone is turned of for 40ms before playing to give a more natural sound. This is particularly important if the same note is to be played, otherwise the first note is just held over.