audio compression (shorten an audio file)
이전 댓글 표시
I want to compress an audio file to make it shorter to put in a game for sound effects. I use the following:
[y,Fs]=wavread('blast.wav');
t1=0;% start time
t2=2;% end time
yNew=y((Fs*t1+1):Fs*t2,1);
wavwrite(yNew,Fs,'soundShort.wav');
The compression is fine and 'soundShort.wav' can play. But command sound(wavread('soundShort.wav')) no longer has any sound, though it's runnable. I wonder what goes wrong.
댓글 수: 13
Geoff Hayes
2018년 12월 4일
a - are you really calling the code as
sound('soundShort.wav')
and so are passing a string to the sound method? If I try that (in my version of MATLAB) then I observe a
Error using sound (line 33)
Audio data must be real and floating point.
What happens when you call
sound(yNew, Fs);
instead? Presumably the yNew array has Fs samples...
a a
2018년 12월 7일
Walter Roberson
2018년 12월 7일
sound() with only one input assumes 8000 Hz.
a a
2018년 12월 8일
Walter Roberson
2018년 12월 8일
8000 samples per second. Fs = 8000 .
a a
2018년 12월 8일
Walter Roberson
2018년 12월 8일
your original code uses a statement that reads in both the signal and the sampling frequency. You need to do that . Then you need to pass the signal and the sampling frequency to sound() like Geoff posted .
a a
2018년 12월 9일
Walter Roberson
2018년 12월 9일
What shows up for size(y) and for min(y) and max(y) ?
a a
2018년 12월 9일
a a
2018년 12월 9일
Walter Roberson
2018년 12월 9일
http://pcauthorities.com/windows-xp/how-to-troubleshoot-sound-problems-in-windows-xp/
a a
2018년 12월 10일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Measurements and Spatial Audio에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!