If you scale a one cycle of cosine wave by a factor of -0.5 and offset it by 0.5 you get a "Hanning function", which goes from 0 to 1 and back to 0 as smoothly as possible. That can be used to shape the amplitude of a sound, turning it on and off smoothly, or it can be used to modulate any characteristic of the sound.
To play short grains of sound, especially ones randomly chosen from a sound file, it's usually necessary to impose some sort of "window"—an amplitude envelope—to taper the ends of the grain in order to avoid clicks. This patch shows how to generate four types of window function, and read through them with a phasor.
A "window" is a function (shape) used to control the amplitude of a sound, briefly turning it up then turning it back down. This example shows how to create a trapezoidal window on a sound file, which will quickly fade the file in and out for a specified duration, repeatedly at some specified triggering interval. The metro triggers a message to the line~ object.
Each MSP object (each object that has signal input and/or output) is always producing signal as long as audio is turned on. For example, signal generators like cycle~ (sinusoidal wave generator) and saw~ (band-limited sawtooth wave generator) are always producing a full-amplitude wave. You control the amplitude of that wave with multiplication, using *~ or some other object that performs a multiplication internally (such as gain~).