SCAMP and SuperCollider tutorial!

Hi everyone! I just put together a tutorial on connecting SCAMP to SuperCollider. Check it out:

It starts by going over all of the OSC messages that SCAMP sends and then shows how to use the ScampUtils extension to easily turn a SynthDef into a playable instrument in SCAMP.

Hope this is useful to you all!

4 Likes

Thanks for making this! Very excited to work in both SCAMP and Supercollider. I’m working through this tutorial and scamp and sc, and have copied the scripts for both python and SC exactly, however, when I run the python script, I’m not getting any OCS messages to register in SC. I’ve double checked the port number. Not sure why the messages aren’t coming through. Any thoughts?

Editing this post because I’ve resolved the problem! I forgot to run the OSCFunc before running the python code. Its working as expected now.

1 Like

OK now that I’ve finished the tutorial, I do have another question!

In the scripts in this tutorial you are sending midi pitch values to SC and this is converted to a frequency.

Is it possible to send a freq value (in Hz) from scamp/python to SC, or does it have to be a midi pitch value?

1 Like

SCAMP always uses MIDI numbers for pitch, but you can easily convert using a utility function from the scamp_extensions package. It can even take a list and return a list, which is useful for chords:

from scamp_extensions.pitch import hertz_to_midi
...
sc_inst.play_note(hertz_to_midi(760), 1, 1)
sc_inst.play_chord(hertz_to_midi([760, 860, 960]), 1, 1)
1 Like

thanks!

Hi Marc! I’m still loving these tools you’ve created, and have another question here about scamp and supercollider:

In your example, the synth goes on forever, and so the duration of the envelop is controlled by dur passed to the play_note function. What happens if I use a synth that has an a built in duration, as in the code below. I guess my question is: how is time and tempo managed between SC and scamp? Is there a way to pass the tempo to sc, because I think what’s happening with this synth is that the scamp dur is in beats and the sc dur is in seconds, so I’m not getting the expected note lengths.

ScampUtils.instrumentFromSynthDef(
SynthDef(“additiveSynth”, {
arg volume = 0.9, freq= 440, ris = 0.1, dur = 2, gate = 0;
var env = EnvGen.kr(Env([0, 1, 0], [ris, dur - ris], [4, -4]), gate);
var sine = SinOsc.ar(freq, 0);
Out.ar(0, sine * volume * env)
})
)

This is an interesting issue you’ve found! The problem is that SCAMP doesn’t pass the duration to the synthdef at the start of the note; it just sets the gate on and off. For your use case, and other similar use cases, this is a bit of an issue.

A good work around for now might be to use an extra playback parameter, and pass it the duration of the note multiplied by the beat length of the current clock, e.g. in Python:

sc_inst.play_note(pitch, volume, duration, {"param_dur": duration * current_clock().beat_length})

It’s a little hacky and redundant, but it should pass along the tempo-modified duration to the dur argument in your SynthDef.

Let me know if that works, and if it makes sense!

Yep, this makes sense and yes I added a conversation factor using session.tempo and it worked just fine!

1 Like