Marc Wilhite's Drum Machine is based on a Euclidean algorithm, and has a corresponding visualizer, so that users can see their beats in action.
“I was studying for a Master’s degree in music tech at NYU, and I discovered papers about the algorithm,” Wilhite describes. “I thought it would be great to build an app from the ground up.”
The app uses a modified version of an algorithm created by Euclid for finding the greatest common divisor between two numbers. The Euclidean Drum Machine uses this basic principle to evenly slot beats within a cycle of a set length. Wilhite explains the specifics in a blog post:
“Essentially it generates a binary sequence where a number of pulses (beats) is evenly spaced within a certain number of steps. The steps without a pulse are silent. For example if one were to place 4 pulses into 7 steps the result would be the sequence 1-0-1-0-1-0-1 and from there the sequence repeats.”
The user simply chooses the length of the cycle and the number of beats within that cycle for each available sound (or the user can choose to not use that sound), and the application does the rest. This simple process allows anyone to quickly create a fun beat, with a practically endless array of possibilities. The Drum Machine resets every 32 beats (the user can change this number) so that the sounds continue to line up as the user intended them to.
“Web Audio API has its own clock that’s separate from the browser clock,” Wilhite explains. “The audio clocks are microseconds accurate. You can use them to schedule events [such as beats] on that clocking system. That’s how you get the audio to sound really really tight.”
Time precision is crucial for an app like this, because a delay of half a second would radically alter the sound.
Whether or not it factors into his career as a Software Engineer going forward, Wilhite will continue to use his programming skills to bolster his hobby in electronic music and music tech.
Want to learn to convert your interests into applications? Apply to Hack Reactor, onsite or online today!