Measuring Audio Amplifiers with MATLAB - Measuring Performance Metrics
This presentation demonstrates the process of assessing several metrics to compare two amplifiers. In this part 3 of 3 series we will be demonstrating how to record the signal and calculate the metrics for comparisons -- Frequency response, Max. gain, THD, SNR, Cross-talk, MOS.
Published: 17 Mar 2024
Hello, everyone. My name is Francis Tiong. And this is Measuring Audio Amplifiers with MATLAB, session 3.
So I just want to remind you that all the code and also the content of my speech here is already written down. And it's available from MATLAB Central. And here's the link.
Now, we're continuing from the previous two sessions. And we have already set up the system. We have already calibrated. Now we are talking about frequency response. And in this session, we will be discussing all these other measurements.
Now, now we're going into the frequency response measurement. So now let's say I have already set up the minus 12. So make sure that I would like to set this one to minus 12. This is the level that I want. And number of excitation, I set it to 1 for now.
I set it to 1 such that I make sure everything works fine, do a test run. And then after that, I will increase it to the maximum. So here we go. I'm just going to click on this Capture signal. And then it will send a chirp signal out and then display the measured spectrum.
[CHIRP SIGNAL]
So now it has sent out-- oh, shoot. I'm talking too soon. It's still running. Oh, I might have affected it. [LAUGHS] So this is the default output. This is in the frequency domain. This is the spectrum that we want.
This is in time domain. It's showing the impulse response. Usually, we only want to look at the spectrum. So what I do is, going to these three dots here on the top right, I click on it. And then I will say-- on the Tile All, I will say Single. And then in a single case, I can then look at just the magnitude response.
And actually, I can close the level meter. And this is what I get. And you can see that-- well, later on, you will find out my loudspeaker actually is only going from 80 hertz to 20k. So therefore, when I overlap the-- when I do this same experiment with the other speaker, you see that the low frequency is matching, and you don't see anything different.
So this is my first run. And you can see that this is about-- I would measure the results that I get. Right now, it's connected to the tube amplifier-- so the first one. And this one has a smaller frequency response. It starts to drop down before 20k. So this is 10k point here.
So this is the frequency response. And now the next step I have to do is I will increase it to the maximum and then click Capture again. Then, in that case, it will then sweep through it and run it 10 times and then get the average and show me.
Then the next step would be repeat the same thing with the second amplifier connected. And when I do that, then I get these results. This is for my-- the two amplifiers.
I physically look at it. I can see that the low frequency is about the same. Well, it's almost identical. That's because it's limited by my loudspeaker. And on the high-end side, it's different. So the tube amplifier has a dropping off after 15k, while the big amplifier that I have, it has a wider bandwidth. It could go all the way to 20k.
Now, this shape here is mostly because of the room reflections-- so meaning that especially after 1k, you can see this dip. If I have better isolation or move around it, my microphone and speaker around, then these dips are different. This will be different.
But the key here is since you are comparing two amplifiers under the same condition, whatever the difference here is the difference of the amplifier. And so you can see that the two has different spectrum.
Now, we're moving on to measure the maximum gain. In this case, we want to calibrate the system to minus 55 dB and then the recorder to minus 45 dB as a start. So that means to say I'm using this level meter all the time to do calibration.
So the key here is this. I now don't have to worry about the quantization. I don't have to worry about the quantization noise because I just want to know which amplifier has a higher gain and about how much is the difference. So I can drop this gain to very low. So for example, in this case, I have dropped it to minus 55. So therefore, it has actually a very low gain.
So I can play. You can see that now, it's very low gain. And since we have a low-gain input, now I can use my analog amplifier, crank the volume all the way up to the top, and see how high it goes. And repeat the same experiment on the second amplifier. And crank it all the way up to the top. And then compare it. So that is the idea.
So I first calibrated both the amplifier to make sure that they can reach this one common point-- minus 55, minus 45. So after they have reached this common point of minus 55 and then I calculate the volume to minus 45, then I will say push one up to the max. And then the other one, start with the same point and also push to the max.
And then in the end, I would then measure the difference between the two at the maximum point. What is received? What is received here? And in this case, my first amp I can get to minus 39 dB for the tube. But then the second amplifier, I can go all the way to minus 14. So that's fairly loud. And in that case, I calculated then the second amplifier, the big one, has an extra 25 dB gain more than the tube amplifier.
Now we're moving on to do a total harmonic distortion measure. And for this measure, we will need to send a sine wave, 1-kilohertz tone. And actually, for subsequent measurements, we'll be using same 1-kilohertz tone. So it's possible that we can use one test, and then the results will be retained, and then use that to measure different things, like THD and SNR.
So this is the code that I've used, a simple script. Much of this is by-- I want to set up a nice beautiful scope. So therefore, all these lines are just to set up the scope properly. And you can see that I want to generate the sound-- I mean capture the sound and write it out as a WAV file.
And so this is the main loop. So in each loop, I will calculate a new signal to be sent out. And then that signal is at exactly minus 12 dB. And sending it out. And then after the meter and all that, I would want to display them. So let me try to run it.
[SINE WAVE TONE]
So you can see that in this display here, I am sending a sine wave. And now I can see that the local peak is received. It's at minus 20. And so this file is created. And I can now change the file name so that I retain the record and run the script again.
And after the two amplifiers have been recorded, then I can use a simple line and say, read the audio files back in. And I don't want to use the whole file, because I think in the beginning, there might be some transient or delay start. So then I want to chop it off. So I'm only using part of the received-- the recorded sound.
And using that, and then I call thd. By simply call thd, you will see the measurements being done and these graphs be displayed. So I have one of them here.
So this is the THD measurement. And actually, you can see the noise also. So this is a fundamental. This is the sine wave that I have sent out. And then these are the harmonics. And then you get these-- all these values. Well, by adding all these values up, I get a measurement that's minus 45.
So yeah, I repeat this experiment for both the amplifiers. And I get these values. So in this case, I can see that my tube amplifier is actually better. It has a lower THD than the bigger amplifier.
I have this script showing you how I generate the sine wave. And this is the results of the two. And one has a lower THD than the other one.
So now we're going into signal-to-noise ratio, pretty much the same way as I did before. So I get the sine wave sent out. And after that, I use this function, snr, to measure the sine wave. And I get these values out for the two different amplifiers. You can see that the tube amplifier is doing better again.
Now, next, we're going to measure the cross-talk leakage. What is cross-talk leakage? That's simply to say I send a 1-kilohertz tone, for example, on the left channel. And then I measure the same tone, whether I can receive it on the right channel. So whatever you hear on the right channel will be leaked from the left channel because the right channel, I'm sending silence. I didn't send anything.
So that's the simple way. And it's recommended that the volume you might need to be playing at a calibrated-- at a louder value than before. But if it's sufficient, then there's no need to go up.
So in my case, I have measured-- one channel is sending the sine wave. The other channel I measure how far down it is. And I realize that the tube amplifier has really a lower cross-talk value. The signal receives at lower value-- minus 44 versus minus 42.
So now to the last measurement, and this is the psychoacoustic measure ViSQOL. And this is an objective metric, meaning that it can return the mean opinion score calculated by the Virtual Speech Quality Objective Listener metric.
So when I was in my old company, when we want to evaluate using-- let's say this amplifier is better or the other amplifier is better, we need to bring in these experts-- or not experts, maybe bring a hundred people and have them listen to it and then give us a score back. And then that's what that means, this MOS. It's opinion score.
But that process is very tedious. It's like sometimes you need to first screen out whether they can hear the defects before you can say whether you want to take these results. Or maybe some people, they don't-- they cannot hear a lot of defects.
And therefore, their score does not value much. And versus there are these experts, they can they can accurately pinpoint everything out. And those people, we call them having a golden ear. And those are like-- we actually pay them quite a bit. They will come in as an expert for evaluation.
But anyway, what I'm trying to say here is that now we don't have to go through that tedious process of hiring people and listening. You can simply play a music. So I have now almost the same code. But instead of reading-- generating a sine wave, I read it from a file.
And then after that, I play this music out and then capture it. And when it's done, then I would compare these two files and simply by calling the visqol command. And I will get the measurements value, the MOS values, back out.
As you can see, the tube amplifier also has a better, higher MOS value. So now at this point, I was thinking, if we can measure the MOS score so easily, is it possible-- let's say I adjust the spectrum by adjusting-- adding an equalizer in the front before I send the music out. Would that actually change the MOS score? Or it's like, are there other things I can do to improve the MOS score? So now I can tune it. So this is a very useful function.
And so this is a summary of what I get. And so you can see that comparing the Amp1 and Amp2, the bigger amp that I have has a wider spectrum. And it can play much louder. But that's about it. Everything else is inferior. Anyway, so that's all for today. Thank you very much.