main content

graphic equalization -凯发k8网页登录

this example demonstrates two forms of graphic equalizers constructed using building blocks from audio toolbox™. it also shows how to export them as vst plugins to be used in a digital audio workstation (daw).

graphic equalizers

equalizers are commonly used by audio engineers and consumers to adjust the frequency response of audio. for example, they can be used to compensate for bias introduced by speakers, or to add bass to a song. they are essentially a group of filters designed to provide a custom overall frequency response.

one of the more sophisticated equalization techniques is known as parametric equalization. parametric equalizers provide control over three filter parameters: center frequency, bandwidth, and gain. audio toolbox™ provides the system object and the block for parametric equalization.

while parametric equalizers are useful when you want to fine-tune the frequency response, there are simpler equalizers for cases when you need fewer controls. octave, two-third octave, and one-third octave have emerged as common bandwidths for equalizers based on the behavior of the human ear. standards like is0 266:1997(e), ansi s1.11-2004, and iec 61672-1:2013 define center frequencies for octave and fractional octave filters. this leaves only one parameter to tune: filter gain. graphic equalizers provide control over the gain parameter while using standard center frequencies and common bandwidths.

in this example, you use two implementations of graphic equalizers. they differ in arrangement of constituent filters: one uses a bank of parallel octave- or fractional octave-band filters, and the other uses a cascade of biquad filters. the center frequencies in both implementations follow the ansi s1.11-2004 standard.

graphic equalizers with parallel filters

one way to construct a graphic equalizer is to place a group of bandpass filters in parallel. the bandwidth of each filter is octave or fractional octave, and their center frequency is set so that together they cover the audio frequency range of [20, 20000] hz.

the transfer function is a sum of transfer function of the branches.

you can tune the gains to boost or cut the corresponding frequency band while the simulation runs. because the gains are independent of the filter design, tuning the gains does not have a significant computational cost. the parallel filter structure is well suited to parallel hardware implementation. the magnitude response of the bandpass filters should be close to zero at all other frequencies outside its bandwidth to avoid interaction between the filters. however, this is not practical, leading to inter-band interference.

you can use the system object to implement a graphic equalizer with a parallel structure.

eq = graphiceq('structure','parallel')
eq = 
  graphiceq with properties:
       eqorder: 2
     bandwidth: '1 octave'
     structure: 'parallel'
         gains: [0 0 0 0 0 0 0 0 0 0]
    samplerate: 44100

this designs a parallel implementation of second order filters with 1-octave bandwidth. it takes ten octave filters to cover the range of audible frequencies. each element of the gains property controls the gain of one branch of the parallel configuration.

configure the object you created to boost low and high frequencies, similar to a rock preset.

eq.gains = [4, 4.2, 4.6, 2.7, -3.7, -5.2, -2.5, 2.3, 5.4, 6.5, 6.5]
eq = 
  graphiceq with properties:
       eqorder: 2
     bandwidth: '1 octave'
     structure: 'parallel'
         gains: [4 4.2000 4.6000 2.7000 -3.7000 -5.2000 -2.5000 2.3000 5.4000 6.5000]
    samplerate: 44100

call visualize to view the magnitude response of the equalizer design.

visualize(eq)

you can test the equalizer implemented in graphiceq using . the audio test bench sets up the audio file reader and audio device writer objects, and streams the audio through the equalizer in a processing loop. it also assigns a slider to each gain value and labels the center frequency it corresponds to, so you can easily change the gain and hear its effect. modifying the value of the slider simultaneously updates the magnitude response plot.

audiotestbench(eq)

graphic equalizers with cascade filters

a different implementation of the graphic equalizer uses cascaded equalizing filters (peak or notch) implemented as biquad filters. the transfer function of the equalizer can be written as a product of the transfer function of individual biquads.

to motivate the usefulness of this implementation, first look at the magnitude response of the parallel structure when all gains are 0 db.

parallelgraphiceq = graphiceq('structure','parallel');
visualize(parallelgraphiceq)

you will notice that the magnitude response is not flat. this is because the filters have been designed independently, and each has a transition width where the magnitude response droops. moreover, because of non-ideal stopband, there is leakage from the stopband of one filter to the passband of its neighbor. the leakage can cause actual gains to differ from expected gains.

parallelgraphiceq_10db = graphiceq('structure','parallel');
parallelgraphiceq_10db.gains = 10*ones(1,10);
visualize(parallelgraphiceq_10db)

note that the gains are never 10 db in the frequency response. a cascaded structure can mitigate this to an extent because the gain is inherent in the design of the filter. setting the gain of all cascaded biquads to 0 db leads to them being bypassed. since there are no branches in this type of structure, this means you have a no-gain path between the input and the output. graphiceq implements the cascaded structure by default.

cascadegraphiceq = graphiceq;
visualize(cascadegraphiceq)

moreover, when you set the gains to 10 db, notice that the resultant frequency response has close to 10 db of gain at the center frequencies.

cascadegraphiceq_10db = graphiceq;
cascadegraphiceq_10db.gains = 10*ones(1,10);
visualize(cascadegraphiceq_10db)

the drawback of cascade design is that the coefficients of a biquad stage need to be redesigned whenever the corresponding gain changes. this isn't needed for the parallel implementation because gain is just a multiplier to each parallel branch. a parallel connection of bandpass filters also avoids accumulating phase errors and quantization noise found in the cascade.

fractional octave bandwidth

the graphiceq object supports 1 octave, 2/3 octave, and 1/3 octave bandwidths. reducing the bandwidth of individual filters allows you finer control over frequency response. to verify this, set the gains to boost mid frequencies, similar to a pop preset.

octavegraphiceq = graphiceq;
octavegraphiceq.gains = [-2.1,-1.8,-1.4,2.7,4.2,4.6,3.1,-1,-1.8,-1.8,-1.4];
visualize(octavegraphiceq)

onethirdoctavegraphiceq = graphiceq;
onethirdoctavegraphiceq.bandwidth = '1/3 octave';
onethirdoctavegraphiceq.gains = [-2,-1.9,-1.8,-1.6,-1.5,-1.4,0,1.2,2.7, ...
    3.2,3.8,4.2,4.4,4.5,4.6,4,3.5,3.1,1.5,-0.1,-1,-1.2,-1.6,-1.8,-1.8, ...
    -1.8,-1.8,-1.7,-1.5,-1.4,-1.3];
visualize(onethirdoctavegraphiceq)

generate audio plugin

to generate and port a vst plugin to a digital audio workstation, run the command. for example, you can generate a two-third octave graphic equalizer through the commands shown below. you will need to be in a directory with write permissions when you run these commands.

twothirdoctavegraphiceq = graphiceq;
twothirdoctavegraphiceq.bandwidth = '2/3 octave';
createaudiopluginclass(twothirdoctavegraphiceq);
generateaudioplugin twothirdoctavegraphiceqplugin

graphic equalization in simulink

you can use the same features described in this example in simulink through the block. it provides a slider for each gain value so you can easily boost or cut a frequency band while the simulation is running.

网站地图