Last active
November 2, 2017 19:16
-
-
Save mbutz/185f50bd9d88febd70ded2606fb47e6f to your computer and use it in GitHub Desktop.
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
# key: live looper | |
# point_line: 1 | |
# point_index: 2 | |
# -- | |
# filename: ctl-live-looper.rb | |
set :metro_vol, 0.5 | |
set :my_bpm, 120 | |
set :playback_master, 10 | |
set :rec_level, 2 | |
set :track1_len, 8 | |
set :track2_len, 16 | |
set :track3_len, 8 | |
set :track4_len, 8 | |
# What this does: | |
# If you press knob no. 1 at Arturia Minilab2 it will evaluate the code from | |
# 'lib-live-looper.rb' and start the recorder | |
# You can switch/arm the tracks from 1-4 with pad 1-4 or disarm all with pad 8 | |
# Press knob 1 again and you will be able to record starting from the next | |
# synchronisation of :metro (as long as 'get(:track[n]_len)'). | |
# Switch tracks, disarm all or press knob 1 again with same track armed to | |
# delete the recording. | |
# Setup: | |
# This controller script can be loaded via snippet 'live looper' | |
# It calls the file: | |
# ~/projects/sonicpi/playground/code/lib/lib-live-looper.rb | |
# via the init.rb referenced as 'live_looper' | |
# Preparation: | |
# Switch Arturia to midi channel 2 (Shift - Pad 2) | |
# Controls (on Arturia Minilab MK2) | |
# Pad 1-4, arm track 1-4 | |
# Knob 1: Evaluate script (start recording) | |
# Knob 13-16, set volume for playback of track 1-4 | |
live_loop :control_change do | |
p = sync "/midi/midi_through_port-0/*/*/control_change" | |
# After pressing knob 1 it will return velocity 127 and immediately velocity 0. | |
# Thus it works as a toggle and runs the code only once it is pressed. | |
if p[0] == 113 and p[1] == 127 then | |
run_file live_looper | |
if get(:track) == 0 then | |
puts "-----------------------------------------" | |
puts "" | |
puts "" | |
puts " No Track armed. " | |
puts " " | |
puts " " | |
puts "-----------------------------------------" | |
else | |
puts "-----------------------------------------" | |
puts "" | |
puts "" | |
puts "Starting recording on TRACK No. #{get(:track)} ..." | |
puts " " | |
puts " " | |
puts "-----------------------------------------" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment