Is there a function for "solo" for a block?

Hi everyone! I have different blocks of code and I would like to hear one in particular: is there a kind of function in SPi which makes this, a sort of “solo” function? I can of course mute one by one the others blocks but it would be convenient to hear just one…
Thanks for your attention and help :blush:

1 Like

Either comment out the parts you want muted or use booleans for each part

Ok! Thanks for the quick help! :slightly_smiling_face:

You don’t have to comment out entire blocks. Use the stop command at the top of the loop.

Building on Davids-Music-Lab suggestion, you could do something like this:

a_on = true
b_on = true
c_on = true

solo = "b"
if solo != "none" then
  a_on = false
  b_on = false
  c_on = false
  if solo == "a" then
    a_on = true
  elsif solo == "b" then
    b_on = true
  elsif solo == "c" then
    c_on = true
  end
end

live_loop :a do
  if a_on == true then
    use_synth :cnoise
    play 60, sustain: 0.075, release: 0.0075, amp: 0.5
  end
  sleep 0.5
end

live_loop :b do
  if b_on == true then
    use_synth :chiplead
    play 63, sustain: 0.2, release: 0.05, amp: 0.5
  end
  sleep 0.8
end

live_loop :c do
  if c_on == true then
    use_synth :chipbass
    play 59, sustain: 0.2, release: 0.05, amp: 0.5
  end
  sleep 1.4
end
1 Like

Hello @cubicinfinity and thank you for this excellent bolean trick…I used to make a “solo” block with stop and commenting out but your solution for big patches is very interesting! So, thanks again! :grinning:

Here is an idea for track toggles without a solo function, but with optional control over different sections:

#Track Toggles

#At the top:
set :toggles, [1,0]  #1 is on, 0 is off, one value per track

#Loop 1:
tick  #should be outside the if block
if get(:toggles)[0] == 1
  #Code for the part goes here
  #This track is active
end
sleep 1
#Loop 1 end

#Loop 2:
tick  #should be outside the if block
if get(:toggles)[1] == 1
  #Code for the part goes here
  #This track is inactive
end
sleep 1
#Loop 2 end


#Track Sections

#At the top:
set :toggles, [1,0]  #0 is off, numbers are sections

#In a loop:
tick  #should be outside the if block
if get(:toggles)[0] == 1
  #Code for part 1 goes here
else if get(:toggles)[0] == 2
  #Code for part 2 goes here
end
sleep 1
#Loop end
2 Likes

Hi
just as Davids Music Lab describes, I use a similar idea to mute running loops - but it doesn’t offer the solo functionality, which would require slightly more sophisticated conditional logic, and I’m lazy :wink:

onoff = [0,0,0,0]
/ 1 = on, 0 = off /


live_loop :loop1 do
  if onoff[0] == 1
  then
    play 60
    sleep 1
  else
    stop
  end
  
end

live_loop :loop2 do
  if onoff[1] == 1
  then
    play 67
    sleep 1
  else
    stop
  end
end

Brendan

1 Like

Stopping the loops will lead to sync issues. In your example, the second loop can not start if the first loop is stopped. Also, longer patterns may not start at the right time.
Putting only the play/sample/midi commands in the if block means the loop stays in sync.
For live coding, I use a metronome loop like this to keep everything in sync:

live_loop :metronome do
  tick
  cue :m1  #Quarter Notes
  cue :m2 if (bools 1,0).look  #Half Notes
  cue :m4 if (bools 1,0,0,0).look  #Bar
  cue :m8 if (bools 1,0,0,0,0,0,0,0).look  #Two Bars
  sleep 1
end
3 Likes

Yes indeed, apologies for that oversight in my hastily written example. I also use a master clock in my performance code :wink:

Brendan

2 Likes

Hi @Davids-Music-Lab @cubicinfinity @brendanmac and thanks a lot for your very creative ideas about that simple question of “solo”…I can now try them and choose one or the other depending on the context and length of the code! :blush: :+1:

2 Likes

I’ve been using an array called “playThese”
e.g.

playThese = [:drms, :bass, :lead]

then, in a live_loop, check to see if something is in the “playThese”

live_loop :drums do
   if playThese.include? :drms
      sample :bd_boom
   end
   sleep 1
end

it’s quite easy to “control” a mix of live_loops I’ve found (ergo “solo-ing” loops ?

1 Like

Hello @philAwesomeTech
thanks for your suggestion but I don’t understand how it works exactly.
I wrote these lines of codes inspired by yours:

playThese = [:drms, :bass,:lead]

live_loop :drums do
  if playThese.include? :drms
    sample :bd_boom
    if playThese.include? :bass
      sample :bass_dnb_f
      if playThese.include? :lead
        sample :elec_blip
      end
      sleep 1
    end
  end
end

It works if in the first sentence, I take off :drums and : lead (for instance) then ok I hear only the bass…Is it the right way to do it? :slightly_smiling_face:

Hello @brendanmac ! at the top of your patch why do we need an array with four "'0 " since we only use 0 and 1 to hear or not the sounds?:

onoff = [0,0,0,0]
/ 1 = on, 0 = off /

Thanks for your help…

Hi
sorry, that’s because I was using 4 different loops

Brendan

1 Like

You are nesting the if statements. It should look like this:

if eval1
  sample
end
if eval2
  sample
end
1 Like

Ok Brendan it was also what I supposed! :wink:

It’s clear for me now David, thank you! :slightly_smiling_face: