SoftwarePractice.org: Home | Courseware | Wiki | Archive

Team H: Loudspeaker characterization and compensation

From SoftwarePractice.org

Contents

Project Team Members

Andrew Pollicina - 10029609 Email:andrew@pollicina.org

Attaporn Phuangpee - 01092648 Email:Attaporn.Phuangpee@student.uts.edu.au

Carlos Jara - 98050762 Email:carlosjara@hotmail.com

Darel Boniface - 01119066 Email:darel_boniface@yahoo.com

Project Overview

The following project will measure and characterize a program, designed for loudspeaker drivers, in order to compensate and enhance the frequency response of an input signal through a loudspeaker.

To achieve this result, the team will use several sound samples in order to tailor a number of possible pass-band filters using Matlab. The characterization and compensation of the loudspeaker driver are the main key purpose of this project.

Team H has chosen this as the topic for their project. From initial observations it appears that there is spectral analysis and filtering required which is of interest to the team.

Project Plan

The following is a brief initial outline on how this project will be carried out. Note this is subject to change as the project advances.

The project has also been temporarily divided into two sections - Part A and Part B. This is also subject to change.

Part A

  • Research possible test sounds that can be used to characterise a loudspeaker.
  • Analyse these sounds in both the time and frequency domain using Matlab.
  • Play the sound through a speaker whilst recording the output. Analyse the output once again in the time and frequency domain comparing to the original test sounds.

Part B

  • Attempt to locate the speakers "ideal" frequency range and build a filter to perfect the speaker for this range.

Project Abstract

For the purposes of understanding this project, some important definitions and examples are mentioned in this section.

Loudspeaker systems are electromechanical or electroacoustic transducers that translate electrical signals into sound waves required for audio production. These systems normally consist of one or more drivers that are allocated to specific areas in a designated space in order to produce the best possible audible sound in a specified area. There are also single driver sound systems, like the one in this project, use in order to test and correct the frequency response of the output.

There are different types of sound waves that can be produced by loudspeakers and most of them differ due to change of certain signal properties. Some of the most important properties that affect a sound wave are: frequency, wavelength, period, amplitude and velocity or speed.

Frequency sample in units of hertz (Hz) is the measurement of the number of times that a repeated event occurs per unit of time. An alternative method to calculate frequency is to measure the time between two consecutive occurrences of the event (the period T) and then compute the frequency f as the reciprocal of this time: F=1/T

The amplitude is the maximum disturbance in the medium during one wave cycle. This is the property that determines how loud or different is a sound wave from others. It is noticeable that the higher the amplitude in the sound wave, the louder the output through the loudspeakers.

Characterization is the process of finding the properties that identify a particular signal in different scenarios. The characterization, for the purposes of this project, will aid the team in finding the representation for our studies. Compensation, in this project, is the process of analyzing the characterized sound wave and applying the appropriate filters, based on the criteria set, to the captured signal in order to enhance the quality of the final output or reproduced the desired modified output.

Signal properties

The frequency response of a loudspeaker is the most useful and important method/tool when testing loudspeakers. The Frequency Response specification attempts to describe the range of signal frequency tones a speaker can reproduce, measured in Hertz or cycles per second.

The range of human hearing is usually regarded as being from 20Hz, very low bass tones, through 20 kHz, the very highest treble. Most probably a speaker that could reproduce that range would sound natural but that is not guarantee since the signal output is subject to its media environment. The most important determinant of a speaker's frequency performance is not its size, but whether it's capable of reproducing all the audible frequencies at the same volume at which they were recorded. Ideally, anyone would want the sounds that are on the input recording to be reproduced as they were recorded, without the loudspeaker driver altering the sound.

When buying a new set of speakers, the last thing a person wants is a loudspeaker to change the mix of tones. In a real scenario, that would ruin the pitch of some voices and instruments, making them sound unnatural. As mentioned before, ideally as loudspeaker buyers, we want the recorded output signals to be reproduced exactly the same without the speaker changing any of the sounds. For example, if we have a recording of all the audible tones at the same volume and play these recorded sounds through a speaker, we would want all the audible tones to come out at the same volume. This example represents the best way of measuring the quality of loudspeakers.

