tomwalters@0
|
1 % support file for 'aim-mat'
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % This external file is included as part of the 'aim-mat' distribution package
|
bleeck@3
|
4 % (c) 2011, University of Southampton
|
bleeck@3
|
5 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
6 % download of current version is on the soundsoftware site:
|
bleeck@3
|
7 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
8 % documentation and everything is on http://www.acousticscale.org
|
tomwalters@0
|
9
|
tomwalters@0
|
10 function [fre,oct,nr_note]=note2fre(note)
|
tomwalters@0
|
11
|
tomwalters@0
|
12 % translates the note to the frequency
|
tomwalters@0
|
13
|
tomwalters@0
|
14 note_names=['A ';'B ';'C ';'C#';'D ';'D#';'E ';'F ';'F#';'G ';'G#';'H '];
|
tomwalters@0
|
15 lowest_note=27.5; % Hz =A1 440 Hz= a5
|
tomwalters@0
|
16
|
tomwalters@0
|
17
|
tomwalters@0
|
18 rnote=note(1);
|
tomwalters@0
|
19 if strcmp(rnote(1),' ') || double(rnote(1))==9
|
tomwalters@0
|
20 note=note(2:end);
|
tomwalters@0
|
21 rnote=note(1);
|
tomwalters@0
|
22 end
|
tomwalters@0
|
23 if strcmp(note(2),'#')
|
tomwalters@0
|
24 rnote=[rnote '#'];
|
tomwalters@0
|
25 octnum=note(3);
|
tomwalters@0
|
26 elseif strcmp(note(2),'b')
|
tomwalters@0
|
27 rnote=[rnote 'b'];
|
tomwalters@0
|
28 octnum=note(3);
|
tomwalters@0
|
29 else
|
tomwalters@0
|
30 octnum=note(2);
|
tomwalters@0
|
31 end
|
tomwalters@0
|
32
|
tomwalters@0
|
33
|
tomwalters@0
|
34 % http://www.jita.com.cn/Seiten/Theorie/musik_theorie_1.htm
|
tomwalters@0
|
35 switch rnote
|
tomwalters@0
|
36 case {'A','a'}
|
tomwalters@0
|
37 nr_note=1;
|
tomwalters@0
|
38 case {'A#','a#','Bb','bb'}
|
tomwalters@0
|
39 nr_note=2;
|
tomwalters@0
|
40 case {'H','h','B','b'}
|
tomwalters@0
|
41 nr_note=3;
|
tomwalters@0
|
42 case {'C','c'}
|
tomwalters@0
|
43 nr_note=4;
|
tomwalters@0
|
44 case {'C#','c#','Db','db'}
|
tomwalters@0
|
45 nr_note=5;
|
tomwalters@0
|
46 case {'D','d'}
|
tomwalters@0
|
47 nr_note=6;
|
tomwalters@0
|
48 case {'D#','d#','Eb','eb'}
|
tomwalters@0
|
49 nr_note=7;
|
tomwalters@0
|
50 case {'E','e'}
|
tomwalters@0
|
51 nr_note=8;
|
tomwalters@0
|
52 case {'F','f'}
|
tomwalters@0
|
53 nr_note=9;
|
tomwalters@0
|
54 case {'F#','f#','Gb','gb'}
|
tomwalters@0
|
55 nr_note=10;
|
tomwalters@0
|
56 case {'G','g'}
|
tomwalters@0
|
57 nr_note=11;
|
tomwalters@0
|
58 case {'G#','g#','Ab','ab'}
|
tomwalters@0
|
59 nr_note=12;
|
tomwalters@0
|
60 otherwise
|
tomwalters@0
|
61 fre=0;
|
tomwalters@0
|
62 return
|
tomwalters@0
|
63 end
|
tomwalters@0
|
64
|
tomwalters@0
|
65 oct=str2num(octnum);
|
tomwalters@0
|
66
|
tomwalters@0
|
67 % compansate for that the octave changes at C
|
tomwalters@0
|
68 if nr_note > 3
|
tomwalters@0
|
69 calcoct=oct-1;
|
tomwalters@0
|
70 else
|
tomwalters@0
|
71 calcoct=oct;
|
tomwalters@0
|
72 end
|
tomwalters@0
|
73 gescent=calcoct*1200+100*(nr_note-1);
|
tomwalters@0
|
74 fre=cent2fre(lowest_note,gescent);
|
tomwalters@0
|
75
|
tomwalters@0
|
76
|