Measuring Audio Amplifiers with MATLAB - Setting Up Systems - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 15:27
Loaded: 1.07%
Stream Type LIVE
Remaining Time 15:27
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 15:27

    Measuring Audio Amplifiers with MATLAB - Setting Up Systems

    This presentation demonstrates the process of assessing several metrics to compare two amplifiers. In this part 1 of 3 series we will be introducing the elements of the system: Amplifiers used, audio driver selection, MATLAB audio interfaces etc.

    Published: 17 Mar 2024

    Hello, everyone. My name is Francis Tiong and today's topic is Measuring Audio Amplifiers with MATLAB. And I want to mention that the code, and also the content, has been written down and can be downloaded through this link here. This is from MATLAB Central.

    OK, so during this session, we will illustrate the process of assessing several metrics to compare two amplifiers. Note that the measurements are relative, and not absolute, meaning that, for example, if you see a dip in the frequency response, [COUGHS] it might be caused by the room effect.

    But you will see the same dip when you measure the second amplifier. So then [COUGHS] since we are comparing just between the two amplifiers, it might be OK.

    So, today we will first talk about how to set up the system. This is followed by a discussion of calibration. And after the calibration, we will then do the measurements. This agenda will be recorded over three different sections. And this is the first video.

    [CLEARS THROAT]

    OK, this is the system block diagram. So we have a PC connecting to the sound card. And from the sound card, I will connect to the audio amplifier. This is the audio amplifier that we are comparing. And we will say, connect the first amplifier.

    [CLEARS THROAT]

    Do the measurements and then swap in the second amplifier, and then do a second set of measurements. This is the loudspeaker. And the sound will be played and recorded in the microphone nearby. I put down here. It's about 0.5 meters away. Record the sound, go back to the sound card, and go to the PC.

    [CLEARS THROAT]

    Notice that the loudspeaker and the microphone are best to be placed inside a huge box in line with acoustic panels, to absorb the sound reflections. If you don't have this, you can try to record it in a quiet outdoor area where there are also minimal reflections of nearby objects.

    And in the worst case, you can also do measurements in the room. And in that case, it's best that you have some sound absorbing materials in the vicinity. Again, this is to minimize the reflections from the wall.

    OK, these are the two amplifiers that I am about to compare. The one on the left is a tube amplifier. And I've had it for four years. The one on the right is a much bigger one. And I've had it for 24 years. This is the loudspeaker that I'm using.

    [CLEARS THROAT]

    Its response is not 20 to 20k. I think it's more like 80 to 20k. We will see in the frequency response curve. This is the microphone that I'm using, and it comes with a response curve for this microphone.

    So I could be using this response, and then subtracting the microphone effect from the measured results. But since we're doing relative measurements, this may not be needed. And this microphone also requires 48 volt phantom power.

    [CLEARS THROAT]

    That means to say from the sound card, you need to select to say 48 volt supply to this mic. OK, these are the sound cards that I have. So you can see that the smallest one, the Focusrite is the cheapest, and the most expensive one is the RME.

    And the RME is like $1,700. Focusrite is like, I forgot, it's like probably a couple $100. But this is just an example. And this is the sound card that I'm talking about. Today I'll be using the RME.

    These sound cards come with their own control panels. This is the software, like the control panel from Roland. And this is the control panel from RME. I will be talking more about this later on.

    [CLEARS THROAT]

    Now, as you plug in your sound card, you have to go to Windows system sound, where you can find these default settings. Here, let me bring it up. I go to system. You click sound. This is on the Windows.

    And you can see all the options for speakers. Scroll down. You can see all them for microphones. And you can see that the selection here is for the default setting.

    [CLEARS THROAT]

    And one more thing that's interesting, is that there is a gain control for the speaker, and also for the microphone. And we can come and talk more about these gains settings later on.

    Yeah, so the RME has a lot more channels than my Focusrite. I'm using the Focusrite to record this session, but for the loudspeaker amplifier comparison testing, I was using the RME. And I'm also using the Impulse Response Measurer app from MATLAB. This app is very useful.

    And not only the frequency response will be done here, but the calibration side will be done all through this level meter.

    OK, now we're going to talk about different parts of the system that has a gain setting. This is what we're going to do. First, connect the first amplifier into the system and then adjust the volume to the minimum. That's over here.

    And that is to say, there's no sound. And we will adjust the volume when we are calibrating it. On the sound card here, all the speaker channels' gains will be maximized. And on the microphone also, it's all maximized. But in addition, I'm boosting it up further by 40 dB.

    [CLEARS THROAT]

    On the PC side, everything is maxed out. And so the idea here, is that I want the gain control mainly to be done on the application side. And everything else is not attenuating any signal along. So that it's easier for us to calibrate and know exactly what the level is at the sound card.

    Now, a lot of these sound cards come with an ASIO driver in Windows. The ASIO driver allows the application to directly access the sound card, and thus, bypassing the control settings in Windows. With this driver, the response time from the application to the sound card would be faster.

    So if I connect the output port, so output port--

    [CLEARS THROAT]

    --to the input port of the sound card here, and then measure the round trip delay, it'll be shorter with the ASIO driver. Now, the default in Windows, the default is directSound.

    And with ASIO, so the default is this directSound. And with ASIO, is this. So you can see that if you have some application using directSound, some using ASIO, then the gain to signal received will have different gain.

    [CLEARS THROAT]

    OK. In MATLAB, we have a function audioPlayerRecorder. This function can send and receive data at the same time. And they will be sampled with the same clock. The default for that is using ASIO driver.

    And we also have two more functions, the audioDeviceWriter and the audioDeviceReader. The DeviceWriter allows you to send data to the sound card, playing it on the loudspeaker. And the DeviceReader is basically getting data from the microphone.

    But these two instructions, they are default to directSound. So that means to say they will be using going through the windows control. So a word of caution, is that we don't want to mix them, meaning that I don't want to mix the first audioDeviceWriter. I manually set it to ASIO and then the reader set it to DirectSound. That's not recommended.

    So I want to emphasize that the DirectSound path and ASIO, they will have different gain. So therefore, like if I implement it using the first line, then this is going to go through ASIO. The second line is actually to two instructions. One is to play, the other instruction is to record.

    If I use this line, then it falls ASIO. So if I do a recording using line one and line two, these will get a different gain received.

    Now let's talk about the control panel at the sound card. Here, my example is the RME control panel. So I have only connected a microphone and a loudspeaker to this sound card. So at the bottom row here, you can see that it says here, hardware outputs.

    So this row controls the hardware connecting to the output. And so as I select, for example, I click on phones, you can see that the middle row and the top row at the bottom here, it says phones. So that means to say all the controls here on the top two rows here, they are going to affect the output line value here to the phones.

    And the middle row here is for controlling software playback. And the top row is for hardware input. So for hardware inputs, I have connected to the microphone. But since this is a playback channel, you can see that my gain is all the way down.

    So if I slide this up, they'll be high. But right now, I don't want to have any effect, so everything is down. So from judging from this here, you can see that the phone's output is only going to take this channel, the playback from the PC.

    Now, if I click on this hardware, you can see that the settings has changed. Now first of all, all the words here, now it says analog 1, 2. And you can see that now the gain on the microphone is high. And this is all the way down. So this is my microphone input channel.

    And notice also here, that there is, when I click on this, you can see that I have an additional 40 dB gain. So I know that different sound card will have a different control panel, but I think the idea might be similar, so therefore was telling you about that.

    Now, here's a simple code that creates a sine wave and send it out using the audioPlayerRecorder. The object is created here and going to be used later on here. And this loop here, this for loop, will create one frame of sine data each time.

    And this frame will be sent to the sound card, followed by retrieving the recorded frame of data. And that data will be sent to this level meter object, where I will measure the instantaneous local peak value.

    And this local peak value, together with the recorded data, will be sent to the scope. And I will have a scope. Let me show you the scope. No, I don't have it. OK, so there will be a scope that shows up. And you can see that both levels are will be displayed.

    And finally, this frame of data will be pushed to this object that will do the AudioFileWriter that stores the data to this wav file. So this will loop through with a specified number of frames.

    And again, the sine wave is created here on the fly using this equation here, sin. This is calculating the phase. And after that, it will be sent to the sine wave.

    OK, so that's all I have for this session. I'm looking forward to see you on the next one.

    Related Information

    View more related videos