Matlab: changing frequency of a .wav file

Click For Summary
The discussion focuses on creating a script in MATLAB to play a Doppler shifted version of a WAV file. The user has successfully implemented a Doppler shift for a single frequency but encounters errors when trying to apply this to an entire WAV file. They receive an "out of memory" error when using wavread and a "matrix dimensions must agree" error when modifying the frequency calculation. The response emphasizes the need for a complete code listing and suggests that there may be issues with the user's setup preventing proper file reading. The conversation highlights the challenges of manipulating audio data in MATLAB and the importance of ensuring code compatibility.
brushman
Messages
112
Reaction score
1

Homework Statement


Write a script which plays a Doppler shifted version of a WAV file.

The Attempt at a Solution



This is the code for a doppler shifted single frequency:
Code:
vs = 1100; % speed of sound in feet per second
v0 = s*22/15; % speed of the vehicle in feet per second
fs = 10000; % sampling frequency
ts = 1/fs; % the sampling period
f0 = 440;
td = d/vs; % this is the time for sound to move the distance d
r = v0/vs; % this ratio should be much less than one of course
t1 = sqrt(1 - td^2)/r -1; % time vehicle passes you
t = [ t1-3: ts: t1+3]; % a time base for the signal, with 3 seconds each side
a = (r^2)*(t-t1)/(1-(r^2));
b = ((td^2)+(r^2).*(t-t1).^2)./(1-(r^2));
tau = ((-1)*(2.*a)+sqrt(((2.*a).^2)+(4).*(b)))/(2); % quad form to solve for tau
y = .5 * sin(2*pi*f0*(t-tau));

What I need is to shift an entire wav file. I tried just setting f0 = wavread('file') but I get an error saying out of memory. Then when I change the f0*(t-tau) to f0.*(t-tau) I get an error saying matrix dimensions must agree.

I'm not really sure which way it's supposed to be, anyways.

Thanks.
 
Physics news on Phys.org
I'm not sure what you're doing exactly; you need to provide a complete code listing. Something is wrong with your setup if you are unable to use wavread to even read the file.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
12K
Replies
3
Views
4K
  • · Replies 4 ·
Replies
4
Views
1K
Replies
2
Views
1K
Replies
10
Views
1K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K