line~
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.
Linear and exponential
This patch demonstrates the sound of linear and exponential changes in pitch and amplitude.
Use stored waveform for a synthesizer
This patch demonstrates the technique of wavetable synthesis: using one cycle of a stored waveform as the wave type for a synthesizer tone. The cycle~ object with no argument produces a cosine wave; however, cycle~ can also refer to a waveform stored in a buffer~, and use that as a wavetable. To do that, you need to create a buffer~, store a waveform in it, and then refer to that buffer~ by creating a cycle~ with the same name.
Simple audio file player
The example demonstrates a simple way to play an audio file.
Simple amplitude control
When you're changing the amplitude of a sound, if the amplitude is changed very suddenly and significantly, it may create a sudden discontinuity in the waveform which will be heard as a high-frequency click. (That phenomenon is demonstrated in the example "Click resulting from amplitude change".) To avoid that problem, it's necessary to interpolate sample-by-sample from the old amplitude value to the new value, over some small period of time, to create a slightly more gentle fade to the new amplitude factor.
Alter phase of sinusoid by milliseconds
This example shows how you can alter the phase of a wave by milliseconds using delay~. The object mstosamps~ converts milliseconds to samples which then are smoothed by line~ to avoid clicks. (See MSP Basics Tutorial 2 for an example and explanation of linear interpolation using line~.)
List audio cue points
To set a list of cue points in an audio file and have them played in order, use either sfplay~ (with a set of cues established by preload messages to sfplay~ or to sflist~) or buffer~ (with start messages to play~, the parameters of which are stored in a coll).
Four way audio crossfader
Here’s a way to create a four-way audio crossfader.
Timed linear fade
This patch shows how to make a fade-in or a fade-out using the line object (for numbers) or line~ (for a signal). You provide the line (or line~) object with a two-item list signifying a destination value and an amount of time, in milliseconds, to get to the destination.