Using Arduino with Sporth

2016-10-07

Today I had some initial success getting an Arduino to talk to Sporth over serial.

Motiviations

One of the courses I am enrolled in at Stanford this quarter is MUSIC 250a: Physical Interaction Design for Music, taught by the wonderful Sasha Leitman. It is a course whose curriculum revolves around Arduino and Max/MSP. While Arduino has open source software that allows it to be run on Linux, Max/MSP is neither open source or able to run on Linux. It was this complication that was enough motivation to build some alternative tooling using Sporth and C.

How does one read serial?

On Linux, reading from peripherals is typically a straightforwad thing, since everything is a just file on Linux. With serial, a few complications arise: baud rate is something that needs to be specified. So how does one do that?

Fortunately, serial read/write is implemented in Csound. Using the Csound C code , I was able to build a plugin for Sporth to read.

I have built a github repository for my arduino sporth plugin so far. Eventually it will become a flexible serial messaging system for Sporth. For now, the code is a little sporadic, as I am using it on-the-fly to complete assignments for class.

Some examples

I have posted some not-too-serious videos on twitter:

A simple button (Rihanna cover)

And here's a Rihanna cover. pic.twitter.com/1rfCeE13uu

— Paul Batchelor (@yesthisispaul) October 7, 2016

Another button (U2 Cover)

The Max lab is where the streets have no name. #sporth #arduino #ccrma pic.twitter.com/YfJ1QwXMfM

— Paul Batchelor (@yesthisispaul) October 7, 2016

2 Knobs

@nickarner I got me some knobs in sporth now pic.twitter.com/7CohKuY3Ds

— Paul Batchelor (@yesthisispaul) October 7, 2016