In order to test the sound quality of a loudspeaker, a recording input device such as a microphone is placed in front of the driver with the purposes of capturing and generating a sound file which then will be analyzed by computer software. In Figure A, we show a test sample of a signal that is comprised of all frequencies at equal volume.

Image:FigureA.PNG

In Figure B, we can appreciate a graph from an ideal loudspeaker response. As we can see, the flat line in the response indicates that the speaker reproduces all the signal tones at the same volume in a room with ideally no reflective surfaces.

Image:FigureB.PNG

The flat line on the graph doesn't mean that a flat speaker will play all recorded sounds at the same volume; it means that it will treat all sounds equally and it will not impose its will on the music. To make this clearer, the frequency response of this loudspeaker will allow you to hear the music as it was recorded. Flat response means that the speaker reproduces sound properly. It is unfortunate that at present, there is no loudspeaker that has been designed to get closer to the flat ideal response but they still fall far short of perfection.

For example, if we see the following frequency response example in Figure C, we can say that this loudspeaker has response that can be specified as 20Hz-20kHz +/- 3dB. This speaker will have one note bass and will make voices and other instruments sound unnatural. Please refer to Figure B in order to see the ideal example.

Image:FigureC.PNG

Loudspeaker testing process

To start the testing process, a testing sound needs to be used in order to play it through the loudspeaker. The output is then captured with the aid of a microphone to a file that will be later examined by Matlab in order to generate a frequency response characterization.

A microphone is a device that converts sounds into electricity in such a way as to retain the information content. The simple way to explain how microphones work is by saying that it records the changes in air pressure in orde rto convert them to changes in voltage. Separation of the microphone from the loudspeaker will take a direct sample of the output signal about to be recorded.

For the purposes of test recording, Team H has used the Telecommunications Lab facilities located in level 23 - UTS main tower.

Signal degradation and noise effects

There are several reasons why input signals passed through a loudspeaker differ from the original input. One the most common reasons is due to the introduction of noise effects in the testing environment.

Indirect sound or noise effect is the type of sound that arrives at the recording device (i.e microphone) by some path other than directly sound from the speakers. The most recognize noise effects in this category can be reflected, diffused, or partially absorbed noise.

  • Absorption is the dissipation of sound energy due to interactions with matter
  • Reflection causes sound waves to reach the recording device after being bounced off of one or more surfaces
  • Diffusion is the bending of sound waves as they pass over an obstacle.

In this project, the testing location mentioned offers moderate noise impact since the room’s furniture does not have high absorption, reflection or diffusion properties. In a properly designed recording studio there is no indirect sound as it is designed to eliminate all reflections of sound.

Total Harmonic Distortion

There are a number of relevant distortion measurements that may be made on loudspeakers. The most common is to drive the loudspeaker with a swept sine wave at various nominal power inputs and measure the relative amounts of second and thrid harmonic components, relative to the fundamental component.


Another way of looking at distortion is a total harmonic distortion (THD). Here a tracking band rejection filter is used to notch out the fundamental frequency, leaving only the power summation of harmonics and any noise that may present. Lower numbers of THD are believed to be better, the human ear usually cannot distinguish THD ratings below 3.3%, in some cases is 2%.


Most harmonic distortion in loudspeakers is related to mechanical non-linearities, and this produces amplitude distortion. In some systems, where cone displacement is exessive, there may be frequency modulation effects as the cone's velocity becomes a significant fraction of the speed of sound. In gerenal, amplitude modulation effects predominate in normal loudspeaker performance.


For an audio measurement specification, the total harmonic distortion (THD) is a measurement of unwanted, added noise level of the harmonic overtones. The measurement used to verify the precision with which the loudspeaker can reproduce the input signal at its output. Total harmonic distortion plus noise (THD+n) is a specification that includes both harmonic distortion of the sine wave and non-harmonic noise. A spectral analysis of the output will show unwanted harmonic distortions. If the loudspeaker is perfect the spectrum of the output will show only the original signal which there is no added components and noises, only original signal.

