function [outfm] = fmod(msg, fc, fs, Ac, kf)
%  FMOD()   -  This function performs frequency modulation, FM. The       %
%              integration of the message signal is perform here.         %
%                                                                         %
%                                                   t                     %
%        Equation:   s(t) = Ac*cos(wc*t + 2pi*kf * SUM m(t) )             %
%                                                   0                     %
%  msg - message signal vector (see note                                  %
%  fc  - carrier frequency                                                %
%  fs  - sampling rate for digitizing                                     %
%  Ac  - amplitude of carrier                                             %
%  kf  - modulation index                                                 %
%                                                                         %
%  Note:  If the message is sampled at a lower frequency, say 8 kHz, it   %
%         must be interpolated to the sampling rate supplied here before  %
%         calling this function.                                          %
%-------------------------------------------------------------------------%

%*************************************************************************%
% Filename  FMOD.M                                                        %
%                                                                         %
% Date      1/8/06                                                        %
% Author     PWS                                                          %
%*************************************************************************%
t = 0:1/fs:(length(msg)-1)/fs;                 % number of samples        %

if( nargin < 5)
   kf = (fc/fs) * (2*pi)/(max(max(abs(msg))));          %modulation index %
end;

outfm = Ac * cos(2*pi*fc*t + 2*pi*kf * cumsum(msg));

