Formation of audio file(.wav) from a matrix.
조회 수: 8 (최근 30일)
이전 댓글 표시
How can i convert a simple 3*3 matrix into an audio file of (.wav)
댓글 수: 0
채택된 답변
Rick Nickle
2021년 11월 17일
편집: Rick Nickle
2021년 11월 17일
Thanks Star Strider!
Hemraj, I understood that you were also interested in writing the .WAV file, so I'll add that.
Populate the 3x3 matrix:
M=randn(3)
Set the sample rate:
Fs=48000
Normalize the data and put it back into 3x3 (I may missing a good optimization here):
y = reshape(normalize(M(:),'range',[-1 1]),3,3)
Write the data to .wav:
audiowrite('3x3.wav', y, Fs)
Now read it back to test:
[yy, FFs] = audioread('3x3.wav')
We can't actually play back using the sound() function because it only supports 2-channel, so play back the first two:
sound(yy(1:end,[1 2]))
댓글 수: 1
Star Strider
2021년 11월 17일
My pleasure.
With extremely rare exceptions (this is not one), I delete my un-accepted Answers, so I have here as well.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!