Software » Max/MSP
Using a multislider to control an envelope.
Max's [function] object is useful for envelopes, but it can be a pain to work with. Sometimes you just want to swipe your mouse across the screen and get an envelope. Multislider is great for this. Here's a simple example of how to do it.
- Copy the text in this box (it's the patcher source code)
- In Max's menu, go to File → New from Clipboard
- Lock the patcher to interact with it
Working backwards from the audio output at the bottom:
- The [noise~] has an envelope applied by [line~].
- [zl reg] stores the envelope as a list of value,time pairs. For each pair of numbers in this list, [line~] reaches the value in time milliseconds.
- The group of objects going up to [multislider] convert its list of values to value,time pairs. [iter] loops over the multislider list, a default time of 15 milliseconds is appended to each value, and [zl group] accumulates everything back into a single list.
- The [multislider] has 63 values ranging from 0.0 to 1.0. A 0 is appended to the list of multislider values to ensure the envelope ends with silence. This creates an envelope of 64 evenly-spaced values, where a default duration of the envelope is 64 * 15 ms = 960 milliseconds.
- The group of objects in the upper right set the envelope duration. The total envelope duration is input into [number], which is divided by 64 (for the 64 envelope values) and updates [append 15]. It also triggers the [multislider] so we can update the envelope's value,time list.
If you're new to Max, those [t ...] objects are important. They are [trigger] objects that control the flow of the patcher. They can also do basic conversion, such as converting any message into a bang message. Take the time to understand what they are doing. Check out the Max help file if needed.
For example, the [t b l] below the multislider sends the list (l) of values through the iter loop where they are stored in [zl group]. Once the list has been processed, [t b l] sends a bang (b) message out its left outlet, which triggers [zl group] to update [zl reg]. Without [t b l] and [zl group], connecting the [append 15] directly into [zl reg] would cause the value,time pairs to arrive separately (because [iter] breaks them up and sends them out 1 by 1 in a loop), and each pair would overwrite the previous one. You'd end up with a single pair element with the final value of 0.
Learning these signal flow structures will help you build more complex patchers.