The measurement is the ratio of the sum of the powers of all harmonic frequencies above the fundamental frequency to the power of the fundamental:

 Image:THDH.jpg

Correction Filters

Filters are one of the most commonly used tools in frequency response analysis and compensation. Most of the cases, they are simple to use since they enhance the quality of an output signal in order to get the best possible performance result.

For the purposes of this project, the team has decided to use Butterworth filters in order to obtain the most enhanced flat response for the number of signal we will use as examples (Refer to “flat response” in Signal Properties).

Butterworth filters are characterized by a magnitude response that is maximally flat in the pass and stop band. Butterworth filters jeopardize roll off steepness in both bands in order to obtained flatness in its response and unless the smoothness of the Butterworth filter is required, an elliptic or Chebyshev filter can be used in order to get steeper roll-off uniqueness with a lower filter order, as per seen in Figure D. Also, Butterworth filters have minimal phase shift over the filter's band pass when compared to other conventional filters and since this type of filters are frequency-base, the effect of filtering can be easily understood and predicted.

Image:butterworth comparison.PNG

In summary, Butterworth filters have monotonic magnitude response at both pass band and stop band with slow roll-off. By allowing ripples in the pass band for type I and in the stop band for type II, the Chebyshev filter can achieve sharper cutoff with the same number of poles. An elliptic filter has even sharper cutoffs than the Chebyshev filter for the same order, but it results in both pass band and stop band ripples. The design of these filters strives to achieve the ideal magnitude response with trade-offs in phase response. However, we must sacrifice steepness in the transition region.

Choosing a cutoff frequency is performed in the “programming characterization” section of this page and the input signal is measured using a microphone from a single location in this project assuming ideal conditions for recording are optimal. The filter design is tested by measuring the frequency response of the signal after the correction filter(s) has been applied. The way we test the filters applied is performed by playing testing samples with and without the filters and comparing the response. At the end of the exercise, the correction filters are applied to the input signal in order to synthesize a corrected signal by using the inverse of the frequency response.

Another challenge of designing the Butterworth filter in this project comes when we design the real time filter GUI interface to any signal we use in our testing. This method applies some concepts explained in the project’s part B.

Maximum Length Sequence

The Maximum Length Sequence (MLS)is a technique use in the field of acoustics. MLS is a pseudo random sequence of pulses that can be use for measuring impulse responses of loudspeakers.

This technique can be use in our project because it is possible to measure the anechoic response of the loudspeaker even without an anechoic chamber, which we do not have.Also MLS has a high signal to noise ratio which alow for measurments in a room with mild background noise. Distortion can also be measured by using different sequences as each sequence has its own distortion characteristic patern.

This technique can be use by the group for this project as the sequence can be easily implemented in Matlab.

Part A - Test Tone Generation

In order to help characterise the loud speaker a series of single frequency test tone will be used. The remainder of this section will introduce the Matlab code used to generate these tones as well as graphs showing both the time and frequency representation of the tones.

The following Matlab m file is use to generate a tone. Values are kept in an array that can be used for play back or analysis.:

function [y] = tone(A,f,fs)

