(New page: %Steve Anderson %Homework 1 Problem 2 clear; clc; [data, srate, brate] = wavread('jpforward.wav'); %reads wav file and stores to array wavplay(data,srate); %play the song normally x = ...)
 
Line 1: Line 1:
%Steve Anderson
+
%Steve Anderson
%Homework 1 Problem 2
+
%Homework 1 Problem 2
 
+
clear;
+
clear;
clc;
+
clc;
 
+
[data, srate, brate] = wavread('jpforward.wav');  %reads wav file and stores to array
+
[data, srate, brate] = wavread('jpforward.wav');  %reads wav file and stores to array
wavplay(data,srate); %play the song normally
+
wavplay(data,srate); %play the song normally
 
+
x = length(data); %length of song array
+
x = length(data); %length of song array
 
+
jpreverse = zeros(x,1);
+
jpreverse = zeros(x,1);
counter = 1;
+
counter = 1;
 
+
for i = x:-1:1  %for loop from end of song to beginning
+
for i = x:-1:1  %for loop from end of song to beginning
    jpreverse(counter) = data(x);  %reverse song into jpreverse
+
    jpreverse(counter) = data(x);  %reverse song into jpreverse
    counter = counter + 1;
+
    counter = counter + 1;
end
+
end
 
+
%play reversed version of song
+
%play reversed version of song
wavplay(jpreverse, srate);
+
wavplay(jpreverse, srate);
 
+
wavwrite(jpreverse, srate, brate, 'jpreversed.wav');
+
wavwrite(jpreverse, srate, brate, 'jpreversed.wav');
 
+
%create and play song reversed but slower
+
%create and play song reversed but slower
wavplay(jpreverse, srate/1.75);
+
wavplay(jpreverse, srate/1.75);
wavwrite(jpreverse, srate/1.75, brate, 'jprevslow.wav');
+
wavwrite(jpreverse, srate/1.75, brate, 'jprevslow.wav');

Revision as of 06:16, 5 September 2008

%Steve Anderson
%Homework 1 Problem 2

clear;
clc;

[data, srate, brate] = wavread('jpforward.wav');  %reads wav file and stores to array
wavplay(data,srate); %play the song normally

x = length(data); %length of song array

jpreverse = zeros(x,1);
counter = 1;

for i = x:-1:1  %for loop from end of song to beginning
    jpreverse(counter) = data(x);  %reverse song into jpreverse
    counter = counter + 1;
end

%play reversed version of song
wavplay(jpreverse, srate);

wavwrite(jpreverse, srate, brate, 'jpreversed.wav');

%create and play song reversed but slower
wavplay(jpreverse, srate/1.75);
wavwrite(jpreverse, srate/1.75, brate, 'jprevslow.wav');

Alumni Liaison

Questions/answers with a recent ECE grad

Ryne Rayburn