Wednesday, July 20, 2011

Detuning oscillators.

I'm still not entirely sure how PmonoArtic works, perhaps it will forever remain a mystery, but I do know how the important part of this synth def I came up with works. Well more or less anyway.



(
SynthDef("aSynth",{

arg lagLev = 0.2, freq= 440, cutoff = 500, gate = 0.5;
var osc1 = Mix.fill(8, { SinOsc.ar(freq + 10.0.rand, 0, 0.05) }); var filterEnv = EnvGen.ar(Env.adsr(0.02, 0.1, 0.05, 1), gate, doneAction:2);
var filterOutput = MoogFF.ar(osc1, cutoff * filterEnv, 3.3); Out.ar(0, filterOutput);


}).store
)

(
PmonoArtic("aSynth",
\freq, Pseq([440,330,440,330,550,770,880], inf),
\legato, Pwrand(#[0.5, 1.0], #[0.1, 0.9], inf),
\dur, 0.3,
\cutoff, Pwhite(5000, 10000, inf)



).play
)

This is inspired by something I read on the SC Users list and it's an attempt at a synth that's more analoguesque. It didn't work quite as well as I had anticipated, so I think I'll have to try some more advanced techniques, but I suppose it's a start.

The significant bit is this line:

var osc1 = Mix.fill(8, { SinOsc.ar(freq + 10.0.rand, 0, 0.05) });

Here I'm using the Mix command along with fill to create an array of eight different oscillators all tuned slightly differently, randomly assigned plus or minus 10hz from the frequency passed to the sythdef. It's supposed to give it a vaguely chorus like effect by layering detuned oscillators, which it does a bit, but the effect isn't quite as noticeable as I thought. Increasing the number of oscillators doesn't help much and increasing the frequency that they can change by sounds pretty horrible.

The mix and fill commands are pretty simple to use, by the way.

On it's own you can use Mix.new(array) to mix an array of channels together, or you can use Mix.fill(n, function) to create a whole new array of channels with the function you specify.

I could be wrong, but I think that when you use Mix.fill in a synth def it will only evaluate the function when the synth is loaded, so if you're using random varaibles like I am above, they'll only be random once when it's run.


4 comments:

  1. First, the detuning should be by ratio instead of a fixed frequency, so it sounds constant to the ear.

    Second, it should have an equal chance of being low or high so that the center pitch is correct instead of being pulled sharp.

    Third, the effect is much more apparent when the waveform has some harmonic content instead of just a sine wave (filtering a sine wave doesn't do much either!).

    Fourth, it's much more typical in an analog synth to have the filter cutoff track the pitch, and to modulate it with an LFO rather than being random per note.

    Fifth, 10.rand always produces an integer, which is probably not what you want! Use 10.0.rand, or (as I've done) a UGen, so that you get a different set with each instantiation.

    Here's my version, somewhat heavy on the detuning (with Pmono for simplicity):

    (
    SynthDef("aSynth", {
    arg lagLev = 0.2, freq= 440, cutoff = 500, gate = 0.5, spread = 1.01;
    var osc1 = Mix.fill(8, { Saw.ar(freq * ExpRand(spread, spread.reciprocal), 0.125) });
    var filt = MoogVCF.ar(osc1, SinOsc.kr(0.5).exprange(freq * 2, freq * 4), 0.85);
    Out.ar(0, filt);
    }).store
    )

    (
    Pmono("aSynth",
    \freq, Pseq([440,330,440,330,550,770,880], inf),
    \dur, 0.3,
    \cutoff, Pwhite(500, 1000, inf),
    \spread, 1.015
    ).play
    )

    ReplyDelete
  2. Whoops, you're doing 10.0.rand, not sure why I thought you weren't.

    ReplyDelete
  3. Afaik, Pmono works this way: it instatiates the synth and send only .set messages to it. PmonoArtic works almos the same way, but it depends on the legao. if legato > 1 , then it keeps the instance of the synth and sends a .set message. If the legato is < 1 then it sends a .set(\gate, 0 ) message to the instantiated synth AND starts a new synth instance (while the last synth makes the release curve, if there is any). I love PmonoArtic, even it sometimes gets stuck when reinterpreting the same code, but hasn't happened lately :-) thx for the blog!

    ReplyDelete
  4. Hey,

    PmonoArtic is basiclly like Pmono in that it makes an instance (node) of the instrument and instead of killing it and starting it each time it fires a note (event) it just changes the paramaters you send it. The difference between Pmono and PmonoArtic is that:

    "PmonoArtic, however, allows events to re-articulate and supports staccato in the middle of a monophonic phrase." So it actually will close the envelope if the 'sustain' is shorted than the 'delta'. Basiclly if you don't sustain to the end of the duration. Try playing with the \sustain and \dur values making one longer than the other to see the difference.

    To try and get more interesting sounds out of SinOsc perhaps look into Feedback FM
    http://books.google.com/books?id=nZ-TetwzVcIC&lpg=PA246&ots=BbStalBl8w&dq=feedback%20FM%20curtis%20roads&pg=PA244#v=onepage&q&f=false

    word
    cpill

    ReplyDelete