Monday, December 8, 2014

Scratch Loop-Based Sequencer

I received a grant from Northwest Missouri State University to purchase Makey-Makey interfaces for my classroom.  The plan for the grant is to have a group of students design their own electronic instruments from both the hardware and the software sides.

Makey-Makey is this great interface invented my Eric Rosenbaum (@ericrosenbizzle) and Jay Silver (@wakeupsilver) that allows you to connect a computer the world.  It takes electrical inputs and translates them into key presses and mouse clicks, so your computer thinks it's talking with a normal keyboard, but really it could be a banana.  The Makey will make it possible to interface with any material that conducts electricity. Scratch will take care of the software side of the project.

Until recently, I had planned on the kids programming a simple Scratch project to respond to a Makey's input.  Something like this:


Then I thought:

"Wouldn't it be cool if we could trigger audio samples in Scratch just like it happens in Ableton?"

In Ableton Live, there is this really cool feature in which you can trigger an audio clip to play, and the program will wait until the downbeat of the next measure to play the clip.  It's really handy when you are launching multiple clips and you don't need to hit it right on the downbeat.

After kicking around some ideas, I designed a small Scratch project to trigger audio on the downbeat of a measure.  Assuming all the audio samples are in the same tempo, they should layer nicely together.  Essentially, the the program keeps track of the beat,waits for the user to press the spacebar, and then triggers the loop on the next downbeat.

Here is the script I came up with:



The next challenge will be to modify this script to trigger multiple audio samples.  I think I could do this my making a sprite for each audio sample and changing this script to play the audio I want.  Hopefully, the kids can use this to create some great instruments.