(maxmsp) waveform~ grooving and glitching, maybe graining…

Two demo patchers for this post: waveformGroove.maxpat and waveformGlitch.maxpat. Look at the waveformGroove patcher first.


The waveform~ object is a graphic editor for buffered audio. The easiest way to make use of waveform~ in a patcher is to copy and paste from the help file. This implementation is copied from the subpatcher for multi-channel audio.

Some things to note in this patcher. (unlock to see all the objects)

  • the waveform~ objects have to be linked to a named buffer. The loadbang to the messages accomplishes this link. The messages are formatted as name buffername channel#.
  • The four tools on the left are part of a pictslider object. The pictslider lets you load pictures that serve as the background for a selectable slider. The index of the tool selection is sent to the subpatcher wfkeys. The tools are: select, loop, move, and draw.
  • The move tool lets you change the zoom of the display by clicking and dragging up or down.
  • You can select loop sections by entering time messages in the number boxes above the waveform, or by using the select tool in the waveform.
  • The set $1 messages update the number boxes above the waveform when you select in the waveform, without creating a feedback loop.
  • Start and End points of the loop selection are sent to the groove~ object.

All other functions in the patcher have been covered before in previous posts and examples.

Now close waveformGroove and open waveformGlitch.

waveformGlitch replaces the MIDI keyboard control section with a glitch section (or grain making section, depending on your aesthetic preference). The key features include:

  • A metro for triggering playback of waveform segments.
  • A loopSize subpatcher that computes the loop size from the start and end points and then divides the loop segment into tenths.
  • The metro bangs a random object, which randomly generates 0 – 9, multiplies it by the segment length (1/10th of loop size), then adds it to the start position of the loop.
  • This position message is sent to groove~, which cause groove~ to jump to that part of the buffer for playback.
  • The right side of the glitch section is an envelope generator.
  • You can set a percentage of the timing interval for the sustain time, and att/rel ramps.
  • Each metro bang sends the line~ generator to scaling objects that provide an envelope for the output of groove~.
  • The metro also can be passed (by means of a gate) to a random object that is scaled to a playback range.
  • The minimum and maximum of the scaling range can be set.

Important controls (output level, playback ratio, percentage of envelope duration, and metro speed) can be assigned to CC’s in the control section.


This is a basic glitch patch (with a slower metro) or grain generator (at faster speeds). There are a number of improvements that could be made, especially if you wanted to develop a granular synthesizer. For example, you could

  • use a MIDI keyboard to set a playback ration and use the random generator to create random deviation within a range around the specified playback ratio.
  • use the metro to move through the buffer in an ordered way, with a possible random deviation from that order.
  • create multiple streams of grains using a poly~ object.


One response to “(maxmsp) waveform~ grooving and glitching, maybe graining…”

  1. Keith Kothman Avatar
    Keith Kothman

    One immediate improvement that I should have put in: when you load a new file into the buffer/waveform, a bang gets sent that “rewinds” the play position of groove~. Fine. But if you select a part to loop playback from in the waveform~ object, it should update the start position to match the startLoop position. If you take a second patch cord out of (first is going into groove~’s second inlet), and patch it into the first inlet of groove~, that should update the playback position to the beginning of the loop. Drawback: changing the loop start point will send the buffer back to the start with every change. What the patcher really needs is a noteon message that would start playback every time with the beginning of the loop.

Leave a Reply