1Preamble
2---
3This document is meant to give you an overview on the idea of having a
4parametric equalizer for sound enhancement and how you can create your
5own presets.  Also the interaction with the equalizer in MOC is described.
6
7I would like to improve this document to make it more usable; so if you
8have any comments and/or ideas feel free to contact me.
9
10- Hendrik Iben (hiben<at>tzi(dot)de)
11
12
13Content
14---
150. Document History
161. Motivation
172. Usage
183. Preset Format
194. Creating Presets
205. TODO
216. References
22
23
240. Document History
25---
2607.09.2008 - Initial version
2715.03.2011 - Reformatted
28
29
301. Nuts and Bolts / Motivation for Implementing the Equalizer
31---
32The equalizer is an implementation of a biquadratic peaking equalizer
33filter looked up from the Audio EQ Cookbook[1].
34
35It happens to be a parametric equalizer and this means that, different
36from other equalizer implementations, the number of bands* is not fixed.
37When I started the idea of implementing the equalizer I looked around
38in the source of other audio playback software and found that a lot of
39them are recycling the code used by the famous XMMS[2] audio player.
40I also would have liked to recycle the code but I decided against it
41for two reasons:
42
43The first reason is that there is almost no documentation on the algorithm
44used.  Maybe the signal processing folks have fun finding out what makes
45this thing work but I was totally lost.  So I decided that I wanted to
46*know* what I am doing if I do it.
47
48As for the second reason, the code used by XMMS is totally optimized for
49integer arithmetic.  There is no problem with this in general but I had
50the goal of implementing something that was as accurate as I could and
51I wanted to use floating point arithmetic.
52
53So I am no signals processing guy, but I have -- I think -- a solid
54understanding of the matter.  I sat down and started to read about
55equalizing, audio processing and signal theory in general.  After some
56time I found a mathematical description and a C implementation of
57biquadratic filters in the Audio Cookbook.  I made an implementation of
58the XMMS equalizer and the biquadratic filter using Octave[3] to compare
59the outcome of both filters.  I was a bit surprised how different filters
60can be but in the end succeeded (?) in finding a quite good biquadratic
61filter set that would produce results not unlike the XMMS equalizer.
62
63Although I did not use the XMMS-code I think that people will be more
64happy to accept this equalizer if they can use their presets with it.
65There is some conversion needed, but it's a straightforward process.
66I converted all presets provided by XMMS into presets for this mixer.
67They should be available at [4].
68
69* A band is a chosen center frequency where a filter has most impact.
70  If you look at WinAmp / XMMS / Beep Media Player you will find that
71  they settled on a common set of 10 bands.
72
73
742. Using the Equalizer
75---
76The default keys for the equalizer are:
77
78'e' - Refresh equalizer
79'E' - Toggle equalizer (on/off)
80'k' - Select next preset
81'K' - Select previous preset
82
83Each of these actions results in a message displayed in the message area.
84This message will be overridden by the next action.
85
86
873. Preset Format
88---
89Presets for the equalizer are to be placed in a directory called 'eqsets'
90in MOC's home directory (e.g., $HOME/.moc/eqsets).  There is no convention
91for the filename, but it will serve as the name in the selection process.
92
93File format in pseudo EBNF:
94
95  EQSET
96  ((<CF> <BW> <AMP>)|(0 <PREAMP>))*
97
98  CF:     Center frequency (sane values are from ~20 to ~20000).
99  BW:     Bandwith in Octaves.  This defines how fast the bands
100          influence vanishes over the frequencies.
101  AMP:    Amplification factor (in dB) to apply to the band.
102  PREAMP: Specifies an amplification factor applied before equalizing.
103
104So a valid equalizer set would be:
105
106  # this is a comment
107  EQSET
108  # amplify audio by 1.4dB
109  0 1.4
110  # damp frequencies at 100Hz by -4dB, filter bandwidth 1.5 octaves
111  100   1.5 -4
112  # amplify frequencies at 4000Hz by 2dB, filter bandwidth 1.5 octaves
113  4000  1.5 2
114
115There is no order to stick to when specifying frequencies.
116
117
1184. Creating Your Own Presets
119---
120For a start you should have a look at the converted presets[4].  The
121bandwidths used in the conversion have been extracted by taking a look
122at the filters signal response (implementation and analysis in Octave).
123I tried to do this as accurately as possible but I don't know if I made
124a mistake.  They sound correct though... :-)
125
126You might note that there is never a positive amplification factor in
127the presets although there are in the original preset.  The reason for
128this is that I used the maximum amplification in the preset as zero
129amplification and adjusted the other values accordingly.
130
131In general, when creating a preset get used to the following idea: Do not
132amplify the frequencies you want but damp those that are of no interest.
133This has the same effect but avoids clipping and this equalizer type seems
134to be very prone to clipping.  Also be very careful with pre-amplifying
135the audio for the same reason.
136
137With that said, the next confusing thing is the bandwidth definition.
138Every band needs a defined bandwidth in octaves where the bandwidth
139defines where the filter's effect has been reduced by 3dB*.  This means
140that if you define a band at 1000Hz with a bandwidth of 1.5 octaves and
141an amplification of -10dB, at 353.6Hz** and at 2828.4Hz the amplification
142will be reduced to -7dB.
143
144If unsure, stay in between 1.0 and 2.0.  Just keep in mind that if two
145bands overlap you might get an undesired amplification.
146
147When designing presets, just save the preset and select it in MOC.  After
148each change press the refresh key (default 'e').  This will re-create the
149equalizer reflecting your changes.
150
151If your preset is not found, have a look at the output of MOC's server
152thread.  Parsing errors are emitted there.
153
154*  3dB is commonly used for bandwidth.  -3dB equals about 70.7% of
155   original amplification.
156** 353.6 =~ 1000*(2^-1.5), 2828.4 =~ 1000*(2^1.5)
157
158
1595. TODO
160---
161- The equalizer is currently not optimized in any way.
162
163- It converts all sound data into floating point values to perform the
164  equalization and converts them back afterwards.  A better approach
165  would be either to provide integer algorithms for equalization or to
166  leave the audio data in floating point format.
167
168- There is no sorting for the presets; their order is defined by reading
169  the directory content.
170
171- Maybe it would be nice to add a name to the preset different from the
172  filename.
173
174
1756. References
176---
177[1] Cookbook formulae for audio EQ biquad filter coefficients
178    http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt
179[2] X Multimedia System
180    http://www.xmms.org/
181[3] GNU Octave
182    http://www.gnu.org/software/octave/
183[4] Converted WinAmp / XMMS Equalizer sets
184    http://www.informatik.uni-bremen.de/~hiben/moc/eqsets.tar.gz
185