
function outwave = ringmodulation(inwave, carrier_freq, fs)
% 
% 
% RINGMODULATION(inwave, carrier_freq, fs) 
% Apply ring modulation to an input signal.
%
%
%       Prior to function call, wave audio signal should be imported to 
%       the workspace in the following manner:
%       [inwave, fs] = wavread('filename');
%
%
%       VARIABLES:
%
%       inwave        =   input signal
%
%       carrier_freq  =   controls rate of carrier signal
%
%       fs            =   sampling frequency (specified via wavread)
%
%
%       For best results, choose a carrier frequency at a musical
%       interval of the input frequency note.
%               Eg. If the input is a single 440 Hz note (A4), try creating
%               the carrier as 659 Hz (E5).
%
%       However, if you are wanting to create a more dissonant type of 
%       sound, then this is not a good approach.
%
%
%       See also WAVREAD

len = 1:length(inwave);

carrier= sin(2*pi*len*(carrier_freq/fs))';

outwave = inwave.*carrier;

sound(outwave,fs);

subplot(3,1,1)
plot(inwave)
title('Ring Modulation Signals')
xlabel('Input Signal')
subplot(3,1,2)
plot(carrier)
xlabel('Carrier Signal')
subplot(3,1,3)
plot(outwave)
xlabel('Output Signal')

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                         %
% G Cuthbert (SID 420081629)                                              %
%                                                                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
