Delay one speaker with imported sound

조회 수: 11 (최근 30일)
Erik
Erik 2012년 10월 26일
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

답변 (2개)

Star Strider
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
Erik
Erik 2012년 11월 9일
편집: Erik 2012년 11월 9일
Thanks for the answer! I have two questions:
-So, what's making the delay? I understand that it is the zeros in DataDly, but how does the zeros create the delay? Is it that the program has to process the zeros on one of the speakers before it "begins with the sound" ?
- Is the columns in DataDly representable for the two different speakers?
Star Strider
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.

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


Erik
Erik 2012년 10월 27일
I guess it should be something like:
a=wavread('wavfile')
z=%something here that delays z
y=a
w=[y.' z.']
sound(w)
end
  댓글 수: 1
Star Strider
Star Strider 2012년 10월 27일
Please see my comment above.

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

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by