Skip to content

Instantly share code, notes, and snippets.

@rbnpi rbnpi/BobbieShaftoe.rb
Last active Jun 29, 2018

Embed
What would you like to do?
A Sonic Pi Glockenspiel

These files contain software to run a solenoid operated glockenspeil controlled by Sonic Pi running on a Raspberry Pi 3. It is also possible to control it from a remote instance of Sonic Pi 3 running on a separate computer. The first pice of software is a python script which controls the GPIO pins connected to the solenoid circuitry using received OSC messages received from Sonic Pi The remaining software consists of various scripts which can be run on Sonic Pi to play the glockenspiel. These are constrained by the range of notes available on the glockenspiel. Full contructional details of the glockenspiel are on my blgo https://rbnrpi.wordpress.com

#Bobbie Shaftoe arranged for Sonic Pi glockenspeil by Robin Newman June 2018
use_osc "localhost",8000
use_debug false
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2)[0..9]+[note(:fs6)]
return nl.index note(n)
end
use_synth :pluck
use_bpm 240
bs=[:g6,:g6,:g6,:c7,:b6,:d7,:b6,:g6,
:d6,:d6,:d6,:g6,:fs6,:a6,:fs6,:d6,
:g6,:g6,:g6,:c7,:b6,:d7,:b6,:g6,
:a6,:c7,:a6,:fs6,:g6,:g6,
:b6,:d7,:b6,:g6,:b6,:d7,:b6,
:a6,:c7,:a6,:fs6,:a6,:c7,:a6,
:b6,:d7,:b6,:g6,:b6,:d7,:b6,
:a6,:c7,:a6,:fs6,:g6,:g6
]
bs2=[:g5]*8+[:d5]*8+[:g5]*8+[:fs5]*4+[:b4]*2+
[:g5,:b5,:g5,:d5,:g5,:b5,:g5,
:fs5,:a5,:fs5,:d5,:fs5,:a5,:fs5,
:g5,:b5,:g5,:d5,:g5,:b5,:g5,
:fs5,:a5,:fs5,:d5,:b4,:g4]
dur=[1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,
1,1,1,1,2,2,
1,1,1,1,1,1,2,
1,1,1,1,1,1,2,
1,1,1,1,1,1,2,
1,1,1,1,2,2]
2.times do #play through twice
in_thread do
sleep rt(0.3) #allow for Pi3 audio latency
bs.zip(dur).each do |n,d|
osc "/note",notenum(n)
sleep d
end
end
with_fx :reverb,room: 0.7,mix: 0.6 do
bs2.zip(dur).each do |n,d| #accompaniment
play n-12,release:d #transpose down an octave -12
sleep d
end
end
end
#CampbellsFarewell arranged for Sonic Pi Glockenspiel by Robin Newman June 2018
use_synth :piano
use_bpm 200
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2).to_a[0..9]+[note(:fs6)]
#puts nl
return nl.index note(n)
end
use_osc "localhost",8000
in_thread do
sleep rt(0.3) #allow for Pi3 audio latency
osc "/note",notenum(note(:D5)+24-5) #play upbeat
end
sleep 0.5 #allow for upbeat
numTimes=2 #play through twice
numTimes.times do |p|
a1=[]
b1=[]
a1[0]=[:G4,:G4,:A4,:B4,:B4,:C5,:D5,:G5,:D5,:D5,:C5,:B4,:G4,:G4,:A4,:B4,:C5,:C5,:A4,:F4,:A4,:G4,:G4,:A4,:B4,:A4,:B4,:C5,:D5,:G5,:D5,:D5,:C5,:B4,:A4,:G4,:F4,:A4,:G4,:r,:D5,:G4,:G4,:A4,:B4,:B4,:C5,:D5,:G5,:D5,:D5,:C5,:B4,:G4,:G4,:A4,:B4,:C5,:C5,:A4,:F4,:A4,:G4,:G4,:A4,:B4,:A4,:B4,:C5,:D5,:G5,:D5,:D5,:C5,:B4,:A4,:G4,:F4,:A4,:G4,:G4,:F5,:E5,:D5,:G5,:G5,:F5,:E5,:D5,:G5,:G5,:D5,:C5,:B4,:G4,:G4,:A4,:B4,:C5,:C5,:A4,:F4,:F5,:E5,:D5,:G5,:G5,:F5,:E5,:D5,:G5,:D5,:D5,:C5,:B4,:A4,:G4,:F4,:A4,:G4,:G4,:G4,:F5,:E5,:D5,:G5,:G5,:D5,:C5,:B4,:G4,:G4,:A4,:B4,:C5,:C5,:A4,:F4,:F5,:E5,:D5,:G5,:G5,:F5,:E5,:D5,:G5,:D5,:D5,:C5,:B4,:A4,:G4,:F4,:A4,:G4,:G4,:G4,:G4,:D5,:D5,:D5,:E5,:F5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1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.5,1.0,0.5,1.0,1.0,2.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.5]
in_thread do
sleep rt(0.3) #allow for Pi3 audio latency
for i in 0..a1.length-1
for j in 0..a1[i].length-1
#play a1[i][j],sustain: b1[i][j]*0.9,release: b1[i][j]*0.1
if a1[i][j]!=:r #ignore rests
osc "/note",notenum(note(a1[i][j])+24-5)
end
sleep b1[i][j]
end
end
end
with_fx :reverb,room: 0.7,mix: 0.7 do
use_transpose -5
a2=[]
b2=[]
a2[0]=[:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:C4,:F4,:A4],:r,[:C4,:F4,:A4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:C4,:F4,:A4],:r,[:C4,:F4,:A4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:C4,:F4,:A4],:r,[:C4,:F4,:A4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:C4,:F4,:A4],:r,[:C4,:F4,:A4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:C4,:F4,:A4],:r,[:C4,:F4,:A4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:D4,:G4,:B4],:r,[:C4,:F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0,0.5]
#in_thread do #remove thread so time is set before next repeat
for i in 0..a3.length-1
for j in 0..a3[i].length-1
play a3[i][j],sustain: b3[i][j]*0.9,release: b3[i][j]*0.1,amp: 0.5
sleep b3[i][j]
end
end
#end
#lead note for next pass (if any)
if p<numTimes-1
in_thread do
sleep rt(0.3) #allow for Pi3 audio latency
puts "last ",notenum(note(:D5)+24-5)
osc "/note",notenum(note(:D5)+24-5)
end
sleep 0.5
end
end
end
#Edelweiss for Sonic Pi glockenspiel by Robin Newman June 2018
use_osc "localhost",8000
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2)[0..9]+[note(:fs6)]
return nl.index note(n)
end
use_bpm 180
a1=[:E4,:G4,:D5,:C5,:G4,:F4,:E4,:E4,:E4,:F4,:G4,:A4,:G4,:E4,:G4,:D5,:C5,:G4,:F4,:E4,:G4,:G4,:A4,:B4,:C5,:C5,:D5,:r,:G4,:G4,:B4,:A4,:G4,:E4,:G4,:C5,:A4,:C5,:D5,:C5,:B4,:G4,:E4,:G4,:D5,:C5,:G4,:F4,:E4,:G4,:G4,:A4,:B4,:C5,:C5,:r,:E4,:G4,:D5,:C5,:G4,:F4,:E4,:E4,:E4,:F4,:G4,:A4,:G4,:E4,:G4,:D5,:C5,:G4,:F4,:E4,:G4,:G4,:A4,:B4,:C5,:C5,:D5,:r,:G4,:G4,:B4,:A4,:G4,:E4,:G4,:C5,:A4,:C5,:D5,:C5,:B4,:G4,:E4,:G4,:D5,:C5,:G4,:F4,:E4,:G4,:G4,:A4,:B4,:C5,:C5]
b1=[2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0,1.0,1.0,1.0,3.0,3.0,2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0,1.0,1.0,1.0,3.0,3.0,1.0,0.5,0.5,1.0,1.0,1.0,1.0,2.0,1.0,3.0,2.0,1.0,2.0,1.0,3.0,3.0,2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0,1.0,1.0,1.0,3.0,2.0,1.0,2.0,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glockenspiel by Robin Newman June 2018
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2).to_a[0..9]+[note(:fs6)]
return nl.index note(n)
end
use_osc "localhost",8000
use_synth :pluck
use_bpm 120
a1=[:E5,:C5,:G4,:G4,:G4,:G4,:G4,:E4,:G4,:A4,:C5,:G4,:G4,:G4,:G4,:E5,:D5,:E5,:C5,:A4,:A4,:A4,:A4,:A4,:G4,:A4,:C5,:G4,:A4,:C5,:D5,:E5,:G5,:D5,:E5,:C5,:G4,:G4,:G4,:G4,:G4,:E4,:G4,:A4,:C5,:G4,:G4,:G4,:G4,:E5,:D5,:E5,:C5,:A4,:A4,:A4,:A4,:A4,:G4,:A4,:C5,:G4,:A4,:C5,:D5,:E5,:D5,:E5,:C5,:D5,:E5,:C5,:D5,:E5,:F5,:D5,:C5,:D5,:E5,:C5,:D5,:C5,:A4,:C5,:D5,:E5,:C5,:D5,:A4,:F5,:A4,:G5,:G4,:G4,:G4,:G4,:E5,:D5,:E5,:C5,:D5,:E5,:C5,:D5,:E5,:F5,:D5,:C5,:D5,:E5,:C5,:D5,:C5,:A4,:C5,:D5,:E5,:C5,:D5,:E5,:F5,:D5,:E5,:F5,:G5,:G4,:F5,:E5,:G5,:D5,:E5,:C5,:G4,:G4,:G4,:G4,:G4,:E4,:G4,:A4,:C5,:G4,:G4,:G4,:G4,:E5,:D5,:E5,:C5,:A4,:A4,:A4,:A4,:A4,:G4,:A4,:C5,:G4,:A4,:C5,:D5,:E5,:G5,:D5,:E5,:C5,:G4,:G4,:G4,:G4,:G4,:E4,:G4,:A4,:C5,:G4,:G4,:G4,:G4,:E5,:D5,:E5,:C5,:A4,:A4,:A4,:A4,:A4,:G4,:A4,:C5,:G4,:A4,:C5,:D5,:E5,:D5,:E5]
b1=[0.5,0.75,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,1.0,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,1.0,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.75,0.25,0.5,0.5,0.75,0.25,0.5,0.5,0.75,0.25,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.75,0.25,0.75,0.25,0.25,0.25,0.5,1.0,0.5,0.5,0.75,0.25,0.5,0.5,0.75,0.25,0.5,0.5,0.75,0.25,0.5,0.5,1.0,0.5,0.5,0.75,0.25,0.5,0.5,0.75,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,1.0,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.75,0.25,0.25,0.25,0.5,1.0,0.5,0.5,0.75,0.25,0.25,0.25,0.5,0.75,0.25,0.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5]
in_thread do
sleep rt(0.3)
for i in 0..a1.length-1
osc "/note",notenum(note(a1[i])+24)
sleep b1[i]
end
end
use_transpose 24
with_fx :reverb,room: 0.7,mix: 0.6 do
a2=[:r,:G2,:G2,:G2,:G2,:G2,:G2,:G2,:r,:A2,:A2,:A2,:A2,:A2,:A2,:A2,:B2,:C3,:G2,:G2,:G2,:G2,:G2,:G2,:r,:A2,:A2,:A2,:A2,:A2,:A2,:A2,:A2,:r,:E3,:C3,:F3,:D3,:E3,:C3,:G3,:F3,:E3,:C3,:F3,:D3,:G3,:G2,:C3,:C3,:E3,:C3,:F3,:C3,:E3,:C3,:G3,:F3,:E3,:C3,:F3,:D3,:C3,:G2,:C3,[:G2,:B2],:G2,:G2,:G2,:G2,:G2,:G2,:G2,:r,:A2,:A2,:A2,:A2,:A2,:A2,:A2,:B2,:C3,:G2,:G2,:G2,:G2,:G2,:G2,:r,:A2,:A2,:A2,:A2,:A2,:A2,:A2,:A2,:r]
b2=[0.5,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.5,0.5,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.5,0.5]
in_thread do
for i in 0..a2.length-1
play a2[i],sustain: b2[i]*0.9,release: b2[i]*0.1
sleep b2[i]
end
end
end
sleep 0.5
24.times do
2.times do
sample :bd_haus
sleep 1
sample :drum_cymbal_closed
sleep 0.5
sample :drum_cymbal_closed
sleep 0.5
end
end
#!/usr/bin/env python3
#OSCglockenspiel.py written by Robin Newman, May 2018
#program sets up an OSC server and receives OSC messages sent to "/note"
#Sonic Pi can be running either on the Raspberry Pi (default),
#or on an external networked computer
#All of the libraries required should be standard on the latest Raspbian apart from pythonosc
#To install this use sudo pip3 install python-osc
from gpiozero import LEDBoard
from pythonosc import udp_client
from pythonosc import dispatcher
from pythonosc import osc_server
from time import sleep
import argparse
import sys
leds=LEDBoard(9,10,11,12,13,14,15,16,17,18,19) #pins connected to ULM2803A driver or TIP120 power transistors
#via GPIO pins 9-19
#This is activated when /note OSC message is received by the server.
#the arguments n represents the note position in the LEDBoard array 0->9
def pulse(unused_addr,args,m): #pulse pin corresponding to received number for 0.05 seconds
print("note",m)
leds[m].on()
sleep(0.05)
leds[m].off()
#The main routine called when the program starts up follows
if __name__ == "__main__":
try: #use try...except to handle possible errors
#first set up and deal with input args when program starts
parser = argparse.ArgumentParser()
#This arg gets the server IP address to use. 127.0.0.1 or
#The local IP address of the PI, required when using external Sonic Pi
parser.add_argument("--ip",
default="127.0.0.1", help="The ip to listen on")
#This is the port on which the server listens. Usually 8000 is OK
#but you can specify a different one
parser.add_argument("--port",
type=int, default=8000, help="The port to listen on")
#This is the port used for the connection, you can change it if you wissh,
#but the default port 8000 should be OK.
args=parser.parse_args()
dispatcher = dispatcher.Dispatcher()
#following dispatcher handles /note osc messages being received
dispatcher.map("/note",pulse,"n")
#Now set up and run the OSC server
server = osc_server.ThreadingOSCUDPServer(
(args.ip, args.port), dispatcher)
print("Serving on {}".format(server.server_address))
#run the server "forever" (till stopped by pressing ctrl-C)
server.serve_forever()
#deal with some error events
except KeyboardInterrupt:
print("\nServer stopped") #stop program with ctrl+C
#Used the AttributeError to specify problems with the local ip address
except AttributeError as err:
print(err.args[0])
#handle errors generated by the server
except OSError as err:
print("OSC server error",err.args)
#anything else falls through
# Test all notes for Sonic Pi glockenspiel by Robin Newman June 2018
use_osc "localhost",8000
11.times do |n|
osc "/note",n
sleep 0.5
end
# Test all notes for Sonic Pi glockenspiel by Robin Newman June 2018
use_osc "localhost",8000
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2).to_a[0..9]+[note(:fs6)]
#puts nl
return nl.index note(n)
end
live_loop :testnotes,delay: 0.5 do
tune = (ring :c6,:e6,:g6,:c7,:e7,:c7,:b6,:a6,:g6,:f6,:e6,:d6,:c6,:fs6,:d7)
osc "/note",notenum(tune.tick)
sleep 0.2
end
#Over the Sea to Skye for Sonic Pi glockenspiel arranged by Robin Newman June 2018
use_osc "localhost",8000
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2)[0..9]+[note(:fs6)]
return nl.index note(n)
end
2.times do #play through twice
use_bpm 120
#glockenspiel part
a1=[:G4,:A4,:G4,:C5,:C5,:D5,:E5,:D5,:G5,:E5,:D5,:E5,:A4,:A4,:G4,:G4,:A4,:G4,:C5,:C5,:D5,:E5,:D5,:G5,:E5,:D5,:E5,:A4,:A4,:G4,:E5,:C5,:E5,:E5,:D5,:A4,:D5,:D5,:C5,:A4,:C5,:C5,:C5,:A4,:E5,:C5,:E5,:E5,:D5,:A4,:D5,:D5,:C5,:A4,:C5,:C5,:C5,:A4,:B4,:G4,:A4,:G4,:C5,:C5,:D5,:E5,:D5,:G5,:G5,:E5,:D5,:E5,:A4,:A4,:G4,:G4,:A4,:G4,:C5,:C5,:D5,:E5,:D5,:G5,:G5,:E5,:D5,:E5,:A4,:B4,:C5]
b1=[0.75,0.25,0.5,1.0,0.5,0.75,0.25,0.5,1.5,0.75,0.25,0.5,1.0,0.5,3.0,0.75,0.25,0.5,1.0,0.5,0.75,0.25,0.5,1.5,0.75,0.25,0.5,1.0,0.5,3.0,0.5,0.5,0.5,1.5,0.5,0.5,0.5,1.5,0.5,0.5,0.5,1.0,0.5,3.0,0.5,0.5,0.5,1.5,0.5,0.5,0.5,1.5,0.5,0.5,0.5,1.0,0.5,1.5,1.5,0.75,0.25,0.5,1.0,0.5,0.75,0.25,0.5,1.0,0.5,0.75,0.25,0.5,1.0,0.5,3.0,0.75,0.25,0.5,1.0,0.5,0.75,0.25,0.5,1.0,0.5,0.75,0.25,0.5,1.0,0.5,3.0]
in_thread do
sleep rt(0.3)
for i in 0..a1.length-1
osc "/note",notenum(note(a1[i])+24-7) #transpose setting 24-7 up 2 octaves, down a fifth
sleep b1[i]
end
end
use_synth :piano
#accompaniment parts
use_transpose -7
a2=[:G4,:G4,:A4,:D5,:C5,:A4,:G4,:G4,:G4,:G4,:A4,:D5,:C5,:A4,:G4,:G4,:C5,:A4,:C5,:C5,:A4,:F4,:A4,:A4,:A4,:A4,:A4,:C5,:A4,:C5,:C5,:A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4,:C4,:B3,:A3,:A3,:D3,:A3,:E3,:A2,:A3,:E3,:A2,:B2,:C3,:D3,:D4,:C4,:B3,:A3,:A3,:D3,:A3,:G3,:C4,:C4,:B3,:C4,:F3,:G3,:C4,:C4,:B3,:C4,:F3,:G3,:C3]
b4=[3.0,2.5,0.5,1.5,1.5,3.0,3.0,2.5,0.5,1.5,1.5,3.0,1.0,0.5,0.75,0.25,0.5,1.5,0.75,0.25,0.5,1.0,0.5,1.5,1.0,0.5,1.5,1.0,0.5,0.75,0.25,0.5,1.5,0.75,0.25,0.5,1.0,0.5,1.5,1.5,1.5,3.0,1.5,1.5,1.5,1.5,3.0,3.0,1.5,1.5,1.5,1.0,0.5,3.0]
for i in 0..a4.length-1
play a4[i],sustain: b4[i]*0.9,release: b4[i]*0.1
sleep b4[i]
end
end
#SwallowTailJig arranged for Sonic Pi glockenspiel by Robin Newman June 2018
define :notenum do |n|
nl=(scale :c6,:major,num_octaves: 2).to_a[0..9]+[note(:fs6)]
return nl.index note(n)
end
use_osc "localhost",8000
2.times do
use_synth :pluck
use_bpm 120
a1=[:D4,:E4,:F4,:D4,:D4,:A4,:D4,:D4,:F4,:D4,:D4,:A4,:G4,:F4,:E4,:C4,:C4,:G4,:C4,:C4,:C5,:B4,:C5,:G4,:F4,:E4,:F4,:D4,:D4,:A4,:D4,:D4,:F4,:D4,:D4,:A4,:B4,:C5,:B4,:C5,:G4,:F4,:E4,:F4,:D4,:D4,:D4,:D4,:E4,:F4,:D4,:D4,:A4,:D4,:D4,:F4,:D4,:D4,:A4,:G4,:F4,:E4,:C4,:C4,:G4,:C4,:C4,:C5,:B4,:C5,:G4,:F4,:E4,:F4,:D4,:D4,:A4,:D4,:D4,:F4,:D4,:D4,:A4,:B4,:C5,:B4,:C5,:G4,:F4,:E4,:F4,:D4,:D4,:D4,:A4,:A4,:B4,:C5,:D5,:E5,:D5,:E5,:D5,:C5,:A4,:A4,:B4,:C5,:D5,:E5,:D5,:C5,:B4,:C5,:A4,:A4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,0.5,0.5,0.25,0.25,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.5,0.5,0.5,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,0.5,0.25,0.25,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,1.0,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,1.5]
in_thread do
for i in 0..a2.length-1
play a2[i],sustain: b2[i]*0.9,release: b2[i]*0.1
sleep b2[i]
end
end
use_transpose 12
a3=[:D4,:E4,[:A3,:D4],[:A3,:D4],[:D4,:A4],[:D4,:A4],[:A3,:D4],[:A3,:D4],[:D4,:A4],[:D4,:A4],[:C4,:G4],[:C4,:G4],[:E4,:C5],[:E4,:G4],[:C4,:G4],[:C4,:G4],[:E4,:C5],[:E4,:G4],[:A3,:D4],[:A3,:D4],[:D4,:A4],[:D4,:A4],[:A3,:D4],[:A3,:D4],[:D4,:A4],[:D4,:A4],[:C4,:G4],[:C4,:G4],[:E4,:C5],[:E4,:G4],:A3,:A3,:A3,:F3,:G3,[:A3,:D4],[:A3,:D4],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5,1.0,0.5,1.5,1.5,1.5,1.5,0.5,0.5,0.5,1.5]
for i in 0..a3.length-1
play a3[i],sustain: b3[i]*0.9,release: b3[i]*0.1
sleep b3[i]
end
end
end
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.