Action on close of spectrumAnalyzer() object/windows
Mostra commenti meno recenti
Dear community,
at the moment I am preparing for some real time processing on audio recordings. I want to end the inifinite recording loop, when the visualizing window is closed. How can I achieve this, i cannot even find the handle to the plotting window.
so far the loop closes when the window with tunable properties is closed and then the spectrumAnalyzer() window is closed.
Note: this is about a spectrumAnalyzer object, not dsp.spectrumAnalyzer()
Unfortunately i cannot have a look into the first, since it is p-code
deviceReader = audioDeviceReader('NumChannels',2);
% Create scope
specScope = spectrumAnalyzer('SampleRate',deviceReader.SampleRate, ...
'Method','Filter bank', ...
'PlotAsTwoSidedSpectrum',false, ...
'FrequencyScale','Log', ...
'AveragingMethod','Exponential', ...
'ShowLegend',true, ...
'ChannelNames',{'Input channel 1','Output channel 1'}, ...
'YLimits',[-102.67239232318423 -22.46657271946507]);
% just a audio plugin doing some processing
sut = audiopluginexample.SpeechPitchDetector;
setSampleRate(sut,deviceReader.SampleRate);
% Open parameterTuner for interactive tuning during simulation
tuner = parameterTuner(sut);
drawnow
% Stream processing loop
nOverruns = 0;
figs=findall(0,'type','figure'); % end loop if any until here opened window is closed
while all(ishandle(figs))
% Read from input, process, and write to output
[in,novr] = deviceReader();
nOverruns = nOverruns + novr; % Increment the overrun counter
in = in(:,1);
out = process(sut,in);
% Visualize input and output data in scope
%%%%%% This call opens the window with representation, but i cannot
%%%%%% find the handle of this window to include it in the whilw
%%%%%% statement
specScope([in(:,1),out(:,1)]);
% Process parameterTuner callbacks
drawnow limitrate
end
% Clean up
delete(specScope)
release(deviceReader)
release(specScope)
Risposta accettata
Più risposte (1)
Jonas
il 12 Dic 2022
Categorie
Scopri di più su Signal Generation in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!