sonic-pi-net / sonic-pi

Code. Music. Live.
https://sonic-pi.net
Other
10.75k stars 918 forks source link

How to randomly choose between FX? #1731

Closed petayan closed 6 years ago

petayan commented 7 years ago

Hi guys,

I´m a musician and total coding noob, so my question is probably very easy for you to answer. I´m searching for at way to make Sonic Pi choose between random effects for samples (but it might as well apply to the synths)

I was thinking of something like this:

live_loop :arpeggio do

random_fx = (with_fx :distortion, with_fx :flanger, with_fx :bitcrusher).choose

with_fx :random_fx, mix: rand(1) do sample samps, 0, beat_stretch: 11.5, cutoff: 110, pan: rrand(-1, 1) sleep 11.5 end end

But of course it doesn´t work:-) What do I do wrong?

Greetings Peta

nicoder commented 7 years ago

Hi Peta,

if you define your random effect this way:

random_fx = [:distortion, :flanger, :bitcrusher].choose

you can then use it this way:

with_fx random_fx, mix: rand(1) do

for example:

live_loop :arpeggio do random_fx = [:distortion, :flanger, :bitcrusher].choose with_fx random_fx, mix: rand(1) do with_fx :level, amp: 2 do sample :tabla_dhec, 0, beat_stretch: 1, cutoff: 110, pan: rrand(-1, 1) sleep 1 end end end

nico

On Wed, Sep 20, 2017 at 10:19 AM, petayan notifications@github.com wrote:

Hi guys,

I´m a musician and total coding noob, so my question is probably very easy for you to answer. I´m searching for at way to make Sonic Pi choose between random effects for samples (but it might as well apply to the synths)

I was thinking of something like this:

live_loop :arpeggio do

random_fx = (with_fx :distortion, with_fx :flanger, with_fx :bitcrusher).choose

with_fx :random_fx, mix: rand(1) do with_fx :level, amp: 2 do sample samps, 0, beat_stretch: 11.5, cutoff: 110, pan: rrand(-1, 1) sleep 11.5 end end end

But of course it doesn´t work:-) What do I do wrong?

Greetings Peta

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/samaaron/sonic-pi/issues/1731, or mute the thread https://github.com/notifications/unsubscribe-auth/AAWSmnUyo8_m42b8JVgREc7jKlu5IfFpks5skMqbgaJpZM4PdgYO .

petayan commented 7 years ago

Nico! I love you, man:-)

Thanks a lot!!!

samaaron commented 6 years ago

Hi there,

this is a fab question and also a super answer, thanks @petayan and @nicoder.

I'm closing this for now, but for future reference, this kind of discussion would be wonderful over on our forums: https://in-thread.sonic-pi.net :-)