TrackTHD
==========

TrackTHD analyses a chosen section of a sound data file are determines
the level of Total Harmonic Distortion present. It is assumed that
the input file contains a (nominal) sinusoidal waveform. Otherwise
the results may be meaningless.

A full explanation of how the program works appeared in 'Archive'.

The files must be in the sound 'data' format as produced by CD/DVDBurn when saving
tracks from an audio CD (not the Wave format).

Before using the TrackTHD you have to set up the following:
  
  1) Decide what directory you will be using to store the file(s) you want
  to analyse. If that directory does not already exist, create it.
  
  2) There is a text file called 'Path' inside the !TrackTHD application.
  Load this into your text editor and you will see it contains the string
  
  ADFS::HardDisc4.$.CD_Tracks.analyse
  
  This is the pathname of the directory I use for sound files to be analysed.
  Change this to the name of the directory you will be using and save the
  result as a new 'Path' file inside the application. Unless you do this
  the application won't be able to find the file(s) you wish to analyse.
  
  3) Note that the output will be written into files on your RamDisc.


Having put a suitable file into the chosen directory you can run !TrackTHD in
the usual way. This opens up a taskwindow and askes for the name of the sound
file. Type in this name and press return. 


You are then asked for a 'starting time' (in seconds). The program will then
examine a section of the file that is 1/20th of a second in duration,
and this value tells it where in the sound file to choose. So if you enter, say
'10.4' and press return the program will take the sound patterns in the section
of the file between 10.4 and 10.45 seconds from the start of the file and
examine that portion of the sound file.

Once you have entered the starting time and pressed <return> the analysis
is carried out. This lists various items of information in the taskwindow
and saves four files to your RAM disc.

The taskwindow confirms the input details, and the mean dc and rms levels
of the input signals are reported. The application then works out the
signal frequency by 'fringe counting' the periodic waveform. It then uses
this value as the fundamental frequency for the rest of the analysis.
Since the detected frequencies may differ slightly for the Left and Right
channels - and in some cases signal may only be present on one channel -
the value for the channel with the greater signal level is chosen
for as the basis for the analysis.


The waveforms are saved into a textfile called "waves_<name> where 
<name> is the name of the input file.


Note that the application checks that it can get a 'sensible' value
for this frequency. If it can't, it abandons the analysis at this
point! If this happens the most likely reason is that the signal
during the chosen section wasn't a clear and easily detectable
periodic waveform. If this happens, examine the output "waves_"
file's content using a plotting application like !Tau and this may
show you the reason the process was abandoned at this point.


The spectra of the input Left and Right waveforms are then saved into
a file "raw_spectrum". The values for the fundamental frequency of the
waveform and the first few harmonics are also printed in the taskwindow.

The application then prints out the THD values of the input waveform
based on the raw data.

For reasons explained in more detail in the Archive article, better results
can be obtained if we `null out' the fundamental component. This is therefore
done, and the resulting waveforms saved in the file "nulled_waves". This
can be compared with the "waves_<name>" and shows the noise and distortion
residual with the intended sinusoid removed.

The application then works out the resulting spectrum, and THD values. The
THD values this `nulled' result produces can be expected to be more
accurate.

Each of the output spectral results lists the frequency (Hz) and then three
power levels in dB. The first two powers are for the Left and Right channels.
The third power is for the Total (power sum) and would be the appropriate
result for a signal like a monophonic test tone or a L-R difference tone
which is coherent between the two channels. This is therefor the normal
result to quote for something like a mono input unless you wish to
consider the differences in linearity between Left and Right channels.



Jim Lesurf
Feb 2007






  