Hi Sawyer,
That’s a great question. As the API stands right now, setSpeaker() is the only Speaker Block action function that is exposed in our Cubelets Code API.
There are certainly lower-level functions at work here. If you’re interested in the gritty details, we’re doing something called PWM, or Pulse-Width Modulation. (http://en.wikipedia.org/wiki/Pulse-width_modulation) We use a set of timers and counters to control the state of the speaker output. By switching states very quickly (and “smoothing” that signal with a capacitor) we can generate tones. The code to do this is very complex.
The cool thing about Cubelets is that they are meant to be simple. When you write programs for Cubelets all of that complexity is abstracted away and you’re left with clean, easy-to-use interfaces.
Modular Robotics is hosting a Hackathon next week, and this would be a great project. Decoupling the pitch, note frequency and note duration of the tones is a bit tricky (we only have so many timers!), but it’s definitely possible. We’ll have all of our engineers there to help hack, and since they know how all the bits and bytes work, you might be able to implement some fun new functionality. Stay tuned for details, we’ll be posting about the event on the blog very soon.