Granular Synth with Sonic Pi?

Is it possible to make granular synthesis with sonic pi?

Hi @laminak,

welcome to the forum and Sonic Pi!

I am also interested in this subject!

There are to my knowledge no explicit functions for granular synthesis within Sonic Pi. But as the definition of “Granular Synthesis” seems to cover quite a lot of ground and the associated techniques are very diverse, you can cerntainly use sample and its options (like num_slices, slice and of course the envelope) to do something which fits into this category.

Moreover there is at least one sketch by @xavierriley which is about granular synthesis. I do not know the current state of it.

@laminak: Martin is right about playing with the sample slices. The sampler can somewhat fake a granular in some circumstances even if it’s not like the real thing. This is a good thing to start with. For more precision and detail, maybe you can try to play with the :slicer effect. There is tons of options and some of them I guess can be really useful for granulation purposes. Sometimes, when the grains are too sparse, I like to smooth the mix by adding a little touch of the :echo effect.

However, I don’t think that you will be easily able to create some more advanced granulation techniques. But all this is a good starting point.

Don’t forget that you can also use external ressources and control them using OSC or MIDI. That’s the most obvious non-vanilla solution to your problem.

Hi @Martin & @Bubo

Thanks for your answers, i will test this and i will come back to discuss my results.

 s = 0.0
 live_loop :slicer do
    32.times do
        sample :loop_amen, start: s, finish: s + 0.05
    if s < 0.9
       s += 0.01
       s = 0.0
   sleep (sample_duration(:loop_amen) / 20)

It works but it is very unstable on my configuration. The code will stop running after a while because Sonic-Pi cannot keep up with the timing.