Synth error

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
filterSet = {
    var cutoff = 1000;
    var resonance = 0.5;
    var filteredSuperior = BPF.ar(superiorOsc, cutoff, resonance);
    var filteredInferior = BPF.ar(inferiorOsc, cutoff, resonance);
    [filteredSuperior, filteredInferior]
}.dup;

// adding arrays with different dimensions- NON VA BENNE with audio
// (Maybe in APL it would unfold into something fun)

finalOutput = (filterSet[0] + filterSet[1] + insectNoise).tanh;

I think there is a mistake in how the array was manipulated. I think the result is not a stereo signal but a nested array. Just removing the .dup with some changes may adjust it. (I can’t test now, and don’t know the context you’re using)



filterSet = {
    var cutoff = 1000;
    var resonance = 0.5;
    [
        BPF.ar(superiorOsc[0], cutoff, resonance),
        BPF.ar(inferiorOsc[0], cutoff, resonance)
    ]
}.value; // REMOVE .dub

// at index to access one channel, then mix
finalOutput = Mix([filterSet[0], filterSet[1], insectNoise]); 
finalOutput = finalOutput.tanh;

If yout want to Mix, you now have arrays with the exact same shape (one dimension)

Note that the .tanh is on the following line to look cleaner. No reason other than that.

BTW… What is OpusModus? Are you using the Common Lisp client?

That worked thank you!

To answer your question - OpusModus is a composition system written in common LISP, you’re correct.
OpusModus is a little different from mosty musical systems in that it is focused on structure, harmony, microtonality and modern compositional methods (especially aleatoric/algortihmic methods). So if you’re into the compositional language and literature of “classical” music (anything post-Darmstadt 1946). It’s created by some interesting folks in Europe (including a guy who tunes the organs in vienna concert halls); all are knowledgeable composers but have the addition of math/coding skills. The creator’s name is Janusz Podrazik
It’s worth checking out and getting a demo of the IDE. One cool thing is there’s lots of visualization tools which make good album covers if you’re desperate: slight_smile:
Not to mention the SuperCollider integration.
I’m just a user of the software but if you have any more questions I’m happy to help!

1 Like

Thanks, I will check it out.

I’ve heard the SuperCollider Common Lisp community is very active in Asia, what’s a good surprise to get, huh))

2 Likes