Hello @morte_conscio Sure.
What is the specific challenge you are having? are you not sure of the correct commands to use? the correct sequence of commands/algorithm to use? both?
Have you got any initial thoughts about the rough procedure, if it were described in plain (not code) language? (This is a very useful technique when thinking about solving a programming challenge!)
You are already half way there, because you are already iterating through the ring of onsets
The first question to answer is probably something like ‘how do we know when the right onset is ready to play so that we can reverse it?’.
Then, we can figure out a way to check it. As is common in many programming situations, there’s several ways we can do this - we could check the specific value of the current onset; we could check the position of the current onset in the slice ring; etc.
Given that, it’s just a matter of then using this to change the rate if the onset is the right one.
Maybe have a read through the tutorial chapter on Ticking: Sonic Pi - Tutorial, especially where it talks about look.
If none of this gives you any further clues, I’m happy to point you closer towards your goal
Sure! So, it’s probably simpler if you just base the choice of rev directly on the slice, rather than tracking it with an entirely separate ring.
For that, it might be worth checking out https://sonic-pi.net/tutorial#section-5-3 - Conditionals - that may clarify for you how you can say ‘if something something, do XYZ’. All you’d need to do is have that conditional statement change the rev based on the value of the slice
Hey @nlb , thank you for advice. I didn’t know about this case and when function, also didn’t find them in the sonic pi tutorial. Just one more question, does it have some diference using the ring outside or inside the live_loop?
##| r = (knit 8, 5)
r = (knit 6,4, 1,4, 4,3, 6,1, 0,2)
puts r
live_loop :vapor do
foo = r.tick
puts foo
if foo == 6
rev = -1
elsif foo ==4
rev = 1.5
else
rev = 1
end
##| case foo
##| when 6
##| rev = -1
##| when 4
##| rev = 1.5
##| else
##| rev = 1
##| end
sample :loop_amen_full, amp: 2, rate: rev, onset: foo, lpf:80,
sustain: 0.25
sleep 0.25
end
If you don’t need your ring in another live_loop you can put it inside the live_loop otherwise you need to set it into the main “scope” outside the live_loop.