Delay one speaker with imported sound

11 Ansichten (letzte 30 Tage)
Erik
Erik am 26 Okt. 2012
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

Antworten (2)

Star Strider
Star Strider am 26 Okt. 2012
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 Kommentare
Erik
Erik am 9 Nov. 2012
Bearbeitet: Erik am 9 Nov. 2012
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 am 9 Nov. 2012
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.

Melden Sie sich an, um zu kommentieren.


Erik
Erik am 27 Okt. 2012
I guess it should be something like:
a=wavread('wavfile')
z=%something here that delays z
y=a
w=[y.' z.']
sound(w)
end

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by