to get matlab code that reads a wav file recorded for 30 seconds and do time sequence for fs 44100

조회 수: 1 (최근 30일)
I want a matlab code that reads wav file recorded for 30 seconds and generates time sequence for sampling freq (fs 44100)
( just want to generate time sequence,thus to export t values that corresponding to amplitude of the wav file)
thanks

답변 (1개)

Walter Roberson
Walter Roberson 2021년 9월 9일
filename = 'YourFile.wav';
[y, fs] = audioread(filename);
thirty_secs = fs * 30;
assert(size(y,1) >= thirty_secs);
y = y(1:thirty_secs,:);
if fs ~= 44100
y = resample(y, 44100, fs);
end
Now y is the amplitude information for the first 30 seconds at 44100, even if the original was recorded at a different sampling frequency.
  댓글 수: 1
Nega Ejjigu
Nega Ejjigu 2021년 9월 9일
appreciated very much.
The code runs but I couldn't able to export array of t values for 30 seconds. My goal is to obtain sequence of thirty seconds in 10^5 . I went at open variables tab in matlab and clicked thirty-secs to export sequence of thirty_secs like each time array 1*10^5 ( prefixSeconds), 2*10^5 (prefixseconds0,.... prefix might be milli or watever.....
Thanks in adavnce for further assistance

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Antennas, Microphones, and Sonar Transducers에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by