Revised computer keyboard note input for Sonic Pi

EDIT in response to a query on youTube about the video for this project, I have added an alternative Sonic Pi program which allows you to choose the synth to be used using the number keys. use SP-KeyboardController3.rb
instead of SP-KeyboardController2.rb with the terminal program terminalcontroller2.rb
You use the number keys to select the required synth.
The code gist is here

Previously in April 2016 I published some code which enabled a computer keyboard to provide note input to Sonic Pi. At that time, Sonic Pi did not externally support OSC messages, and I opted to use a tcp/ip link, which had certain shortcomings in respect to speed, and error messages when the link was not created in the proper manner. Recently another thread has referenced this code, and that spurred me on to revisit the code and to update it to use OSC messaging, now supported for input by Sonic Pi 3.1 The result was an easier interface to set up, and one which turned out to be much more responsive.

The link above goes to an article listing the code, and also shows a truncated video of teh system in action. A fuller video is available on you tube here

7 Likes

Thanks for this, just what I was looking for

How did I I miss this when it was posted the first time???!!!

Time to break out the Makey Makey!

I got this running to the point that Sonic Pi is receive the OSC messages from the terminal. However, I am not hearing any sound.

I notice that the incoming OSC messages in the cue log say “osc:127.0.0.1:65396/key” but in the youtube video the messages are just coming in as “osc/key” as is written in the Sonic Pi code. Could this be affecting Sonic PI receiving the message? When I stop the terminal code running and then restart it, that 5 digit number changes in the OSC message.

I’m also using V3.2.0 instead of 3.1 like in the video.

Hey @mrbombmusic,

The latest versions of Sonic Pi (v3.2+) now include the full host/port details in the address as you have seen.
As such, the standard way of handling this is to include a wildcard * in the sync command, to easily handle the changing port etc. So, for example, you could use this:

sync "/osc*/key"
1 Like

Thanks @ethancrawford That did it!

1 Like