Measuring Audio Amplifiers with MATLAB - System Calibration - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 18:06
Loaded: 0.91%
Stream Type LIVE
Remaining Time 18:06
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 18:06

    Measuring Audio Amplifiers with MATLAB - System Calibration

    This presentation demonstrates the process of assessing several metrics to compare two amplifiers. In this part 2 of 3 series we will be demonstrating how to set the gain levels at different stage of the system. The targeting level may differ depending on the metrics to be measured.

    Published: 17 Mar 2024

    Hello, everyone. My name is Francis Tiong. And this is Measuring Audio Amplifiers with MATLAB, session 2.

    I just wanted you to know that the code and also the content has been written down. And it's accessible through this link. And that is the MATLAB Central File Exchange. Now we are continuing. And here, we are at calibration. This is the main topic for this session.

    We will mainly be using the Impulse Response Measurer. And this is MATLAB. And when you open up, on top here, second tab to the right, you can see Apps. On the Apps, you can go all the way to the end. Click on the down arrow. Here, you can find all the apps that we have.

    And Impulse Response Measurer is under Signal Processing and Communications. And it's right here-- Impulse Response Measurer. I will click on it. And here it is.

    First thing you notice is that on the left here, upper left here, I can select a sound card. And over here now, I am using the RME. So this is called the Fireface USB interface. You can click on this Refresh button to see what other cards you have just plugged in.

    Sampling frequency, I will leave it at 44.1k. Samples per frame, I set it to 1,024. And this is setting the playback channel. And for my RME, I have 22 to choose from. Recording channel for my sound card, I also have 20.

    This is the signal to be used when I am measuring the frequency response or the impulse response. I would like to use Swept Sine. Number of runs here is to set how many of times-- how many times I want to measure the frequency response.

    And before I got everything right, I will just set it to 1. And when I have it I think the system is ready, I will max it out. And when I max it out-- for example, it will go to 10-- then it will run the test 10 times and show me the averaged results.

    Duration, I set it to 20. And the excitation level, this is the one that we're going to talk about. And you might start with a different value. But whatever that value is I will have to calibrate the system and then find out. So I will let you know about this level later on.

    But most of the time, we are talking about calibration of the level first and then do measurements. And calibration is mainly done using this Level Monitor here. Clicking on the Level Monitor I see that these are the things that's come up.

    When you first bring it up, I think the Test Signal will be set to None, and none meaning that you are not transmitting anything. But you can hit the Play button. And it will be displaying you the signal level received at the microphone.

    And so this level monitor is by itself meaning that I will test the received signal at the microphone. Or I can say now I want to send out pink noise. This is now-- you can see that I'm sending out pink noise. And this is the adjustment of what is the digital signal that I want to send out.

    On the left here is the digital signal sending to the sound card. On the right side is what the level is at the microphone. And once I have calibrated, I know what is the level that I need, then I will set it back here to be used when I'm measuring the frequency response.

    So now let me talk more about-- let me talk more about the-- these signal levels. There are a few things that you noticed. One thing is the output level here has a unit of dBFS. So I think I need to explain more about what that is.

    And then the second thing is the meter here is also showing in dB level. And I would like to explain that this is dBFS. And what does it mean by having 0 dB-- dBFS? And in addition, we are using pink noise for calibration. But what is pink noise? So these are the few things that I would like to talk about first.

    Now, what is dBFS? When you have a sine wave that is having a full swing, it will go from minus 1 to 1. And this having this maximum amplitude, 1, minus 1, we will call it a 0 dBFS. dBFS stands for dB level for full-scale signal.

    And this 1.0 is the maximum level that is acceptable at the sound card. Now, if I take a sine wave and I scale it to 0.25, that means to say I have divided by half and then half again.

    And this divided by half twice would get me a minus 12 dB down signal level. And this would equivalently be labeled as minus 12 dBFS. So it's minus 12 dB down from the full scale.

    It is a standard rule of thumb that each halving of the amplitude results in 6 dB decrease in level. So this principle is also often referred to as 6 dB per bit with the understanding that shifting the signal 1 bit to the right in a digital system is equivalent to dividing the amplitude by 2.

    Now, the test signal level indicates the scaled level of the transmitted signal. In the scenario described, the sine wave signal has a level of minus 12 dBFS. We can take a look at this at the code.

    I have written this code here to say generate a sine wave out. And the amplitude is at 0.25. And using the audio level meter, I can find out the instantaneous peak level. And for that, the measured output is exactly minus 12.

    So this is what we were referring to. In our version 24B, you will see that we will have a sine wave here. And that sine wave is exactly what we see, but if I set it to minus 12 dBFS. So now, setting it to minus 12 dBFS, if it is a deterministic signal, you will see that the signal is exactly lined up here at the transmit side-- that's the player side-- at minus 12 dB.

    Now, what about a random signal? Now, for that, let's talk about, what is pink noise? If it is a white noise, then you will see the spectrum being a horizontal line in the frequency domain. And with a pink noise, the spectrum slopes gently down. And that's what we call it pink. And pink noise is generally more pleasant to the ear, making it the preferred choice for calibrating our system here.

    So the instantaneous-- OK, I'm referring to here. As I was playing here, you can see that this bar here is showing the instantaneous peak level. And we want to say, make sure that the system does not click.

    But the issue now is when it is not a deterministic signal, that it's a random signal, it goes up and down. And also, we do not know what is the maximum value that it should take. This is where the peak2rms, root mean square, function comes in.

    Now, let me reiterate-- actually, there are two points I want to make. First, the goal of setting up the gains at the maximum is that we want to have a maximum digital signal going into the sound card. Second, we want to control the digital signal to be-- we want it to be high but have a very small chance of clipping.

    Clipping happens when you send a signal larger than 1.0 to the sound card. These two goals would allow the maximum number of bits to be used at a sound card and thus minimizes the quantization noise. For example, if I send a sine wave with a low amplitude, like 0.005, and with a sound card expecting an amplitude of 1.0, you might be representing a sine wave with 4 bits and thus having a very high quantization noise.

    So for testing, we would like to use a high-level digital sample but not high enough to clip. The peak to root mean square for sine wave is at 1.4. But for noise, it could be three or four times higher, as we have seen here. The pink noise will have 4.3. And the white noise has 4.9. So that is much higher than a deterministic signal. So therefore, we can use the peak2rms to gauge how much room we want to leave it on top so we have to scale it down the signal by.

    And a simple way to do that is generate a signal and then run the peak2rms. And with that, we can find out how many dB or what's the level that it has to be further attenuated.

    Now, for a random signal we will talk about. Theoretically, a Gaussian random variable, for example, its peak can be infinity. But at 4 sigma, we have a 0.9935 probability of the signal being not clipping, not being getting beyond 4 sigma.

    So therefore, we know that by default, we want to scale it by four times lower. And four times is divided by 4. And that is right-shifting twice, or meaning that it will be 12 dB down. So if our target signal we want to attenuate it 2 bits in the front to have room, and for random signal we want to get further down by 12 dB, meaning that we will be at least want it to have a level that is minus 24 dB down.

    And for pink noise, when we do that, we set it to-- the level, target level, to 0.25. And with it being a random signal, we scale further down. And it comes up to having a value of minus 28.8. So almost 29 dB down. And that is exactly what we get when we set this guy to minus 12. You can see that when I set it to minus 12, it's roughly at minus 29 or minus 30.

    Now, that is interesting to say, what happens when we set it to white noise? Well, white noise, we did not internally scale it down. And so therefore, this is still at your deterministic value of minus 12. So at this point, if you're using white noise, you should manually scale it down yourself, at least further down by minus 12 dB.

    An interesting question would be, if I use-- when I do a frequency response test, I was using these two signals-- MLS or Swept Sine. In that case, where would the digital level be? Would it be clipped if I set it to minus 12, for example?

    And to answer that, I have tried dumping the result out and measure it and find that this chirp signal is exactly deterministic. So it's the same as the sine wave. So therefore, if I set it to minus 12 dB-- if I set this to minus 12 dB, it will correspond to the minus 12 dB level. And so that's what we want to use.

    Now, with this, let's move on. For calibration, what is the procedure then? So the procedure for doing so is-- well, first, I will put in my first amplifier and connected it up. And then the second step is I will bring up my level meter, set it to pink noise. I would like to set to have 2 bits headroom. So it's like minus 12 dB.

    And when I play it, you can see that it's-- the digital level is about minus 30. OK, I will leave it at that. And then the next step, I would have to adjust my analog gain such that the microphone is picking up at-- picking a signal up at the wanted level. So I'm going to stop talking for a while and adjust.

    [PINK NOISE]

    Let's say I want to adjust it, for example, to set it to minus 30 dB, like so. And so I will repeat this experiment for the second amplifier. And thereby both the amplifier 1 and 2 will be set at the same power level, I would say, such that the microphone pick it up at the same level. Here's how we calibrate the system. And this ends the second session. I'm looking forward to the third one.