Audio Meter during audio capture and playback (using PsychPortAudio)

8 visualizaciones (últimos 30 días)
Clément
Clément el 16 de Mayo de 2023
Respondida: Raja Palanimurugan el 24 de Jun. de 2025
Hello,
I am doing simultaneous sending and recording of an audio signal with PsychPortAudio and I want to visualize the sound pressure during the process.
On the "Impulse Response Measurer App" of Matlab, there is the "Level Monitor". I would like to have something similar with PsychPortAudio (peak meter and/or RMS meter).
Can you help me?
PS: I've seen "loudnessMeter" but it works with dsp.AudioFileReader. Is there an equivalent?
Thank you!

Respuestas (2)

Raja Palanimurugan
Raja Palanimurugan el 24 de Jun. de 2025
Starting in R2023b, we introduced a uiaudiometer component in Audio Toolbox. You can use this component in your apps, built programmatically or using App Designer.
It is a purely visual component, i.e., it doesn't compute levels itself. Instead you can feed the level data computed separately. This gives you flexibility to pair it with one of our computational objects depending on what you want to display:
  • audioLevelMeter – for digital peak level of audio signals
  • loudnessMeter – for perceptual loudness in accordance with EBU R 128 and ITU-R BS.1770-4 standards
  • splMeter – for sound pressure levels
  • Or even just the rms function for a simple RMS level
See the following examples for starting points:

Rahul
Rahul el 10 de Jun. de 2025
I understand that you wish to create a visualizer which would show the RMS Meter highlighting the rms values of the audio being recoded using 'PsychPortAudio'. Since there is no built-in functionality for this for 'PsychPortAudio', it can be implemented by plotting chunks of rms values of audio data while being recorded since returns audio data in chunks.
Here is a small example:
figure;
hBar = bar([0 0]); % One bar per channel
ylim([0 1]); % Assuming normalized signal
title('Live Audio Level Monitor');
xlabel('Channel');
ylabel('Level');
while true
% Fetch available audio data (recording)
[audiodata, ~, ~] = PsychPortAudio('GetAudioData', pahandle, 0.05, fs);
if ~isempty(audiodata)
% RMS per channel
rmsLevels = rms(audiodata, 2);
% Or Peak level per channel
% peakLevels = max(abs(audiodata), [], 2);
% Update plot
set(hBar, 'YData', rmsLevels);
drawnow;
end
end
Note: Adjust the loop according to your requirement, currently it is a while true loop, which would not end recording. You can wither set a time limit for your recording or listen for a kepress to break out of a loop.
The following MathWorks documentations can be referred:
Thanks.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by