Skip to content

Instantly share code, notes, and snippets.

@dirkk0

dirkk0/sonic-pi-osc.py

Last active Apr 23, 2018
Embed
What would you like to do?
# do this first:
# pip install pyosc
import OSC
import time
def sendCmd(cmd,par = None):
oscmsg = OSC.OSCMessage()
oscmsg.append('MY_PYTHON_GUI')
oscmsg.setAddress(cmd)
if par:
oscmsg.append(par)
c.send(oscmsg)
c = OSC.OSCClient()
c.connect(('127.0.0.1', 4557)) # connect to SuperCollider
#change these:
MYPATH = "/Users/dirk/Dropbox/projects/pi-osc/"
# currentSong = MYSONG + ".txt"
# song = open( currentSong, 'r').read()
# MYSONG = "cloudbeat"
song = """
# music by Pit Noack
# http://www.maschinennah.de/sonic-pi-codeschnipsel-compus-loop/
use_bpm 80
live_loop :compus do
with_fx :ixi_techno, phase: [0.125, 0.25, 0.5, 1, 2].choose do
sample :loop_compus, beat_stretch: (ring 4, 8)[tick], amp: 4
sleep (ring 4, 8)[look]
end
end
"""
sendCmd("/stop-all-jobs")
sendCmd("/start-recording")
sendCmd("/run-code", song)
# the recording time should be calculated
time.sleep(3)
sendCmd("/stop-all-jobs")
# wait for reverb tail, etc
time.sleep(1)
sendCmd("/stop-recording")
time.sleep(0.1)
# sendCmd("/save-recording", MYPATH + MYSONG + ".wav")
sendCmd("/save-recording", MYPATH + "song.wav")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.