(New page: == MATLAB Code == <pre> % Travis Safford % September 5, 2008 % % Homework 1.2 - This file is supposed to reverse and slow down a Judas Priest song % Begin by clearing the console and all ...)
 
(MATLAB Code)
Line 20: Line 20:
 
Length_Array=size(data);
 
Length_Array=size(data);
 
Length=Length_Array(1);
 
Length=Length_Array(1);
reversedata=zeros(Length,1);
+
data_reverse=zeros(Length,1);
 
for j=Length:-1:1
 
for j=Length:-1:1
     reversedata(Length-j+1,1)=data(j);
+
     data_reverse(Length-j+1,1)=data(j);
 
end
 
end
disp('Playing reverse at normal speed...');
+
wavplay(data_reverse,sample);
wavplay(reversedata,fs);
+
wavwrite(data_reverse,sample,rate,'jpreverse.wav');
wavwrite(reversedata,fs,nbits,'jpreverse.wav');
+
  
 
%To slow the original data, we can just write out the reversed data with
 
%To slow the original data, we can just write out the reversed data with
 
% a fraction of the correct sampling rate.
 
% a fraction of the correct sampling rate.
disp('Playing reverse at 67% speed...');
+
wavwrite(reversedata,sample/1.5,rate,'jpreverseslow.wav');
wavwrite(reversedata,fs/1.5,nbits,'jpreverseslow.wav');
+
wavplay(reversedata,sample/1.5);
wavplay(reversedata,fs/1.5);
+
 
</pre>
 
</pre>

Revision as of 16:46, 4 September 2008

MATLAB Code

% Travis Safford
% September 5, 2008
%
% Homework 1.2 - This file is supposed to reverse and slow down a Judas Priest song

% Begin by clearing the console and all saved memory.
clear;
clc;

%Open the wave file and get its length, sample size, and sampling rate
%Make sure the file is in your present working directory for matlab
[data,sample,rate]=wavread('jpforward.wav');

%Play the file once at normal speed
wavplay(data,sample);

%Reverses the data, plays it, then saves it to a file
Length_Array=size(data);
Length=Length_Array(1);
data_reverse=zeros(Length,1);
for j=Length:-1:1
    data_reverse(Length-j+1,1)=data(j);
end
wavplay(data_reverse,sample);
wavwrite(data_reverse,sample,rate,'jpreverse.wav');

%To slow the original data, we can just write out the reversed data with
% a fraction of the correct sampling rate.
wavwrite(reversedata,sample/1.5,rate,'jpreverseslow.wav');
wavplay(reversedata,sample/1.5);

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang