miller-book/node30.html

546 lines
17 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
original version by: Nikos Drakos, CBLU, University of Leeds
* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<TITLE>Timbre stretching</TITLE>
<META NAME="description" CONTENT="Timbre stretching">
<META NAME="keywords" CONTENT="book">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="book.css">
<LINK REL="next" HREF="node31.html">
<LINK REL="previous" HREF="node29.html">
<LINK REL="up" HREF="node26.html">
<LINK REL="next" HREF="node31.html">
</HEAD>
<BODY >
<!--Navigation Panel-->
2022-04-12 23:32:40 -03:00
<A ID="tex2html988"
HREF="node31.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="next.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html982"
HREF="node26.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="up.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html976"
HREF="node29.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="prev.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html984"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="contents.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html986"
HREF="node201.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="index.png"></A>
<BR>
2022-04-12 23:32:40 -03:00
<B> Next:</B> <A ID="tex2html989"
HREF="node31.html">Interpolation</A>
2022-04-12 23:32:40 -03:00
<B> Up:</B> <A ID="tex2html983"
HREF="node26.html">Wavetables and samplers</A>
2022-04-12 23:32:40 -03:00
<B> Previous:</B> <A ID="tex2html977"
HREF="node29.html">Enveloping samplers</A>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html985"
HREF="node4.html">Contents</A></B>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html987"
HREF="node201.html">Index</A></B>
<BR>
<BR>
<!--End of Navigation Panel-->
2022-04-12 23:32:40 -03:00
<H1><A ID="SECTION00640000000000000000"></A>
<A ID="sect2.stretching"></A>
<BR>
Timbre stretching
</H1>
<P>
The wavetable oscillator of Section <A HREF="node27.html#sect2.oscillator">2.1</A>, which we extended in
Section <A HREF="node28.html#sect2.sampling">2.2</A> to encompass grabbing waveforms from arbitrary
wavetables such as recorded sounds, may additionally be extended in
a complementary way, that we'll refer to as
2022-04-12 23:32:40 -03:00
<A ID="2263"></A><I>timbre stretching</I>, for reasons we'll develop in this section. There are
also many other possible ways to extend wavetable synthesis, using for
instance frequency modulation and waveshaping, but we'll leave them to later
chapters.
<P>
The central idea of timbre stretching is to reconsider the idea of the wavetable
oscillator as a mechanism for playing a stored wavetable (or part of one) end
to end. There is no reason the end of one cycle has to coincide with the
beginning of another. Instead, we could ask for copies of the waveform to
be spaced with alternating segments of silence; or, going in the opposite
direction, the waveform copies could be spaced more closely together so that
they overlap. The single parameter available in Section
<A HREF="node27.html#sect2.oscillator">2.1</A>--the frequency--has been heretofore used to control
two separate aspects of the output: the period at which we start new
copies of the waveform, and also the length of each individual copy. The
idea of timbre stretching is to control the two independently.
<P>
Figure <A HREF="#fig02.09">2.9</A> shows the result of playing a wavetable in three ways.
In each case the output waveform has period 20; in other words, the output frequency
is <IMG
WIDTH="39" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img181.png"
ALT="$R/20$"> if <IMG
WIDTH="15" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
SRC="img36.png"
ALT="$R$"> is the output sample rate. In part (a) of the figure, each
copy of the waveform is played over 20 samples, so that the wave form fits
exactly into the cycle with no gaps and no overlap. In part (b), although the
period is still 20, the waveform is compressed into the middle half of the
period (10 samples); or in other words, the
2022-04-12 23:32:40 -03:00
<A ID="2267"></A><I>duty cycle</I>--the relative amount of time the waveform fills the
cycle--equals 50 percent. The remaining 50 percent of the time, the output
is zero.
<P>
2022-04-12 23:32:40 -03:00
<DIV ALIGN="CENTER"><A ID="fig02.09"></A><A ID="2271"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 2.9:</STRONG>
A waveform is played at a period of 20 samples: (a) at 100 percent
duty cycle; (b) at 50 percent; (c) at 200 percent</CAPTION>
<TR><TD><IMG
WIDTH="609" HEIGHT="304" BORDER="0"
SRC="img221.png"
ALT="\begin{figure}\psfig{file=figs/fig02.09.ps}\end{figure}"></TD></TR>
</TABLE>
</DIV>
<P>
In part (c), the waveform is stretched to 40 samples, and since it is still
repeated every 20 samples, the waveforms overlap two to one. The duty cycle
is thus 200 percent.
<P>
Suppose now that the 100 percent duty cycle waveform has a Fourier series
(Section <A HREF="node14.html#sect1.fourier">1.7</A>) equal to:
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{x_{100}}[n] = {a_0} +
{a_1} \cos \left ( \omega n + {\phi_1} \right ) +
{a_2} \cos \left ( 2 \omega n + {\phi_2} \right ) + \cdots
\end{displaymath}
-->
<IMG
WIDTH="387" HEIGHT="28" BORDER="0"
SRC="img222.png"
ALT="\begin{displaymath}
{x_{100}}[n] = {a_0} +
{a_1} \cos \left ( \omega n + {\phi...
...+
{a_2} \cos \left ( 2 \omega n + {\phi_2} \right ) + \cdots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
where <IMG
WIDTH="14" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
SRC="img27.png"
ALT="$\omega $"> is the angular frequency (equal to <IMG
WIDTH="37" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img223.png"
ALT="$\pi/10$"> in our example since
the period is 20.) To simplify this example we won't worry about where
the series must end, and will just let it go on forever.
<P>
We would like to relate this to the Fourier series of the other two waveforms
in the example, in order to show how changing the duty cycle changes the
timbre of the result. For the 50 percent duty cycle case (calling the
signal <IMG
WIDTH="44" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img224.png"
ALT="${x_{50}}[n]$">), we observe that the waveform, if we replicate it out
of phase by a half period and add the two, gives exactly the original waveform
at twice the frequency:
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{x_{100}}[2n] = {x_{50}}[n] + {x_{50}}[n+{\pi \over \omega}]
\end{displaymath}
-->
<IMG
WIDTH="209" HEIGHT="35" BORDER="0"
SRC="img225.png"
ALT="\begin{displaymath}
{x_{100}}[2n] = {x_{50}}[n] + {x_{50}}[n+{\pi \over \omega}]
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
where <IMG
WIDTH="14" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
SRC="img27.png"
ALT="$\omega $"> is the angular frequency (and so <IMG
WIDTH="31" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img226.png"
ALT="$\pi / \omega$"> is half the
period) of both signals. So if we denote the Fourier series of <IMG
WIDTH="44" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img224.png"
ALT="${x_{50}}[n]$">
as:
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{x_{50}}[n] = {b_0} +
{b_1} \cos \left ( \omega n + {\theta_1} \right ) +
{b_2} \cos \left ( 2 \omega n + {\theta_2} \right ) + \cdots
\end{displaymath}
-->
<IMG
WIDTH="373" HEIGHT="28" BORDER="0"
SRC="img227.png"
ALT="\begin{displaymath}
{x_{50}}[n] = {b_0} +
{b_1} \cos \left ( \omega n + {\thet...
...
{b_2} \cos \left ( 2 \omega n + {\theta_2} \right ) + \cdots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
and substitute the Fourier series for all three terms above, we get:
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{a_0} +
{a_1} \cos \left ( 2 \omega n + {\phi_1} \right ) +
{a_2} \cos \left ( 4 \omega n + {\phi_2} \right ) + \cdots
\end{displaymath}
-->
<IMG
WIDTH="327" HEIGHT="28" BORDER="0"
SRC="img228.png"
ALT="\begin{displaymath}
{a_0} +
{a_1} \cos \left ( 2 \omega n + {\phi_1} \right ) +
{a_2} \cos \left ( 4 \omega n + {\phi_2} \right ) + \cdots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
=
{b_0} +
{b_1} \cos \left ( \omega n + {\theta_1} \right ) +
{b_2} \cos \left ( 2 \omega n + {\theta_2} \right ) + \cdots
\end{displaymath}
-->
<IMG
WIDTH="327" HEIGHT="28" BORDER="0"
SRC="img229.png"
ALT="\begin{displaymath}
=
{b_0} +
{b_1} \cos \left ( \omega n + {\theta_1} \right...
...
{b_2} \cos \left ( 2 \omega n + {\theta_2} \right ) + \cdots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
+
{b_0} +
{b_1} \cos \left ( \omega n + \pi + {\theta_1} \right ) +
{b_2} \cos \left ( 2 \omega n + 2 \pi + {\theta_2} \right ) + \cdots
\end{displaymath}
-->
<IMG
WIDTH="389" HEIGHT="28" BORDER="0"
SRC="img230.png"
ALT="\begin{displaymath}
+
{b_0} +
{b_1} \cos \left ( \omega n + \pi + {\theta_1} ...
...\cos \left ( 2 \omega n + 2 \pi + {\theta_2} \right ) + \cdots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
= 2 {b_0} +
2 {b_2} \cos \left ( 2 \omega n + {\theta_2} \right ) +
2 {b_4} \cos \left ( 4 \omega n + {\theta_4} \right ) + \cdots
\end{displaymath}
-->
<IMG
WIDTH="359" HEIGHT="28" BORDER="0"
SRC="img231.png"
ALT="\begin{displaymath}
= 2 {b_0} +
2 {b_2} \cos \left ( 2 \omega n + {\theta_2} \...
... {b_4} \cos \left ( 4 \omega n + {\theta_4} \right ) + \cdots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
and so
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{a_0} = 2{b_0}, \,\, {a_1} = 2{b_2}, \,\, {a_2} = 2{b_4}
\end{displaymath}
-->
<IMG
WIDTH="199" HEIGHT="27" BORDER="0"
SRC="img232.png"
ALT="\begin{displaymath}
{a_0} = 2{b_0}, \,\, {a_1} = 2{b_2}, \,\, {a_2} = 2{b_4}
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
and so on: the even partials of <IMG
WIDTH="26" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img233.png"
ALT="$x_{50}$">, at least, are obtained by stretching
the partials of <IMG
WIDTH="32" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img234.png"
ALT="$x_{100}$"> out twice as far. (We don't yet know about the odd
partials of <IMG
WIDTH="26" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img233.png"
ALT="$x_{50}$">, and these might be in line with the even ones or not,
depending on factors we can't control yet. Suffice it to say for the moment,
that if the waveform connects smoothly with the horizontal axis at both
ends, the odd partials will act globally like the even ones. To make this
more exact we'll need Fourier analysis, which is developed in Chapter 9.)
<P>
Similarly, <IMG
WIDTH="32" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img234.png"
ALT="$x_{100}$"> and <IMG
WIDTH="32" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img235.png"
ALT="$x_{200}$"> are related in exactly the same way:
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{x_{200}}[2n] = {x_{100}}[n] + {x_{100}}[n+{\pi \over \omega}]
\end{displaymath}
-->
<IMG
WIDTH="222" HEIGHT="35" BORDER="0"
SRC="img236.png"
ALT="\begin{displaymath}
{x_{200}}[2n] = {x_{100}}[n] + {x_{100}}[n+{\pi \over \omega}]
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
so that, if the amplitudes of the fourier series of <IMG
WIDTH="32" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img235.png"
ALT="$x_{200}$"> are denoted
by <IMG
WIDTH="17" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img237.png"
ALT="$c_0$">, <IMG
WIDTH="17" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img238.png"
ALT="$c_1$">, <IMG
WIDTH="22" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
SRC="img239.png"
ALT="$\ldots$">, we get:
<BR><P></P>
<DIV ALIGN="CENTER">
<!-- MATH
\begin{displaymath}
{c_0} = 2{a_0}, {c_1} = 2{a_2}, {c_2} = 2{a_4}, \ldots
\end{displaymath}
-->
<IMG
WIDTH="213" HEIGHT="27" BORDER="0"
SRC="img240.png"
ALT="\begin{displaymath}
{c_0} = 2{a_0}, {c_1} = 2{a_2}, {c_2} = 2{a_4}, \ldots
\end{displaymath}">
</DIV>
<BR CLEAR="ALL">
<P></P>
so that the partials of <IMG
WIDTH="32" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img235.png"
ALT="$x_{200}$"> are those of <IMG
WIDTH="32" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img234.png"
ALT="$x_{100}$"> shrunk, by half,
to the left.
<P>
We see that squeezing the waveform by a factor of 2 has the effect of
stretching the Fourier series out by two, and on the other hand stretching the
waveform by a factor of two squeezes the Fourier series by two. By the same
sort of argument, in general it turns out that stretching the waveform by a
factor of any positive number <IMG
WIDTH="13" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
SRC="img112.png"
ALT="$f$"> squeezes the overtones, in frequency, by the
reciprocal <IMG
WIDTH="28" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img241.png"
ALT="$1/f$">--at least approximately, and the approximation is at least
2022-04-12 23:17:03 -03:00
fairly good if the waveform "behaves well" at its ends.
(As we'll see later, the waveform can always be forced to behave at least
reasonably well by enveloping it as in Figure <A HREF="node29.html#fig02.07">2.7</A>.)
<P>
Figure <A HREF="#fig02.10">2.10</A> shows the spectra of the three waveforms--or in
other words the one waveform at three duty cycles--of Figure
<A HREF="#fig02.09">2.9</A>. The figure emphasizes the relationship between the three
spectra by drawing curves through each, which, on inspection, turn out to be
the same curve, only stretched differently; as the duty cycle goes up, the
curve is both compressed to the left (the frequencies all drop) and amplified
(stretched upward).
<P>
2022-04-12 23:32:40 -03:00
<DIV ALIGN="CENTER"><A ID="fig02.10"></A><A ID="2511"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 2.10:</STRONG>
The Fourier series magnitudes for the waveforms shown in Figure
2022-04-12 23:17:03 -03:00
<A HREF="#fig02.09">2.9</A>. The horizontal axis is the harmonic number. We only "hear"
the coefficients for integer harmonic numbers; the continuous curves are the
2022-04-12 23:17:03 -03:00
"ideal" contours.</CAPTION>
<TR><TD><IMG
WIDTH="474" HEIGHT="317" BORDER="0"
SRC="img242.png"
ALT="\begin{figure}\psfig{file=figs/fig02.10.ps}\end{figure}"></TD></TR>
</TABLE>
</DIV>
<P>
The continuous curves have a very simple interpretation. Imagine squeezing the
waveform into some tiny duty cycle, say 1 percent. The contour will be
stretched by a factor of 100. Working backward, this would allow us to
interpolate between each pair of consecutive points of the 100 percent duty
cycle contour (the original one) with 99 new ones. Already in the figure the
50 percent duty cycle trace defines the curve with twice the resolution of
the original one. In the limit, as the duty cycle gets arbitrarily small, the
2022-04-12 23:17:03 -03:00
spectrum is filled in more and more densely; and the limit is the "true"
spectrum of the waveform.
<P>
2022-04-12 23:17:03 -03:00
This "true" spectrum is only audible at suitably low duty cycles, though. The
200 percent duty cycle example actually misses the peak in the ideal
(continuous) spectrum because the peak falls below the first harmonic. In
general, higher duty cycles sample the ideal curve at lower resolutions.
<P>
Timbre stretching is an extremely powerful technique for generating
sounds with systematically variable spectra. Combined with the possibilities of
mixtures of waveforms (Section <A HREF="node27.html#sect2.oscillator">2.1</A>) and of snatching
endlessly variable waveforms from recorded samples (Section
<A HREF="node28.html#sect2.sampling">2.2</A>), it is possible to generate all sorts of sounds.
For example, the block diagram of Figure <A HREF="node29.html#fig02.07">2.7</A> gives us a
way to to grab and stretch timbres from a recorded wavetable. When the
2022-04-12 23:17:03 -03:00
"frequency" parameter <IMG
WIDTH="13" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
SRC="img112.png"
ALT="$f$"> is high enough to be audible as a pitch, the
2022-04-12 23:17:03 -03:00
"size"
parameter <IMG
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
SRC="img208.png"
ALT="$s$"> can be thought of as controlling timbre stretch, via the
formula <IMG
WIDTH="67" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
SRC="img209.png"
ALT="$t = fs/R$"> from Section <A HREF="node28.html#sect2.sampling">2.2</A>, where we now
reinterpret <IMG
WIDTH="9" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
SRC="img82.png"
ALT="$t$"> as the factor by which the timbre is to be stretched.
<P>
<HR>
<!--Navigation Panel-->
2022-04-12 23:32:40 -03:00
<A ID="tex2html988"
HREF="node31.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
SRC="next.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html982"
HREF="node26.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
SRC="up.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html976"
HREF="node29.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
SRC="prev.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html984"
HREF="node4.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
SRC="contents.png"></A>
2022-04-12 23:32:40 -03:00
<A ID="tex2html986"
HREF="node201.html">
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
SRC="index.png"></A>
<BR>
2022-04-12 23:32:40 -03:00
<B> Next:</B> <A ID="tex2html989"
HREF="node31.html">Interpolation</A>
2022-04-12 23:32:40 -03:00
<B> Up:</B> <A ID="tex2html983"
HREF="node26.html">Wavetables and samplers</A>
2022-04-12 23:32:40 -03:00
<B> Previous:</B> <A ID="tex2html977"
HREF="node29.html">Enveloping samplers</A>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html985"
HREF="node4.html">Contents</A></B>
2022-04-12 23:32:40 -03:00
&nbsp; <B> <A ID="tex2html987"
HREF="node201.html">Index</A></B>
<!--End of Navigation Panel-->
<ADDRESS>
Miller Puckette
2006-12-30
</ADDRESS>
</BODY>
</HTML>