work log
Michael Karpelson, Julian Chang, ECE 476 Spring 2004

System Performance

The project performed to our satisfaction. An impressive level of functionality was attained in almost every objective category. Some photos of the final system are below.

The serial interface is fully functional and can be used to program up to five melodies of up to 200 notes into Mega32’s 1kB EEPROM. The system is able to accurately play back the melodies. The playback speed is adjustable, permitting the shortest tone (one eighth) to be set anywhere from 0.5s to 0.075s (the last value intended mostly to prove that the device could best any human in xylophone playing speed). The system can reproduce 13 notes, and more notably, chords. A human xylophone player with twin mallets would be unable to reproduce a three-note chord… unless, of course, said character was the fastest xylophone player in the West.

The device produces good sound quality despite the metal solenoid cores serving as impacters (a xylophone is traditionally played with a rubber or wood mallet, and coating the core tips in rubber cement dampened the impact sound entirely). Slight mechanical adjustment of individual solenoids appears to be the quickest path to improving sound quality.

The pitch detection hardware failed several times on account of a polarized capacitor breakage. At the time of this writing, replacing it with a ceramic capacitor appeared to solve the problem. The mechanism is accurate over 95% of the time for a single note (the inaccuracies are mostly to be found when detecting lower frequency notes, where higher harmonics disrupt the zero crossing algorithm). However, the mechanism is not very robust, since the xylophone keys must be hit with relatively precise strength and sharpness (bashing on the keys is likely to cause an erroneous detection). Only one note may be hit at a time, and hitting several keys in reasonably rapid succession will likely prevent the correct detection of all of them. A better microphone would greatly improve the system, as would moving to a more advanced algorithm based on Fast Fourier Transforms (FFT) rather than zero-crossing or peak detection.

Nonetheless, the mechanism is accurate enough to detect the first few notes of a stored melody and play it back (naturally, since only five notes are collected, the melodies must differ sufficiently in their first five notes to be differentiated correctly). The mechanism is also useful to provide the starting point for random melody generation. We feel this is an adequate proof of concept for the pitch detection mechanism.

The random melody algorithm itself is functional and appears to behave in accordance with the rules dictated by the probability matrices. Evaluating the quality of music produced is highly subjective; it appears to us that an interesting and not particularly dissonant tune surfaces every few iterations of the algorithm. In the future, it would be interesting to consider a genetic algorithm with human input on top of the Markov chain algorithm to try and refine the music generation rules. It would also be interesting to receive continuous input from someone knowledgeable in music, rather than, say, random acquaintances who have five minutes to spare before they need to go work on their physics problem set.


The usability of the system is somewhat of an issue. While playback is relatively simple, programming the system can be a pain. Faced with a RAM shortage, we restricted the serial interface to accept one note at a time only, making the programming of long melodies rather tedious. This problem could be alleviated by having the input buffer share some of the large arrays normally used by the pitch detection algorithm, which is not expected to be in use during programming. The custom note encoding is probably very easy to learn for someone with no musical experience, since notes and durations are represented by letters, but would be an exercise in unpleasantness to someone used to sheet music. A graphical user interface should be considered in future versions of the device. Finally, it would be desirable to use two buttons for playback speed adjustment (up/down) instead of the current single button which wraps around the speed range.

Safety and Interference

The device uses somewhat high currents (one solenoid draws ~0.5A), and safety can be a concern. All the solenoid leads are isolated and contained within the wood frame, while the solderboard itself has no dangerous protruding leads. Although situated outside the frame for display and adjustment purposes, it would also normally be enclosed and isolated from the user. However, responsible conduct around the device, as with any electrical device, is the best way to guarantee user safety.

The system is not expected to produce harmful interference.