How do I perform clustering of audio signal?
7 views (last 30 days)
Show older comments
<<
<<
<<
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159560/image.jpeg)
>>
>>
>>
I want to perform clustering of audio signal in matlab. If I use the matlab function of spectrogram it results in 3D data. How do I perform clustering on such data? So far I have generated spectrograms from my noise (reference) and original audio signal. The code is below:
%clear, clc, close all
glas=audioread('glas-11025.wav');
noise=audioread('noise-11025.wav');
windowSize=1024;
% get a section of the sound file
[x1, fs1] = audioread('glas-11025.wav'); % read the file
x1 = x1(:, 1); % get the first channel
N = length(x1); % signal length
t1 = (0:N-1)/fs1; % time vector
% plot the signal spectrogram
figure()
[S,F,T]=spectrogram(x1, windowSize, 3/4*windowSize, [], fs1, 'yaxis');
spectrogram(x1, windowSize, 3/4*windowSize, [], fs1, 'yaxis');
grid on
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
xlabel('Time, s')
ylabel('Frequency, Hz')
title(['Spectrogram of the signal glas (' num2str(windowSize) ' window)']);
h = colorbar;
set(h, 'FontName', 'Times New Roman', 'FontSize', 14)
ylabel(h, 'Magnitude, dB')
% Noise
[x2, fs2] = audioread('noise-11025.wav'); % read the file
x2 = x2(:, 1); % get the first channel
N = length(x2); % signal length
t2 = (0:N-1)/fs2; % time vector
% plot the signal spectrogram
figure()
[S2,F2,T2]=spectrogram(x2, windowSize, 3/4*windowSize, [], fs2, 'yaxis');
spectrogram(x2, windowSize, 3/4*windowSize, [], fs2, 'yaxis');
grid on
set(gca, 'FontName', 'Times New Roman', 'FontSize', 14)
xlabel('Time, s')
ylabel('Frequency, Hz')
title(['Spectrogram of the signal noise (' num2str(windowSize) ' window)']);
h = colorbar;
set(h, 'FontName', 'Times New Roman', 'FontSize', 14)
ylabel(h, 'Magnitude, dB')
5 Comments
Image Analyst
on 8 Jan 2017
I have no idea what you'd want to cluster in that spectrum. If you want to separate noise from signal then why not use a weiner filter or ICA http://research.ics.aalto.fi/ica/icademo/ ?
Answers (1)
Image Analyst
on 8 Jan 2017
That's what ICA and BSS were made for. If you know the spectrum of the noise though, you can use a wiener filter. Or if you know the noise and signal occur in different regions of the spectrum, you can do a high pass, low pass, or band pass filter. Perhaps you can figure it out by examining the spectra with and without noise, like maybe subtract the spectra to see which frequencies are different.
2 Comments
Edward Oakeley
on 6 Dec 2017
Hi, I actually have almost exactly the same problem.
As you seem to have answered your own question, I was wondering if you could share the solution for how you solved the clustering problem.
Also, as you are using an FFT, I assume that the time component is lost so you will not be able to determine the order of the sound clusters only the frequency of clusters within your data. Are you doing a sliding window? Have you considered some kind of wavelet analysis rather than FFT?
See Also
Categories
Find more on Spectral Estimation 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!