I included the example patcher (grooveplay.maxpat) in the zipped soundfilepatcher archive from Monday.
buffer~
Preliminary stuff first. buffer~ allows you to load a sound file into RAM. You can play it back with a number of objects, get information about it, etc., but it is in effect like sampler memory.
The object takes arguments for buffer name, length (in ms), and number of channels. You “read” files into a buffer (instead of sfplay~’s open), but it is more beneficial to use a replace message. The replace message resizes the buffer to match the length of the sound file loaded.
You can double-click the buffer to see a graphic waveform display of the loaded sound file. The left outlet of buffer will report mouse position (in ms) when you click on the graphic display. The right outlet sends a bang when a sound file is finished loading. This bang is useful for sending to objects that provide info about the sound, and for other uses.
groove~
I just love the name of this object! The groove~ object plays sound from a buffer. It needs an argument for the buffer name to read from, and for the number of channels. The number of outlets depends on the number of channels for playback — there will always be one more than the number of channels. (The last outlet sends out a sync signal, which we will seldom if ever use.)
groove~ takes a signal-rate input for playback speed, expressed as a decimal ratio. Unity playback is the ratio 1. Negative ratios play backwards. I’m scaling a CC and sending it to a sig~ object (converts a float to a signal). The output of the sig~ object is sent to groove~. The toggle can be used to start and stop playback, although it won’t change playback speeds. The extra 0. message is included as a simple stop button.
groove~ has one big gotcha to get it to start playing. You have to tell it where to start in the buffer (time in ms). I’m using the message with “0.” to do that (it’s marked with the rewind comment). If you aren’t looping playback, you’ll need to “rewind” the playback position to play the sound again.
Looping status is set with the loop message. Loop 1 (or true) turns looping on; loop 0 (false) turns looping off. The second inlet can be used to set the minimum loop position (loop start); the third inlet sets the maximum loop position (loop end). If neither min or max points have been set, groove~ will loop the entire sound file.
Leave a Reply