Recording to and playing sounds from RAM
This patch demonstrates a method of storing and recalling sound in RAM using the buffer~ object and the various objects that can access a buffer.
This patch demonstrates a method of storing and recalling sound in RAM using the buffer~ object and the various objects that can access a buffer.
This patch demonstrates a method of storing and recalling sound in RAM using the buffer~ object and the various objects that can access a buffer.
Use the timer object to measure the time between when you turn on recording and when you stop recording.
This patch records while the spacebar is held down, and starts looping when the spacebar is released.
To record the output of a line~ as a series of numbers, a buffer~ can be used to capture the entirety of its output. To record the output, connect the line~ to a record~ with the same name as the buffer~. The buffer can then be played back by creating a play~ object with the same name as the buffer~ and sending it a start message.
A named record~ object records audio data into the buffer~ object that shares the same name. When the record~ object receives the message 1 (or any nonzero number) it begins recording the audio signal it receives, by placing that data in the associated buffer~, starting at the beginning of the buffer~. When record~ receives a 0 message, it stops recording.
This example is essentially the same as "Basic RAM recording into buffer~", except that it's designed for recording and playing back a stereo signal instead of a single channel of audio. The buffer~ object has an additional argument to specify 2 channels of storage.
To record a sound into RAM, you must first allocate/designate a place in RAM into which to record. The buffer~ object creates a named buffer in memory large enough to store the specified duration of audio data. In this example, the buffer is named "theholdingplace" and holds up to 60,000 milliseconds (one minute) of audio. The incoming audio signal from the adc~ object goes into a record~ object that refers to that memory buffer.
This patch shows several techniques relevant to granular synthesis, playing a stream of short excerpts of recorded sound. (The patch uses one abstraction, called pan~, that's provided in the example titled "Constant-intensity panning subpatch". You'll need to download that abstraction and save it with the name pan~ somewhere in Max's file search path.)
In classic granular synthesis, grains are very short windowed segments of sound, normally from 5 ms to 100 ms in length. A stream of sound grains be spaced at exactly the same time interval as the grain length, or at some greater interval of time. The spacing can even be randomized (some random time interval greater than or equal to the grain length). A single stream of grains is all you can do with a single groove~ object.