Monitoring and detecting audio gap
2 views (last 30 days)
Show older comments
Hi, I have an audio speaker that receives audio data from a PC on the network. The system is mostly working, but sometimes audio gaps occur during playback. It happens quite rarely, so I don't want to stay around, listening to it constantly to detect the audio gap. Here is what I want to do, but I'm not sure if it's possible with matlab or not:
I want to generate a 1 KHz tone from the PC on the network to this speaker. Then I want to record the audio that arrives at the speaker using MATLAB. But the recording shouldn't be done into a file. Instead MATLAB should record the audio into a matrix and should confirm that the audio samples received represent a clean 1 KHz tone. I am thinking something like doing continuous FFT and validating that there is high energy around 1 KHz and very little energy anywhere else. Is this possible? Or is there another method that would work better? Basically, matlab should be like a continuous listener and detector of an anomaly with the 1KHz tone.
0 Comments
Answers (1)
Image Analyst
on 15 Oct 2017
If the gap is an artifact of the playback, and not actually in the signal, and you record through a microphone the played back signal, then I think you might be best off just computing the longest stretch of silence in the time domain rather than using the Fourier domain like you'd do with spectrogram(). Of course neither the input, nor the recorded output signal should have any silent stretches longer than a fraction of a second.
silentParts = signal < 0.05; % or whatever
% Get rid of silent stretches shorter than 50 elements (or whatever);
silentParts = bwareaopen(silentParts, 50);
% Measure lengths of the remaining silent parts.
props = regionprops(silentParts, 'Area');
if length(props) >= 1
% There is at least one silent part.
allSilentLengths = [props.Area];
end
% The longest silent part = max(allSilentLengths) elements long.
See Also
Categories
Find more on Audio I/O and Waveform Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!