function y=horn(note,fs)
% FM horn instrument (Moore p. 327)
%
% note is in duration-frequency-amplitude format
% (duration in seconds, frequency in Hz, amplitude usually between 0 and 1)
%
% Example usage:
%
%   fs=20e3;
%   sound(horn([1 440 1],fs),fs)


% generate time vector
dur=note(1);
tt=0:1/fs:dur;

fc = note(2);	%carrier frequency
h = 1;		%harmonicity ratio
fm = h*fc;	%modulating frequency
Imin=0;		%minimum modulation index
Imaxmin = 5;	%modulation index (max value above Imin)

% envelopes
env=gen4([0 0 -1; 0.2 1 -1; 0.3 0.708 0; 0.8 .631 -1; 1 0 0],dur,fs);
%disp(['env ' num2str(size(env)) 'tt ' num2str(size(tt))])
aa = note(3)*env; 
ii = Imin+Imaxmin*env;

% output waveform
y = aa.*sin(2*pi*fc*tt + ii.*sin(2*pi*fm*tt));
