Skip to content

Instantly share code, notes, and snippets.

@rbnpi
Last active April 20, 2018 10:56
Show Gist options
  • Save rbnpi/26b4fa12beca586c2ece0e9324af4e24 to your computer and use it in GitHub Desktop.
Save rbnpi/26b4fa12beca586c2ece0e9324af4e24 to your computer and use it in GitHub Desktop.
TouchOSC file for phonekeyboard.touchosc To use, download and then compress (zip) it and rename resulting file phonekeyboard.touchosc
<?xml version="1.0" encoding="UTF-8"?><layout version="15" mode="0" orientation="vertical"><tabpage name="a2Jk" scalef="0.0" scalet="1.0" ><control name="YzE=" x="25" y="5" w="157" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="0" data2f="0" data2t="127" sysex="" /></control><control name="ZDE=" x="26" y="36" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="2" data2f="0" data2t="127" sysex="" /></control><control name="ZTE=" x="26" y="67" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="4" data2f="0" data2t="127" sysex="" /></control><control name="ZjE=" x="26" y="99" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="5" data2f="0" data2t="127" sysex="" /></control><control name="ZzE=" x="27" y="130" w="155" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="7" data2f="0" data2t="127" sysex="" /></control><control name="YTE=" x="26" y="161" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="9" data2f="0" data2t="127" sysex="" /></control><control name="Y3Mx" x="101" y="20" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="1" data2f="0" data2t="127" sysex="" /></control><control name="YjE=" x="26" y="193" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="11" data2f="0" data2t="127" sysex="" /></control><control name="YzI=" x="26" y="224" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="12" data2f="0" data2t="127" sysex="" /></control><control name="ZDI=" x="26" y="255" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="14" data2f="0" data2t="127" sysex="" /></control><control name="ZTI=" x="26" y="287" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="16" data2f="0" data2t="127" sysex="" /></control><control name="ZjI=" x="26" y="318" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="17" data2f="0" data2t="127" sysex="" /></control><control name="ZzI=" x="26" y="349" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="19" data2f="0" data2t="127" sysex="" /></control><control name="YTI=" x="26" y="381" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="21" data2f="0" data2t="127" sysex="" /></control><control name="YjI=" x="26" y="412" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="23" data2f="0" data2t="127" sysex="" /></control><control name="YzM=" x="26" y="444" w="156" h="30" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="24" data2f="0" data2t="127" sysex="" /></control><control name="ZHMx" x="101" y="56" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="3" data2f="0" data2t="127" sysex="" /></control><control name="ZnMx" x="101" y="111" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="6" data2f="0" data2t="127" sysex="" /></control><control name="Z3Mx" x="101" y="147" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="8" data2f="0" data2t="127" sysex="" /></control><control name="YXMx" x="101" y="184" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="10" data2f="0" data2t="127" sysex="" /></control><control name="Y3My" x="101" y="238" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="13" data2f="0" data2t="127" sysex="" /></control><control name="ZHMy" x="101" y="274" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="15" data2f="0" data2t="127" sysex="" /></control><control name="ZnMy" x="101" y="329" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="18" data2f="0" data2t="127" sysex="" /></control><control name="Z3My" x="101" y="365" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="20" data2f="0" data2t="127" sysex="" /></control><control name="YXMy" x="101" y="404" w="81" h="28" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" ><midi var ="x" type="1" channel="1" data1="22" data2f="0" data2t="127" sysex="" /></control><control name="b2N0YXZl" x="206" y="34" w="50" h="141" color="yellow" scalef="0.0" scalet="1.0" type="multitoggle" number_x="1" number_y="4" ex_mode="true" local_off="false" ><midi var ="x4" type="0" channel="1" data1="4" data2f="0" data2t="127" sysex="" /><midi var ="x3" type="0" channel="1" data1="3" data2f="0" data2t="127" sysex="" /><midi var ="x2" type="0" channel="1" data1="2" data2f="0" data2t="127" sysex="" /><midi var ="x1" type="0" channel="1" data1="1" data2f="0" data2t="127" sysex="" /></control><control name="dm9sdW1l" x="188" y="189" w="85" h="30" color="green" scalef="0.0" scalet="1.0" type="faderh" response="absolute" inverted="false" centered="false" ><midi var ="x" type="0" channel="1" data1="5" data2f="0" data2t="127" sysex="" /></control><control name="c3ludGg=" x="206" y="312" w="50" h="141" color="orange" scalef="0.0" scalet="1.0" type="multitoggle" number_x="1" number_y="4" ex_mode="true" local_off="false" ><midi var ="x4" type="0" channel="1" data1="9" data2f="0" data2t="127" sysex="" /><midi var ="x3" type="0" channel="1" data1="8" data2f="0" data2t="127" sysex="" /><midi var ="x2" type="0" channel="1" data1="7" data2f="0" data2t="127" sysex="" /><midi var ="x1" type="0" channel="1" data1="6" data2f="0" data2t="127" sysex="" /></control><control name="cmVsZWFzZQ==" x="188" y="260" w="85" h="30" color="purple" scalef="0.0" scalet="1.0" type="faderh" response="absolute" inverted="false" centered="false" ><midi var ="x" type="0" channel="1" data1="10" data2f="0" data2t="127" sysex="" /></control><control name="bGFiZWwx" x="256" y="45" w="20" h="122" color="red" type="labelv" text="T2N0YXZlIFN3aXRjaGVy" size="14" background="true" outline="false" ></control><control name="bGFiZWwy" x="256" y="326" w="20" h="111" color="red" type="labelv" text="U3ludGggU2VsZWN0b3I=" size="14" background="true" outline="false" ></control><control name="bGFiZWw0" x="251" y="221" w="20" h="37" color="green" type="labelv" text="Vm9sLg==" size="14" background="true" outline="false" ></control><control name="bGFiZWw1" x="202" y="222" w="24" h="36" color="purple" type="labelv" text="UmVsLg==" size="14" background="true" outline="false" ></control></tabpage></layout>
#Simple TouchOSC keyboard player for Sonic Pi. Works on iPhone or iPad
#by Robin Newman, May 2017 (updated for SP 3.1amJam talk)
#pdated to use set and get instead of variable passing to live_loops
#use with TouchOSC and phonekeyboardOSC.touchosc
######## SETUP CONNECTIONS ##################
use_cue_logging false
use_midi_logging false
use_osc_logging true
use_osc "172.20.10.5",9000 #address to send osc messages back to touchOSC
#names used for set/get
octo="/octo"
vol="/vol"
relval="/relval"
syn="/syn"
#######INITIALISE TouchOSC selectors #########
osc "/kbd/octave/1/2","1" #set octave switch on TouchOSC
set octo,48#intial octave offset (4 octaves)
set vol,0.5 #initial volume setting
sleep 0.1 #allow OSC link time
osc "/kbd/volume","0.5" #set volume slider on TouchOSC to initial value
sleep 0.1 #allow OSC link time
osc "/kbd/synth/1/3","1" #set inital synth position on TouchOSC
set syn,:saw #initial synth
sleep 0.1
osc "/kbd/release","0.167" #range 0.1->1, slider goes 0->1 0.167-> 0.25 value
set relval,0.25
############# START CONTROL AND NOTE INPUT LIVE LOOPS ############
live_loop :get_vol do
use_real_time
b = sync "/osc/kbd/volume"
set vol, b[0]
puts "vol",get(vol)
end
define :getdata do |address| #decode synth multi-toggle address
return get_event(address).to_s.split(",")[6][address.length+1].to_i
end
live_loop :get_synth do
use_real_time
b = sync "/osc/kbd/synth/1/*"
if b[0]==1 #only respond to button going down
set(syn, [:piano,:tb303,:saw,:fm][getdata("/osc/kbd/synth/1/*")-1]) #offset as counts from 0
puts get(syn)
end
end
live_loop :get_octave do
use_real_time
b = sync "/osc/kbd/octave/1/*"
if b[0]==1 #only respond to button going down
set(octo,24+getdata("/osc/kbd/octave/1/*")*12)
puts get(octo)
end
end
live_loop :get_release do
use_real_time
b = sync "/osc/kbd/release"
set(relval,b[0]*0.9+0.1) #range 0.1->1 for release Slider goes 0->1
puts get(relval)
end
live_loop :play_note do
use_real_time
b= sync "/osc/kbd/[abcdefg]**"
if b[0]>0 #only respond to key going down
puts "key offset",b[0]-1
use_synth get (syn)
play b[0]+get(octo)-1,attack: 0.05,amp: get(vol),release: get(relval) if b[0]!=0#play note, adjusted for offset, with selected amp, and release
puts get(octo),get(syn)
end
end
#karioke sing-along input
##| with_fx :compressor, pre_amp: 4, amp: 2 do
#live_audio :mic,amp: 2
##| end
@Mickiman
Copy link

did as you wrote down on the top.
tried to open it in editor when it says:

Failed to open layout.
File might be corrupted or unreadable

win10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment