Forums > Max For Live

newb coding question.

Apr 08 2011 | 5:36 am


I’m making a simple additive synth using poly~. I’ve gotten to the point where I’ve got my oscillator code off in a stand alone patch so it can be reused. I want three oscillators so I’m having to create the interfaces for each oscillator in the main patch and then in the poly patch I’m having to create an oscillator object for each oscillator I want. And then for each oscillator I’m hooking it up to the proper interface via send and receive objects.

Is there a way to make this more data driven? It seems like a lot of cutting and pasting for each oscillator. What if I want another one? Then I’ve got to do all this cutting and pasting again. Is there a way to make it so you say how many oscillators you want and it works?

I remember in the tutorials there’s a way to generate max patch code on the fly. Is that the only way or is there something more elegant? Can I use another poly~ within the poly patch?



Apr 08 2011 | 6:38 am

May have a look at the [oscbank~] object. It can contain as many oscillators as you need in one object.


Apr 08 2011 | 10:07 am

Thx Jan, oscbank~ looks interesting. Do they all have to be the same waveform though?

I was able to get the poly~ within a poly~ thing working. And I wrapped the ui components in a bpatcher using an argument to specify the oscillator number (1-3). So now I don’t have to cut and paste so much anymore. Should make it easier to add things too. It ate up a lot of cpu at first but then I was able to fix it by copying the thispoly~ stuff from Additive Heaven for both the subpatch and sub-sub patch.

Apr 08 2011 | 10:40 am

Yes in oscbank~ all oscillators are sine waves. That’s because the principle behind additive synthesis is that you can create any periodic waveform by summing sine waves.

i.e. to create a sawtooth of 100hz you would make the addition of sine waves:

100 Hz with an amplitude 1
200 Hz with an amplitude of 1/2
300 Hz with an amplitude of 1/3
400 Hz with an amplitude of 1/4
500 Hz with an amplitude of 1/4

and so on… (all at a phase of 180 degree)

And of course you can create any other standard waveform (like triangle, square etc.) and all non standard forms as well.

Apr 08 2011 | 10:52 pm

Oh thanks! I’ve heard of that principle before, but my brain couldn’t make the connection. Now that I understand what that’s about I’ll have to integrate it into my oscillators, which is going to make it look a lot like Operator, but extensible, with microtonal capabilities. :)


Viewing 5 posts - 1 through 5 (of 5 total)

Forums > Max For Live