Skip to content

introduced run_count var#3523

Open
hq9000 wants to merge 1 commit intosonic-pi-net:devfrom
hq9000:introduce_run_count_var
Open

introduced run_count var#3523
hq9000 wants to merge 1 commit intosonic-pi-net:devfrom
hq9000:introduce_run_count_var

Conversation

@hq9000
Copy link
Copy Markdown

@hq9000 hq9000 commented Apr 12, 2026

This PR introduces a run_count var that shows how many reruns (Alt+r) have happends after full stop (Alt+s). This var is available for user code which can use its value (distinguishing between run_count == 1 - first run and runt_count >1 - subsequent runs).

Example:

live_loop :control_loop do
  print run_count
  sleep 1
end

One application of this is to be able to "control effects dynamically", as discussed in this thread and is based on the idea of a workaround proposed here.

With run_count available, the problem of controlling FX is solved as follows

#experimenting with changing cutoff using a single command line
#by Robin Newman

set :st,sample_duration(:loop_amen) #store duration of the sample

with_fx :rlpf, cutoff: 120 do |c|
  
  # This is the original workaround:
  # set :cv,c #comment after first run from stop, before re-run
  
  # This is how how we do it with `run_count`, no need to comment the code!
  set :cv,c if run_count == 1
  
  control get(:cv),cutoff: 120,cutoff_slide: get(:st)
  #                        ^^^
  #               change this number and hit Alt+r
  #                you will hear the changes
  
  live_loop :loop do
    print run_count
    st=get(:st)
    sample :loop_amen
    sleep st
  end
end

@hq9000 hq9000 force-pushed the introduce_run_count_var branch from 30f32a9 to 6412b87 Compare April 12, 2026 16:16
@hq9000 hq9000 force-pushed the introduce_run_count_var branch from 6412b87 to 8b1fee4 Compare April 12, 2026 16:18
@rbnpi
Copy link
Copy Markdown
Contributor

rbnpi commented Apr 12, 2026

Could be useful, although one potential problem. I'm not sure that the run count would be unique to a given code buffer. If you run a different code buffer to the one containing your example code and then switch that your example code buffer with the first one still running, then when you press run it will register >1 for the count.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants