Hi, my first idea was to build my file using switches to mute/unmute live_loops during performance.
it seems that i miss something here during expressing my conditions.
use_sample_bpm :loop_amen
use_debug false
########## LivePad Mixer :
# PLAY-SWITCHES
switch = 1
switchPhone = 1
switchBeat = 0
# PARAM-VALUES
sTime = 1
mainSync :dnb
### PAD 1 SETUP :
with_fx :rlpf, cutoff: 10, cutoff_slide: 4 do |c|
live_loop :dnb do
if switch == 1
sample :bass_dnb_f, amp: 4
sample :loop_amen, amp: 5
sleep sTime
sample :bass_dnb_f, amp: 5
sample :loop_amen, amp: 4
sleep sTime
sample :bass_dnb_f, amp: 4
sample :loop_amen, amp: 5
sleep sTime
sample :loop_amen, amp: 5, onset: pick
sample :bass_dnb_f, amp: 4
sleep sTime
sample :bass_dnb_f, amp: 5
sleep sTime
play 44
sample :loop_amen, amp: 5, onset: pick
#sample :bass_dnb_f, amp: 4
sleep sTime
#sleep sTime
control c, cutoff: rrand(100, 120), cutoff_slide: rrand(1, 3)
else
sleep 1
end
end
end
with_fx :ixi_techno do
live_loop :effects do
#sync mainSync
if switchPhone == 1
sample :mehackit_phone3, amp: 0.9
sleep 1
else
sleep 1
end
end
end
###----------------------------------------------------------
define :simpleKickSample do
sample :bd_tek, rate: 0.8, amp: 3
end
live_loop :DRUMS do
#sync mainSync
if switchBeat == 1
simpleKickSample
sleep 0.25
else
sleep 0.25
end
end
As you can see, i was thinking a simple condition will allow me to control those loops, but it seems that something is wrong. Also i was looking for a way to āMuteā straight a running loop, but i didnt find the coresponding docā¦
Alsoā¦ i was surprised to read the doc and only find an exemple of a simple condition (like a bool) and not something about āelse ifā, and double conditionsā¦ is this so obvious that it is not present in the educational doc ?
Technically, those simple conditions will in fact work.
It may be helpful for you to describe in more detail what you are observing that is āwrongā.
There is no built-in volume control for an individual loop. This has been thought about a little bit, and may be introduced in a future update, but itās not yet fully discussed.
In the meantime, there are several ways to āmuteā a loop:
one is to use a variable in much the same way that you have, that either causes the code to play nothing, or play sound at a volume of zero (either individual synths, or by wrapping the loop contents in a :level fx and causing that to respond to the volume variable).
Another is to use kill to stop individual synths or fx that are already playing, as nlb refers to above.
still another is to use the stop function to halt a loopās execution altogether.
There may be other techniques that Iām forgetting.
I canāt say for sure about the exact reason for this.
While the tutorial covers āelseā in chapter 5.3 - āConditionalsā:
Perhaps it was decided that complex multi-conditional statements (else-if/case/switch type statements etc) were not useful to cover in the documentation or include as āofficial Sonic Pi languageā for the original target audience of Sonic Pi (young school children learning the very basics of computing through live-coding). There may be merit in adding such information to the tutorial, but itās up to Sam really
Hi Ethan,
Thanks for all thoses detailsā¦ this community is new to me, and i always prefer asking when i dont find what i need for the course of for myself. Anyway, conditional statements is generaly in the first part of any coding book, and i was surprised that nothing refers to it. In general, that one of the first block of code that students try to implement. but i would t be rude or anything, i know how documentation release is a pain.
by wrapping the loop contents in a :level fx and causing that to respond to the volume variable
yes, much better ! i dont really need to kiil any process at this stage, i am not running out of memory, so you are completely right, level change (mix) will be perfect. i gonna apply this right now. thank you.
and set different values during performance for mutes, dynamic changes etc.
There are quite a few implementations out there, all revealing slightly different approaches to solve the issue. Just have to spend the time going through them all and adapting them to your requirements.
Hi Hussein, thanks a lot, looks what i needā¦ in this manners, it is very easy to include a kind of ācode blocksā that will serve the purpose of control UI for performanceā¦ great !
the on/off switch ! butā¦ wait a minuteā¦ i didn t see anything in the params of the Beep synth with this optionā¦ but it works for any of thoses synths ! so powerful! and very practical for live set !