Last active
August 3, 2017 14:00
-
-
Save rbnpi/aae8a0c0e5c8dd86800eda7621f56386 to your computer and use it in GitHub Desktop.
Sonic Pi 3 Synth Driver A combination of a Sonic Pi program nc1.1.rb and a TouchOSC file nc1.1.touchosc which can be used from TouchOSC on an iPad to control Sonic Pi 3. Project at https://rbnrpi.wordpress.com/sonic-pi-3-synth-driver/ video at https://youtu.be/HE-NlZCGnYU
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
<?xml version="1.0" encoding="UTF-8"?><layout version="15" mode="1" orientation="vertical"><tabpage name="bmM=" scalef="0.0" scalet="1.0" ><control name="eHkx" x="429" y="95" w="220" h="220" color="red" scalef="0.0" scalet="1.0" type="multixy" inverted_x="false" inverted_y="false" ></control><control name="eHky" x="433" y="690" w="220" h="220" color="red" scalef="0.0" scalet="1.0" type="multixy" inverted_x="false" inverted_y="false" ></control><control name="ZW5hYmxlMg==" x="431" y="942" w="45" h="45" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="a2lsbDI=" x="323" y="942" w="45" h="45" color="red" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="bXV0ZTI=" x="532" y="942" w="45" h="45" color="yellow" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="dW5tdXRlMg==" x="643" y="942" w="45" h="45" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azI=" x="30" y="153" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azQ=" x="30" y="206" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azU=" x="30" y="261" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azc=" x="31" y="316" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azk=" x="30" y="371" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azEx" x="30" y="426" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azEy" x="30" y="482" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE0" x="30" y="535" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE2" x="30" y="591" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE3" x="30" y="645" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE5" x="30" y="700" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azIx" x="30" y="755" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azIz" x="30" y="810" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azI0" x="30" y="865" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azA=" x="30" y="97" w="250" h="50" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE=" x="150" y="123" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azM=" x="150" y="185" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azY=" x="150" y="289" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azg=" x="150" y="348" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azEw" x="150" y="406" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azEz" x="150" y="509" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE1" x="150" y="570" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azE4" x="150" y="673" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azIw" x="150" y="730" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="azIy" x="150" y="787" w="130" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ></control><control name="c3ludGhyaWdodA==" x="441" y="521" w="200" h="50" color="purple" scalef="0.0" scalet="1.0" type="multitoggle" number_x="6" number_y="1" ex_mode="true" local_off="false" ></control><control name="dmZhZGVrZXlz" x="50" y="940" w="200" h="50" color="yellow" scalef="0.0" scalet="1.0" type="faderh" response="absolute" inverted="false" centered="false" ></control><control name="dmZhZGUy" x="443" y="627" w="200" h="50" color="yellow" scalef="0.0" scalet="1.0" type="faderh" response="absolute" inverted="false" centered="false" ></control><control name="dmZhZGUx" x="443" y="24" w="200" h="50" color="yellow" scalef="0.0" scalet="1.0" type="faderh" response="absolute" inverted="false" centered="false" ></control><control name="ZmFkZXJzcmVsZWFzZQ==" x="49" y="24" w="200" h="50" color="purple" scalef="0.1" scalet="2.0" type="faderh" response="absolute" inverted="false" centered="false" ></control><control name="a2Jkb2N0YXZl" x="291" y="381" w="50" h="200" color="blue" scalef="0.0" scalet="1.0" type="multitoggle" number_x="1" number_y="4" ex_mode="true" local_off="false" ></control><control name="c3ludGhsZWZ0" x="439" y="382" w="200" h="50" color="purple" scalef="0.0" scalet="1.0" type="multitoggle" number_x="6" number_y="1" ex_mode="true" local_off="false" ></control><control name="bGFiZWwx" x="479" y="437" w="25" h="80" color="purple" type="labelv" text="U2F3" size="14" background="true" outline="false" ></control><control name="bGFiZWwy" x="511" y="437" w="25" h="80" color="purple" type="labelv" text="UHJvcGhldA==" size="14" background="true" outline="false" ></control><control name="bGFiZWwz" x="543" y="437" w="25" h="80" color="purple" type="labelv" text="VEIzMDM=" size="14" background="true" outline="false" ></control><control name="bGFiZWw0" x="575" y="437" w="25" h="80" color="purple" type="labelv" text="Rk0=" size="14" background="true" outline="false" ></control><control name="bGFiZWw1" x="608" y="437" w="25" h="80" color="purple" type="labelv" text="TW9kIFNhdw==" size="14" background="true" outline="false" ></control><control name="bGFiZWw2" x="447" y="437" w="25" h="80" color="purple" type="labelv" text="VHJp" size="14" background="true" outline="false" ></control><control name="c3ludGhM" x="657" y="367" w="25" h="80" color="purple" type="labelv" text="TGVmdCBTeW50aA==" size="14" background="true" outline="false" ></control><control name="bGFiZWw4" x="657" y="504" w="25" h="80" color="purple" type="labelv" text="UmlnaHQgU3ludGg=" size="14" background="true" outline="false" ></control><control name="UGl0Y2ggeSBSZWxlYXNlIHg=" x="654" y="136" w="25" h="138" color="red" type="labelv" text="UGl0Y2ggeSBSZWxlYXNlIHg=" size="14" background="true" outline="false" ></control><control name="Vm9sIExlZnQ=" x="657" y="10" w="25" h="80" color="yellow" type="labelv" text="Vm9sIExlZnQ=" size="14" background="true" outline="false" ></control><control name="bGFiZWwxMg==" x="657" y="617" w="25" h="80" color="yellow" type="labelv" text="Vm9sIFJpZ2h0" size="14" background="true" outline="false" ></control><control name="bGFiZWwxMw==" x="657" y="708" w="25" h="185" color="green" type="labelv" text="TG9uZyBOb3RlIEN1dG9mZiB4IFBpdGNoIHk=" size="14" background="true" outline="false" ></control><control name="bGFiZWwxNA==" x="347" y="427" w="25" h="105" color="blue" type="labelv" text="S2JkIE9jdGF2ZQ==" size="14" background="true" outline="false" ></control><control name="bGFiZWwxNQ==" x="263" y="1" w="25" h="91" color="purple" type="labelv" text="S2JkIFJlbGVhc2U=" size="14" background="true" outline="false" ></control><control name="bGFiZWwxNg==" x="263" y="925" w="25" h="80" color="yellow" type="labelv" text="S2JkIFZvbA==" size="14" background="true" outline="false" ></control><control name="bGFiZWwxNw==" x="479" y="924" w="25" h="80" color="green" type="labelv" text="U3RhcnQgTm90ZQ==" size="14" background="true" outline="false" ></control><control name="bGFiZWwxOA==" x="370" y="924" w="25" h="80" color="red" type="labelv" text="S2lsbCBOb3Rl" size="14" background="true" outline="false" ></control><control name="bGFiZWwxOQ==" x="689" y="925" w="25" h="80" color="green" type="labelv" text="VW4tTXV0ZQ==" size="14" background="true" outline="false" ></control><control name="bGFiZWwyMA==" x="582" y="925" w="25" h="80" color="brown" type="labelv" text="TXV0ZSA=" size="14" background="true" outline="false" ></control><control name="bGFiZWwyMQ==" x="380" y="82" w="33" h="246" color="yellow" type="labelv" text="U29uaWMgUGkgMyBTeW50aCBEcml2ZXI=" size="22" background="true" outline="false" ></control><control name="bGFiZWwyMg==" x="384" y="375" w="33" h="205" color="yellow" type="labelv" text="YnkgUm9iaW4gTmV3bWFu" size="22" background="true" outline="false" ></control><control name="a2Jkc3ludGg=" x="291" y="155" w="50" h="99" color="purple" scalef="0.0" scalet="1.0" type="multitoggle" number_x="1" number_y="2" ex_mode="true" local_off="false" ></control><control name="bGFiZWwyMw==" x="342" y="134" w="25" h="141" color="purple" type="labelv" text="S2JkIFN5bnRoIFNlbGVjdA==" size="14" background="true" outline="false" ></control><control name="bGFiZWwyNA==" x="298" y="255" w="25" h="58" color="purple" type="labelv" text="UmlnaHQ=" size="14" background="true" outline="false" ></control><control name="bGFiZWwyNQ==" x="300" y="91" w="25" h="59" color="purple" type="labelv" text="TGVmdA==" size="14" background="true" outline="false" ></control><control name="bGVkc2s=" x="402" y="954" w="20" h="20" color="gray" scalef="0.0" scalet="1.0" type="led" ></control><control name="bGVkbXU=" x="614" y="955" w="20" h="20" color="gray" scalef="0.0" scalet="1.0" type="led" ></control><control name="dHJhbnNwb3Nl" x="318" y="614" w="50" h="300" color="pink" scalef="0.0" scalet="1.0" type="multitoggle" number_x="1" number_y="15" ex_mode="true" local_off="false" ></control><control name="bGFiZWwyNg==" x="397" y="726" w="25" h="84" color="purple" type="labelv" text="VHJhbnNwb3Nl" size="14" background="true" outline="false" ></control><control name="bGFiZWwzMA==" x="373" y="614" w="25" h="25" color="purple" type="labelv" text="LTEy" size="14" background="true" outline="false" ></control><control name="bGFiZWwzNA==" x="290" y="634" w="25" h="25" color="purple" type="labelv" text="LTEw" size="14" background="true" outline="false" ></control><control name="bGFiZWwzNQ==" x="373" y="653" w="25" h="25" color="purple" type="labelv" text="LTg=" size="14" background="true" outline="false" ></control><control name="bGFiZWwzNg==" x="290" y="673" w="25" h="25" color="purple" type="labelv" text="LTc=" size="14" background="true" outline="false" ></control><control name="bGFiZWwzNw==" x="373" y="692" w="25" h="25" color="purple" type="labelv" text="LTU=" size="14" background="true" outline="false" ></control><control name="bGFiZWwzOA==" x="290" y="712" w="25" h="25" color="purple" type="labelv" text="LTM=" size="14" background="true" outline="false" ></control><control name="bGFiZWwzOQ==" x="373" y="731" w="25" h="25" color="purple" type="labelv" text="LTE=" size="14" background="true" outline="false" ></control><control name="bGFiZWw0MA==" x="290" y="751" w="25" h="25" color="purple" type="labelv" text="MA==" size="14" background="true" outline="false" ></control><control name="bGFiZWw0MQ==" x="373" y="770" w="25" h="25" color="purple" type="labelv" text="Mg==" size="14" background="true" outline="false" ></control><control name="bGFiZWw0Mg==" x="290" y="790" w="25" h="25" color="purple" type="labelv" text="NA==" size="14" background="true" outline="false" ></control><control name="bGFiZWw0Mw==" x="373" y="809" w="25" h="25" color="purple" type="labelv" text="NQ==" size="14" background="true" outline="false" ></control><control name="bGFiZWw0NA==" x="290" y="829" w="25" h="25" color="purple" type="labelv" text="Nw==" size="14" background="true" outline="false" ></control><control name="bGFiZWw0NQ==" x="373" y="848" w="25" h="25" color="purple" type="labelv" text="OQ==" size="14" background="true" outline="false" ></control><control name="bGFiZWw0Ng==" x="290" y="868" w="25" h="25" color="purple" type="labelv" text="MTE=" size="14" background="true" outline="false" ></control><control name="bGFiZWw0Nw==" x="372" y="887" w="25" h="25" color="purple" type="labelv" text="MTI=" size="14" background="true" outline="false" ></control><control name="ZmFkZXJSZXZlcmI=" x="688" y="373" w="22" h="200" color="pink" scalef="0.0" scalet="1.0" type="faderv" response="absolute" inverted="false" centered="false" ></control><control name="bGFiZWw0OA==" x="688" y="300" w="25" h="66" color="pink" type="labelv" text="UmV2ZXJi" size="14" background="true" outline="false" ></control></tabpage></layout> |
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
#nc (Note Continuous) program for Sonic Pi 3 controlled by TouchOSC | |
#written by Robin Newman, August 2017 (ver 1.1) | |
#Three separate note inputs are controlled. | |
#For each one, synth,volume,pitch,sustain nd transpose are controlled | |
#One uses a virtual 2 octave+ 1 note keyboard, which can be octave shifted | |
#One uses an xy input to control Pitch and Release | |
#One generates a continous note with xy control of pitch and cutoff. | |
#This note can be muted/unmuted, or restarted with a differnt synth setting | |
#TouchOSC controls everything, by sending a variety of OSC messages to Sonic Pi 3 | |
#It also receives feed back (via OSC messages) which set up the initial controller positions | |
#and controls two leds which indicate settings for the "long note" | |
#It features the use of set and get commands to send and receive information between the multiple | |
#live loops in the program. | |
#It uses two undocumented features of Sonic Pi 3 (which therefore may change in the future) | |
#1: use of n.kill to kill a synth node n | |
#2: use of the get_event function to retrieve address information for OSC messages | |
#this enables one live loop to control ALL the keyboard button inputs, and enables | |
#the address decoding of the multi-toggle buttons used for synth/transpose and kbd octave | |
TouchOSC_IP="192.168.1.50" #adjust for IP of TouchOSC | |
use_osc TouchOSC_IP,9000 #TouchOSC set to receive on port 9000 | |
use_debug false | |
use_cue_logging false | |
#initialise set values. These are used to communicate with the various live_loops | |
set :volLN2,0 #used to hold "long Note" volume level | |
set :volLeft,0.5 #vol for left hand XY pad | |
set :volKbd,0.5 #vol for keyboard | |
set :kbdRelease,0.5 #keyboard release time | |
set :kbdOctave,1 #keyboard octave shift | |
set :ncontrol,36 #used to hold controlled note value for "long note" | |
set :kill,1 #used to kill "long note" | |
set :mutevol,1 #used to mute/unmute "long note" | |
set :cutoff_val,80 #cutoff value for "long note" | |
set :leftpitch,60 #left note starting pitch | |
set :synleft,:tri #current synth name for buttons and "left note" | |
set :synright,:tri #current synth name for "long note" | |
set :kbdsyn,:tri #current synth name for keyboard | |
set :kbdsynptr,1 #points to left (1) or right(2) synth list | |
set :trsetting,0 #transpose setting in semitomes | |
define :setLed do |name,col,intensity| #sets LED colour and intensity | |
osc "/nc/"+name+"/color",col | |
osc "/nc/"+name,intensity | |
end | |
define :init do #OSC messages to set up TouchOSC controls | |
osc "/nc/vfade1",0.5 | |
osc "/nc/vfade2",0 | |
osc "/nc/synthleft/1/1",1 | |
osc "/nc/synthright/1/1",1 | |
osc "/nc/fadersrelease",0.5 | |
osc "/nc/kbdoctave/1/2",1 | |
osc "/nc/volKbd",0.5 | |
osc "/nc/kbdsynth/1/1",1 | |
osc "/nc/transpose/1/8",1 # equiv 0 transpose | |
osc "/nc/faderReverb",0.5 | |
setLed("ledsk","red",1) | |
setLed("ledmu","green",1) | |
end | |
init #intialise TouchOSC | |
define :pdec2 do |n| #for nice printing to 2 decimal places | |
return (n.to_f*100).round.to_f/100 | |
end | |
########## CONTROL SECTION ADJUSTS VOL SYNTHS, MUTE ETC #### | |
define :getsyn do |address| #decode synth multi-toggle address | |
return get_event(address).to_s.split(",")[6][address.length-1].to_i | |
end | |
live_loop :get_synthR do #Right synth selector | |
use_real_time | |
b= sync "/osc/nc/synthright/?/1" | |
if b[0]>0 | |
slist=[:tri,:saw,:prophet,:tb303,:fm,:mod_saw] | |
p= getsyn("/osc/nc/synthright/?/1") - 1 #to get offset from 0 | |
set(:synright,slist[p]) | |
set(:kbdsyn,get(:synright)) if get(:kbdsynptr) == 2 | |
puts "synRight is",get(:synright) | |
end | |
end | |
live_loop :get_synthL do #left synth selector | |
use_real_time | |
b= sync "/osc/nc/synthleft/?/1" | |
if b[0]>0 | |
slist=[:tri,:saw,:prophet,:tb303,:fm,:mod_saw] | |
p= getsyn("/osc/nc/synthleft/?/1") - 1 #to get offset from 0 | |
set(:synleft,slist[p]) | |
set(:kbdsyn,get(:synleft)) if get(:kbdsynptr)==1 | |
puts "synLeft is",get(:synleft) | |
end | |
end | |
live_loop :volLN2 do #long note vol select | |
use_real_time | |
b = sync "/osc/nc/vfade2" | |
set :volLN2,b[0]*2 | |
puts "Vol long note is",pdec2(get(:volLN2)) | |
end | |
live_loop :volLeft do #left xy pad Vol | |
use_real_time | |
b = sync "/osc/nc/vfade1" | |
set :volLeft,b[0]*2 | |
puts "Vol left note is",pdec2(get(:volLeft)) | |
end | |
define :getTranspose do |address| #decode Transpose button | |
return get_event(address).to_s.split(",")[6][address.length+1..-2].to_i | |
end | |
live_loop :setTranspose do #set Transpose | |
use_real_time | |
b= sync "/osc/nc/transpose/1/*" | |
if b[0]==1 | |
tr= getTranspose("/osc/nc/transpose/1/*")-1 | |
puts "tr is",tr | |
set(:trsetting,[-12,-10,-8,-7,-5,-3,-1,0,2,4,5,7,9,11,12][tr]) | |
puts "Transpose (semitones)",get(:trsetting) | |
end | |
end | |
live_loop :volKbd do #set kbd volume | |
use_real_time | |
b = sync "/osc/nc/vfadekeys" | |
set :volKbd,b[0]*2 | |
puts "Vol keyboard note is",pdec2(get(:volKbd)) | |
end | |
live_loop :releaseKbd do #set kbd release time | |
use_real_time | |
b = sync "/osc/nc/fadersrelease" | |
set :kbdRelease,b[0] | |
end | |
define :getkbdOctave do |address| #decode Octave multi-toggle selected | |
return get_event(address).to_s.split(",")[6][address.length+1].to_i | |
end | |
live_loop :selectKbdOctave do #select kbd offset | |
use_real_time | |
b = sync "/osc/nc/kbdoctave/1/*" | |
if b[0]==1 | |
octave=getkbdOctave("/osc/nc/kbdoctave/1/*")-1 #num from 0 | |
puts("Kbd octave offset ",octave) | |
set :kbdOctave,octave | |
end | |
end | |
define :getkbdsynth do |address| #decode kbd synth select multi-toggle address | |
return get_event(address).to_s.split(",")[6][address.length+1].to_i | |
end | |
live_loop :selectkbdsynth do #select kbd synth from appropriate list | |
use_real_time | |
b = sync "/osc/nc/kbdsynth/1/*" | |
if b[0]==1 | |
s=getkbdsynth("/osc/nc/kbdsynth/1/*") | |
puts"s is",s | |
set :kbdsynptr,s | |
set :kbdsyn,get(:synleft) if s==1 | |
set :kbdsyn,get(:synright) if s==2 | |
puts "kbd synth is",get(:kbdsyn) | |
end | |
end | |
live_loop :durationLeftNote do #left XY duration setting | |
use_real_time | |
b = sync "/osc/nc/xy1/1" | |
set :dur,b[1]*0.98+0.02 | |
puts "Left note pitch",pdec2(get(:leftpitch)),"duration",pdec2(get(:dur)) | |
end | |
live_loop :kill2 do #set kill flag for "long" note | |
b=sync "/osc/nc/kill2" | |
set :kill,1 if b[0]>0 #only on push, not release | |
end | |
live_loop :long_pitch do #change pitch of "long" note | |
use_real_time | |
b= sync "/osc/nc/xy2/1" | |
set :ncontrol,b[0]*12+36 | |
set :cutoff_val,b[1]*40+80 | |
#print current data for Long Note | |
puts "Long Note pitch:",pdec2(get(:ncontrol)+get(:trsetting)),"Cutoff:",pdec2(get(:cutoff_val)) | |
end | |
live_loop :muteln2 do #temp mute "long note" | |
use_real_time | |
b=sync "/osc/nc/mute2" | |
setLed("ledmu","red",1) | |
set :mutevol,0 | |
end | |
live_loop :unmuteln2 do #used to unmute "long note" | |
use_real_time | |
b=sync "/osc/nc/unmute2" | |
setLed("ledmu","green",1) | |
set :mutevol,1 | |
end | |
###### PLAYING SECTION BELOW ##### | |
with_fx :reverb,room: 0.8,mix: 0.5 do |rv| #playing section inside fx reverb | |
in_thread do #thread to alter reverb value | |
loop do #loop to react to reverb slider | |
b=sync "/osc/nc/faderReverb" | |
control rv,mix: b[0],mix_slide: 0.1 #adjust reverb according to slider | |
puts"Reverb mix is",pdec2(b[0]) | |
end | |
end | |
live_loop :continuous_note do #setup up "long note" and control it | |
use_real_time | |
b= sync "/osc/nc/enable2" #start the "long" note | |
if b[0]>0 and get(:kill)==1 #don't restart running note | |
set :kill,0 | |
setLed("ledsk","green",1) | |
use_synth get(:synright) | |
puts"long note started with synth",get(:synright) | |
n= play get(:ncontrol)+get(:trsetting),sustain: 1000,cutoff: get(:cutoff_val),amp: 0 #start "long note" with zero volume for 1000 seconds | |
10000.times do | |
control n,note: get(:ncontrol)+get(:trsetting),note_slide: 0.1,amp: get(:mutevol)*get(:volLN2),amp_slide: 0.1,cutoff: get(:cutoff_val),cutoff_slide: 0.1 | |
sleep 0.1 | |
break if get(:kill)==1 #if kill==1 abort loop | |
end | |
setLed("ledsk","red",1) | |
control n, amp: 0,amp_slide: 0.1 #fade out and stop | |
sleep 0.1 | |
n.kill | |
end | |
end | |
live_loop :leftNote do #adjust pitch from left xy pad | |
use_real_time | |
f = sync "/osc/nc/xy1/1" | |
set :leftpitch,f[0]*24+60+get(:trsetting) | |
synth get(:synleft),note: get(:leftpitch),attack: 0.15,release: get(:dur),amp: get(:volLeft) #or use synth get(:syn) | |
sleep get(:dur)*0.05+0.01 | |
end | |
define :getkey do |address| #decode key num from OSC address | |
return get_event(address).to_s.split(",")[6][address.length..-2].to_i | |
end | |
live_loop :kybd do #play note pushed | |
use_real_time | |
b= sync "/osc/nc/k[!i]**" #match k0...k24 (exclude kill1 match) | |
n= getkey("/osc/nc/k**")+48 | |
kn=n+get(:kbdOctave)*12+get(:trsetting) #calc pitch | |
puts "keybd note",kn | |
synth get(:kbdsyn),note: kn,attack: 0.1,release: get(:kbdRelease),amp: get(:volKbd) if b[0]==1 | |
end | |
end #fx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The file index.xml needs to be converted to a format which is used by TouchOSC. To do this, download the raw file and save it as index.html Then turn it into a zip file. On the Mac do this by right clicking the index.xml file in Finder, and choosing the compress option. This will produce a file named index.xml.zip Now rename this file to nc1.1.touchosc (NB touchosc is the file extension). This file can then be loaded into the TouchOSC editor which comes with TouchOSC and downloaded to the TouchOSC app running on an iPad in the usual way. See the article on https://rbnrpi.wordpress.com/2017/08/03/sonic-pi-3-synth-driver/ for more details on usage.
Since the video was made line 171 of nc1.1.rb was altered from
set :dur,b[1]*0.99+0.01
toset :dur,b[1]*0.98+0.02
as I noticed a timing error message due to this in the video.