28 Jan 2010
03 Feb 2010)
Collection of functions for working with musical notes, intervals, frequencies, and cents.
function T = freq2tone(f)
% MUSIC.FREQ2TONE converts a frequency to a musical semitone.
% T = MUSIC.FREQ2TONE(F) converts frequency F to the nearest
% T = music.freq2tone(220) % returns -3
% See also music.freq2note, music.freq2interval, music.tone2freq.
% Author: E. Johnson
% Copyright 2010 The MathWorks, Inc.
fC4 = 261.625565300599; % middle C (C4) is 261.63 Hz
T = 12 * log2(f./fC4);
T = round(T);