function [CPMSignal, PAMSignal] = CPM(Symbols, A, h, Pulse, fsT)
% CPM - continuous-phase modulation
%
% Function generates the baseband equivalent of a CPM signal for a given
% sequence of symbols.
%
% Inputs:
%   Symbols - a vector of symbols drawn from alphabet -(M-1):2:(M-1)
%   A       - amplitude of signal
%   h       - modulation index 
%   Pulse   - Frequency shaping pulse 
%   fsT   - normalized sampling rate (number of samples per symbol period)
%
% Outputs:
%   CPMSignal - CPM signal
%   PAMSignal - intermediate PAM signal
%
% Examples:
%   CPMSignal = CPM(Symbols, A, h, Pulse, fsT)
%   [CPMSignal, PAMSignal] = CPM(Symbols, A, h, Pulse, fsT)

%% Initialization
% ensure Pulse is properly normalized, integrates to 1/2
Pulse = Pulse/(2/fsT*sum(Pulse));

%% Generate PAM signal, using function LinearModulation
PAMSignal = LinearModulation( Symbols, Pulse, fsT );

%% Integrate PAM signal using a filter with difference equation
% y(n) = y(n-1) + x(n)/fsT and multiply with 2*pi*h
a = [1 -1];
b = 1/fsT;
Phase = 2*pi*h*filter(b, a, PAMSignal);

%% Baseband equivalent signal
CPMSignal = A*exp(j*Phase);

