Home > voicebox > cent2frq.m

cent2frq

PURPOSE ^

FRQ2ERB Convert Hertz to Cents frequency scale [C,CR]=(FRQ)

SYNOPSIS ^

function [frq,cr] = cent2frq(c)

DESCRIPTION ^

FRQ2ERB  Convert Hertz to Cents frequency scale [C,CR]=(FRQ)
    frq = frq2mel(c) converts a vector of frequencies in cents
    to the corresponding values in Hertz.
   100 cents corresponds to one semitone and 440Hz corresponds to 5700
   cents.
   The optional cr output gives the gradient in Hz/cent.

    The relationship between cents and frq is given by:

    c = 1200 * log2(f/(440*(2^((3/12)-5)))

    Reference:

     [1] Ellis, A.
         On the Musical Scales of Various Nations
         Journal of the Society of Arts, 1885, 485-527

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [frq,cr] = cent2frq(c)
0002 %FRQ2ERB  Convert Hertz to Cents frequency scale [C,CR]=(FRQ)
0003 %    frq = frq2mel(c) converts a vector of frequencies in cents
0004 %    to the corresponding values in Hertz.
0005 %   100 cents corresponds to one semitone and 440Hz corresponds to 5700
0006 %   cents.
0007 %   The optional cr output gives the gradient in Hz/cent.
0008 %
0009 %    The relationship between cents and frq is given by:
0010 %
0011 %    c = 1200 * log2(f/(440*(2^((3/12)-5)))
0012 %
0013 %    Reference:
0014 %
0015 %     [1] Ellis, A.
0016 %         On the Musical Scales of Various Nations
0017 %         Journal of the Society of Arts, 1885, 485-527
0018 
0019 %      Copyright (C) Mike Brookes 1998
0020 %      Version: $Id: cent2frq.m 3123 2013-06-19 19:03:53Z dmb $
0021 %
0022 %   VOICEBOX is a MATLAB toolbox for speech processing.
0023 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 %   This program is free software; you can redistribute it and/or modify
0027 %   it under the terms of the GNU General Public License as published by
0028 %   the Free Software Foundation; either version 2 of the License, or
0029 %   (at your option) any later version.
0030 %
0031 %   This program is distributed in the hope that it will be useful,
0032 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0034 %   GNU General Public License for more details.
0035 %
0036 %   You can obtain a copy of the GNU General Public License from
0037 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0038 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0040 persistent p q
0041 if isempty(p)
0042     p=1200/log(2);
0043     q=5700-p*log(440);
0044 end
0045 % c = 1200*sign(frq).*log2(frq/(440*2^((3/12)-5)));
0046 af=(exp((abs(c)-q)/p));
0047 frq=sign(c).*af;
0048 cr=af/p;
0049 if ~nargout
0050     plot(c,frq,'-x');
0051     ylabel(['Frequency (' yticksi 'Hz)']);
0052     xlabel(['Frequency (' xticksi 'Cents)']);
0053 end

Generated on Tue 10-Oct-2017 08:30:10 by m2html © 2003