This example shows how to delay midi note input by a random amount.
This example shows a simple way to delay the input of midi notes.
To achieve delays that are quantized to a named transport, use a combination of pipe (delay numbers by the desired amount), translate (to set the pipe to the desired delay time), zl group (hold onto numbers as they come out of the pipe) and metro (following a particular named transport and quantized to the time unit you want).
This example shows how to delay incoming midi notes by a specified note duration. In order to achieve this we are introducing a pipe object in the middle of the notein and noteout objects that can be found by default on a max for live midi device. Furthermore, we need to define pipe’s ‘delaytime’ attribute to ‘0 ticks’ and set the ‘quantize’ attribute to the desired note duration.
This patch is one method of outputting a list of integers individually spread out over time. The iter object outputs each integer in the list one at a time. The trigger ‘b i’ sends the integer to the pipe which adds the specified time interval to the current value in the accum which changes the delay time of the next object sent to pipe. The patch could be easily adapted to work for floats as well.
This example demonstrates how to iterate through elements of a message with a delay interval.
Upon patch initialization, one might be tempted to use multiple loadbang objects attached to delay objects in order to control the order of operations. A different approach, however, would be to use a single loadbang at the top level and use send or forward to send the messages you want, where you want, and in the order you want.
One possible solution to the problem of clicks occurring when delay time is changed is to fade the amplitude of the delayed sound to 0 just before changing the delay time, then fade back up immediately after the change. This does avoid clicks, but causes an audible momentary break or dip in the sound. This shows one way you could implement such momentary "ducking" of the amplitude.
This is an example patch you can use to try out the delaynote patch shown in "Delay MIDI note messages." Of course, you will first have to download the patch from that example and save it with the name "delaynote".