Controlling parameters as in Supercollider


#1

Is there some way possible to control a parameter in Sonic Pi using e.g a sine wave and mapping this to a value?

E.g in Supercollider one could write:
{ var mod = SinOsc.kr(1); SinOsc.ar(LinLin.kr(mod, -1,1, 900, 1900))*0.1 }.play;

Is there some way to get the same result in Sonic Pi?


#2

Are you playing with custom SynthDefs made in SuperCollider or are you trying to play with the built-in synthesizers proposed by Sonic-Pi ?


#3

I think Supercollider offer some great possibilities but for me it is to complex to be creative with the tool. For that reason I like to work in Sonic Pi. However one thing I really like in Supercollider is the creative possibility to use dynamic variables, and I was just wondering if anyone knew of similar possibilities in Sonic Pi. It could be used for a number of applications. Eg if one had a variable declared as:

value = SineWave(1).range(0,1)

This would output values from 0 to 1 in a sine cycle of 1 second. This could be used with effects e.g:

    live_loop :q1 do
      with_fx :reverb, mix: value
        play :C
      sleep 1
    end

Or with play:

live_loop :q1 do
    play :C, amp: value
  sleep 1
end

Or maybe to change the tone itself:

value = SineWave(1).range(100,1500)
      live_loop :q1 do
           play hz_to_midi(value),sustain: 60
          sleep 100
        end

#4

Oh I see. I don’t think that Sonic-Pi can output continuous values right now, but the software is really good at faking it so I definitely see a few ways to achieve this. Here is a very short example. I am sure that you can try to play with this (line) operator to do what you are thinking about:

live_loop :sin do; tick
  with_fx :level, amp: (line 0, 1, steps: 10).mirror.look do
    play :c4, release: 0.1
    sleep 0.1
  end
end

EDIT: another example changing frequency (beware, it’s loud):

live_loop :sin do; tick
  with_fx :level, amp: (line 0, 1, steps: 10).mirror.look do
    a = (line 400, 600, steps: 20).mirror.look
    play hz_to_midi a
    sleep 0.1
  end
end

You may be able to refine this using the slide values, but I never really played with this!


#5

Many thanks Bubo!

I have been playing around with line now and I see many potential creative uses for this. Thanks for pointing me in that direction :grinning:

Are there other functions like this I should know about? I asume using line without the mirror part would simulate a saw tooth wave, but maybe there are other ones I have missed?


#6

Take a look at the bottom of section 8.4 of the tutorial on “Ring Constructors”:

https://sonic-pi.net/tutorial.html#section-8-4


#7

Yes. There is a bunch of them and a bunch of methods to make it even more precise. Some of them are rarely used but you may find yourself using them some day. Like @samaaron said, everything is detailed in the doc.


#8

Many thanks for the advise Sam Aaron and Bubo! I really like playing with these kinds of constructs and I look forward to dive in and understand how they work. Just one follow up… In 8.4 under the constructors it says Take a look at their respective documentation for more information. Do you know where I can find this additional documentation? Thanks again so much :+1::grinning:


#9

It’s in the Lang section of the built-in help system. You can also hit C-i when the cursor is over the function name you’d like to see the documentation of :slight_smile:


#10

Brilliant! Thanks again for your advises :grinning: