# SuperCollider On Organelle

**URL:** <https://forum.critterandguitari.com/t/supercollider-on-organelle/2051>\
**Category:** Patching\
**Created:** [November 27, 2017, 12:53pm UTC](https://forum.critterandguitari.com/t/supercollider-on-organelle/2051 "2017-11-27T12:53:20Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![thetechnobear](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.critterandguitari.com/thetechnobear/32/42_2.png) [@thetechnobear](https://forum.critterandguitari.com/u/thetechnobear)\
**Post date:** [December 3, 2017, 4:12pm UTC](https://forum.critterandguitari.com/t/supercollider-on-organelle/2051/18 "2017-12-03T16:12:10Z")

</div>

Ok, Its very nearly ready… Im working on mother.scd (mother.pd equiv.) as we speak…

currently, my test polyphonic synth is working… with full organelle functionality 🙂

Actually I quite like SC, as you’ll see below in my example, is really compact for coding things up.

things still left to do for mother.scd

- aux key

- encoder handling

- expression pedal

- volume knob, this will patches using an audio bus, rather than using bus 0 (similar to throw~ in PD)

- vumeter display

- midi  
possibly, similar default CC/note I/O like PD, not decided, as i dont really use this, and it can be patches

Im not planning on initially on multiple page menu, user patches can do that… so think of its a mother.pd (v1).

Im pretty new to SC, so if there are some SC gurus out there that want to help on developing the mother.scd please shout… there are some interesting ‘technical issues’ 🙂

anyway, unfortunately other things to do today… so will be a few days before release , but its getting there !

* * *

Ok, so on to the test synth … and what it looks like…

# code breakdown of main.scd

all in one file, called main.scd, in the Patches directory… like PD.

## Initialisation

notice here how I send messages to the OLED.

```auto
~voices = Dictionary.new;
~cutoff = 5000.0;
~oled.screen(5,"Test Patch Loaded");
~oled.screen(1,format("Cutoff % Hz",~cutoff.asInteger));
```

## knob handling

create a callback function for handling the knobs, and then register it for callbacks (addDependent).  
you can see I also take the opportunity to update the display… and any playing voices.

```auto
~knobfunc = {
    arg func, msg, knob, value;
    if(knob==0, {
        ~cutoff = value.linexp(0,1,50,20000);
        ~oled.screen(1,format("Cutoff % Hz",~cutoff.asInteger));
        ~voices.values.do({ arg v; v.set(\cutoff,~cutoff); }
        );
    });
};
~knobs.addDependant(~knobfunc);
```

## key handling

create a callback function for handling the keys, and then register it for callbacks (addDependent).  
simply here, I create a voice if necessary for the key, and turn it off on note-off

```auto
~keyfunc = {
    arg func, msg, key, vel;
    if(vel>0 , {
        if(~voices[key]!=nil,{~voices[key].set(\gate,0);});
        ~voices[key] = Synth.new(\testSynth,[
            \freq, (key+59).midicps,
            \cutoff, ~cutoff,
        ]
    );
    } , {
        if(~voices[key]!=nil,{~voices[key].set(\gate,0);});
        ~voices[key] = nil;
    };
    )
};
~keys.addDependant(~keyfunc);
```

## a synth to play 🙂

and then a simply synth that has a low pass filter, so I can demonstrate the knobs (via cutoff)

```auto
SynthDef(\testSynth,
    {
        arg freq=440,gate=1,cutoff=440;
        var sig,env,amp=0.3;
        sig = Saw.ar(freq);
        env = EnvGen.ar(Env.adsr(),gate,doneAction:2);
        sig = sig * env * amp;
        sig = LPF.ar(sig,cutoff.clip(10,24000));
        Out.ar(0,sig!2);
    }
).add;
```

---

_[View the full topic](https://forum.critterandguitari.com/t/supercollider-on-organelle/2051)._
