Created
December 2, 2017 19:39
-
-
Save rbnpi/5f5e9356e627d1cbc52086efbb56456c to your computer and use it in GitHub Desktop.
Sonic Pi carol medley controlling The PiHut Christmas Tree. Both are run on a Raspberry Pi 3 with Sonic-Pi 3.0.1 Also sudo pip3 install python-osc Further details on in-thread.sonic-pi.net Video at https://youtu.be/ChHajjxiLvM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Christmas Medley synced to The PiHut Christmas tree | |
#coded by Robin Newman, December 2nd 2017 | |
use_osc_logging false | |
use_debug false | |
use_osc "127.0.0.1",5005 | |
define :flash do |n| | |
time_warp rt(0.2) do #time warp to sync leds with sound | |
osc "/xmas/pulse",n | |
end | |
end | |
puts "Shimmer Christmas tree" | |
flash(8)# turn on xmas tree shimmer | |
sleep(4) | |
flash(0) #turn off all leds | |
flash(0) #belt and braces. Sometimes a led is missed | |
use_synth :tri | |
use_bpm 160 | |
s=1.0/8 | |
dsq = 1 * s #note length definitions | |
sq = 2 * s | |
q= 4 * s | |
qd = 6 * s | |
c = 8 * s | |
cd = 12 * s | |
m = 16 * s | |
md = 24 * s | |
b = 32 * s | |
bd = 48 * s | |
ppp = 0.1 | |
pp = 0.2 | |
p = 0.3 | |
mf = 0.4 | |
f = 0.6 | |
ff = 0.8 | |
define :pl do |val,notes,durations,vol=0.8| | |
notes.zip(durations).each do |n,d| | |
play n,sustain: 0.9*d,release: 0.1*d,amp: vol | |
if val!="" | |
in_thread do | |
flash(val) | |
end | |
end | |
sleep d | |
end | |
end | |
puts "The Holly and the Ivy" | |
n1=[:ab4,:ab4,:ab4,:ab4,:f5,:eb5,:c5,:ab4,:ab4,:ab4,:ab4,:f5,:eb5,:eb5,:db5,:c5,:bb4,:ab4,:c5,:c5,:f4,:f4,:eb4,:ab4,:bb4,:c5,:db5,:c5,:bb4,:ab4,:r,:ab4] | |
d1=[c,q,q,c,c,c,cd,q,q,q,c,c,m,q,q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eb4,:eb4,:ab4,:g4,:f4,:eb4] | |
dv2=[q,q,c,q,q,m,q,q,q,q,q,q,q,q,c,c,c,q,q,c,c,q,q,c,q,q,q,q,q,q,q,q,m] | |
nv2b=[:r,:f4,:g4] | |
dv2b=[m,q,q] | |
nv3=[:c4,:db4,:eb4,:db4,:eb4,:eb4,:eb4,:db4,:c4,:ab3,:db4,:c4,:bb3,:ab3,:bb3,:ab3,:ab3,:ab3,:ab3,:ab3,:ab3,:g3,:ab3,:ab3,:ab3,:bb3,:c4,:db4,:c4] | |
dv3=[q,q,c,c,m,q,q,q,q,c,q,q,c,c,c,q,q,c,c,q,q,c,q,q,q,q,c,c,m] | |
nv4=[:ab3,:bb3,:c4,:db4,:c4,:ab3,:g3,:g3,:f3,:eb3,:db3,:c3,:bb2,:eb3,:f3,:g3,:ab3,:ab3,:c3,:bb2,:ab2,:db3,:db3,:db3,:c3,:db3,:eb3,:eb3,:eb3,:eb3,:ab2] | |
dv4=[q,q,c,c,c,c,q,q,q,q,q,q,c,c,c,c,q,q,c,q,q,q,q,c,q,q,q,q,c,c,m] | |
define :refrain do | |
in_thread do | |
pl(1,nv1,dv1) | |
end | |
in_thread do | |
pl(2,nv2,dv2) | |
end | |
in_thread do | |
pl(2,nv2b,dv2b) | |
end | |
in_thread do | |
pl(3,nv3,dv3) | |
end | |
pl(4,nv4,dv4) | |
end | |
define :verse do | |
in_thread do | |
pl(1,n1,d1) | |
end | |
in_thread do | |
pl(2,n2,d2) | |
end | |
in_thread do | |
pl(3,n3,d3) | |
end | |
pl(4,n4,d4) | |
end | |
verse | |
refrain | |
sleep 1 | |
puts "Jingle Bells!" | |
use_synth :pretty_bell | |
n1=[:eb4,:c5,:bb4,:ab4,:eb4,:c5,:bb4,:ab4,:f4,:db5,:c5,:bb4,:g4,:eb5,:d5,:eb5,:g5,:f5,:eb5,:db5,:c5,:bb4,:ab4,:g4] | |
d1=[q,q,q,q,m+q,q,q,q,m+q,q,q,q,q,q,q,q,sq,sq,sq,sq,sq,sq,sq,sq] | |
n2=[:c4,:r,:c4,:r,:db4,:r] | |
d2=[q,cd,m+q,cd,m+q,b+q] | |
n3=[:ab2,:ab3,:eb3,:ab3,:ab2,:ab3,:eb3,:ab3,:ab2,:ab3,:eb3,:ab3,:db3,:ab3,:f3,:ab3,:db3,:bb3,:f3,:bb3,:eb3,:bb3,:g3,:bb3,:eb3,:eb4,:g3,:bb3] | |
d3=[q]*4*7 | |
n4=[:ab4,:ab4,:ab4,:db4,:db4,:eb4,:eb4] | |
d4=[m]*7 | |
in_thread do | |
pl(1,n1,d1,1) | |
end | |
in_thread do | |
pl(2,n2,d2,0.8) | |
end | |
in_thread do | |
pl(3,n3,d3,0.3) | |
end | |
pl(4,n4,d4,0.3) | |
play [:ab3,:c4,:ab4],sustain: c | |
flash(7) | |
sleep m | |
nt1=[:c5,:c5,:c5,:c5,:c5,:c5,:c5,:eb5,:ab4,:bb4,:c5,:db5,:db5,:db5,:db5,:db5,:c5,:c5,:c5,:c5,:c5,:bb4,:bb4,:c5,:bb4,:eb5] | |
dt1=[q,q,c,q,q,c,q,q,qd,sq,m,q,q,qd,sq,q,q,q,sq,sq,q,q,q,q,c,c] | |
nt1.concat [:c5,:c5,:c5,:c5,:c5,:c5,:c5,:eb5,:ab4,:bb4,:c5,:db5,:db5,:db5,:db5,:db5,:c5,:c5,:c5,:c5,:eb5,:eb5,:f5,:g5,:ab5] | |
dt1.concat [q,q,c,q,q,c,q,q,qd,sq,m,q,q,qd,sq,q,q,q,sq,sq,q,q,q,q,c,c] | |
nt2=[:ab3,:g3,:f3,:eb3,:ab3,:g3,:f3,:eb3,:ab3,:g3,:f3,:eb3,:ab3,:g3,:f3,:eb3] | |
nt2.concat [:bb3,:ab3,:g3,:f3,:bb3,:ab3,:g3,:f3,:d3,:eb3,:f3,:g3,:eb3] | |
nt2.concat [:ab3,:g3,:f3,:eb3,:ab3,:g3,:f3,:eb3,:ab3,:g3,:f3,:eb3,:ab3,:g3,:f3,:eb3] | |
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,:c4,:d4,:d4] | |
dc3=[c,c,c,c,c,m,c,c,c,c,c,c,m,c,c,c,m,c,c,c,c,c,c,c,c,m,m] | |
nc4=[:r,:a3,:bb3,:d3,:c3,:d3,:eb3,:d3,:c3,:r,:f3,:g3,:bb2,:a2,:bb2,:c3,:bb2,:a2,:r,:d3,:eb3,:g3,:g3,:g3,:a3,:bb3,:eb3,:g3,:f3,:f3,:bb2,:bb2] | |
dc4=[c,c,c,c,c,c,q,q,c,c,c,c,c,c,c,q,q,c,c,c,c,c,c,c,c,c,c,c,c,c,m,m] | |
define :refrain do |vol| | |
in_thread do | |
pl(1,nc1,dc1,vol) | |
end | |
in_thread do | |
pl(2,nc2,dc2,vol) | |
end | |
in_thread do | |
pl(3,nc3,dc3,vol) | |
end | |
pl(4,nc4,dc4,vol) | |
end | |
verse | |
refrain(0.4) | |
refrain(1) | |
sleep 1 | |
puts "Now bring us some figgy pudding" | |
n1=[:eb4,:ab4,:ab4,:bb4,:ab4,:g4,:f4,:f4,:f4,:bb4,:bb4,:c5,:bb4,:ab4,:g4,:eb4,:eb4,:c5,:c5,:db5,:c5,:bb4,:ab4,:f4,:eb4,:eb4,:f4,:bb4,:g4,:ab4] | |
d1=[c,c,q,q,q,q,c,c,c,c,q,q,q,q,c,c,c,c,q,q,q,q,c,c,q,q,c,c,c,m] | |
n2=[:eb4,:c4,:c4,:c4,:c4,:c4,:db4,:db4,:db4,:d4,:d4,:d4,:d4,:d4,:eb4,:eb4,:eb4,:e4,:e4,:e4,:e4,:e4,:f4,:c4,:eb4,:eb4,:db4,:f4,:eb4,:eb4] | |
d2=[c,c,q,q,q,q,c,c,c,c,q,q,q,q,c,c,c,c,q,q,q,q,c,c,q,q,c,c,c,m] | |
n3=[:eb3,:eb3,:eb3,:eb3,:ab3,:ab3,:ab3,:ab3,:ab3,:f3,:f3,:ab3,:g3,:f3,:bb3,:g3,:g3,:g3,:g3,:g3,:c4,:c4,:c4,:ab3,:ab3,:ab3,:ab3,:db4,:db4,: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q,q,c,c,c,m] | |
define :refrain do | |
in_thread do | |
pl(1,n1c,d1c) | |
end | |
in_thread do | |
pl(2,n2c,d2c) | |
end | |
in_thread do | |
pl(3,n3c,d3c) | |
end | |
pl(4,n4c,d4c) | |
end | |
verse | |
refrain | |
verse | |
puts "Shimmer Christmas Tree" | |
flash(8) | |
sleep 10 | |
flash(0) | |
flash(0)#belt and braces as cam miss a led | |
puts "All finished. Happy Christmas" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
#OSCserver for The PiHut Christmas Tree, driven from Sonic Pi 3 | |
#written by Robin Newman | |
import argparse | |
import math | |
from gpiozero import LEDBoard | |
from gpiozero.tools import random_values | |
from time import sleep | |
from pythonosc import dispatcher | |
from pythonosc import osc_server | |
treelights=[ 18, 5, 9, 11, 21, 10, 7, 12, 6, 1,14, 3, 20, 24, 13, 15,2, 17, 16, 23,8, 22, 4, 19 ] #list of leds | |
tl1=[1,10,19,11,20,2] #6 subsets of leds | |
tl2=[6,16,22,21,7,15] | |
tl3=[9,3,17,18,12,4] | |
tl4=[14,24,8,5,13,23] | |
tl5=tl1+tl2 | |
tl6=tl3+tl4 | |
treemap={ 1:4, 7:5, 16:6, 22:7, 6:8 , 14:9, 8:10, 21:11, 15:12, 3:13, 19:14, 2:15, 9:16, 10:17, 20:18, 18:19,17:20, 4:21, 24:22, 23:23, 13: | |
24, 5:25, 12:26, 11:27 | |
} | |
leds=LEDBoard(*range(4,28), pwm=True) #set up led board | |
def labelToPin(l): | |
return treemap[l] | |
def toBoard(l): | |
return labelToPin(l)-4 | |
def xmas_handler(unused_addr, args, part): | |
if part==0: | |
for led in leds: | |
led.source_delay = 0.05 | |
led.source = led.off() | |
if part==1: | |
for i in tl1: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in tl1: | |
leds.off(toBoard(i)) | |
if part==2: | |
for i in tl2: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in tl2: | |
leds.off(toBoard(i)) | |
if part==3: | |
for i in tl3: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in tl3: | |
#sleep(0.01) | |
leds.off(toBoard(i)) | |
if part==4: | |
for i in tl4: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in tl4: | |
leds.off(toBoard(i)) | |
if part==5: | |
for i in tl5: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in tl5: | |
leds.off(toBoard(i)) | |
if part==6: | |
for i in tl6: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in tl6: | |
leds.off(toBoard(i)) | |
if part==7: | |
for i in treelights: | |
leds.on(toBoard(i)) | |
sleep(0.01) | |
for i in treelights: | |
leds.off(toBoard(i)) | |
if part==8: | |
for led in leds: | |
led.source_delay = 0.05 | |
led.source = random_values() | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--ip", | |
default="127.0.0.1", help="The ip to listen on") | |
parser.add_argument("--port", | |
type=int, default=5005, help="The port to listen on") | |
args = parser.parse_args() | |
dispatcher = dispatcher.Dispatcher() | |
dispatcher.map("/xmas/pulse",xmas_handler,"part") | |
server = osc_server.ThreadingOSCUDPServer( | |
(args.ip, args.port), dispatcher) | |
print("Serving on {}".format(server.server_address)) | |
server.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may meed to install python-osc on your Raspberry Pi
do this with:
sudo pip3 install python-osc
To use with treeserver.py (and the Christmas Tree) on a Raspberry Pi 3 (or pizero-w) Start the treeserver with
./treeserver.py --ip ip.address.of.raspberrypi
To make the treeserver.py program executable when you have downloaded it do
chmod +x treeserver.py
Run the lightsmedley.rb Sonic Pi program on Sonic Pi 3.0.1 running on a Mac or Ubuntu and change the line
use_osc "127.0.0.1",5005
to
use_osc "ip.address.of.raspberrypi",5005
Also, you can probably remove the time warp from the flash function iei change the function to
You will also need to use
run_file "path.to.lightsmedley.rb"
to run it on a Mac as it is too long for a Sonic Pi buffer on the Mac