% reverb_Schroeder1_eg.m
% Script to call the Schroeder1 Reverb Algoritm

close all;
clear all;

filename='../acoustic.wav';

% read the sample waveform
[x,Fs,bits] = wavread(filename);

% Call Schroeder1 reverb
%set the number of allpass filters
n = 6;
%set the gain of the allpass filters
g = 0.9;
%set delay of each allpass filter in number of samples
%Compute a random set of milliseconds and use sample rate
rand('state',sum(100*clock))
d = floor(0.05*rand([1,n])*Fs);
%set gain of direct signal
k= 0.2;


[y b a] = schroeder1(x,n,g,d,k);

% write output
wavwrite(y,Fs,bits,'out_schroederreverb.wav');

figure(1);
hold on
plot(y,'r');
plot(x,'b');
title('Schroeder Reverberated Signal');

