# Copyleft - Jérôme Prudent
notes = (scale :c, :major)
live_loop :main do
n = notes.choose
# changing this will adapt the amen speed
r = (line 1.5, 2, steps: 20).mirror.tick
# changing this gives a new feeling, the amen may not be suited for all kind of chords
c_type = [:minor7, :major7].choose
set :note, [n,r,0, c_type]
sleep r
end
live_loop :parrot do
n,r,transp, chord_type = sync :note
use_synth :sine
sleep rrand(0.1, 0.2)
parrot = chord(n, chord_type, invert: [0,1,2].choose)
if one_in(2)
parrot = parrot.reverse
end
use_transpose transp
rythme = [0.5, 0.125, 0.250]
play parrot[0], amp: 0.7
sleep rythme.tick
play parrot[1], amp: 0.5
sleep rythme.tick
with_fx :flanger do
play parrot[2], amp: 0.7
sleep rythme.tick
end
end
live_loop :chords do
use_synth :dpulse
n,r,transp, chord_type = sync :note
use_transpose -0
ch = chord(n, chord_type)
with_fx :lpf do
with_fx :reverb do
play_chord ch, attack: 0.2, sustain: [0.5,(r - 1 - 0.2)].max, release: 1, cutoff: 44, amp: 0.7
end
end
sleep 0.1
end
live_loop :rythme do
n,r,transp, chord_type = sync :note
with_fx :ixi_techno, mix: knit(1, 1, 0, 9).choose do
sample :loop_amen, beat_stretch: r, amp: 0.5
end
sleep r-0.1
end
Hi @jrm
Some interesting ideas in your code. Thanks to share you ideas with the sonic pi community !
Okay… I thought I was getting quite good at SP, but your
code has me flummoxed…
You use: set once in your code, in :main
**set :note, [n,r,0, c_type]**
but you never use get: anywhere to bring
back the values…
You use sync in just about every loop:
**n,r,transp, chord_type = sync :note**
but there’s no cue: in the whole of your code.
F1 help on sync: says the following:
Pause/block the current thread until a cue heartbeat with a matching cue_id is received. When a matching cue message is received, unblock the current thread, and continue execution with the virtual time set to match the thread that sent the cue heartbeat. The current thread is therefore synced to the cue thread. …
Yeah… I really need explanation of your control process, please.
Eli…
This is a slightly sneaky one @Eli! it’s understandable that it might not be so obvious though, unless you’ve read specific pages in the lang reference.
You may recall that both set/get
and cue/sync
operate on the time state store. In fact, (Well, not quite, see my further comment below )set
and cue
are equivalent, as are get
and sync
.
So here, @jrm is mixing the two sets of commands - and in this case it works just fine.
Sneaky? SNEAKY?!…
It’s down right underhanded, is what it is Sir!
I call ‘FOUL PLAY’… this is just not Cricket, Sir!!.
Grumble, mutter
Eli…
Actually, forget that
set/get
and cue/sync
are equivalent when it comes to storing and retrieving data in/from the time state. get
doesn’t block. So in that regard, it can’t be used to pause/wait/sleep like sync
.
@samaaron - you will know how it all works - feel free to elaborate or correct me if necessary
I’m pretty sure this is all covered in the tutorial. Please let me know if it’s missing anything: Sonic Pi - Tutorial
Hello @Eli
In section Passing values into the Future of https://sonic-pi.net/tutorial.html#section-10-2 there is an example where a value is get from store using sync. This is a shortcut for cue
+ get
.
I just tried syncing on a loop but I got nothing.
Definitely cricket
Just to be clear, sync
is not a shortcut for cue
+ get
. This thread might help shed some more light:
In particular this section:
Hi! Just checking in for the first time.
If someone has an account on Github, please post the code in there so that people can read it easily. I can’t do that right now. Though I’d like to help the community.
And add a sample audio file too, it is necessary after all. If possible, choose an open format that does not require codes which are not always available for install.
And optimize the page loads for the https://sonic-pi.net/tutorial.html#section-10 page. Just ask a web developer if you’re unsure.
And if you don’t want people to mispronounce your name, use some hints. I don’t care about my name, but some people on other “friendly” forums get really weird about that. And don’t respond kindly to reasonable advice.
Enon, the great
Hi Enon the Great (hum hum…)
What the hell are you talling about ?
If you want to help Sam to keep on developing Sonic PI and give him money to ask help to a web developer do not forget to visit Patreon
Actually I think code snippets like this are much better placed here in the forums. Requiring people to use and understand external sites like GitHub raise the barrier to entry - especially for those that are brand new to programming in general.
Perhaps for much larger and unusual projects there might be some benefit, but in general I highly recommend that people use the forums for sharing and discussing their music code
I wrote the code for the tutorial and manage the website. I’m not quite sure what you mean by “optimising the page loads”. Do you mean compress things? Use a CDN?
It’s only a simple site that doesn’t see huge traffic and I’ve not noticed any overly large page load times or data transfer amounts.