Go to:
Title Page               Chapter 1           Appendix A   Appendix J
Copyright                Chapter 2           Appendix B   Appendix K
Abstract                 Chapter 3           Appendix C   Appendix L
Acknowledgements         Chapter 4           Appendix D   References
Table of Contents        Chapter 5           Appendix E
List of Figure           Conclusions/        Appendix F
List of Tables           Future Directions   Appendix G
List of Audio Examples                       Appendix H
List of Programs                             Appendix I


Appendix F

C++ source code for programs used in Chapter 5



I. General description and usage

equalize is a program that implements a wavelet-based, time-varying, wideband equalizer with variable number of bands. It allows for the equalization of an existing AIFF soundfile of any AIFF-compliant sampling rate, number of channels, and sample bitwidth. An output file having the same characteristics as the input file will be created, erasing any previously existing file with the specified output name. This program allows the user to independently specify band, time, and level equalization data for each channel in the soundfile. Using a control file, the user specifies certain points in time at which a certain band acting on a certain channel must have a certain value; all time points in between these values are interpolated. In this manner, EQ values change smoothly from one point to the next. Type equalize at the command line to view the usage message:

Time-varying wavelet-based equalizer.

Written by Corey Cheng, Spring 1996.

usage: equalize <control file>

The control file is a human-readable ASCII file which contains all parameters relevant to the equalization process. Here is an example control file which illustrates its standard syntax. Note that there are some intentional non-fatal errors in this file left in to illustrate the error-handling properties of the control-file interpreter:

// test.equ - test control file for equalize

// the following information must all appear on the first non-

// commented, non-blank line:

// [input_file] [output_file] [channels] [iterations_of_the

// wavelet_transform_to_perform] [window_size_in_frames]

// [units_to_use_for_time]

in.aiff out.aiff 2 5 32768 percent

// list all EQ data in time-sorted

// order for each channel/band block!

// [channel] [band] [time(in appropriate units)]

// [percent_of_original_wavelet_coefficient_value]

//channel 0, band 0

0 0 .5 1.0

0 0 .7 2.0

0 0 .9 0.0

//channel 0, band 1

//channel 0, band 2

//channel 0, band 3

//channel 0, band 4

//channel 0, band 5

0 5 .3 2.0

0 5 .4 1.0

0 5 .33 .5

0 5 .41 0

0 5 1.1 2.1

// channel 1, band 0

1 0 0 0.0

// channel 1, band 1

1 1 0 0.0

// channel 1, band 2

1 2 0 2.0

1 2 .5 1.0

1 2 .51 1 0

1 2 .7 1.0

// channel 1, band 3

1 3 0 0.0

// channel 1, band 4

1 4 0 0.0

// channel 1, band 5

1 5 0 0.0


Control file formatting rules

1) Comments can occur anywhere in the file, but must be on their own separate line. The comment must begin with // in the leftmost column of the file.

2) The number of EQ bands is equal to the number of iterations used in the wavelet transform plus one. The bands have approximate bandwidths listed below. Note that the bandwidths directly reflect the octave-band decomposition property of the standard, dyadic wavelet transform:
1sr/16
iterationsnumber of EQ bands band nameapproximate bandwidth
12 1sr/4 tosr/2
0 0 sr/4
23 2sr/4 tosr/2
1 sr/8 sr/4
0 0 sr/8
34 3sr/4 tosr/2
2 sr/8 sr/4

where sr is the sample/playback rate of the input file

Table F.1

3) The window_size_in_frames is the size of the window to use when executing the forward and inverse wavelet transform. This value should be a power of two adequate to handle the number of iterations asked for. In general, a size of 2(iterations+2) is good enough.

4) "units to use for time" specifies the type of units to use in the EQ time data entries. One may use one of the following:

percent - all times are given in values between 0.0 and 1.0, with 0.0 referring to the start of the file, and 1.0 referring to the end of the file.

