AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

420_paper.tex (33718B)


      1 % !TeX program = pdflatex
      2 % !BIB program = bibtex
      3 % Template LaTeX file for DAFx-19 papers
      4 %
      5 % To generate the correct references using BibTeX, run
      6 %     latex, bibtex, latex, latex
      7 % modified...
      8 % - from DAFx-00 to DAFx-02 by Florian Keiler, 2002-07-08
      9 % - from DAFx-02 to DAFx-03 by Gianpaolo Evangelista
     10 % - from DAFx-05 to DAFx-06 by Vincent Verfaille, 2006-02-05
     11 % - from DAFx-06 to DAFx-07 by Vincent Verfaille, 2007-01-05
     12 %                          and Sylvain Marchand, 2007-01-31
     13 % - from DAFx-07 to DAFx-08 by Henri Penttinen, 2007-12-12
     14 %                          and Jyri Pakarinen 2008-01-28
     15 % - from DAFx-08 to DAFx-09 by Giorgio Prandi, Fabio Antonacci 2008-10-03
     16 % - from DAFx-09 to DAFx-10 by Hannes Pomberger 2010-02-01
     17 % - from DAFx-10 to DAFx-12 by Jez Wells 2011
     18 % - from DAFx-12 to DAFx-14 by Sascha Disch 2013
     19 % - from DAFx-15 to DAFx-16 by Pavel Rajmic 2015
     20 % - from DAFx-16 to DAFx-17 by Brian Hamilton 2016
     21 % - from DAFx-18 to DAFx-19 by Dave Moffat 2019
     22 %
     23 % Template with hyper-references (links) active after conversion to pdf
     24 % (with the distiller) or if compiled with pdflatex.
     25 %
     26 % 20060205: added package 'hypcap' to correct hyperlinks to figures and tables
     27 %                      use of \papertitle and \paperauthorA, etc for same title in PDF and Metadata
     28 %
     29 % 1) Please compile using latex or pdflatex.
     30 % 2) If using pdflatex, you need your figures in a file format other than eps! e.g. png or jpg is working
     31 % 3) Please use "paperftitle" and "pdfauthor" definitions below
     32 
     33 %------------------------------------------------------------------------------------------
     34 %  !  !  !  !  !  !  !  !  !  !  !  ! user defined variables  !  !  !  !  !  !  !  !  !  !  !  !  !  !
     35 % Please use these commands to define title and author(s) of the paper:
     36 \def\papertitle{Real-time Physical Modelling for Analog Tape Machines}
     37 \def\paperauthorA{Jatin Chowdhury}
     38 
     39 % Authors' affiliations have to be set below
     40 
     41 %------------------------------------------------------------------------------------------
     42 \documentclass[twoside,a4paper]{article}
     43 \usepackage{dafx_19}
     44 \usepackage{amsmath,amssymb,amsfonts,amsthm}
     45 \usepackage{euscript}
     46 \usepackage[latin1]{inputenc}
     47 \usepackage[T1]{fontenc}
     48 \usepackage{ifpdf}
     49 
     50 \usepackage[english]{babel}
     51 \usepackage{caption}
     52 \usepackage{subfig} % or can use subcaption package
     53 \usepackage{color}
     54 
     55 \setcounter{page}{1}
     56 \ninept
     57 
     58 \usepackage{times}
     59 % Saves a lot of ouptut space in PDF... after conversion with the distiller
     60 % Delete if you cannot get PS fonts working on your system.
     61 
     62 % pdf-tex settings: detect automatically if run by latex or pdflatex
     63 \newif\ifpdf
     64 \ifx\pdfoutput\relax
     65 \else
     66    \ifcase\pdfoutput
     67       \pdffalse
     68    \else
     69       \pdftrue
     70 \fi
     71 
     72 \ifpdf % compiling with pdflatex
     73   \usepackage[pdftex,
     74     pdftitle={\papertitle},
     75     pdfauthor={\paperauthorA},
     76     colorlinks=false, % links are activated as colror boxes instead of color text
     77     bookmarksnumbered, % use section numbers with bookmarks
     78     pdfstartview=XYZ % start with zoom=100% instead of full screen; especially useful if working with a big screen :-)
     79   ]{hyperref}
     80   \pdfcompresslevel=9
     81   \usepackage[pdftex]{graphicx}
     82 %  \usepackage[figure,table,hypcap=true]{caption}
     83 \else % compiling with latex
     84   \usepackage[dvips]{epsfig,graphicx}
     85   \usepackage[dvips,
     86     colorlinks=false, % no color links
     87     bookmarksnumbered, % use section numbers with bookmarks
     88     pdfstartview=XYZ % start with zoom=100% instead of full screen
     89   ]{hyperref}
     90   % hyperrefs are active in the pdf file after conversion
     91 %  \usepackage[figure,table,hypcap=true]{caption}
     92 \fi
     93   \usepackage[hypcap=true]{caption}
     94 \usepackage{cleveref}
     95 \usepackage{tikz}
     96 \usetikzlibrary{dsp,chains}
     97 
     98 \DeclareMathAlphabet{\mathpzc}{OT1}{pzc}{m}{it}
     99 \newcommand{\z}{\mathpzc{z}}
    100 
    101 \title{\papertitle}
    102 
    103 \affiliation{
    104 \paperauthorA \,}
    105 {\href{http://ccrma.stanford.edu}{Center for Computer Research in Music and Acoustics} \\ Stanford University \\ Palo Alto, CA \\ {\tt \href{mailto:jatin@ccrma.stanford.edu}{jatin@ccrma.stanford.edu}}}
    106 
    107 \begin{document}
    108 % more pdf-tex settings:
    109 \ifpdf % used graphic file format for pdflatex
    110   \DeclareGraphicsExtensions{.png,.jpg,.pdf}
    111 \else  % used graphic file format for latex
    112   \DeclareGraphicsExtensions{.eps}
    113 \fi
    114 
    115 \maketitle
    116 
    117 \begin{abstract}
    118 For decades, analog magnetic tape recording was the most popular
    119 method for recording music, but has been replaced over the past 30 years first by
    120 DAT tape, then by DAWs and audio interfaces \cite{Kadis}. Despite being replaced
    121 by higher quality technology, many have sought to recreate a "tape" sound
    122 through digital effects, despite the distortion, tape ``hiss'', and other
    123 oddities analog tape produced. The following paper describes the general process
    124 of creating a physical model of an analog tape machine starting from basic
    125 physical principles, then discusses in-depth a real-time implementation
    126 of a physical model of a Sony TC-260 tape machine.
    127 \newline\newline
    128 "Whatever you now find weird, ugly, uncomfortable, and nasty
    129 about a new medium will surely become its signature. CD distortion, the jitteriness
    130 of digital video, the crap sound of 8-bit - all of these will be cherished
    131 and emulated as soon as they can be avoided." -Brian Eno \cite{Eno}.
    132 \end{abstract}
    133 
    134 \section{Introduction}
    135 While analog magnetic tape recording (see \cref{TapeMachine}) is rarely used in modern recording
    136 studios, the sound of analog tape is still often sought after by mixing
    137 and mastering engineers. To that end, several prominent audio
    138 plugin manufacturers including Waves\footnote{\url{https://www.waves.com/plugins/j37-tape}},
    139 Universal Audio\footnote{\url{https://www.uaudio.com/uad-plugins/plug-in-bundles/magnetic-tape-bundle.html}},
    140 and U-He\footnote{\url{https://u-he.com/products/satin/}} have created
    141 tape emulating plugins. Unfortunately,
    142 the existing literature on analog tape emulation is somewhat lacking.
    143 While Arnadottir et at. \cite{tapeDelay} and Valimaki et al. \cite{DAFX_book}
    144 describe the emulation of tape echo/delay devices, and Valimaki et al
    145 \cite{disks} describe the emulation of disk-based audio recording media,
    146 we were unable to locate any existing research directly discussing digital
    147 emulation of the magnetisation process, a gap in research that this 
    148 publication intends to fill. That said, Kadis \cite{Kadis} and Camras
    149 \cite{Camras:1987:MRH:27189} discuss musical use of analog tape recorders
    150 in a useful technical manner, and Bertram \cite{1994tmr..book.....B}
    151 gives a in-depth technical description of the physical underpinnings of
    152 analog magnetic recording; this work intends to build on their foundations.
    153 While tape machines also contain electronic circuits that contribute to the 
    154 machine's characteristic sound, this publication only considers processes
    155 that relate directly to tape magnetisation. For readers
    156 wishing to emulate tape machine circuits, a good overview of circuit
    157 modelling techniques can be found in \cite{Yeh}.
    158 
    159 \begin{figure}[ht]
    160     \center
    161     \includegraphics[width=2.5in]{../Refs/Pictures/sony_tc-260.jpg}
    162     \caption{\label{TapeMachine}{\it An analog tape recorder (Sony TC 260)}}
    163 \end{figure}
    164 %
    165 
    166 \section{Continuous Time System}
    167 Audio recorded to and played back from a tape machine can be thought of as going
    168 through three distinct processors: the record head, tape magnetisation, and the play
    169 head.
    170 
    171 \subsection{The Record Head}
    172 For an instantaneous input current $I(t)$, the magnetic field output of the record 
    173 head is given as a function of distance along the tape ($x$), and depth into 
    174 the tape ($y$). Using the Karlqvist medium field approximation, we find
    175 \cite{1994tmr..book.....B}:
    176 
    177 \begin{multline}
    178     H_x(x,y) = \frac{1}{\pi} H_0 \Big(\tan^{-1} \Big(\frac{(g/2) + x}{y} \Big) \\
    179     + \tan^{-1} \Big(\frac{(g/2) - x}{y} \Big) \Big)
    180     \label{eq:H_x}
    181 \end{multline}
    182 \begin{equation}
    183     H_y(x,y) = \frac{1}{2 \pi} H_0 \ln \Big(\frac{((g/2) - x)^2 + y^2}{((g/2) + x)^2 + y^2} \Big)
    184     \label{eq:H_y}
    185 \end{equation}
    186 %
    187 where $H_x$ and $H_y$ are components of the magnetic field $\vec{H}$,
    188 $g$ is the head gap, and $H_0$ is the deep gap field, given by:
    189 
    190 \begin{equation}
    191     H_0 = \frac{NEI}{g}
    192 \end{equation}
    193 %
    194 where $N$ is the number of turns of wire around the head, and $E$ is the head 
    195 efficiency which can be calculated by:
    196 
    197 \begin{equation}
    198     E = \frac{1}{1 + \frac{l  A_g}{\mu_r g} \int_{core} \frac {d \vec{l}}{A(l)}}
    199 \end{equation}
    200 %
    201 where $A_g$ is the gap area, $\mu_r$ is the core permeability relative to 
    202 free space ($\mu_0$), and $A(l)$ is the cross-sectional 
    203 area at a point $l$ along its circumferential length.
    204 
    205 \subsection{Tape Magnetisation}
    206 The magnetisation recorded to tape from a magnetic field can be described
    207 using a hysteresis loop, as follows \cite{1994tmr..book.....B}:
    208 
    209 \begin{equation}
    210     \vec{M}(x,y) = F_{Loop}(\vec{H}(x,y))
    211 \end{equation}
    212 %
    213 where $F_{Loop}$ is a generalized hysteresis function.
    214 \newline\newline
    215 Using the Jiles-Atherton magnetisation model, the following
    216 differential equation describes magnetisation in some direction ($M$)
    217 as a function of the magnetic field in that direction ($H$) \cite{Hysteresis}:
    218 
    219 \begin{equation}
    220     \frac{dM}{dH} = \frac{(1-c) \delta_M (M_{an} - M)}{(1-c) \delta_S k - \alpha (M_{an} - M)} + c \frac{dM_{an}}{dH}
    221     \label{eq5}
    222 \end{equation}
    223 %
    224 where $c$ is the ratio of normal and anhysteric initial susceptibilities,
    225 $k$ is a measure of the width of the hysteresis
    226 loop, $\alpha$ is a mean field parameter, representing inter-domain
    227 coupling, and $\delta_S$ and $\delta_M$ are given by:
    228 
    229 \begin{equation}
    230     \delta_S = \begin{cases}
    231         1 & \text{if H is increasing} \\
    232         -1 & \text{if H is decreasing}
    233     \end{cases}
    234 \end{equation}
    235 \begin{equation}
    236     \delta_M = \begin{cases}
    237         1 & \text{if $\delta_S$ and $M_{an} - M$ have the same sign} \\
    238         0 & \text{otherwise}
    239     \end{cases}
    240 \end{equation}
    241 %
    242 $M_{an}$ is the anisotropic magnetisation given by:
    243 
    244 \begin{equation}
    245     M_{an} = M_s L \Big( \frac{H + \alpha M}{a} \Big)
    246 \end{equation}
    247 %
    248 where $M_s$ is the magnetisation saturation, $a$ characterizes the shape
    249 of the anhysteric magnetisation and $L$ is the Langevin function:
    250 
    251 \begin{equation}
    252     L(x) = \coth (x) - \frac{1}{x}
    253 \end{equation}
    254 
    255 \subsection{Play Head}
    256 \subsubsection{Ideal Playback Voltage}
    257 The ideal playback voltage as a function of tape magnetisation at a point
    258 $x$ along the tape is given by
    259 \cite{1994tmr..book.....B}:
    260 
    261 \begin{equation}
    262     V(x) =  NWEv \mu_0 \int_{-\infty}^{\infty} dx' \int_{-\delta/2}^{\delta/2} dy' \vec{h}(x' + x, y') \cdot \frac{\vec{M}(x', y')}{dx}
    263     \label{eq:Vx}
    264 \end{equation}
    265 %
    266 where $N$ is the number of turns of wire, $W$ is the width of the playhead, $E$ is the playhead
    267 efficiency, $v$ is the tape speed, $\delta$ is the thickness of the tape,
    268 and $\mu_0$ is the permeability of free space.
    269 Note that $V(x) = V(vt)$ for constant $v$. $\vec{h}(x, y)$ is defined as:
    270 
    271 \begin{equation}
    272     \vec{h} (x, y) \equiv \frac{\vec{H} (x, y)}{NIE}
    273     \label{eq12}
    274 \end{equation}
    275 %
    276 where $\vec{H} (x, y)$ can be calculated by \cref{eq:H_x,eq:H_y}.
    277 
    278 \subsubsection{Loss Effects}
    279 There are several frequency-dependent loss effects associated with playback,
    280 described as follows \cite{Kadis}:
    281 
    282 \begin{equation}
    283     V(t) = V_0(t) [e^{-kd}] \Big[\frac{1 - e^{-k \delta}}{k \delta} \Big] \Big[\frac{\sin (kg /2)}{kg/2} \Big]
    284     \label{eq:lossEffects}
    285 \end{equation}
    286 %
    287 for sinusoidal input $V_0(t)$, where $k$ is the wave number, $d$ is the distance between the tape and the playhead,
    288 $g$ is the gap width of the play head, and again $\delta$ is the thickness of the tape. The wave number
    289 is given by:
    290 
    291 \begin{equation}
    292     k = \frac {2 \pi f}{v}
    293     \label{eq:wavenumber}
    294 \end{equation}
    295 %
    296 where $f$ is the frequency and $v$ is the tape speed.
    297 
    298 \section{Digitizing the System}
    299 \subsection{Record Head}
    300 For simplicity, let us assume,
    301 \begin{equation}
    302     \vec{H}(x,y,t) = \vec{H}(0,0,t)
    303     \label{eq:spatialApprox}
    304 \end{equation}
    305 %
    306 In this case $H_y \equiv 0$, and $H_x \equiv H_0$. Thus,
    307 \begin{equation}
    308     H(t) = \frac{NEI(t)}{g}
    309     \label{eq15}
    310 \end{equation}
    311 %
    312 or,
    313 \begin{equation}
    314     \hat{H}(n) = \frac{NE\hat{I}(n)}{g}
    315     \label{eq:Hin}
    316 \end{equation}
    317 
    318 \subsection{Hysteresis}
    319 Beginning from \cref{eq5}, we can find the derivative of $M$ w.r.t. time,
    320 as in \cite{Hysteresis}:
    321 \begin{equation}
    322     \frac{dM}{dt} = \frac{\frac{(1-c) \delta_M (M_sL(Q) - M)}{(1-c) \delta_S k - \alpha (M_sL(Q) - M)} \dot{H} + c \frac{M_s}{a} \dot{H} L'(Q)}{1 - c \alpha \frac{M_s}{a} L'(Q)}
    323     \label{eq:dmdt}
    324 \end{equation}
    325 %
    326 where $Q = \frac{H + \alpha M}{a}$, and
    327 
    328 \begin{equation}
    329     L'(x) = \frac{1}{x^2} - \coth^2(x) + 1
    330 \end{equation}
    331 %
    332 Note that \cref{eq:dmdt} can also be written in the general form for non-linear
    333 Ordinary Differential Equations:
    334 \begin{equation}
    335     \frac{dM}{dt} = f(t,M,\vec{u})
    336 \end{equation}
    337 where $\vec{u} = \begin{bmatrix}
    338     H \\
    339     \dot{H}
    340     \end{bmatrix}$.
    341 \newline\newline
    342 Using the trapezoidal rule for derivative approximation, we find:
    343 
    344 \begin{equation}
    345     \dot{\hat{H}}(n) = 2\frac{\hat{H}(n) - \hat{H}(n-1)}{T} - \dot{\hat{H}}(n-1)
    346     \label{eq:hDeriv}
    347 \end{equation}
    348 %
    349 We can use the Runge-Kutta 4th-order method \cite{Yeh} to find an explicit solution
    350 for $\hat{M}(n)$:
    351 \begin{align}
    352 \begin{split}
    353     k_1 &= T f \Big(n-1, \hat{M}(n-1), \hat{\vec{u}}(n-1) \Big)\\
    354     k_2 &= T f \Big(n - \frac{1}{2}, \hat{M}(n-1) + \frac{k_1}{2}, \hat{\vec{u}}  \Big(n-\frac{1}{2} \Big) \Big)\\
    355     k_3 &= T f \Big(n- \frac{1}{2}, \hat{M}(n-1) + \frac{k_2}{2}, \hat{\vec{u}} \Big(n-\frac{1}{2} \Big) \Big)\\
    356     k_4 &= T f \Big(n, \hat{M}(n-1) + k_3, \hat{\vec{u}}(n) \Big)\\
    357     \hat{M}(n) &= \hat{M}(n-1) + \frac{k_1}{6} + \frac{k_2}{3} + \frac{k_3}{3} + \frac{k_4}{6}
    358     \label{eq:Mn}
    359 \end{split}
    360 \end{align}
    361 %
    362 We use linear interpolation to find the half-sample values used to calculate $k_2$ and $k_3$.
    363 Note that many audio DSP systems prefer
    364 lower-order implicit methods such as the trapezoidal rule to solve
    365 differential equations rather than a higher-order method like the
    366 Runge-Kutta method \cite{Yeh}. However in this case, it was found that
    367 the lower-order methods quickly became unstable for high-frequency input,
    368 particularly when the input is modulated by a bias signal (see \Cref{bias}).
    369 
    370 \subsubsection{Numerical Considerations} \label{numerical}
    371 To account for rounding errors in the Langevin function for values close to 
    372 zero, we use the following approximation about zero, as in \cite{Hysteresis}:
    373 \begin{equation}
    374     L(x) = \begin{cases}
    375         \coth(x) - \frac{1}{x} & \text{for $|x| > 10^{-4}$} \\
    376         \frac{x}{3} & \text{otherwise}
    377     \end{cases}
    378 \end{equation}
    379 \begin{equation}
    380     L'(x) = \begin{cases}
    381         \frac{1}{x^2} - \coth^{2}(x) + 1 & \text{for $|x| > 10^{-4}$} \\
    382         \frac{1}{3} & \text{otherwise}
    383     \end{cases}
    384 \end{equation}
    385 %
    386 Additionally, $\tanh(x)$, and by extension $\coth(x)$ is a
    387 rather computationally expensive operation. With this in mind,
    388 for real-time implementation, we approximate $\coth(x)$ as the
    389 reciprocal of a Gaussian continued fraction for $\tanh(x)$
    390 \cite{MATH}, namely
    391 \begin{equation}
    392     \tanh(x) = \frac{x}{1 + \frac{x^2}{3 + \frac{x^2}{5 + \frac{x^2}{7}}}}
    393     \label{eq:continuedFrac}
    394 \end{equation}
    395 
    396 \begin{figure}[ht]
    397     \center
    398     \includegraphics[width=3in]{../Simulations/Hysteresis/Sim2-M_H.png}
    399     \caption{\label{HysteresisSim}{\it Digitized Hysteresis Loop Simulation}}
    400 \end{figure}
    401 %
    402 \subsubsection{Simulation}
    403 The digitized hysteresis loop was implemented and tested offline
    404 in \texttt{Python}, using the constants $M_s$, $a$, $\alpha$, $k$,
    405 and $c$ from \cite{JilesAtherton1986}. For a sinusoidal input signal
    406 with frequency 2kHz, and varying amplitude from 800 - 2000 Amperes per
    407 meter, \cref{HysteresisSim} shows the Magnetisation output.
    408 
    409 \subsection{Play Head}
    410 By combining \cref{eq:Vx} with \cref{eq12,eq15}, we get:
    411 \begin{equation}
    412     V(t) =  NWEv \mu_0  g M(t)
    413 \end{equation}
    414 %
    415 or,
    416 \begin{equation}
    417     \hat{V}(n) =  NWEv \mu_0  g \hat{M}(n)
    418     \label{eq:Vout}
    419 \end{equation}
    420 %
    421 \subsubsection{Loss Effects} \label{Loss_Effects}
    422 In the real-time system, we model the playhead
    423 loss effects with an FIR filter, derived by
    424 taking the inverse DFT of the
    425 loss effects described in \cref{eq:lossEffects}.
    426 It is worth noting that as in \cref{eq:wavenumber},
    427 the loss effects, and therefore the FIR filter
    428 are dependent on the tape speed.
    429 \newline\newline
    430 The loss effects filter was implemented and
    431 tested offline in \texttt{Python} with tape-head 
    432 spacing of 20 microns, head gap width of 5 microns, 
    433 tape thickness of 35 microns, and tape speed of 15 ips.
    434 The following plot shows the results of the simulation,
    435 with a filter order of 100.
    436 \begin{figure}[ht]
    437     \center
    438     \includegraphics[width=3in]{../Simulations/LossEffects/Loss_Effects.png}
    439     \caption{\label{lossEffectsSim}{\it Frequency Response of Playhead Loss Effects}}
    440 \end{figure}
    441 %
    442 
    443 \section{Tape and Tape Machine Parameters}
    444 In the following sections, we describe the implementation of
    445 a real-time model of a Sony TC-260 tape machine, while attempting
    446 to preserve generality so that the process can be repeated for any
    447 similar reel-to-reel tape machine.
    448 
    449 \subsection {Tape Parameters}
    450 A typical reel-to-reel tape machine such as the Sony TC-260 uses 
    451 Ferric Oxide ($\gamma F_2O_3$) magnetic tape. The following
    452 properties of the tape are necessary for the tape hysteresis
    453 process \cref{eq:dmdt}:
    454 \begin{itemize}
    455 \item Magnetic Saturation ($M_s$): For Ferric Oxide tape
    456 the magnetic saturation is $3.5e5$ (A/m) \cite{jilesBook}.
    457 \item Hysteresis Loop Width ($k$): For soft materials, $k$ can be approximated
    458 as the coercivity, $H_c$ \cite{Jiles1992}. For Ferric Oxide, $H_c$ is approximately
    459 $27$ kA/m \cite{jilesBook}.
    460 \item Anhysteric magnetisataion ($a$): Knowing the coercivity and remnance magnetism of Ferric Oxide
    461 \cite{jilesBook}, we can calculate $a$ = 22  kA/m by the method described in
    462 \cite{Jiles1992}.
    463 \item Ratio of normal and hysteris initial susceptibilities ($c$): From \cite{Jiles1992}, $c$ = 1.7e-1.
    464 \item Mean field parameter ($\alpha$): From \cite{Jiles1992}, $\alpha$ = 1.6e-3.
    465 \end{itemize}
    466 
    467 \subsection{Tape Machine Parameters}
    468 \subsubsection {Record Head}
    469 To determine the magnetic field output of the
    470 record head using \cref{eq:Hin}, the following parameters 
    471 are necessary:
    472 \begin{itemize}
    473 \item Input Current ($\hat{I} (n)$): For the Sony TC-260
    474 the input current to the record head is approximately
    475 0.1 mA peak-to-peak \cite{RefManual}.
    476 \item Gap Width ($g$): The gap width for recording heads
    477 can range from 2.5 to 12 microns \cite{Kadis}.
    478 \item Turns of wire ($N$): The number of turns of wire
    479 is typically on the order of 100 \cite{1994tmr..book.....B}.
    480 \item Head Efficiency ($E$): The head efficiency is typically
    481 on the order of 0.1 \cite{1994tmr..book.....B}.
    482 \end{itemize}
    483 %
    484 These values result in a peak-to-peak magnetic field
    485 of approximately 5e5 A/m.
    486 
    487 \subsubsection{Play Head}
    488 Similar to the record head, the following parameters
    489 are needed to calculate the output voltage using
    490 \cref{eq:Vout,eq:lossEffects} (note that values are only included
    491 here if notably different from the record head):
    492 \begin{itemize}
    493 \item Gap Width ($g$): The play head gap width ranges from
    494 1.5 to 6 microns\cite{Kadis}.
    495 \item Head Width ($W$): For the Sony TC-260, the play head
    496 width is 0.125 inches (note that this is the same as the
    497 width of one track on the quarter-inch tape used by the 
    498 machine) \cite{RefManual}.
    499 \item Tape Speed ($v$): The Sony TC-260 can run at 3.75 inches
    500 per second (ips), or 7.5 ips \cite{RefManual}. Note that many
    501  tape machines can run at 15 or 32 ips \cite{Kadis}.
    502 \item Tape Thickness ($\delta$): Typical tape that would be used
    503 with the TC-260 is on the order of 35 microns thick \cite{RefManual}.
    504 \item Spacing ($d$): The spacing between the tape and the play
    505 head is highly variable between tape machines. For a typical
    506 tape machine spacing can be as high as 20 microns \cite{Kadis}.
    507 \end{itemize}
    508 
    509 \begin{figure}[ht]
    510     \center
    511     \includegraphics[width=3in]{../Simulations/Bias/BiasEx.png}
    512     \caption{\label{Bias}{\it Example of a biased signal}}
    513 \end{figure}
    514 %
    515 \subsection{Tape Bias}
    516 \label{bias}
    517 A typical analog recorder adds a high-frequency "bias"
    518 current to the signal to avoid the "deadzone" effect when the input signal
    519 crosses zero, as well as to linearize the output. The input
    520 current to the record head can be given by
    521 \cite{Camras:1987:MRH:27189}:
    522 \begin{equation}
    523     \hat{I}_{head}(n) = \hat{I}_{in}(n) + B \cos(2 \pi f_{bias} n T)
    524     \label{eq:bias}
    525 \end{equation}
    526 %
    527 Where the amplitude of the bias current $B$ is usually
    528 about one order of magnitude larger than the input,
    529 and the bias frequency $f_{bias}$ is well above the
    530 audible range. \Cref{Bias} shows a unit-amplitude,
    531 2 kHz sine wave biased by a 50 kHz sine wave with amplitude 5.
    532 To recover the correct output signal, tape machines use a
    533 lowpass filter, with a cutoff frequency well below the bias
    534 frequency, though still above the audible range \cite{Kadis}.
    535 \newline\newline
    536 For the Sony TC-260, the bias frequency is 55 kHz, with a gain
    537 of 5 relative to the input signal. The lowpass filter used to recover
    538 the audible signal has a cutoff at 24 kHz, though note that due to
    539 the frequency response of the playhead loss effects, the effects
    540 of this filter may be essentially neglible to the real time system.
    541 \cite{RefManual}
    542 
    543 \subsection{Wow and Flutter} \label{flutter}
    544 Each tape machine has characteristic timing imperfections
    545 known as ``wow'' and/or ``flutter.'' These imperfections
    546 are caused by minor changes in speed from the motors
    547 driving the tape reels, and can cause fluctuations in
    548 the pitch of the output signal. To characterize these
    549 timing imperfections, we use a method similar to \cite{tapeDelay}:
    550 We recorded a pulse train of 1000 pulses through a TC-260,
    551 then recorded the pulses back from the tape. \Cref{timingSim}
    552 shows a section of a superimposed plot of the original
    553 pulse train against the pulse train recorded from the tape
    554 machine. From this data, we were able to generate a periodic
    555 function that accurately models the timing imperfections of
    556 the TC-260. The process was performed at both 7.5 ips and 3.75
    557 ips. In the real-time system, the timing imperfection model
    558 is used to inform a modulating delay line, to achieve the
    559 signature "wow" effect of an analog tape machine.
    560 
    561 \begin{figure}[ht]
    562     \center
    563     \includegraphics[width=3in]{../Simulations/TimingEffects/timing_diff_7-5.png}
    564     \caption{\label{timingSim}{\it Input pulse train superimposed with pulse train recorded from TC-260}}
    565 \end{figure}
    566 %
    567 \begin{figure}[ht]
    568     \begin{center}
    569         \begin{tabular}{|| c | c ||}
    570             \hline
    571             Record Head Constants & \\
    572             \hline
    573             Turns of wire (N) & 100 \\
    574             Head Efficiency (E) & 0.1 \\
    575             Record Head Gap (g) & 6 (microns) \\
    576             \hline
    577             \hline
    578             \hline
    579             Tape Constants & \\
    580             \hline
    581             Magnetic Saturation ($M_s$) & 3.5e5 (A/m) \\
    582             Hysteresis Loop Width (k) & 27 (kA/m) \\
    583             Anhysteric Magnetisation (a) & 22 (kA/m) \\
    584             Ratio of magnetic susceptibilities (c) & 1.7e-1 \\
    585             \hline
    586             \hline
    587             \hline
    588             Play Head Constants & \\
    589             \hline
    590             Play Head Width (W) & 0.125 (in) \\
    591             \hline
    592         \end{tabular}
    593     \end{center}
    594     \caption{\label{constants}{\it Constant values for model implementation}}
    595 \end{figure}
    596 %
    597 \begin{figure*}[ht]
    598     \center
    599     \begin{tikzpicture}
    600         \matrix (m1) [row sep=10mm, column sep=8mm]
    601         {
    602                                                                                 &
    603                                                                                 &
    604             \node[dspnodeopen,dsp/label=above]   (b0) {Bias Signal};            &
    605                                                                                 &
    606                                                                                 &
    607                                                                                 &
    608             \node[dspnodeopen,dsp/label=above]   (b1) {Flutter ($\tau$)};       &
    609             \node[dspnodeopen,dsp/label=above]   (b2) {Tape Speed ($v$)};       \\
    610             %---------------------------------------------------------------
    611             \node[dspnodeopen,dsp/label=left]    (x0) {$x[n]$};              &
    612             \node[dspsquare]                     (x1) {\upsamplertext{M}};   &
    613             \node[dspadder]                      (x2) {};                    &
    614             \node[dspfilter]                     (x3) {$H_{record}$};        &
    615             \node[dspfilter]                     (x4) {Hysteresis};          &
    616             \node[dspsquare]                     (x5) {\downsamplertext{M}}; &
    617             \node[dspsquare]                     (x6) {$z^{-\tau}$};         &
    618             \node[dspfilter]                     (x7) {$H_{play}(v)$};       &
    619             \node[dspnodeopen,dsp/label=right]   (x8) {$y[n]$};              \\
    620         };
    621         \draw[dspconn] (b0) -- (x2);
    622         \draw[dspconn] (b1) -- (x6);
    623         \draw[dspconn] (b2) -- (x7);
    624         \foreach \i [evaluate = \i as \j using int(\i+1)] in {0,1,...,7}
    625             \draw[dspconn] (x\i) -- (x\j);
    626     \end{tikzpicture}
    627     \caption{\label{flowchart}{\it Flowchart of realtime system: 
    628                                    M is the oversampling factor,
    629                                    $H_{record}$
    630                                    is the transfer function of the record
    631                                    head, and
    632                                    $H_{play}$ is the play head transfer
    633                                    function including loss effects, and a 
    634                                    de-biasing filter.}}
    635 \end{figure*}
    636 %
    637 \section{Real-Time Implementation}
    638 We implemented our physical model of the Sony TC-260 as a
    639 VST audio plugin using the JUCE framework. \Cref{flowchart}
    640 shows the signal flow of the system in detail. We allow the user
    641 to control parameters in real-time including the tape speed, bias gain, gap
    642 width, tape thickness, tape spacing, and flutter depth.
    643 \newline\newline
    644 Bias modulation is implemeted using \cref{eq:bias}, where bias gain
    645 $B$ and bias frequency $f_{bias}$ are controlled by the user.
    646 \newline\newline
    647 The record head transfer function calculates the record head magnetic
    648 field $H$ from the input current $I$, and is implemented using \cref{eq:Hin},
    649 with constant values shown in \cref{constants}.
    650 \newline\newline
    651 The hysteresis process calculates the tape magnetisation $M$ from the
    652 record head magnetic field $H$, and is implementated using the Runge-Kutta
    653 method described in \cref{eq:Mn}, with constant value defined in \cref{constants}.
    654 \newline\newline
    655 The flutter process is implemented using a modulated delay line as described in
    656 \cref{flutter}, with user controlled modulation depth.
    657 \newline\newline
    658 The play head transfer calculates the play head voltage $V$ from the
    659 tape magnetisation $M$, using \cref{eq:Vout} and the loss effects filter
    660 described in \cref{Loss_Effects}. The gap width $g$, tape speed $v$, tape
    661 thickness $\delta$, and spacing $d$ are controlled by the user, and
    662 other constant values are shown in \cref{constants}.
    663 \newline\newline
    664 C/C++ code for the full real-time implementation is open-source
    665 and is available on GitHub.\footnote{\url{https://github.com/jatinchowdhury18/AnalogTapeModel}}
    666 
    667 %
    668 \subsection{Oversampling}
    669 If no oversampling is used, the system will be unstable
    670 for input signal at the Nyquist frequency, due to limitations
    671 of the trapezoid rule derivate approximation used in \cref{eq:hDeriv}.
    672 To avoid this instability, early versions of the real-time
    673 implementation used a lowpass filter with cutoff frequency
    674 just below Nyquist. However, due to aliasing caused by the
    675 nonlinearity of the tape hysteresis model, oversampling is
    676 necessary to mitigate aliasing artifacts \cite{Yeh}. Further,
    677 the system must be able to faithfully recreate not only the
    678 frequencies in the audible range but the bias frequency as
    679 well. Since the TC-260 uses a bias frequency of 55 kHz \cite{RefManual}
    680 and the minimum standard audio sampling rate is 44.1 kHz,
    681 a minimum oversampling factor of 3x is required. However,
    682 since the biased signal is then fed into the hystersis model,
    683 even more oversampling is required to avoid aliasing. With these
    684 considerations in mind, our system uses an oversampling
    685 factor of 16x.
    686 
    687 \begin{figure}[ht]
    688     \center
    689     \includegraphics[width=2.8in]{../Testing/DeadzoneTest.png}
    690     \includegraphics[width=2.8in]{../Testing/FlutterTest.png}
    691     \caption{\label{tests}{\it Testing results for real-time system:
    692                             sine wave output with no biasing (above),
    693                             input vs. output pulse train comparison (below).}}
    694 \end{figure}
    695 %
    696 \begin{figure}[ht]
    697     \center
    698     \includegraphics[width=2.8in]{../Testing/HysteresisTest.png}
    699     \includegraphics[width=2.8in]{../Testing/HysteresisTest_Tape.png}
    700     \caption{\label{tests2}{\it Test results comparing real-time system
    701                                 to Sony TC-260 physical unit:
    702                                 hysteresis loop for real-time system (above),
    703                                 hysteresis loop for TC-260 (below).}}
    704 \end{figure}
    705 %
    706 
    707 \subsection{Results}
    708 In subjective testing, our physical model sounds quite convincing,
    709 with warm, tape-like distortion, and realistic sounding
    710 flutter. The high-frequency loss and low-frequency
    711 ``head bump'' change correctly at different tape speeds,
    712 and are approximately within the frequency response
    713 specifications of the TC-260 service manual \cite{RefManual}.
    714 When the input to the plugin is silent, the hysteresis processing
    715 of the bias signal produces a very accurate ``tape hiss'' sound.
    716 The distortion and frequency response characteristics
    717 of our model are subjectively very close when compared to
    718 the output of an actual TC-260, though not nearly close enough to 
    719 ``fool'' the listener. Additionally, as the bias
    720 gain is lowered, the ``deadzone'' effect appears exactly
    721 as expected \cite{Camras:1987:MRH:27189}.
    722 The largest difference between the model and the physical
    723 machine is the subtle electrical and mechanical noises
    724 and dropouts present in the physical machine, presumably
    725 caused by the age and wear-and-tear of the machine, which
    726 we did not attempt to characterize in our model.
    727 \Cref{tests} shows the results
    728 of tests performed on the real-time system, including
    729 an example of the ``deadzone'' effect, and the timing
    730 irregularities or ``flutter''. \Cref{tests2} shows
    731 a comparison of hysteresis characteristics between
    732 the real-time software model and a physical Sony TC-260
    733 tape machine. Note that some
    734 differences between the two hysteresis loops may be due
    735 to the circuitry of the tape machine that we did not
    736 attempt to model in the real-time system.
    737 Audio examples from the real-time system can be found
    738 online.\footnote{\url{https://ccrma.stanford.edu/~jatin/420/tape/}}
    739 
    740 \subsection{Evaluation}
    741 While there is an audible difference between the
    742 real-time software model and a physical Sony
    743 TC-260, the most fundamental aspects of the tape
    744 machine sound including tape saturation, tape hiss, flutter/wow,
    745 and frequency response, are clearly audible and sound
    746 very accurate. The main distinctions between the two
    747 systems can be attributed to the tape machine circuitry
    748 (in particular the TC-260 contains two shelving filters),
    749 as well as mechanical wear of the system, both elements
    750 that were not considered in our model.
    751 \newline\newline
    752 In our opinion, the
    753 strongest proof of the efficacy of our model is that the
    754 model responds accurately to the adjustement of model parameters.
    755 In particular, the hysteresis process
    756 reacted correctly to changes in input gain (saturating for
    757 overdriven input, or fading into tape hiss for underdriven
    758 input), as well as bias gain (saturation for overbiasing, or
    759 ``deadzone'' effect for underbiasing).
    760 Additionally, adjusting the loss effect parameters
    761 correctly demonstrated known tape machine phenomena including
    762 head ``bump'' (a resonance at the wavelength of the play
    763 head gap width), and spacing loss (filtering due to the
    764 spacing between the the play head and tape). The reader is
    765 invited to download the plugin (available with the source code)
    766 and evaluate the model for themselves. In conclusion, we believe
    767 that our model successfully approximates the physical tape
    768 recording process, however for those wishing to model a full
    769 tape machine, we suggest using this model in combination with
    770 a model of the tape machine's circuits.
    771 
    772 \section{Future Improvements}
    773 \subsection{Spatial Magnetic Effects}
    774 The most obvious improvement to be made for the physical model
    775 is the inclusion of spatial effects of the tape. In particular,
    776 the approximations made in \cref{eq:spatialApprox}, negate any
    777 effects caused by magnetisation along the longitudinal length
    778 of the tape, and into the depth of the tape. Including spatial
    779 effects would involve deriving digital analogues for
    780 \cref{eq:H_x,eq:H_y,eq:Vx}, and re-deriving \cref{eq:Mn}
    781 to take an 2-dimensional magnetic field input at every timestep,
    782 rather than the zero-dimensional input it currently takes. This change
    783 would greatly increase the computational complexity of the system.
    784 At an oversampling rate of 16x,
    785 using just 100 spatial samples would be 1600x more
    786 computationally complex than the current system.
    787 
    788 \section{Acknowledgements}
    789 Many thanks to Julius Smith for guidance and support, and
    790 thanks to Irene Abosch for kindly donating her Sony TC-260.
    791 
    792 %\newpage
    793 \nocite{*}
    794 \bibliographystyle{IEEEbib}
    795 \bibliography{references}
    796 
    797 \end{document}