tomwalters@0: % support file for 'aim-mat' tomwalters@0: % tomwalters@0: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org tomwalters@0: tomwalters@0: function [fre,oct,nr_note]=note2fre(note) tomwalters@0: tomwalters@0: % translates the note to the frequency tomwalters@0: tomwalters@0: note_names=['A ';'B ';'C ';'C#';'D ';'D#';'E ';'F ';'F#';'G ';'G#';'H ']; tomwalters@0: lowest_note=27.5; % Hz =A1 440 Hz= a5 tomwalters@0: tomwalters@0: tomwalters@0: rnote=note(1); tomwalters@0: if strcmp(rnote(1),' ') || double(rnote(1))==9 tomwalters@0: note=note(2:end); tomwalters@0: rnote=note(1); tomwalters@0: end tomwalters@0: if strcmp(note(2),'#') tomwalters@0: rnote=[rnote '#']; tomwalters@0: octnum=note(3); tomwalters@0: elseif strcmp(note(2),'b') tomwalters@0: rnote=[rnote 'b']; tomwalters@0: octnum=note(3); tomwalters@0: else tomwalters@0: octnum=note(2); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % http://www.jita.com.cn/Seiten/Theorie/musik_theorie_1.htm tomwalters@0: switch rnote tomwalters@0: case {'A','a'} tomwalters@0: nr_note=1; tomwalters@0: case {'A#','a#','Bb','bb'} tomwalters@0: nr_note=2; tomwalters@0: case {'H','h','B','b'} tomwalters@0: nr_note=3; tomwalters@0: case {'C','c'} tomwalters@0: nr_note=4; tomwalters@0: case {'C#','c#','Db','db'} tomwalters@0: nr_note=5; tomwalters@0: case {'D','d'} tomwalters@0: nr_note=6; tomwalters@0: case {'D#','d#','Eb','eb'} tomwalters@0: nr_note=7; tomwalters@0: case {'E','e'} tomwalters@0: nr_note=8; tomwalters@0: case {'F','f'} tomwalters@0: nr_note=9; tomwalters@0: case {'F#','f#','Gb','gb'} tomwalters@0: nr_note=10; tomwalters@0: case {'G','g'} tomwalters@0: nr_note=11; tomwalters@0: case {'G#','g#','Ab','ab'} tomwalters@0: nr_note=12; tomwalters@0: otherwise tomwalters@0: fre=0; tomwalters@0: return tomwalters@0: end tomwalters@0: tomwalters@0: oct=str2num(octnum); tomwalters@0: tomwalters@0: % compansate for that the octave changes at C tomwalters@0: if nr_note > 3 tomwalters@0: calcoct=oct-1; tomwalters@0: else tomwalters@0: calcoct=oct; tomwalters@0: end tomwalters@0: gescent=calcoct*1200+100*(nr_note-1); tomwalters@0: fre=cent2fre(lowest_note,gescent); tomwalters@0: tomwalters@0: