To make a sampler, we just record a real sound into a wavetable and then later read it back out again. In music stores the entire wavetable is usually called a ``sample" but to avoid confusion we'll only use the word ``sample" here to mean a single point in an audio signal, as described in Chapter 1.
Going back to figure 2.2, suppose that instead of 40 points the wavetable is a one-second recorded sample, originally recorded at a sample rate of 44100, so that it has 44100 points; and let in part (b) of the figure have a period of 22050 samples. This corresponds to a frequency of 2 Hz. But what we hear is not a pitched sound at 2 cycles per second (that's too slow to hear as a pitch) but rather, we'll hear the original sample played back repeatedly at double speed. We've just re-invented the sampler.
At its simplest, a sampler is simply a wavetable oscillator, as was shown in figure 2.3. However, in the earlier discussion we imagined playing the oscillator back at a frequency high enough to be perceived as a pitch, at least 30 Hz or so. In the case of sampling, the frequency is usually lower than 30 Hz, and so the period, at least 1/30 second and perhaps much more, is long enough that you can hear the individual cycles as separate events.
In general, if we assume the sample rate of the recorded sample is the same as
the output sample rate, if the wavetable has samples and if we play
it back using a sawtooth wave of period ,
the sample is transposed by
a factor of , equal to if is the frequency in Hz of the
sawtooth. As an interval, the transposition in half steps is given by the
TRANSPOSITION FORMULA FOR LOOPING WAVETABLES:
So far we have used a sawtooth as the input wave , but, as suggested in parts (d) and (e) of figure 2.2, we could use anything we like as an input signal. In this case, the transposition is time dependent and is controlled by the rate of change of the input signal.
As a speed multiple the
transposition multiple and the transposition in half steps are given
by the:
MOMENTARY TRANSPOSITION FORMULAS FOR WAVETABLES:
It's well known that transposing a sample also transposes its timbre--this is the ``chipmunk" effect. Not only are any periodicities (such as might give rise to pitch) in the sample transposed, but so are the frequencies of the overtones. Some timbres, notably those of vocal sounds, can be described in terms of frequency ranges in which overtones are stronger than their neighbors. These frequency ranges are also transposed, which is heard as a timbre change. In language that will be made more precise in section 5.1, we say that the spectral envelope is transposed along with the pitch or pitches.
In both this and the preceding section, we have considered playing wavetables periodically. In section 2.1 the playback repeated quickly enough that the repetition gives rise to a pitch, say between 25 and 4000 times per second, roughly the range of a piano. In the current section we assume a wavetable one second long, and in this case "reasonable" transposition factors (less than four octaves up) would give rise to a rate of repetition below 25, usually much lower, and going down as low as we wish.
The number 25 is significant for another reason: it is roughly the maximum number of separate events the ear can discern per second; for instance, 25 syllables of speech or melodic notes per second, or attacks of a snare drum roll, are about the most we can hope to crowd into a second before our ability to distinguish them breaks down.
A continuum exists between samplers and wavetable oscillators, in that the patch of Figure 2.3 can either be regarded as a sampler (if the frequency of repetition is less than about 20 Hz.) or as a wavetable oscillator (if the frequency is greater than about 40 Hz.) It is possible to move continuously between the two regimes. Furthermore, it is not necessary to play an entire sample in a loop; with a bit more arithmetic we can choose sub-segments of the sample, and these can change in length and location continuously as the sample is played.
The practice of playing many small segments of a sample in rapid succession is often called granular synthesis. For much more discussion of the possibilities, see [Roa01].
Figure 2.5 shows how to build a very simple looping sampler. In the figure, if we call the frequency and the segment size in samples is , the output transposition factor is given by , where R is the sample rate at which the wavetable was recorded (which need not equal the sample rate the block diagram is working at.) In practice, this equation must usually be solved for either or to attain a desired transposition.
In the figure, a sawtooth oscillator controls the location of wavetable lookup, but the lower and upper values of the sawtooth aren't statically specified as they were in Figure 2.3; rather, the sawtooth oscillator simply ranges from 0 to 1 in value and the range is adjusted to select a desired segment of samples in the wavetable.
It might be desirable to specify the segment's location either as its left-hand edge (its lower bound) else as the segment's midpoint; in either case we specify the length as a separate parameter. In the first case, we start by multiplying the sawtooth by , so that it then ranges from to ; then we add so that it now ranges from to . In order to specify the location as the segment's midpoint, we first subtract from the sawtooth (so that it ranges from to , and then as before multiply by (so that it now ranges from to and add to give a range from to .
In the looping sampler, we will need to worry about the continuity between the beginning and the end of segments of a sample, which we'll consider in the next section.
A further detail is that, if the segment size and location are changing with time (they might be digital audio signals themselves, for instance), they will affect the transposition factor, and the pitch or timbre of the output signal might waver up and down as a result. The simplest way to avoid this problem is to synchronize changes in the values of and with the regular discontinuities of the sawtooth; since the signal jumps discontinuously there, the transposition is not really defined there anyway, and, if you are enveloping to hide the discontinuity, the effects of changes in and are hidden as well.