A|Lab
GitHub and code info
A|Lab
Matlab-based software for measuring acoustic parameters and experiments (Acoustic Laboratory).
This software is made up of different types of measurement (impedance tube, transmission tube, general, etc.) and expansion modules for different specific projects. The software is under development and will be adding more measure methods.
If you find any bug in the interface or in the calculations, please inform and I will fix it as soon as possible. To feature requests or bug reports go to Issues.
The software has been made with the collaboration of the Waves in Complex Media group located in the Higher Polytechnic School of Gandia which is part of the Polytechnic University of Valencia, mainly giving access to equipment and instrumentation and data to be able to validate the results.
The heart of the app
The software uses the MATLAB audio libraries, specifically, to transmit and receive simultaneously, the MATLAB audioPlayerRecorder object is used.
In order to make use of the audioPlayerRecorder object, it is necessary to have a sound card that supports 'Full-Duplex'. All external audio cards have 'Full-Duplex', but the audio cards integrated in computers, especially laptops, do not usually have support for this object. A|Lab will notify you with a window if your hardware is not compatible (image below), if you have several sound cards and one that is valid, enter the configuration and select it.
If you are only opening a previous project, you can ignore the warning.
Examples
The software allows you to save the entire measurement project to be able to open it again at any time and view or export the results. To be able to test the software quickly, some examples of impedance tube and transmission tube measurements have been included, open them from the top menu File->Load project
.
Table of contents
General
Open the software
To open the software you have two options:
-
Source code: download the source code and run the ALab.mlapp file with MATLAB.
-
Installable package: to install the software within matlab download the package from here.
Device setup and calibration
In this panel you can configure the parameters of the audio device and calibrate the system latency (useful for correcting delays in the impulse response). Also, if you have a microphone calibrator, you can calibrate each input channel.
Options:
- Harware configuration: Sample rate, Samples per Frame, Device driver, Audio device and Bit depth.
- Calibrate latency: Selects the input and output channel and calibrates automatically.
- Calibrate inputs: Select calibrator signal level, input channel and run calibration.
- Air parameters: Sound speed and air density.
Calibrate latency
All systems have an internal latency from the moment the signal is emitted until it is received. With this calibration, the latency of the system is obtained and the correction is applied in all measurements, the delay added by the system in the received signal is eliminated.
To calibrate the latency you must connect a cable directly from an output of the sound card to an input. Once connected, choose the channels where the cable is connected and press Calibrate latency
. The software will make 5 measurements to calculate the latency of the system.
% Latency calculation
inCalibration; % Input signal from latency calibration measure
outCalibration; % Output signal from latency calibration measure
[cross,time] = xcorr(inCalibration,outCalibration);
[~,Midx] = max(abs(cross)); % Find peak
Latency = time(Midx)/fs; % Latency time value in seconds
% Latency correction
Latency; % Latency time in seconds
sigReceived; % Signal received in a measurement from general method, impedance tube, ...
DelaySamples = floor(Latency*SampleRate);
sigReceived = [sigReceived(DelaySamples+1:end);zeros(DelaySamples,1)];
Calibrate inputs
To obtain the correct level in the measurements calculations, it is necessary to obtain a factor that applies a dimension to the input signal. This is the calibration factor and it is obtained from a source that has a known acoustic pressure. Usually a calibrator emits 94dB but if you have another type of calibrator you can indicate the reference level.
You must place the calibrator on the microphone you want to calibrate and click on Calibrate channel N
, the calibration factor will automatically be calculated. This calibration factor is automatically applied to all measured signals.
% Calculate calibration factor
Lcal; % Calibrator reference value in dB (Typical: 94)
sigCal; % Measured signal with calibrator placed on the microphone
Pcal = 10^(Lcal/20) * 2e-5; % Calibration reference in Pa
Xrms = sqrt(sum(sigCal.^2)/length(sigCal)); % = rms(sigCal)
K = Xrms / Pcal; % Calibration factor
% Apply calibration factor to a measured signal
K; % Calibration factor
sigReceived; % Signal received in a measurement from general method, impedance tube, ...
sigReceived = sigReceived ./ K; % Calibrated signal
Signal panel
The signal selection panel appears in all types of measurements.
The available signals depend on the chosen measurement method. The following signals are available:
-
MLS
fs; % Sample rate duration; % Duration in seconds of a sequence nseq; % Number of sequences signal = mls(round(fs*duration+1)); signal = repmat(signal,nseq,1); signal = [signal;zeros(round(fs*duration+1),1)];
-
Sweep
fs; % Sample rate duration; % Duration in seconds dur_sil; % Silence duration in seconds fini; % Initial frequency in hertz fend; % End frequency in hertz signal = sweeptone(duration,dur_sil,fs,'SweepFrequencyRange',[fini,fend]);
-
White Noise
fs; % Sample rate duration; % Duration in seconds signal = randn(round(duration*fs),1);
-
Pink Noise
fs; % Sample rate duration; % Duration in seconds signal = pinknoise(round(duration*fs));
-
Pure Tone
fs; % Sample rate duration; % Duration in seconds freq; % Tone frequency in hertz signal = cos(2*pi*freq*(0:1/fs:duration));
-
Custom signal
If you want to use a different signal you can import it by selecting it within this panel. The signal must be in a text file with a single column, the sampling frequency will be the one defined in the software configuration.
All signals are normalized between 0.5 and -0.5: signal = (signal/max(abs(signal)))*0.5;
.
Information panel
This panel always appears in the bar on the right. It displays the relevant information of the audio device.
If latency calibration has not been performed it shows the approximate value (SamplesPerFrame/SampleRate*2
) but this value is not applied to signals.
If at least one input of the device has been calibrated, the word 'Yes' and the channels numbers will be displayed in the input calibration.
Methods
General
This method is only to perform some tests and see some options that MATLAB offers us, such as the calculation of common parameters in sound level meters. Remember: only for test.
Tip: If you have calibrated the input of a microphone, take a measurement with the calibrator attached to the microphone. You can see the measured value in the 'Sound Pressure Level' panel, it must be the same as the reference value of the calibrator. This way you will check that everything is working correctly.
Impedance Tube (ISO 10534-2)
Table of contents
The impedance tube method is detailed in ISO 10534-2. In this software the measure has been implemented in full compliance with the standard.
The steps to follow (also indicated in the standard) are:
- Calibrate the inputs to be used (configuration panel). (Recommended)
- Enter tube parameters (distances and shape).
- Calibrate the impedance tube system (if you use two microphones). (Recommended)
- Measure.
The results obtained are: reflection factor, sound absorption coefficient, specific acoustic impedance, impulse response (two inputs) and frequency response (two inputs).
The side panels that appear in this measurement method are:
- Left panel: Here you can open the tube parameter configuration panel, measure with one or two microphones or review the information of the measurement method.
- Right panel: Here you can choose the type of signal and its parameters. You will also have information about the tube and the audio hardware.
Left panel | Right panel |
---|---|
Tube parameters
Enter in this panel the geometric parameters of the tube: shape, distance between microphones and distance to the sample. Make sure all distances are measured correctly. Also do not forget to indicate the shape of the tube.
One-Mic measurement
If you only have one microphone, you can perform the measurement through this panel.
First place the microphone in position [A] and press Measure [A]
, then move the microphone to position [B] and press Measure [B]
. Finally, click on the button Calculate results
in the right panel.
Two-Mic measurement
To measure with two microphones simply place the microphones in position and press Measure
.
You can also calibrate the system by pressing Calibrate (optional)
.
Once the measurement is finished, press the button Calculate results
in the right panel. If you have calibrated the tube, the software will ask you if you want to use the calibration.
Calibrate the impedance tube system
To calibrate the system, two measurements must be made, one with the normal microphone position, and other one with the swapped position.
It is also advisable to have an absorbent material to slightly reduce reflections.
The figures indicate the position of the microphones for each measurement, make sure they are located correctly before measuring. Once the two measurements are finished, click on Return
.
Information panel
In this panel you will see a summary of the measurement method and the limitations according to the tube parameters.
Results visualization
In the results panel you can choose the resolution of the FFT and see the standard results.
You can also export the results in text file to use it in another software, also export the graphs (PNG, JPG, PDF, EPS or FIG) or see the impulse and frequency responses of the measured signals (Other results
button).
Transmission Tube (ASTM 2611)
Table of contents
- Tube parameters
- One-Mic measurement
- Two-Mic measurement
- Four-Mic measurement
- Measure information
- Results visualization
The transmission tube method is detailed in ASTM 2611. In the software the method is implemented to be able to use one, two or four microphones. It is necessary to have a transmission tube with 4 microphone positions, two on the upstream side and two on the downstream side.
If the sample to be analyzed is symmetrical, only an anechoic end of the tube is necessary. If it is not symmetric, it will be necessary to measure with anechoic end and with rigid end.
The steps to follow (also indicated in the standard) are:
- Calibrate the inputs to be used (configuration panel). (Recommended)
- Enter tube parameters (distances and shape).
- Calibrate the impedance tube system (if you use four microphones). (Recommended)
- Measure with anechoic end and, if not symmetrical sample, repeat measure with rigid end.
The results obtained are: transmission loss, characteristic impedance, transmission factor, reflection factor, propagation wavenamber in material, sound absorption coefficient, impulse response and frequency response (four inputs) for anechoic and rigid end measure (if not symmetrical).
The side panels that appear in this measurement method are:
- Left panel: Here you can open the tube parameter configuration panel, measure with one, two or four microphones or review the information of the measurement method.
- Right panel: Here you can choose the type of signal and its parameters. You will also have information about the tube and the audio hardware.
Left panel | Right panel |
---|---|
Tube parameters
The panel shown here is used to enter the geometric parameters of the tube. Make sure all distances are measured correctly. Also do not forget to indicate the shape of the tube.
One-Mic measurement
If you only have one microphone, it is possible to perform the measurement by placing the microphone in each of the measurement positions.
Every time a measurement is made the graph is updated to show which parts have already been measured. Also, if you are not sure that you have carried out the measurement correctly, you can delete it and do it again.
Two-Mic measurement
If you have two microphones you can perform the measurement faster than the one microphone option. The operation is the same, except that now two input channels are chosen, one for each microphone.
The first measurement is made with the microphones in positions A
and B
(upstream) and the second in C
and D
(downstream), that is why microphone 1 corresponds to position A
and C
, and microphone 2 to position B
and D
.
Four-Mic measurement
This is the best option, it reduces errors when manipulating the position of the microphones obtaining better results (although it is not a big difference).
This option also allows you to calibrate the microphones before making the measurement.
Calibrate the transmission tube system
To calibrate the transmission tube, it is necessary to perform 4 measurements:
- Take a measurement first with all four microphones in their normal positions. (Microphones order: [1,2,3,4])
- Swap the position of microphone 1 with microphone 2 (leave the other microphones in their normal position) and measure. (Microphones order: [2,1,3,4])
- Put the microphone 2 back to its position, put the microphone 1 in the position of the microphone 3 and the microphone 3 in the position of the microphone 1. Measure. (Microphones order: [3,2,1,4])
- Put the microphone 3 back to its position, put the microphone 1 in the position of the microphone 4 and the microphone 4 in the position of the microphone 1. Measure. (Microphones order: [4,2,3,1])
Once all the measurements are finished, click on Done
.
Measure information
In this panel you will see some information about the measurement method.
Results visualization
When you press the button to calculate results, you will see this panel with the different results defined by the standard. If you click on any of the graphs you can see it larger.
Also, if you press the button for other results, you will be able to see the impulse and frequency response of all the measurements.
In the main results panel you can choose to export all the results in text file, export the transfer matrix (T11,T12,T21,T22) in text file for your own calculations or if you click on any graph you go to: Single result.
Single results visualization
In this panel you will be able to see the larger graph and you will also be able to export only that result to a text file or graphic file. In addition, in the case of absorption and reflection, by clicking on their graphs you will see both the hard-backed calculation that defines the ASTM 2611 standard and the anechoic-backed calculation (from transfer matrix method).
Robot measurement (Polytechnic University of Valencia)
This measurement method is exclusive to the Polytechnic University of Valencia. It performs acoustic measurements by using a three-axis robot for automated measurements in a plane or volume. A page dedicated to this method will be included soon to facilitate use by students and researchers at the Polytechnic University of Valencia.
Standards and theory
Here is a table of the sources used for the implementation of some of the measures developed in the software.
Measure | Source | M-File |
---|---|---|
Impedance tube | ISO 10534-2:1998 | calculationsTwoMicISO105342.m |
Transmission tube | ASTM 2611 - 19 | calculationsFourMicASTM2611.m |
Supports
Thanks to the Waves in Complex Media group, Higher Polytechnic School of Gandia and Polytechnic University of Valencia for providing the necessary equipment to develop some of the measures implemented in the software and for all the support in time, meet, talk and discussions.
Author
Jose M. Requena Plens, 2021. (jmrplens.github.io)
Cite As
José M. Requena Plens (2024). A|Lab (https://github.com/jmrplens/A-Lab/releases/tag/v0.5.1), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
include/General Methods
include/General UI
include/General UI/Signals
include/Measurements/General Method
include/Measurements/General Method/UI
include/Measurements/Impedance Tube - ISO 10534-2
include/Measurements/Impedance Tube - ISO 10534-2/Other Methods
include/Measurements/Impedance Tube - ISO 10534-2/UI
include/Measurements/Special Research - UPV Robot
include/Measurements/Special Research - UPV Robot/Methods
include/Measurements/Special Research - UPV Robot/PostProcess Methods
include/Measurements/Special Research - UPV Robot/PostProcess UI
include/Measurements/Special Research - UPV Robot/UI
include/Measurements/Special Research - UPV Robot/UI/Geometric Coords Panels
include/Measurements/Transmission Tube - ASTM 2611
include/Measurements/Transmission Tube - ASTM 2611/Other Methods
include/Measurements/Transmission Tube - ASTM 2611/UI
Version | Published | Release Notes | |
---|---|---|---|
0.5.1 | See release notes for this release on GitHub: https://github.com/jmrplens/A-Lab/releases/tag/v0.5.1 |
||
0.5 |