Hello! I’ve been using the OpusModus SC library
Forums/more info: SuperCollider - Opusmodus
And I kept getting an error with my synthdef and finally tried it in Supercollider both in the application and terminal (sclang on mac). I’m getting an error, but I’m not sure how to fix it and it seems to be on the supercollider side. I may have bitten off more than I can chew on this synth so I’m hoping someone with more supercollider under their belt than me (I’m nostly OpusModus) can explain what’s wrong here.
Any advice is appreciated!
// Define the Mechanism Synth
(
SynthDef(\mechanism, {
|freq = 440, amp = 0.5, pan = 0, finePitch = 0, pitchControl = 0|
// Oscillator parameters
var superiorOsc, inferiorOsc, crossfade, adsr, ringMod, insectNoise, filterSet, finalOutput;
// Superior Oscillator Set
superiorOsc = {
var parabolic = SinOsc.ar(freq + pitchControl + finePitch, 0, amp);
var sine = SinOsc.ar(freq + pitchControl + finePitch, 0, amp * 0.5);
crossfade = XFade2.ar(parabolic, sine, 0.5); // Crossfade between oscillators
adsr = EnvGen.ar(Env.perc(0.01, 0.5), doneAction: 2); // ADSR envelope
ringMod = Ringz.ar(crossfade, 440, 0.1); // Ring modulator
ringMod * adsr
}.dup; // Duplicate for stereo
// Inferior Oscillator Set
inferiorOsc = {
var parabolic = SinOsc.ar(freq + pitchControl + finePitch, 0, amp);
var sine = SinOsc.ar(freq + pitchControl + finePitch, 0, amp * 0.5);
crossfade = XFade2.ar(parabolic, sine, 0.5); // Crossfade between oscillators
adsr = EnvGen.ar(Env.perc(0.01, 0.5), doneAction: 2); // ADSR envelope
ringMod = Ringz.ar(crossfade, 440, 0.1); // Ring modulator
ringMod * adsr
}.dup; // Duplicate for stereo
// Insect Noise
insectNoise = {
var noise = WhiteNoise.ar(0.1);
var hpFilter = HPF.ar(noise, 2000); // High-pass filter
var lpFilter = LPF.ar(hpFilter, 5000); // Low-pass filter
lpFilter
}.dup; // Duplicate for stereo
// Filter Set
filterSet = {
var cutoff = 1000; // Example cutoff frequency
var resonance = 0.5; // Example resonance
var filteredSuperior = BPF.ar(superiorOsc, cutoff, resonance);
var filteredInferior = BPF.ar(inferiorOsc, cutoff, resonance);
[filteredSuperior, filteredInferior]
}.dup; // Duplicate for stereo
// Final Output
finalOutput = (filterSet[0] + filterSet[1] + insectNoise).tanh; // Combine and limit
finalOutput = Pan2.ar(finalOutput, pan); // Panning
Out.ar(0, finalOutput * 0.5); // Output to speakers
}).add;
)
// Create the synth and assign it to x
x = Synth(\mechanism);
x.free; // Uncomment this line to free the synth when done