Eli , I don’t actually kill live_loops in the program but use stop
to stop them. I use kill
to kill a playing sample as documented in the help files.
In the same way I don’t use kill on an fx. I stop the live loop inside the fx, but don’t touch that directly. By calling the live_loop inside a function each time it is possible to restart it.
My final code is now available at
ReadMe.md
The original question was concerned with using mekey-makey as the "swtich input" source.
Here I have used a TouchOSC templaret with 11 pushbuttons on it as the input source. To make it more interesting,
I also drive a large "LED" on the TouchOSC screen with OSC commands from the Sonic Pi program.
The program has been streamlined to use just ONE live loop to detect the switches being pushed,
and another to detect them being released. Sonic Pi supports wild cards in OSC addresses, and using the undocumented get_event
function I have parsed the received address and obtained the information as to which switch has been acticated.
In the original development separate live Loops were used for each button.
Also, in teh first versions I dewveloped separate functiosn for dealing with each button, which led to some repetition in code.
IN this version I have developed generic functions for each required use, into which the samples to be used, pus information
about which button has been pressed can be fed.
This file has been truncated. show original
SPloopController.rb
#Sonic Pi Loop Controller by Robin Newman
#Tested on a Mac, but may work with some modification on a Pi3
#in particular uses some new :loop samples only in version 3.1
#These can be copied to teh samples folder on version 3.0.1 if required
#or you can specify different ones.
#Also may have to cut down use of fx calls on Pi3 as may overload it otherwise.
#This version uses 11 push buttons on TouchOSC for input and 1 LED on TouchOSC for output
#Can be modified to use any suitable OSC source thant can give on/off signals when a button is pressed
use_real_time
use_osc "192.168.1.240",9000 #adjust for output IP to which to send LED on/off signals (TouchOSC)
This file has been truncated. show original
index.xml
<?xml version="1.0" encoding="UTF-8"?><layout version="16" mode="0" orientation="horizontal"><tabpage name="MQ==" scalef="0.0" scalet="1.0" li_t="" li_c="gray" li_s="14" li_o="false" li_b="false" la_t="" la_c="gray" la_s="14" la_o="false" la_b="false" ><control name="bGVkMQ==" x="19" y="81" w="275" h="275" color="brown" scalef="0.0" scalet="1.0" type="led" ></control><control name="cHVzaDE=" x="132" y="84" w="45" h="45" color="red" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDI=" x="194" y="106" w="45" h="45" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDM=" x="238" y="164" w="45" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDQ=" x="237" y="226" w="45" h="45" color="orange" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDU=" x="194" y="283" w="45" h="45" color="yellow" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="bGFiZWwx" x="19" y="26" w="268" h="25" color="yellow" type="labelh" text="U29uaWMgUGkgTG9vcCBDb250cm9sbGVy" size="18" background="true" outline="false" ></control><control name="bGFiZWwy" x="29" y="372" w="247" h="25" color="red" type="labelh" text="UHJlc3MgYnV0dG9ucyB0byBjb250cm9sIGxvb3Bz" size="14" background="true" outline="false" ></control><control name="cHVzaDY=" x="132" y="306" w="45" h="45" color="red" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDc=" x="74" y="281" w="45" h="45" color="yellow" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDg=" x="32" y="226" w="45" h="47" color="orange" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDk=" x="31" y="167" w="45" h="45" color="blue" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDEw" x="73" y="110" w="45" h="45" color="green" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="cHVzaDEx" x="134" y="193" w="45" h="45" color="pink" scalef="0.0" scalet="1.0" type="push" local_off="false" sp="true" sr="true" ></control><control name="bGFiZWwz" x="64" y="408" w="178" h="20" color="blue" type="labelh" text="d3JpdHRlbiBieSBSb2JpbiBOZXdtYW4=" size="14" background="true" outline="false" ></control></tabpage></layout>