function freq = note2f(note);

% convert note name to frequency according to mean scale
%    freq = note2f(note);
%       freq : frequency in Hz
%       note : note name (ex. 'eis3', 'a5')
%    ex.) note2f('a4') returns 440.00
%
%      see also f2note

if nargin < 1
  help note2f;
  return;
end

notename = ['ais'; 'b  '; 'c  '; 'cis'; 'd  '; 'dis'; 'e  '; 'f  '; 'fis'; 'g  '; 'gis'; 'a  '];

n = length(note);
for k=1:n
  if is_matlab
    cn = char(note(k));
  else
    cn = toascii(note(k));
  end
  if cn >= 48 & cn <= 57
    notec = str2num(note(k));
%    if k+1 <= n
%      if str2num(note(k+1))
%	error('note height must be less than 9');
%      end
%    end
    break;
  end
end

% k
% notec
if(k > 1)
  notechar = note(1:k-1);
else
  error('Invalid note name\n');
end
notei = -1;
for k=1:12
  if(notename(k,2) == ' ')
    if(strcmp(notename(k), notechar))
      notei = k-1;
      break;
    end
  else
    if(strcmp(notename(k,:), notechar))
      notei = k-1;
      break;
    end
  end
  if(strcmp(notename(k,:), notechar))
    notei = k-1;
    break;
  end
end

if(notei == -1)
	note
	error('Invalid note name. not match\n');
end

freq = 440*2^(((notec-4)*12+notei-11)/12);
