Batuhan88
Newbie level 2
Hello I found a Matlab code here and modified it a bit.
It simply takes three signals with different frequencies (nots C G and E) and inputs these three signals into one signal at a 4th frequency.
If i didn't get it wrong, this code envelopes f1 f2 f3 signals (that are C G & E notes respectively) at a frequency of 440 Hz which is the A note.
So what's that i am hearing? A note? C major chord? anything like that?
Also, fs value can't take anything lower than around 1000 Hz. Why is that?
It simply takes three signals with different frequencies (nots C G and E) and inputs these three signals into one signal at a 4th frequency.
Code:
%% configure signal settings
duration = 3; % duration in seconds
amplitude = 0.8; % amplitude
f1 = 523; % frequency in Hertz
f2 = 659;
f3 = 783;
phi = 2*pi*0.5; % phase offset, e.g.: 2*pi*0.25 = 1/4 cycle
%% configure output settings
fs = 1760; % sampling rate
T = 1/fs; % sampling period
t = 0:T:duration; % time vector
%% create the signal
omega1 = 2*pi*f1; % angular frequency in radians
omega2 = 2*pi*f2;
omega3 = 2*pi*f3;
partial1 = cos(omega1*t + phi)*amplitude; % sinusoidal partial 1
partial2 = cos(omega2*t + phi)*amplitude; % sinusoidal partial 2
partial3 = cos(omega3*t + phi)*amplitude; % sinusoidal partial 3
signal = (partial1 + partial2 + partial3)/3;
%signal = (partial1 );
%% plot the signal
plot(t, signal);
xlabel('Time (seconds)');
ylabel('Amplitude');
title('Complex Signal');
%% play the signal
sound(signal, fs);
%% save signal as stereo wave file
stereo_signal = [x1; x1]';
wavwrite(stereo_signal, fs, 'test.wav');
If i didn't get it wrong, this code envelopes f1 f2 f3 signals (that are C G & E notes respectively) at a frequency of 440 Hz which is the A note.
So what's that i am hearing? A note? C major chord? anything like that?
Also, fs value can't take anything lower than around 1000 Hz. Why is that?
Last edited by a moderator: