nlb
January 20, 2021, 4:41pm
1
Hi,
just stucked with tick
roots = (ring :c, :f, :g, :g)
live_loop :chords do
use_synth :piano
root = roots.tick
play chord root, 'major'
sleep 4
end
live_loop :bass do
use_synth :fm
play roots.look
sleep 1
end
I want the root note to change every four beats and the chord playing the root major one every beat but change at 4
Ideas ?
emlyn
January 20, 2021, 6:17pm
2
What about:
live_loop :bass do
use_synth :fm
tick
4.times do
play roots.look
sleep 1
end
end
Tick is local to the thread (or live_loop) it’s used in, not connected to the collection you use it on.
Martin
January 20, 2021, 7:57pm
3
Hi,
sorry, do not have the time to figure out an example that fits your case but I am pretty sure Modulo could help here also. See here for some examples if you like. As always in these cases this comes without warranty as it is not part of SP core.
nlb
January 20, 2021, 8:23pm
4
Thanks both of you. I will see it tomorrow but I missed the point that tick was independent of the collection. See you
Eli
January 20, 2021, 11:15pm
5
Sorry to hijack the thread, but whilst messing with your
code I came across this beautiful drone…
roots = (ring :c, :f, :g, :e)
live_loop :drone do
use_synth [:fm , :hollow].choose
tick
4.times do
play chord(roots.look, :minor ), attack: 4, release: 2
sleep 1
end
end
Eli…
1 Like
nlb
January 21, 2021, 8:03am
6
Hi,
Okay so now i understand the tick way thanks to your help !
this piece of code allows to change the chord nature based on a root note determined.
roots = (ring :c, :f, :g, :e)
use_bpm 180
live_loop :chords do
use_synth :dark_ambience
use_synth_defaults attack: 0.15, sustain: 4.05, cutoff: 80, amp:2
play chord roots.tick, (ring "major","major", "sus4", "7").tick(:accords)
sleep 4
end
live_loop :bass do
use_synth :fm
bass_note = roots.tick
4.times do
play bass_note, amp: 0.5
sleep 1
end
end
Concerning the named tick, this syntax seems to be equal to this one. The doc talks only about the :foo
way.
play chord roots.tick, (ring "major","major", "sus4", "7").tick("foo")
play chord roots.tick, (ring "major","major", "sus4", "7").tick(:foo)
Is it normal ?
It is allowed, (and means the same thing) but (I’m guessing) not mentioned in docs for simplicity’s sake.
As the source code shows, a string is just converted to a symbol:
def self.get_or_create_counters counters = __thread_locals.get(:sonic_pi_local_core_thread_local_counters) return counters if counters counters = {} __thread_locals.set_local(:sonic_pi_local_core_thread_local_counters, counters) counters end def self.tick(k = :___sonic_pi_default_tick_key___, *args) k = (k && k.is_a?(String)) ? k.to_sym : k if k.is_a? Symbol opts = args.first || {} else opts = k k = :___sonic_pi_default_tick_key___ end raise "Tick key must be a symbol, got #{k.class}: #{k.inspect}" unless k.is_a? Symbol raise "Tick opts must be key value pairs, got: #{opts.inspect}" unless opts.is_a? Hash step = opts[:step] || 1
1 Like