% tonetest.m ver 000
%
% Create a tone sweep and filter it.
%
% Usage:
%  - start octave in terminal
%  - <octave> tonetest
%
% Result:
%  You should see the first 512 samples of a tone sweep.
%
% Notes:
%  <octave> i=500:800; plot(t(i),y(i))   <-- to see samples 500-800.

Fs = 8000;        % sampling frequency in HZ
maxfreq=2000;     % highest freq in sweep
lenInSec=1; 
n = 1:lenInSec*Fs;  % n is a vector of integers
T = 1/Fs;           % T is the sampling interval
t = n*T;            % t is for ploting natural time
f = maxfreq*(n/length(n));  % create an increasing frequency array
x = sin(2*pi*n*T.*f);       % create tone from frequency
%[B,A]=oct3dsgn(1000,Fs,3); % call 1/3 band octave filter maker
B  =[1];                    % make numerator of transfer function a0 = 1
A  =[1];                    % make denominator of transfer function b0 = 1
y = filter(B,A,x);          % octave.sourceforge.net/octave/function/filter.html 
index = 1:512;              % integer index to pluck out t and x values
plot(t(index),x(index));    % ploting input only, filter output not shown

% TODO: create filtered output, y1, y2, plot on same graph to see 
% the effects of frequency dependent filtering on the time domain
% signal (e.g. the output of the filter(B,A,x) function).
%clf                 % clear figure
%hold;               % tell plotter to not erase plots
%plot(t,y1,'r');     % plot in red
%plot(t,y2,'g');     % plot in green
