how to convert audio signal having (4.82MB size ,44100 as sampling frequency , stereo signal ) to different frame length that is 1024 samples,512 samples and 2048 samples?Whether I should resample it if not than how is it possible in matlab?

1 view (last 30 days)
my second question is that Can I convert this signal to different sampling rate also I mean at 22050Hz,48000hz etc.?or at different time interval 14.34 seconds,57.36seconds ?And its actual length in seconds is 28.68 seconds and total number of samples is 1264896?

Accepted Answer

Walter Roberson
Walter Roberson on 24 Aug 2015
framesize = 1024;
framedSignal = permute(reshape(YourSignal.', 2, framesize, []), [2 1 3]);
Now the first dimension of framedSignal is the sample number, the second dimension is the channel number, and the third dimension is the frame number.
  2 Comments
PRATIBHA WARKADE
PRATIBHA WARKADE on 25 Aug 2015
actually I am getting error after putting this code as: Error using reshape Product of known dimensions, 2048, not divisible into total number of elements, 12.
Walter Roberson
Walter Roberson on 25 Aug 2015
I should have written
framedSignal = permute(reshape(YourSignal.', size(YourSignal,2), framesize, []), [2 1 3]);
to account for the possibility that your signal has only 1 channel.
However, you told us that you had 1264896 samples and now your error message is as if you have only 12 samples.
1264896 samples is divisible into frames of length 256 but not into frames of length 512, 1024, or 2048. You have not defined how you want to handle the partial frames.
You should consider using buffer() once for each channel.

Sign in to comment.

More Answers (0)

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!