frames - all times are given in frame count; 1 is the first frame of the file, the end frame count must be known in advance. Not recommended unless the total number of frames of the input file is known beforehand. Recall that one frame is one sample per channel; a stereo frame is 2 samples, one for the left channel, one for the right.

seconds - all times are given in seconds, 0.0 is the start of the file, the end time must be known in advance. not recommended unless the total number of frames of the input file is known in advance.

5) EQ time data

a) Channel numbering starts at zero (for stereo files, therefore, 0 is the left channel, 1 is the right channel) If an illegal channel number is entered, the EQ entry line will be ignored.

b) The band number is specified in 2) above.

c) time data

i) Each frequency band of each channel of the audio file may be controlled separately. Data is given for each channel and band independently, and can appear in any order in the control file. However, each channel and band's time values must be specified in increasing order in the control file.

ii) For each channel and band, the data is linear-interpolated between the specified EQ points. For example, the following two entries would cause channel 0 band 0 to linearly increase from 0% to 100% over the duration of the file:

0 0 0.0 0.0

0 0 1.0 1.0

iii) If no information is given for a certain channel and band the band is left unaltered during processing.

iv) The first entry for a channel and band does not have to have a start time of zero; it may start at any other time. However, all audio material prior to that point will have the same EQ value as the first point. For example, if a user specifies an EQ of 200% at time = .5 (percent through file), then all material that occurs before time .5 will also have an equalization of 200% (for that band and iteration only).

v) EQ entries with times outside of the range of the input soundfile's time span will be ignored.

vi) Resolution issues. One of the benefits of wavelet analysis is the ability to resolve higher frequency, higher bandwidth material over shorter periods of time. Likewise, a lower frequency, lower bandwidth piece of material has a longer associated time period. However, implicit in this description is that EQ changes can only occur on certain time boundaries. The resolution and time-density of allowable EQ changes, therefore, depends on which iteration, or band is being equalized; lower band numbers correspond to lower frequencies and have lower resolution; EQ changes can only happen on a more coarse scale. Similarly, higher band numbers correspond to higher frequencies and have higher resolution; EQ changes can happen on a more frequent, finer time scale. This program does this band-dependent time quantization automatically. That is, if an EQ entry's time value is too close to the previous EQ entry (for that channel and band), it is quantized to the previous quantized time. In essence, the earlier EQ point is lost. For example, on level 0, the following two points would leave only one audible result; the second EQ point would override the first since it is too close to be resolved at that low of a wavelet analysis level:

0 0 1.0 .75

0 0 1.00000000001 0.0

6) EQ value - specifies the percentage of the original wavelet coefficient desired for the current channel, band, and time.

Note: Notwithstanding the wideband equalization quality as described above, the actual cutoff frequencies and rolloff are largely dependent on the actual wavelet filters used for the analysis and resynthesis. For now, the 6/10 analysis/synthesis pair is used, providing for 3/3 zeros at pi/vanishing moments. This selection provides a reasonable set of filters with reasonable cutoff and rolloff characteristics.

II. Compiling the program

This program was written in C++ with the GNU G++ dialect, version 2.6.2. The user must have the normal_wavelet_transforms.h, ac.h, ac2.h, ac.cc, and ac.error.cc files in the same directory as the main source file, equalize.cc to compile the program properly. The audio libraries libaudio.a and libaudiofile.a, available in standard releases of the Irix operating system, are required for compilation. No Makefile is provided, as all compilation can be done with the following command:

g++ -O3 -mips2 -mcpu=r4000 -o equalize

equalize.cc ac.cc ac.error.cc -lm -laudio

-laudiofile


Go to:
Title Page               Chapter 1           Appendix A   Appendix J
Copyright                Chapter 2           Appendix B   Appendix K
Abstract                 Chapter 3           Appendix C   Appendix L
Acknowledgements         Chapter 4           Appendix D   References
Table of Contents        Chapter 5           Appendix E
List of Figure           Conclusions/        Appendix F
List of Tables           Future Directions   Appendix G
List of Audio Examples                       Appendix H
List of Programs                             Appendix I