% usage: tone(A,f,fs)
% Tone parameters defined by:
% A - amplitude
% f - frequency[[Image:
% fs - sampling frequency

% Create 1 secs worth of tone.
x=[0:1/fs:1-1/fs];
y=A*sin(2*pi*f*x);

To see a time domain representation of the tone, the following m file takes the values of A, f and fs and plots a graph of 1 period.:

function plottd(A,f,fs)

% usage: plottd(A,f,fs)
% Tone parameters defined by:
% A - amplitude
% f - frequency
% fs - sampling frequency

% Plot 1 period of the tone
x=[0:1/fs:1/f];
y=A*sin(2*pi*f*x);
plot(x,y);
title('Time Domain Signal Representation');
xlabel('Time (sec)');
ylabel('Amplitude');

To complete this, the next m file produces a frequecy response of the plot for values A, f and fs.:

function plotfd(A,f,fs)

% usage: plotfd(A,f,fs)
% Tone parameters defined by:
% A - amplitude
% f - frequency
% fs - sampling frequency

% Create 1 secs worth of tone
x=[0:1/fs:1-1/fs];
y=A*sin(2*pi*f*x);

% Take the Fourier Series of y.
% The following is taken from:
% http://www.aw-bc.com/lee_varaiya/matlab/fourierSeries.m
p=length(y);
ff=fft(y)/p;
magnitude(1)=abs(ff(1));
upper=p/2;
magnitude(2:upper)=2*abs(ff(2:upper));
magnitude(upper+1)=abs(ff(upper+1));
phase(1)=angle(ff(1));
phase(2:upper)=angle(ff(2:upper));
phase(upper+1)=angle(ff(upper+1));

% Plot the frequency resopnse.
frequencies=[0:fs/p:fs/2];
plot(frequencies,magnitude);
title('Frequency Domain Signal Representation');
xlabel('frequency in Hertz');
ylabel('amplitude');


Using the above m files the following plots were produced for a 400Hz signal tone sampled at 8000 samples per second.

Image:grouph-400hztd.png

Image:grouph-400hzfd.png

The next phase will require creating a range of tones and playing them through a loud speaker whilst recording the output. The outputs will be read in and analyised and compared to the inputs.

Simulation 1

Below we have produced the first test simulation as a benchmark for our project. We created a 500Hz tone sampled at 22050 samples/sec. The top plot shows the frequency domain representation of the original tone and the bottom shows the frequency domain representation of the recorded tone.

Image:Simulation1.png

The System

The central component of the loudspeaker characterisation and compensation system is the Matlab GUI. The methodology chosen for the compensator attempts to characterise a loud speaker and form a filter that only allows frequencies that are best reproduced by the loud speaker to be played.

The GUI allows the user to input the following parameters:

  • Sweep start frequency
  • Sweep end frequency
  • Spacing between frequency samples
  • Sampling frequency
  • Amplitude cut off threshold factor
  • Butterworth filter order

The first three inputs are used to produce a sweep starting from the start frequency and stopping at the end frequency with the specified spacing between each frequency. At each frequency a signal is produced from a sine wave with magnitude of 1 lasting for 0.5 seconds. Each of these signals are then concatenated together to form the final signal which is the sweep. The sine expression is:

y=A*sin(2*pi*s*i*x)

where y is the 0.5 second signal creates, A is the amplitude, s is the frequency spacing factor and i is a step index.

Once the first sweep is created a FFT is completed and frequency domain plot is formed. The sweep is then played out through the loudspeaker and recorded back in again simultaneously. The recorded signal is saved into an array. A FFT is also preformed on the recorded signal and a frequency domain plot is again formed.

The recorded signal is then analysed using the make_filter.m function. The purpose of this function is to determine the optimal Butterworth filter for the loudspeaker from the first recording of the sweep. The function scans through the recorded signal and looks for where the largest magnitude occurs. It then multiples this magnitude value with the cut off threshold factor and produces a cut off threshold in terms of magnitude. The recorded signal is then scanned again and the position of each frequency that is greater then or equal to the threshold is stored in an array. From this array the lower and upper cut off frequencies can be determined to produce the band pass Butterworth filter along with the filter order specified by the user.

The original sweep is then passed through the filter created to produce a filtered version of the sweep which again is has a FFT preformed and plot drawn. The filtered sweep is then played back out again through the loudspeaker and recorded in again so a final FFT can be performed and plot drawn. The final recording and filtered sweep are also saved as a wave file for playback and use later on.

The follow link is a Microsoft PowerPoint demostration animating how filtering is performed. Filter Demo

THD is also computed to provide additional information to the user.

The flowchart below shows the steps involved for the GUI.

Image:Grouph model flowchart.jpg

So the GUI performs two basic steps.

  1. Characterisation - Produce, play and record a sweep to characterise and form the optimal filter for the loud speaker.
  2. Compensation - Pass a signal through the filter before playing it through the loud speaker.

The following diagram represents to this two step approach.

Image:Grouph model.jpg

The Test Results

The following graph represents the interface result of the Matlab code developed and used by Team H for this project. As we can see, all the settings are listed in the bottom left hand side and the result values calculated at the bottom right hand corner.

Image:Result1.PNG

The top left hand side graph represents the original sound signal without any interference or noise introduced. We can also call this graph, the ideal graph. The top right hand side graph is the main graph and represents the characterisation of the original signal passed through the loudspeaker and captured with a microphone. As we can see, all the room or environment noise effect is displayed in this graph since it does not look the same as the original signal. From this graph the GUI program can calculate all the important results based on average values, as per explained in the previous section. The upper and lower cut frequencies are determine based on amplitude threshold set by the program operator. In this scenario, the threshold has been set to 90%, meaning that anything above or below this average mark will be cut in order to enhance the quality of the filtered output. In this sample, these values were determined to be before 500 Hz and after 5000 Hz, as per seen in the details of the GUI graph output. The order of the filter represents how steep the filter is going to cut the unwanted frequency from the original input. In this case, a 6th order filter will have a very steep stop band frequency. In the next Figure, we have changed the values of the filter settings in order to compare the values previously measured in the testing section.


Image:Result2.PNG

As we can see in the graph above, the amplitude threshold has been set to 60% and the filter order has been set to 2. From the result obtained, we can appreciate that the cut off frequencies in the graph are unnoticed after the filters have been applied. There is not much room to improve the quality of the signal using this settings, as per seen in the final recorded. Also, since the filter order is not as high as the previous one, the steepness is not as pronounced as the last one. In conclusion, the filter does not cut much of the unwanted frequencies as per the previous example, leaving less room for any compensation enhancement. We believe that the final output looks similar to the input before filters were applied except for a few high amplitudes around 100Hz.

Next, we display the waterfall results for our test. The Waterfall block displays multiple vectors of data at one time in order to display the values plotted in X, Y, Z domain or three-dimensional. These vectors represent the input data at consecutive sample times. The x-axis represents amplitude, the y-axis represents samples, and the z-axis represents time.

Image:Result3waterfall.PNG

As we can see, the top graph is the input signal without any filter or compensation. The bottom graph is the output signal compensated with all the filters calculated. There is a difference in the amplitudes due to the reduction of noise or any unwanted effects.

The time domain tool is used to compare both the filtered sweep and the second recording in the time domain. It provides another way of seeing how the signal amplitude changes with time. Since frequency and time increase together an understanding can be gained as to how the amplitude changes. In the example below it can be seen that as time increases the signal decreases in amplitude (from about 28 seconds onwards). From the nature of the sweep function used, the frequency at any time t can be found by:

f(t)=2*s*t+a

where s is the frequency spacing and a is the starting frequency. Note that this function is limited by an ending frequency. Therefore, in the example case given, if the amplitudes starts decreasing at 28 seconds and the start frequency and spacing is 100Hz then at 28 seconds the frequency is approximately 5700Hz.

Also the built in zoom function of Matlab can be used to zoom into any part of the graph which can be used to identify other variations in the signals such as noise.

Image:Result4timedom.PNG

When played through a loudspeaker it can show that time the driver takes to respond to changes. In the below example it can be seen that this driver took approximately 0.05 seconds to respond from the time that the step started to the time the driver restabilised. Logically, for a driver, the smaller the response times the better.


Image:Result5stepinput.PNG

The step response tool is a simple tool that can show the time response of the loudspeaker. The step is a basic function where for time < 0 the amplitude is zero and for time >= 0 amplitude is one. Note that for the purpose of the simulation this tool limits the step function to 0.5 seconds.

The step response test is used to find out the performance of the speaker. The result from the step response gives us information on the system’s settling time, if there are overshoots and its rise time. The rise time is the time it takes for the output to increase from 10% to 90% of its maximum amplitude. In the above figure the rise time is quite instantaneous. The settling time is the time taken for the output to settle to within 0.1% of its final value. From our test this is just below 0.1 of a second and no overshoots can be observed. The absent of the overshoots suggests that distortion of signals will be at a minimum.

References

Wikipedia library: ‘The free encyclopaedia’, viewed 1 august 2006, http://www.wikipedia.com/

William Stalling, 1990, Business Data communications, Fourth edition, Macmillan, New York - US

Edward Lee & Pravin Varaiya, Structured and interpretation of signal and systems, international edition, New York – US, Adison Wesley

John Proakis, Contemporary communication systems using Matlab, Canada – Brroks/Cole

http://www.purebits.com/mlsteo.html link MLS

http://www.silcom.com/~aludwig/Signal_processing/Maximum_length_sequences.htmlink


Scratch Pad

This section can be used by project group members as a placed to jot down thoughts and ideas or things to do. This is an informal area and should be included in the the final submission.

29/08/2006 by Mac - I have been thinking how this would be tested and I came up with this idea;

  • Generate a test file using audio software such as CoolEdit.
  • Playback the test file using a mp3 or cd player, instead of using two PCs.
  • Now see how the result would tell us any things.

What do you think?

02/09/06 - by Carlos -

Guys, i'm gathering background information about this project which i'll be posting by tomorrow. i basically covered some concepts that will give an introduction to the topic.

Mac, your plan sounds good. I guess we need to split the work so some of us can work in the testing part and others in the documentation of this projects since those are the two areas of concern. any volunteers? we need to allocate this so we can be more productive with our time.

04/09/06 - by Carlos (98050762) -

everyone... i've added some text to the abstract/introduction of this project. i think this is the format we should follow (academic) in order to stick to a format that is easy to read. any comments to my work, please feel free to let me know. i'm currently working in writing more documentation for the testing section. ....cheers, Carlos

05/09/2006 by Mac -

Carlos, I think you need to give some references to your things if there is any. I have created a section for that.

06/09/2006 by Andrew - Here is a link with some test sounds: AUDIO SYSTEM TEST FILES

20/09/2006 by Mac -

Check this out good people 1. Plan 2. [1] 3. [2] 4. [3]

27/09/2006 by Carlos -

Today, the team got together in order to check the work progress of every member of the team. Overall, we are all satisfied with our achievements and continue support to this research. It was decided to that our current task allocation approach was the best way to complete this project on time. It was decided to even increase our efforts in order to obtained better examination results for this subject.

The tasks allocations for the next two weeks are:

Andrew is in charge of creating the testing samples for the analysis and flow charts for the project report. Attaporn was allocated the task of designing the filters to be used for the compensation process. Darel was allocated research tasks for MLS and filter designing assistance together with Attaporn. Carlos is in charge of the project research, administration of the information available in our project website and filter research.

The team decided to meet again after VC week in order to re-evaluate our progress and re-allocate efforts where required. Also, we have confirm that any queries will be forwarded via e-mail to all the group members.


16/10/2006 by Carlos -

Guys,

Andrew is almost done with his code and he will do his demo on wednesday. i have done the research about filters which i added to this website, along with the referencing. we need to discuss the code and we need to finish part B. Be aware, only 2 weeks to have everything ready and let's hope that after wednesday 90% of the work is completed.

have all your work ready for this wednesday and don't forget to add your completed sections to this page. also, i need some feedback in order to continue to fill in the information in part A.

And if anyone is lost or needs any help, please don't forget to add your comments or send an e-mail to everyone. we may need to do some task relocation this wednesday in order to spread the work.

see ya's everyone on wednesday....Carlos

2/11/2006 by Carlos -

Guys, i uploaded the latest graphs for the website, please feel free to change anything you like. i reckon the graphs look good. we need to work in describing the extra bits such as step input, waterfall and all that. i'll review the website later on. any suggestions about restructuring the whole page?? i'll be working on this project on friday, send me your suggestions cheers....carlos

6/10/2006 by Mac -

I've formatted the page, but I think might have to do a bit more, of course before Wed.

Personal tools