audio waves energetic attenuation diagram
2 ビュー (過去 30 日間)
古いコメントを表示
Hi:
I want to convert audio files into images,please refer to the attached picture.
How can i do it?
Thank!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1588176/image.png)
0 件のコメント
回答 (1 件)
Ayush Anand
2024 年 1 月 11 日
Hi,
To create a log Power vs. time plot as shown in the picture provided, you could sum the power across all frequencies at each time point to get the total power at that time, and then plot this on a log scale. This could be considered a variant of the common spectogram with frequency domain collapsed, hence the "spectogram" function could be used for the same.
Here's how you can implement this in code:
% Read the Audio File
[audioData, fs] = audioread('sample.wav');
%Since spectogram accepts first argument as vector, ensure audioData is a vector by converting stereo audio to mono if necessary
if size(audioData, 2) == 2
audioData = mean(audioData, 2);
end
% Convert audioData to double if it's not already double
audioData = double(audioData);
% Create the Spectrogram with desired parameters
windowSize = 256; % Window size for the spectrogram
overlap = round(windowSize * 0.75); % Overlap between windows
nfft = 1024; % Number of FFT points
[S, F, T, P] = spectrogram(audioData, windowSize, overlap, nfft, fs);
%Sum the power across all frequencies to get total power at each time point
totalPower = sum(P, 1);
%Create the plot and save it as an image
scatter(T, 10*log10(totalPower));
%... customize the plot
You can refer to the link below to read more on the "spectogram" function:
Hope this helps!
6 件のコメント
参考
カテゴリ
Help Center および File Exchange で Multirate Signal Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!