Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What's This Sound Musically? (Included Matlab, Requires Musical Knowledge)

Status
Not open for further replies.

Batuhan88

Newbie level 2
Joined
May 5, 2015
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
20
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.

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:

fs = 1760; % sampling rate

You may hear musical tones at this low a sample rate. However sample rates for audio are normally much greater than this. I heard the figure 8kHz for video streaming. CD quality is 44.1 kHz.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top