Delay one speaker with imported sound
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi
I want to import a .wav file into matlab and remake it so that one speaker is delayed. So for example I want to import a already existing music track (or something) and want to delay the right speaker with, let's say, 10ms. How do I do that?
/Erik
댓글 수: 0
답변 (2개)
Star Strider
2012년 10월 26일
I suggest something like this:
x = linspace(0, 2, 2*8192);
Wave = sin(2*pi*1000*x);
Data = [Wave; Wave]';
Fs = 8192;
dly = ceil(10E-3 * Fs); % 10ms delay
DataDly = zeros(size(Data,1)+dly, 2);
q1 = dly:size(Data,1)+dly-1;
q2 = 1:size(Data,1);
DataDly(q1,1) = Data(:,1);
DataDly(q2,2) = Data(:,2);
soundsc(DataDly, 8192)
The 10ms delay sounds like a sort of click echo with this code, but it does what you want it to do. A longer delay is more noticable.
댓글 수: 12
Star Strider
2012년 11월 9일
My pleasure!
You're correct that the zeros create the delay. They ‘pad’ the vectors so that when MATLAB begins to play the sound, it encounters zeros in the delayed channel (a zero-amplitude signal), then starts playing the sound when it gets that far. It's not a matter of ‘processing’ the zero values in the sound or soundsc function, but simply playing the sound vectors that it is given. Near the end, the non-delayed channel is then silent (playing a zero-amplitude signal) for the length of dly, while the delayed channel is still playing.
Yes. I believe column 1 of DataDly is the left channel, and column 2 is the right channel.
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!