(max) beginnings of an arpeggiator patcher

We’re starting our arpeggiator patcher, learning some basics of how Max works, and how to translate our what we want to do into Max code.

goal

Receive a midi note input from a MIDI keyboard to set a pitch, and play that pitch at a regular, repeating time interval.

translation

We can translate parts of that common language description of the task into Max objects.

  • Receive a midi not input from a MIDI keyboard: <notein>
  • regular, repeating time interval: <metro> (which usually includes a <toggle> to start and stop)
  • play that pitch: play a note, <makenote>

implementation

Day2-RepeatingNoteProblems.maxpat

This first patcher attempt, as noted in the filename, does a lot of the task but still present a few issues. MIDI pitch from a <notein> object is sent to a <makenote> object, which is played at a repeating time interval by way of a <metro> object.

The patcher also does some things we didn’t ask it to do. It plays a note whenever I press a MIDI key, and whenever I release a MIDI key. It does that because MIDI pitch is sent directly to <makenote>, and MIDI pitch is generated every time I press a MIDI key (a noteon message), and every time I release a MIDI key (a noteoff message).

improvement

Day2-RepeatingNote.maxpat

So what is needed to prevent MIDI keyboard presses from being directly echoed out of Max? The second patcher implements two additional features. The first addition is a <stripnote> object. <stripnote> looks at all noteon messages and only passes the pitch through if the velocity is above zero. It prevents noteoff messages from passing through. Remember that you have to connect both pitch and velocity from a <notein> object to <stripnote>. 

The second addition is a set message. Using a <message> object, the keyword “set” along with the variable $1 tells the subsequent <number> object to set its value to the input without sending it as output. The $1 is variable placeholder argument. It means, “use the first message in a list.” We aren’t sending a list to the <message> object, but a single message can be considered the first item in a list.

So now, only pitch data from noteon messages are being sent, and when they are sent, the <number> object updates its data but does not pass the data on to <makenote>. The bang message from the <metro> tells the <number> object to output its current value.

playing multiple notes at a time

Day2RepeatingNoteMultiple.maxpat

This final patcher shows that we do not need multiple <makenote> objects to play multiple notes at the same time. We can simply send two pitches to <makenote> and it will play them both. The pitch from the <number> object is being sent both to <makenote> to an addition object <+>, where an interval is added to it and sent to <makenote>. You can change the interval by typing a new number into the <number> object that is connected to the right inlet of <+>.