(max) basic audio, oscillators and envelopes

Now that we’ve had a little fun with our Theremin, let’s turn to some basic synthesis with oscillators and envelope generators.

The Very Basic Setup

Download the BasicAudio.maxpat. This patcher provides a very basic adjustable synthesizer, with a saw~ object feeding into an audio multiply (*~). Changes to frequency and amplitude are made with float objects. Amplitude changes can be made with either the float feeding a message or a pack object. Both function the same way.

Adding Envelope Control

Next, we turn to the BasicSynthEnvelope.maxpat. Messages are sent to line~ in the <target time> format, meaning what value to change to over how long. Moving left to right, the first pair of messages show individual envelope line segments creating an attack and release. (Remember, to hear anything you must enter a frequency.)

The next message over, triggered by the space bar, includes an entire ADSR envelope description. The first 0. followed by a comma tells line to go to that value immediately, then target/time pairs follow:

  • 0.9 10 (reach amplitude of 0.9 over 10 ms) Attack
  • 0.25 100 (go to amp 0.25 over 100 ms) initial Decay
  • 0.25 1000 (stay on amp 0.25 over 1000 ms) Sustain level and time
  • 0. 250 (go to amp 0. over 250 ms) Release

As an organizing tip, I specify amps (target values) in floating point numbers, and time in integers. It helps me read through the list.

The final message on the right, triggered by the 1 key, is just a slow attack and release envelope.

Using the Function Editor and Presets

Download the BasicSynthEnvelopeGraphic.maxpat and explore the preset and function objects.

The preset object stores and recalls data in user interface objects like number boxes (integer and floats), function editor, toggle states, sliders and dials. You store a information by sending the message store #. Recalling a preset just involves sending a number. Dark grey circles have a preset stored at that location. The blue circle is the current preset. The patcher loads preset 1 as current.

Preset objects can store all or some of the UI objects in a patcher. I’m using the left outlet of preset to connect to inputs of objects that I want to store in a preset location.

The function editor is a graphic breakpoint editor. You add points by clicking in the window. You can drag points, add as many as you like, and delete points (shift-click). As you move a point around you see its current X and Y values. When you send a bang to function, it will output to its second outlet its contents as target/time pairs for sending to line~. The spacebar is set to send a bang to function. You can see the output of function in the message below it.

Choose preset 2 by typing a 2 on the keyboard. When you subtract 48 from the key input you get numbers that you type aligning with values output.

Hit the spacebar again to compare settings. Frequency, function, and the number object all change. The number object that feeds into prepend setdomain changes the overall length of the function. All points scale to the new length. (Y is the domain of the function editor; X is the range.)

Sustain Points

The final addition is adding sustain points in the function editor. Download BasicSynthEnvelopeGraphicSustain.maxpat. It has two changes: the function editor colors have changed to better show the sustain points, and a toggle has been added to the space bar feeding either a bang or a next message.

Cmd-click any point in function and you make that point a sustain point. You can have as many sustain points as you want in the function editor. Sending a bang to function initiates the function, stopping at the sustain point. A next message tells function to continue through the points.


Comments

Leave a Reply