Skip to content

Commit 7097881

Browse files
committed
Link - Spider - Add new user method: set_link_bpm!
To set the BPM of the Link clock (and all connected network peers)
1 parent 272a931 commit 7097881

File tree

1 file changed

+32
-1
lines changed
  • app/server/ruby/lib/sonicpi/lang

1 file changed

+32
-1
lines changed

app/server/ruby/lib/sonicpi/lang/core.rb

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3562,7 +3562,38 @@ def with_cue_logging(v, &block)
35623562

35633563

35643564

3565-
3565+
def set_link_bpm!(bpm)
3566+
raise ArgumentError, "use_bpm's BPM should be a positive value or :link. You tried to use: #{bpm}" unless bpm == :link || (bpm.is_a?(Numeric) && bpm > 0)
3567+
raise "ArgumentErrot, set_link_bpm! requires a number for the bpm argument in the range 20 -> 999. You tried to use: #{bpm}" unless bpm.is_a?(Numeric) && bpm >= 20 && bpm <= 999
3568+
@tau_api.link_set_bpm_at_clock_time!(bpm.to_f, __get_spider_time)
3569+
end
3570+
doc name: :set_link_bpm!,
3571+
introduced: Version.new(3,4,0),
3572+
summary: "Set the tempo for the link metronome.",
3573+
doc: "Set the tempo for the link metronome in BPM. This is 'global' in that the BPM of all threads/live_loops in Link BPM mode will be affected.
3574+
3575+
Note that this will *also* change the tempo of *all link metronomes* connected to the local network. This includes other instances of Sonic Pi, Music Production tools like Ableton Live, VJ tools like Resolume, DJ hardware like the MPC and many iPad music apps.
3576+
3577+
For a full list of link-compatable apps and devices see: https://www.ableton.com/en/link/products/
3578+
3579+
Also note that the current thread does not have to be in Link BPM mode for this function to affect the Link clock's BPM.
3580+
3581+
To change the current thread/live_loop to Link BPM mode see: `use_bpm :link`",
3582+
args: [[:bpm, :number]],
3583+
opts: nil,
3584+
accepts_block: false,
3585+
intro_fn: false,
3586+
examples: ["
3587+
use_bpm :link # Switch to Link BPM mode
3588+
set_link_bpm! 30 # Change Link BPM to 30
3589+
3590+
8.times do
3591+
bpm += 10
3592+
set_link_bpm! bpm # Gradually increase the Link BPM
3593+
sample :loop_amen, beat_stretch: 2
3594+
sleep 2
3595+
end
3596+
"]
35663597

35673598
def use_bpm(bpm, &block)
35683599
raise ArgumentError, "use_bpm does not work with a block. Perhaps you meant with_bpm" if block

0 commit comments

Comments
 (0)