Hi @enkerli,
very, very nice! Overtones, especially in a row, do have a very distinct magic.
As to your “autosample”: I don’t know exactly what you are aiming at, but my different experiments to create a live looper for Sonic Pi (e. g. here and here - very old and ugly code!) somehow seem to go into this direction. I meant to record external (e. g. another musician) and internal sound (meaning: route SP sound back into SP); this is then immediatelly available as a sample within SP.
In addition to that I couldn’t resist to start turning your code into a little ‘overtone sequencer’ as I had already a sequencer sketch written down. The idea is, that you fill an array (or more precisely: a ring) as a kind of buffer with notes (in this case: overtones), which you can then play in different modes; right now the mode is just the direction of notes (up, down, up and down, reverse, random). I used a similar script to create a simple midi sequencer for my Make Noise 0-coast to play with…
You can tweak the parameters while playing (which is the main idea, of course), but it is just a very rough sketch and a quick test shows: it is buggy (also I did not manage yet to incorporate your dynamic use of amp and release) … but you will get the idea:
set :partials, 32
set :dura, 0.075
set :pdamp, 0.5
set :fund, 60
set :mode, "mirror" # default, "reverse", "mirror", random
use_synth :sine
use_synth_defaults attack: 0.05, sustain: 1
overtones = []
defonce :init do
set(:overtones, (ring :r))
end
live_loop :build_overtones do
get(:partials).times do
sleep get(:dura)
cnt = (tick % get(:partials)) + 1 # we need 1-based indexing
freq = hz_to_midi(get(:fund) * cnt)
if overtones.size < get(:partials)
overtones.push(freq)
end
end
set(:overtones, overtones.ring)
sleep get(:dura) * get(:partials)
overtones = []
end
# play_overtones
live_loop :play_overtones do
p = get(:partials)
cnt = (tick % p) + 1
#use_synth_defaults amp: 1/(get(:pdamp) * cnt), release: (p - cnt + 1) * get(:dura)
case get(:mode)
when "reverse"
play get(:overtones).reverse.look
when "mirror"
play get(:overtones).mirror.look
when "random"
play get(:overtones).shuffle.look
else
play get(:overtones).look
end
sleep get(:dura)
end