Snapshot of a signal

Similarly to the sample and hold object sah~, the snapshot~ object can be used to capture the amplitude of a signal at a specific instant. Whereas sah~ sends out a constant signal, however, snapshot~ sends out a single Max message. Thus, you can think of snapshot~ as providing a message that “takes a snapshot” of, and reports the amplitude of, a signal at one specific instant. You can either trigger snapshot~ with a ‘bang’ message, or you can set it to report automatically at a certain interval of time.

 

report signal value

This patch does almost exactly the same thing as the example demonstrating Sample and hold. The main distinction is that snapshot~ is controlled by the Max event scheduler, whereas the sah~ object uses a triggering signal, and thus is potentially “sample-accurate” in its timing. If you don’t need sample-level timing accuracy, this snapshot~ method is slightly more computationally efficient.

The noise~ object continually produces random sample values from -1 to 1. The snapshot~ object grabs and reports one of those samples every 125 ms. Using a *~ and a +~ object, we can move that value (from -1 to 1) into a range from 440 to 880 (660 ± as much as 220) to be used as the frequency value for a cycle~ oscillator.

Sample and hold

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. The signal you want to sample goes in the left inlet of sah~, and a triggering signal goes in the right inlet. Whenever the triggering signal surpasses a particular threshold (going upward), whatever the amplitude value of the left inlet’s signal is at that instant will be sent out as a constant signal value, until the next trigger.

 

Capture a new value periodically

The phasor~ object is a good candidate to use as a repetitive triggering signal because it produces a reliably repeating shape. In this example, a threshold value of 0.5 is used by sah~, and because phasor~ always goes upward from 0 to 1, it’s sure to pass 0.5.

The noise~ object continually produces random sample values from -1 to 1. The sah~ object grabs and holds one of those samples, triggered by the phasor~ which is surpassing the threshold 8 times per second. Using +~ and a *~ objects you can move that value (from -1 to 1) into a range from 440 to 880 to be used as the frequency value for a cycle~ oscillator. (In this example, we first move the value into the range 0 to 1, then move that into the range 440 to 880, to show the conversion explicitly.)

Conditional timepoint

The timepoint object automatically and reliably sends out a ‘bang’ when the specified point in time is reached. How would you specify a point in time, and also make the notification “conditional”, such that it only occurs if a certain condition is met? This patch shows two different ways you might do that.

time point occurs if a condition is met

The method shown on the left is to have a timepoint object with no time specified. When the condition is met (the number 1 is received) the timepoint object receives a time specification. And if you want to cancel that, you can just set the timepoint to some time that will almost certainly never be reached.

The method shown on the right is to use a gate that can be conditionally opened (when the number 1 is received), and that is otherwise closed preventing the ‘bang’ from the timepoint from getting through.