(maxmsp) recording to a buffer, more groove

Demo patcher: RecordNGroove.maxpat

Today’s demo patcher is based on grooveplay, from the buffer~ and groove~ post.

Some minor changes, before diving into the new stuff. The buffer~ object (in the green section) is getting audio from the record~ object. I’ve deleted the read messages. You can put them back in, of course. In the groove section I changed sig~ to line~. The float feeding the right inlet sets a slew time (or portamento time) between ratio changes that come in the left inlet. This smooths out changes in playback ratio.

recording (ezadc~, record~)

The recording section has an ezdac~ (microphone) for input, feeding a record~ object (buffer name, length in ms, number of channels). Starting and stopping of recording is controlled by a toggle. The toggle can be controlled by a CC (sustain pedals/foot switches work really well). The timer section to the right keeps time between the toggle turning on (any non-zero number) and the toggle turning off (zero). Timing information sets the ending loop point for groove~, and triggers a bang to set the play position of groove~ back to the beginning of the sound buffer.

Since we’re recording into a buffer, we can’t resize the buffer to match our recorded input. There is a resize message for buffer~, but it erases the buffer~. The trick is to set the buffer~ size comfortably larger than you intend to use, and set the end loop point to the end of the recording.


The groove section (red/pink) gets playback ratio from either a CC (like before) or a MIDI keyboard (discussed later). You have loop control being sent from the timer in the record section. This section is mostly the same as the last demo.

midi keyboard control

The blue section in the lower right contains a collection of objects designed to let you specify playback ratios by playing on a midi keyboard. The kslider lets you pick a root key, or key that sets unity ratio (1.) playback. The midi note number is converted to frequency, and that frequency is used as the denominator in our division operation. Incoming noteon messages provide a note number that is also converted to frequency and used as the numerator in the division operation. The result is a ratio that matches equal temperament** intervals and is sent via kbRatio.

Key velocity is being used to start and stop playback of groove~. On velocities coming from stripnote are sent via startBang to “rewind” the buffer, with a playback ratio following quickly afterwards. All velocities are sent to a select 0 object. Off velocities send out a bang, triggering the 0. message to be sent as the kbRatio. A playback ratio of zero stops playback.

**If you want to generate ratios for non-12-tone equal temperament you can generate any ratio you like as part of an expression object. Just intonation can be derived from integer ratios. Microtonal intervals can be generated with a formula of 2 to the x/y power, where y is the number of steps in the octave and x is the number of steps of your interval from the root key.


Leave a Reply