Delay one speaker with imported sound

2 次查看(过去 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

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by