Play a stream of random grains from a sound file
This patch demonstrates a method for playing a stream of sound grains randomly chosen from a sound file.
This patch demonstrates a method for playing a stream of sound grains randomly chosen from a sound file.
This example shows how to isolate a single FFT bin, as opposed to displaying the entire spectrum. The example uses fft~ instead of fftin~, but the principle is the same.
The idea of “sample and hold” is to capture the amplitude of a signal at a particular instant in time, and hold it constant for a while. In MSP, the sah~ object allows you to do just that.
A phasor~ object, like other MSP objects such as cycle~ that use a rate for their timing, can have its repetition rate specified as a transport-related tempo-relative time value (note values, ticks, etc.). So if you want a phasor~ to work at a rate that is related to the transport's tempo, you can type in a tempo-relative time as an argument to specify its period of repetition instead of typing in a frequency.
How do we detect, with sample-accurate precision, the precise moment when phasor~ begins a new cycle from 0 to 1? We need to detect the sample on which it leaps from 1 back to 0. However, because phasor~ is constantly interpolating between 0 and 1, it might not leap down to exactly 0. So we can't just use a ==~ object to see when its value is 0.
In analog electronics, a sample-and-hold device does what its name implies, it takes a sample of the voltage coming into it at a precise instant, and holds that voltage as a constant output signal. The sampling is commonly done at regular intervals, controlled by a clock, but the it can be done in response to any triggering control signal. In MSP, the sah~ object works this way.