Beruflich Dokumente
Kultur Dokumente
School of Engineering
Spring 2015
Sophocles J. Orfanidis
ECE Department
orfanidi@ece.rutgers.edu
Example: Octave Frequency Scales
• Tasks:
• generate and print the major notes (do, re, mi, fa, sol, la, si, do) of
the middle (4th) octave, and play them forward & backward on the
PC’s soundcard (need earphones in the DSV lab)
1 2 3 4 5 6 7
A0 A1 A2 A3 C A4 A5 A6 A7
27.5 Hz 55 Hz 110 Hz 220 Hz 440 Hz 880 Hz 1760 Hz 3520 Hz
20 21 22 23 24 25 26 27
octaves = log2 ( ) f
f0
.
f = f0 2
oc taves
You can also “publish” your programs directly to PDF or DOC formats.
key, k=0 key, k=87
1 2 3 4 5 6 7
A0 A1 A2 A3 C A4 A5 A6 A7
27.5 Hz 55 Hz 110 Hz 220 Hz 440 Hz 880 Hz 1760 Hz 3520 Hz
20 21 22 23 24 25 26 27
octaves = log2 ( ) f
f0 f = f0 . 2
octaves
5000
4000
3000
2000
1000
0
0 20 40 60 80 100
frequ encies on a pia no keyboa r d
3960 all 88 keys
3520 'A' k eys on ly
3080
2640
f (H z)
2200
1760
1320
880
440
0
0 12 24 36 48 60 72 84
k , pia no k ey
ka = 0:12:87; red color, open circles
fa = f(ka+1);
figure; plot(k,f, ka,fa,'ro'); plot fa vs. ka,
i.e., the ‘A’ keys
% ka = [0, 12, 24, 36, 48, 60, 72, 84]
% fa = [27.5, 55, 110, 220, 440, 880, 1760, 3520]
0 1 2 3 4 5 6 7 8 9 10 11 12
B C D E F G A B C D E F G A B C
A3 A4
middle C is 3/12 of an 220 Hz 440 Hz
octave above A3, or, middle C
9/12 octaves below A4 261.63 Hz
. 3/12 . -9/12
261.63 = 220 2 = 440 2
cell arrays
% formatted printing of frequencies and key names
% define cell arrays of key names to facilitate printing
keys = {'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#',...
'A', 'A#', 'B', 'C'};
empty string