Revised computer keyboard note input for Sonic Pi

A new version of code to enable you to use your computer keyboard for note input in realtime for  Sonic Pi.

Full details on this page, including links to a video and to the code required.

Advertisements

Sonic Pi controls Spirograph – version 2

I have made some changes to version 1 which makes the program more flexible. The main change is that it is now possible to re-run the Sonic Pi program (now named spiroAuto.rb) which will abort the drawing currently in progress and start drawing a new design. This make it possible to change to a new drawing without having to wait for ` drawing to finish.
Also, instead of just having a few pre-chosen drawing parameters in the program, I now generate the parameters at random (with certain constraints), which means that you can continuously call up new designs. Thirdly I have added an option which changes the plot colour of a drawing to a random value at periodic intervals while it is drawing. This is set to a fairly low probability by line 34 in the spiroAuto.rb program

 p+=[["purple","red","yellow","green","blue"].choose,["saw","tri","piano"].choose,
      ["true","false","false","false"].choose]

To adjust the probability simply change the section

["true","false","false","false"].choose

to give change the ratio of “true” to “false”. e.g. changing the overall line to

 p+=[["purple","red","yellow","green","blue"].choose,["saw","tri","piano"].choose,
      ["true","false"].choose]

would give equal probability to random colour changes or fixed colour drawing.(random when true, fixed when false). Similarly you could give a larger selection of fixed colours in the first part of the list if you wish.

To make the program easier to install, I have put the code into a repository in github at
https://github.com/rbnpi/SpirographWithSonicPi/
From there you can download the repository to your computer, and set it up ready to go following the instructions in the READMEforSonicPi.md file

A video of the new program in action can be found here

Sonic Pi 3 drives the LEDs on pi-topPULSE module

The new pi-topPULSE module contains a 7×7 LED array, a microphone and an audio amplifier. The latter can be used by Sonic Pi as its output audio path, and Sonic PI version 3 can also be used to control the LEDs on the PULSE module using OSC messages, which can be received by a python program which decodes them, and uses the commands to control the LEDs.

I have written a full article giving a detailed explanation of how this is done, which you can read here.

There is also a link in the article to the code which is used, and to a video of the program in action on youtube.

Sonic Pi 3 Synth Driver

Following on from the PS3 project, I used some of the same code, and expanded and modified it to produce a project I entitled Sonic Pi 3 Synth Driver. This incorporates the “Long Note” synth introduced in the PS3 project, which produces a continuously sounding synth note, which can have various characteristics such as synth, pitch, cutoff, volume and reverb altered. The project drives Sonic Pi3 using OSC messages from TouchOSC running on an iPad. Full details are in this article which includes links to a video and to the code used.
TouchOSC is available on the App store, and is also available for Android.

Control Sonic Pi 3 with a PS3 wireless controller

Recently I published a video on YouTube showing Sonic Pi 3 being controlled by a PS3 wireless games controller. This post contains a link to the software required to do this, should you wish to try it out.

Two files are included. The first, ps3.py should be run on a Raspberry Pi, into which the wireless dongle of the PS3 controller is plugged. Two pieces of supporting software need to be installed first.

sudo apt-get update
sudo apt-install joystick
sudo pip3 install python-osc

The second software file is a Sonic Pi 3 script, which should be loaded into a buffer on Sonic Pi 3, which can be running either on the Raspberry Pi, or on an external computer.

NB if you want to run Sonic Pi 3 on the Raspberry Pi you need to wait for the Raspbian Stretch to be released, or upgrade a new copy of Rasbian Jessie to Stretch yourself. The released version of Sonic Pi 3 will NOT run on Raspbian Jessie
This is specified on the command line when running the ps3.py script by adding an argument –sp xxx.xxx.xxx.xxx where xxx.xxx.xxx.xxx is the IP address of the computer running Sonic Pi.
In addition, on the IO preferences in Sonic Pi you must make sure that the option to receive remote OSC messages is ticked

To run the ps3.py file, make sure it is executable by typing:
chmod 755 ps3.py
then type
./ps3.py     or        ./ps3.py –sp xxx.xxx.xxx.xxx        Putting in the appropriate IP address of your remote Sonic Pi 3 computer.
As an alternative you can type python3 ps3.py
or         python3 ps3.py –sp xxx.xxx.xxx.xxx

The software can be downloaded from here