Matlab: changing frequency of a .wav file

Click For Summary
SUMMARY

The discussion focuses on creating a Doppler shifted version of a .wav file using MATLAB. The user attempts to modify a script to read a .wav file with the function wavread, but encounters memory errors and matrix dimension issues. The key solution involves ensuring that the frequency variable f0 is correctly defined and that the dimensions of the arrays match when performing operations. A complete code listing is necessary for effective troubleshooting.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of Doppler effect principles
  • Knowledge of audio signal processing
  • Experience with handling .wav files in MATLAB
NEXT STEPS
  • Learn how to use wavread and its alternatives in MATLAB
  • Research MATLAB's array operations to resolve dimension mismatch errors
  • Explore audio signal manipulation techniques in MATLAB
  • Study the implementation of the Doppler effect in audio processing
USEFUL FOR

Audio engineers, MATLAB programmers, and anyone interested in audio signal processing and manipulation techniques.

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
2K
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K