I am currently singing this piece with my local choir, and decided as a challenge to see what it would be like to arrange it for Sonic Pi. It has a good range of orchestral instruments not to mention a four part choir, with 17 different channels, and I decided to use the free VMPK (Virtual Midi Piano) project to play these. I wanted to automate the set up of the VMPK and used the midi_pc command to select the instrument for each channel. I also used the midi_cc 10 control to set the pan position of each instrument and adjusted the balance of the instruments by setting different velocity settings for each channel, using the velocity: parameter for Sonic PI’s midi command. Overall volume level was set using the midi_cc 11 control (expression). By sending the output of this (range 0->127) to every channel I could implement crescendos and decrescendos in the piece. The overall result comes out quite well, and I found it a good exercise for exploring how to control midi output from Sonic Pi, and then use the live_audio input command to retrieve the resulting audio (which I fed back using Amoeba’s Loopback utility) and further process that with some reverb.
You can hear the result on SoundCloud:
The code is available on my gist site