Mercurial > hg > aimmat
comparison aim-mat/tools/note2fre.m @ 0:74dedb26614d
Initial checkin of AIM-MAT version 1.5 (6.4.2011).
author | tomwalters |
---|---|
date | Fri, 20 May 2011 12:32:31 +0100 |
parents | |
children | 20ada0af3d7d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:74dedb26614d |
---|---|
1 % support file for 'aim-mat' | |
2 % | |
3 % This external file is included as part of the 'aim-mat' distribution package | |
4 % http://www.pdn.cam.ac.uk/cnbh/aim2006 | |
5 % $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $ | |
6 % $Revision: 585 $ | |
7 | |
8 function [fre,oct,nr_note]=note2fre(note) | |
9 | |
10 % translates the note to the frequency | |
11 | |
12 note_names=['A ';'B ';'C ';'C#';'D ';'D#';'E ';'F ';'F#';'G ';'G#';'H ']; | |
13 lowest_note=27.5; % Hz =A1 440 Hz= a5 | |
14 | |
15 | |
16 rnote=note(1); | |
17 if strcmp(rnote(1),' ') || double(rnote(1))==9 | |
18 note=note(2:end); | |
19 rnote=note(1); | |
20 end | |
21 if strcmp(note(2),'#') | |
22 rnote=[rnote '#']; | |
23 octnum=note(3); | |
24 elseif strcmp(note(2),'b') | |
25 rnote=[rnote 'b']; | |
26 octnum=note(3); | |
27 else | |
28 octnum=note(2); | |
29 end | |
30 | |
31 | |
32 % http://www.jita.com.cn/Seiten/Theorie/musik_theorie_1.htm | |
33 switch rnote | |
34 case {'A','a'} | |
35 nr_note=1; | |
36 case {'A#','a#','Bb','bb'} | |
37 nr_note=2; | |
38 case {'H','h','B','b'} | |
39 nr_note=3; | |
40 case {'C','c'} | |
41 nr_note=4; | |
42 case {'C#','c#','Db','db'} | |
43 nr_note=5; | |
44 case {'D','d'} | |
45 nr_note=6; | |
46 case {'D#','d#','Eb','eb'} | |
47 nr_note=7; | |
48 case {'E','e'} | |
49 nr_note=8; | |
50 case {'F','f'} | |
51 nr_note=9; | |
52 case {'F#','f#','Gb','gb'} | |
53 nr_note=10; | |
54 case {'G','g'} | |
55 nr_note=11; | |
56 case {'G#','g#','Ab','ab'} | |
57 nr_note=12; | |
58 otherwise | |
59 fre=0; | |
60 return | |
61 end | |
62 | |
63 oct=str2num(octnum); | |
64 | |
65 % compansate for that the octave changes at C | |
66 if nr_note > 3 | |
67 calcoct=oct-1; | |
68 else | |
69 calcoct=oct; | |
70 end | |
71 gescent=calcoct*1200+100*(nr_note-1); | |
72 fre=cent2fre(lowest_note,gescent); | |
73 | |
74 |