sonic-pi icon indicating copy to clipboard operation
sonic-pi copied to clipboard

Feature Request: Onw synth creation

Open merspieler opened this issue 6 years ago • 5 comments

I want to be able to create my own synths.

I could imagine the code to look like this (sorry for the C++ style :P)

lead = Synth.new();
lead.addOscillator("Saw"); // Add saw oscillator
lead.addOscillator("Saw").pitch(-12).detune(13); // Add saw oscillator pitched 12 lower than the played one and with some detune
lead.setUnison(8); // Number of unison voices. default: 1 max: ?
lead.setUnisonDetune(70); // detune of the unison voices. Default: 0 max: 100
lead.setUnisonPaning(65); // makes some voices go left and others right. Default 0: max: 100
lead.add(Effect.new("Reverb")); // Add reverb effect
lead.add(Effect.new("Delay"));
lead.setFliterMode("LP"); // set filter to low pass

And then I can use lead as any already existing synth but I still can tweak the synth if I feel like it.

I think you get the picture of what new cool stuff could be done with this.

I'd really want to see this since the synths are actually what is stopping me to use sonic-pi in a productive way.

merspieler avatar Jul 05 '19 08:07 merspieler

Hi,

to create your own synths, you need to design them using the SuperCollider language then load them in using the load_synthdefs fn. Take a look at this excerpt from the the docstring for load_synthdefs:

If you wish your synth to work with Sonic Pi’s automatic stereo sound infrastructure you need to ensure your synth outputs a stereo signal to an audio bus with an index specified by a synth arg named out_bus. For example, the following synth would work nicely:

(
SynthDef(\piTest,
         {|freq = 200, amp = 1, out_bus = 0 |
           Out.ar(out_bus,
                  SinOsc.ar([freq,freq],0,0.5)* Line.kr(1, 0, 5, amp, doneAction: 2))}
).writeDefFile("/Users/sam/Desktop/")
)

samaaron avatar Jul 05 '19 08:07 samaaron

The help says something about precompiled files. I've installed supercollider but couldn't figure out, how to compile the example.

merspieler avatar Jul 05 '19 08:07 merspieler

Never mind, i've figured it out with scide... tho i still would prefer to manipulate the synth live

merspieler avatar Jul 05 '19 08:07 merspieler

@merspieler you can sort of manipulate them live if you put load_synth_defs within your live loop:

live_loop :foo do
  load_synthdefs "/path/to/synths/folder"
  synth "your_super_synth"
  sleep 0.125
end

If you run this live loop, then in scide redefine and write a new synthdef file to that folder, it will be automatically reloaded and used next time round the live loop.

samaaron avatar Jul 21 '19 18:07 samaaron

hm... I've currently parameterized the synth. Tho I haven't tested, if it works.

(
SynthDef(\Lead,
{
                arg freq=440, amp=1, out_bus=0, revWet=0.33, cutoff=22000, attack=0, decay=3, sustain=1, release = 0.3;
// More stuff here
                // Output
                Out.ar(0, left);
                Out.ar(1, right);
}
).writeDefFile("/home/myuser/synths")
)

merspieler avatar Jul 23 '19 00:07 merspieler