How do I perform a frequency sweep on a .WAV file?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello,
I found the following code online and am using it as a sort of template for performing a frequency sweep on a .WAV file in MatLab.
wave_file = 'name.wav';
[wave_data_time, sample_rate] = wavread('name.wav');
N_temp = length(wave_data);
N = 2^nextpow2(N_temp);
buff = floor((N-N_temp)/2)+1;
Nyq = sample_rate/2;
df = sample_rate/N;
f = -Nyq:df:Nyq-df;
wave_data_time_pad = zeros(size(f));
wave_data_time_pad(buff:buff-1+N_temp) = wave_data_time;
wave_data_freq = fftshift(fft(wave_data_time_pad));
figure;
plot(f,real(wave_data_freq),'b-',f,imag(wave_data_freq),'r-');
However, after compiling, I am recieving this error:
Undefined function or variable 'wavread'.
Error in freq_sweep_ECE223 (line 2)
[wave_data_time, sample_rate] = wavread('name.wav');
Is there an alternative function or approach that newer versions of MatLab supports? Also, is there an easier way to perform a frequency sweep on an input audio file using the spectrogram function in MatLab?
Many thanks!
댓글 수: 0
답변 (1개)
Star Strider
2019년 6월 27일
‘Is there an alternative function or approach that newer versions of MatLab supports?’
‘Also, is there an easier way to perform a frequency sweep on an input audio file using the spectrogram function in MatLab?’
The spectrogram function will likely do what you want. Try it!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!