486 lines
15 KiB
HTML
486 lines
15 KiB
HTML
<!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>Pitch shifting</TITLE>
|
|
<META NAME="description" CONTENT="Pitch shifting">
|
|
<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="node116.html">
|
|
<LINK REL="previous" HREF="node114.html">
|
|
<LINK REL="up" HREF="node104.html">
|
|
<LINK REL="next" HREF="node116.html">
|
|
</HEAD>
|
|
|
|
<BODY >
|
|
<!--Navigation Panel-->
|
|
<A NAME="tex2html2268"
|
|
HREF="node116.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
|
|
SRC="next.png"></A>
|
|
<A NAME="tex2html2262"
|
|
HREF="node104.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
|
|
SRC="up.png"></A>
|
|
<A NAME="tex2html2256"
|
|
HREF="node114.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
|
|
SRC="prev.png"></A>
|
|
<A NAME="tex2html2264"
|
|
HREF="node4.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
|
|
SRC="contents.png"></A>
|
|
<A NAME="tex2html2266"
|
|
HREF="node201.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
|
|
SRC="index.png"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html2269"
|
|
HREF="node116.html">Examples</A>
|
|
<B> Up:</B> <A NAME="tex2html2263"
|
|
HREF="node104.html">Time shifts and delays</A>
|
|
<B> Previous:</B> <A NAME="tex2html2257"
|
|
HREF="node114.html">Fidelity of interpolating delay</A>
|
|
<B> <A NAME="tex2html2265"
|
|
HREF="node4.html">Contents</A></B>
|
|
<B> <A NAME="tex2html2267"
|
|
HREF="node201.html">Index</A></B>
|
|
<BR>
|
|
<BR>
|
|
<!--End of Navigation Panel-->
|
|
|
|
<H1><A NAME="SECTION001190000000000000000"></A>
|
|
<A NAME="sect7.pitchshift"></A>
|
|
<BR>
|
|
Pitch shifting
|
|
</H1>
|
|
|
|
<P>
|
|
A favorite use of variable delay lines is to alter the pitch of an incoming
|
|
sound using the Doppler effect. It may be desirable to alter the pitch
|
|
variably (randomly or periodically, for example), or else
|
|
to maintain a fixed musical interval of transposition over a length of time.
|
|
|
|
<P>
|
|
Returning to Figure <A HREF="node113.html#fig07.17">7.17</A>, we see that with a single variable
|
|
delay line we can maintain any desired pitch shift for a limited
|
|
interval of time, but if we wish to sustain a fixed transposition we will always
|
|
eventually land outside the diagonal strip of admissible delay times. In
|
|
the simplest scenario, we simply vary the transposition up and down so as to remain
|
|
in the strip.
|
|
|
|
<P>
|
|
|
|
<DIV ALIGN="CENTER"><A NAME="fig07.19"></A><A NAME="8151"></A>
|
|
<TABLE>
|
|
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.19:</STRONG>
|
|
Vibrato using a variable delay line. Since the pitch shift
|
|
alternates between upward and downward, it is possible to maintain it without
|
|
drifting outside the strip of admissible delay.</CAPTION>
|
|
<TR><TD><IMG
|
|
WIDTH="380" HEIGHT="344" BORDER="0"
|
|
SRC="img799.png"
|
|
ALT="\begin{figure}\psfig{file=figs/fig07.19.ps}\end{figure}"></TD></TR>
|
|
</TABLE>
|
|
</DIV>
|
|
|
|
<P>
|
|
This works, for example, if we wish to apply vibrato
|
|
to a sound as shown in Figure <A HREF="#fig07.19">7.19</A>.
|
|
Here the delay function is
|
|
<BR><P></P>
|
|
<DIV ALIGN="CENTER">
|
|
<!-- MATH
|
|
\begin{displaymath}
|
|
d[n] = {d_0} + a \cos(\omega n)
|
|
\end{displaymath}
|
|
-->
|
|
|
|
<IMG
|
|
WIDTH="145" HEIGHT="28" BORDER="0"
|
|
SRC="img800.png"
|
|
ALT="\begin{displaymath}
|
|
d[n] = {d_0} + a \cos(\omega n)
|
|
\end{displaymath}">
|
|
</DIV>
|
|
<BR CLEAR="ALL">
|
|
<P></P>
|
|
where <IMG
|
|
WIDTH="18" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img801.png"
|
|
ALT="$d_0$"> is the average delay, <IMG
|
|
WIDTH="11" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img4.png"
|
|
ALT="$a$"> is the amplitude of variation about
|
|
the average delay, and <IMG
|
|
WIDTH="14" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img27.png"
|
|
ALT="$\omega $"> is an angular frequency. The Momentary
|
|
Transposition (Page <A HREF="node113.html#eq.momentarydel"><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
|
SRC="crossref.png"></A>), is approximately
|
|
<BR><P></P>
|
|
<DIV ALIGN="CENTER">
|
|
<!-- MATH
|
|
\begin{displaymath}
|
|
t = 1 + a \omega \cos(\omega n - \pi/2)
|
|
\end{displaymath}
|
|
-->
|
|
|
|
<IMG
|
|
WIDTH="174" HEIGHT="28" BORDER="0"
|
|
SRC="img802.png"
|
|
ALT="\begin{displaymath}
|
|
t = 1 + a \omega \cos(\omega n - \pi/2)
|
|
\end{displaymath}">
|
|
</DIV>
|
|
<BR CLEAR="ALL">
|
|
<P></P>
|
|
This ranges in value between <IMG
|
|
WIDTH="49" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img803.png"
|
|
ALT="$1 - a \omega$"> and <IMG
|
|
WIDTH="49" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img804.png"
|
|
ALT="$1 + a \omega$">.
|
|
|
|
<P>
|
|
|
|
<DIV ALIGN="CENTER"><A NAME="fig07.20"></A><A NAME="8159"></A>
|
|
<TABLE>
|
|
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.20:</STRONG>
|
|
Piecewise linear delay functions to maintain a constant transposition
|
|
(except at the points of discontinuity). The outputs are enveloped as suggested
|
|
by the bars above each point, to smooth the output at the points of discontinuity
|
|
in delay time.</CAPTION>
|
|
<TR><TD><IMG
|
|
WIDTH="325" HEIGHT="346" BORDER="0"
|
|
SRC="img805.png"
|
|
ALT="\begin{figure}\psfig{file=figs/fig07.20.ps}\end{figure}"></TD></TR>
|
|
</TABLE>
|
|
</DIV>
|
|
|
|
<P>
|
|
Suppose, on the other hand, that we wish to maintain a constant transposition
|
|
over a longer interval of time. In this case we can't maintain the
|
|
transposition forever, but it is still possible to maintain it over fixed
|
|
intervals of time broken by discontinuous changes, as shown in Figure
|
|
<A HREF="#fig07.20">7.20</A>.
|
|
The delay time is the output of a suitably normalized sawtooth function, and
|
|
the output of the variable delay line is enveloped as shown in the figure
|
|
to avoid discontinuities.
|
|
|
|
<P>
|
|
|
|
<DIV ALIGN="CENTER"><A NAME="fig07.21"></A><A NAME="8165"></A>
|
|
<TABLE>
|
|
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.21:</STRONG>
|
|
Using a variable delay line as a pitch shifter. The sawtooth wave
|
|
creates a smoothly increasing or decreasing delay time. The output of the
|
|
delay line is enveloped to avoid discontinuities.
|
|
Another copy of the same diagram should run 180 degrees (<IMG
|
|
WIDTH="13" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img41.png"
|
|
ALT="$\pi $"> radians) out
|
|
of phase with this one.</CAPTION>
|
|
<TR><TD><IMG
|
|
WIDTH="281" HEIGHT="403" BORDER="0"
|
|
SRC="img806.png"
|
|
ALT="\begin{figure}\psfig{file=figs/fig07.21.ps}\end{figure}"></TD></TR>
|
|
</TABLE>
|
|
</DIV>
|
|
|
|
<P>
|
|
This is accomplished as shown in Figure <A HREF="#fig07.21">7.21</A>.
|
|
The output of the sawtooth generator is used in two ways. First it is adjusted
|
|
to run between the bounds <IMG
|
|
WIDTH="18" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img807.png"
|
|
ALT="${d_0}$"> and <IMG
|
|
WIDTH="45" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img808.png"
|
|
ALT="${d_0}+s$">, and this adjusted sawtooth
|
|
controls the delay time, in samples. The initial delay <IMG
|
|
WIDTH="18" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img801.png"
|
|
ALT="$d_0$"> should be at
|
|
least enough to make the variable delay feasible; for four-point interpolation
|
|
it must be at least one sample. Larger values of <IMG
|
|
WIDTH="18" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img801.png"
|
|
ALT="$d_0$"> add a constant,
|
|
additional delay to the output; this is usually offered as a control in a
|
|
pitch shifter since it is essentially free. The quantity <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> is sometimes
|
|
called the
|
|
<A NAME="8171"></A><I>window size</I>. It corresponds roughly to the sample length in a
|
|
looping sampler (Section <A HREF="node28.html#sect2.sampling">2.2</A>).
|
|
|
|
<P>
|
|
The sawtooth output is also used to envelope the output in exactly the same
|
|
way as in the enveloped wavetable sampler of Figure <A HREF="node29.html#fig02.07">2.7</A>
|
|
(Page <A HREF="node29.html#fig02.07"><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
|
SRC="crossref.png"></A>). The
|
|
envelope is zero at the points where the sawtooth wraps around, and in
|
|
between, rises smoothly to a maximum value of 1 (for unit gain).
|
|
|
|
<P>
|
|
If the frequency of the sawtooth wave is <IMG
|
|
WIDTH="13" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img112.png"
|
|
ALT="$f$"> (in cycles per second), then
|
|
its value sweeps from 0 to 1 every <IMG
|
|
WIDTH="33" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img809.png"
|
|
ALT="$R/f$"> samples (where <IMG
|
|
WIDTH="15" HEIGHT="14" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img36.png"
|
|
ALT="$R$"> is the sample rate).
|
|
The difference between successive values is thus <IMG
|
|
WIDTH="33" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img810.png"
|
|
ALT="$f/R$">. If we let <IMG
|
|
WIDTH="31" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img80.png"
|
|
ALT="$x[n]$">
|
|
denote the output of the sawtooth oscillator, then
|
|
<BR><P></P>
|
|
<DIV ALIGN="CENTER">
|
|
<!-- MATH
|
|
\begin{displaymath}
|
|
x[n+1] - x[n] = {f \over R}
|
|
\end{displaymath}
|
|
-->
|
|
|
|
<IMG
|
|
WIDTH="136" HEIGHT="39" BORDER="0"
|
|
SRC="img811.png"
|
|
ALT="\begin{displaymath}
|
|
x[n+1] - x[n] = {f \over R}
|
|
\end{displaymath}">
|
|
</DIV>
|
|
<BR CLEAR="ALL">
|
|
<P></P>
|
|
(except at the wraparound points). If we adjust the output range of the
|
|
wavetable oscillator to the value <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> (as is done in the figure) we get a
|
|
new slope:
|
|
<BR><P></P>
|
|
<DIV ALIGN="CENTER">
|
|
<!-- MATH
|
|
\begin{displaymath}
|
|
s \cdot x[n+1] - s \cdot x[n] = {{sf} \over R}
|
|
\end{displaymath}
|
|
-->
|
|
|
|
<IMG
|
|
WIDTH="180" HEIGHT="39" BORDER="0"
|
|
SRC="img812.png"
|
|
ALT="\begin{displaymath}
|
|
s \cdot x[n+1] - s \cdot x[n] = {{sf} \over R}
|
|
\end{displaymath}">
|
|
</DIV>
|
|
<BR CLEAR="ALL">
|
|
<P></P>
|
|
Adding the constant <IMG
|
|
WIDTH="18" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img801.png"
|
|
ALT="$d_0$"> has no effect on this slope. The Momentary
|
|
Transposition (Page <A HREF="node113.html#eq.momentarydel"><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
|
SRC="crossref.png"></A>) is then:
|
|
<BR><P></P>
|
|
<DIV ALIGN="CENTER">
|
|
<!-- MATH
|
|
\begin{displaymath}
|
|
t = 1 - {{sf} \over R}
|
|
\end{displaymath}
|
|
-->
|
|
|
|
<IMG
|
|
WIDTH="74" HEIGHT="39" BORDER="0"
|
|
SRC="img813.png"
|
|
ALT="\begin{displaymath}
|
|
t = 1 - {{sf} \over R}
|
|
\end{displaymath}">
|
|
</DIV>
|
|
<BR CLEAR="ALL">
|
|
<P></P>
|
|
To complete the design of the pitch shifter we must add the other copy halfway
|
|
out of phase. This gives rise to a delay reading pattern as shown in
|
|
Figure <A HREF="#fig07.22">7.22</A>.
|
|
|
|
<P>
|
|
|
|
<DIV ALIGN="CENTER"><A NAME="fig07.22"></A><A NAME="8183"></A>
|
|
<TABLE>
|
|
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 7.22:</STRONG>
|
|
The pitch shifter's delay reading pattern using two delay lines,
|
|
so that one is at maximum amplitude exactly when the other is switching.</CAPTION>
|
|
<TR><TD><IMG
|
|
WIDTH="326" HEIGHT="343" BORDER="0"
|
|
SRC="img814.png"
|
|
ALT="\begin{figure}\psfig{file=figs/fig07.22.ps}\end{figure}"></TD></TR>
|
|
</TABLE>
|
|
</DIV>
|
|
|
|
<P>
|
|
The pitch shifter can transpose either upward (using negative sawtooth
|
|
frequencies, as in the figure) or downward, using positive ones. Pitch shift is
|
|
usually controlled by changing <IMG
|
|
WIDTH="13" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img112.png"
|
|
ALT="$f$"> with <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> fixed. To get a
|
|
desired transposition interval <IMG
|
|
WIDTH="9" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img82.png"
|
|
ALT="$t$">, set
|
|
<BR><P></P>
|
|
<DIV ALIGN="CENTER">
|
|
<!-- MATH
|
|
\begin{displaymath}
|
|
f = {{(t - 1) R} \over s}
|
|
\end{displaymath}
|
|
-->
|
|
|
|
<IMG
|
|
WIDTH="89" HEIGHT="40" BORDER="0"
|
|
SRC="img815.png"
|
|
ALT="\begin{displaymath}
|
|
f = {{(t - 1) R} \over s}
|
|
\end{displaymath}">
|
|
</DIV>
|
|
<BR CLEAR="ALL">
|
|
<P></P>
|
|
<A NAME="sect7.psformula"></A>The window size <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> should be chosen small enough, if possible, so that the
|
|
two delayed copies
|
|
(<IMG
|
|
WIDTH="26" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img214.png"
|
|
ALT="$s/2$"> samples apart) do not sound as distinct echoes. However, very small
|
|
values of <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> will force <IMG
|
|
WIDTH="13" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img112.png"
|
|
ALT="$f$"> upward; values of <IMG
|
|
WIDTH="13" HEIGHT="30" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img112.png"
|
|
ALT="$f$"> greater than about 5 Hertz
|
|
result
|
|
in very audible modulation. So if very large transpositions are required, the
|
|
value of <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> may need to be increased. Typical values range from 30 to 100
|
|
milliseconds (about <IMG
|
|
WIDTH="39" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img816.png"
|
|
ALT="$R/30$"> to <IMG
|
|
WIDTH="39" HEIGHT="32" ALIGN="MIDDLE" BORDER="0"
|
|
SRC="img817.png"
|
|
ALT="$R/10$"> samples).
|
|
|
|
<P>
|
|
Although the frequency may be changed at will, even discontinuously, <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> must
|
|
be changed more carefully. A possible solution is to mute the output while
|
|
changing <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> discontinuously; alternatively, <IMG
|
|
WIDTH="10" HEIGHT="13" ALIGN="BOTTOM" BORDER="0"
|
|
SRC="img208.png"
|
|
ALT="$s$"> may be ramped continuously but
|
|
this causes hard-to-control Doppler shifts.
|
|
|
|
<P>
|
|
A good choice of envelope is one half cycle of a sinusoid. If we assume
|
|
on average that the two delay outputs are uncorrelated (Page
|
|
<A HREF="node13.html#eq-meanpowersum"><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
|
SRC="crossref.png"></A>), the signal power from the two delay lines, after
|
|
enveloping, will add to a constant (since the sum of squares of the two
|
|
envelopes is one).
|
|
|
|
<P>
|
|
Many variations exist on this pitch shifting algorithm. One
|
|
classic variant uses a single delay line, with no enveloping at
|
|
all. In this situation it is necessary to choose the point at
|
|
which the delay time jumps, and the point it jumps to, so that the output
|
|
stays continuous. For example, one could find a point where the output signal
|
|
passes through zero (a ``zero crossing") and jump discontinuously to another one.
|
|
Using only one delay line has the advantage that the signal output sounds
|
|
more ``present". A disadvantage is that, since
|
|
the delay time is a function of input signal value, the output is no longer
|
|
a linear function of the input, so non-periodic inputs can give rise to
|
|
artifacts such as difference tones.
|
|
|
|
<P>
|
|
<HR>
|
|
<!--Navigation Panel-->
|
|
<A NAME="tex2html2268"
|
|
HREF="node116.html">
|
|
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next"
|
|
SRC="next.png"></A>
|
|
<A NAME="tex2html2262"
|
|
HREF="node104.html">
|
|
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
|
|
SRC="up.png"></A>
|
|
<A NAME="tex2html2256"
|
|
HREF="node114.html">
|
|
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
|
|
SRC="prev.png"></A>
|
|
<A NAME="tex2html2264"
|
|
HREF="node4.html">
|
|
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents"
|
|
SRC="contents.png"></A>
|
|
<A NAME="tex2html2266"
|
|
HREF="node201.html">
|
|
<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index"
|
|
SRC="index.png"></A>
|
|
<BR>
|
|
<B> Next:</B> <A NAME="tex2html2269"
|
|
HREF="node116.html">Examples</A>
|
|
<B> Up:</B> <A NAME="tex2html2263"
|
|
HREF="node104.html">Time shifts and delays</A>
|
|
<B> Previous:</B> <A NAME="tex2html2257"
|
|
HREF="node114.html">Fidelity of interpolating delay</A>
|
|
<B> <A NAME="tex2html2265"
|
|
HREF="node4.html">Contents</A></B>
|
|
<B> <A NAME="tex2html2267"
|
|
HREF="node201.html">Index</A></B>
|
|
<!--End of Navigation Panel-->
|
|
<ADDRESS>
|
|
Miller Puckette
|
|
2006-12-30
|
|
</ADDRESS>
|
|
</BODY>
|
|
</HTML>
|