Digital Music Programming II: Homework 3

The echo object

You shall make a Max object which generates a set of echos whenever you play a note on a MIDI keyboard connected to Max.

The object should have four inlets:

  1. MIDI key number
  2. MIDI key velocity
  3. duration between note-off and next note-on in echo pattern in milliseconds.
  4. decay value for the amplitude of each note. (must be a float).

There are two outlets: the first is for the output key numbers, and the second outlet is for the velocities that go with the key number.

Object Requirements:

  1. Only one note echo is necessary at a time. Either ignore a new input note while the old echo is dieing out, or cut the old echo short and start echoing the new note instead.

  2. Output note durations should be the same as the input note durations.

  3. No stuck note-ons should be generated by the object.


  1. To calculate the input note durations, refer to the duration lab.

  2. To schedule the next note in the echo, refer to the mymakenote lab.

  3. The decay of the amplitude will be using float data types. Decay of 1.0 will mean that the echo notes will never stop playing. A decay value of 0.0 will mean to never echo the note. To calculate the next note attack velocity, do something like this:
       amplitude = decay * amplitude;
    Then, when you are ready to send the attack velocity for the next note, output the value like this:
       outlet_int(mo->outputVelocity, (long)mo->amplitude);

  4. The decay parameter inlet should limit the decay range between 0.0 and 0.99 (or so.) it should not be allowed to exceed 1.0 (unless you really want that). Here is the function call which will add the decay inlet:
       addftx((method)InputDecay, 1);

Extra Credit

  1. Instead of echoing the same note as the input note, have each echo be 1/2-step higher, or 1/2-step lower, or some other melodic pattern.

  2. Add a "stop" message to your echo object to tell it to stop outputing echo notes.

  3. Allow your object to echo notes polyphonically. In other words, make your object keep track of several echoing notes at the same time, so that you can play echoing chords, or fast melodies which echos all of the notes in the main() function.

Email me the source code for your program when it is finished and after you have compiled it and tested it in Max.