# v_erb2frq

## PURPOSE

V_ERB2FRQ Convert ERB frequency scale to Hertz FRQ=(ERB)

## SYNOPSIS

function [frq,bnd] = v_erb2frq(erb)

## DESCRIPTION

    V_ERB2FRQ  Convert ERB frequency scale to Hertz FRQ=(ERB)
        frq = v_erb2frq(erb) converts a vector of ERB-rate values
        to the corresponding frequencies in Hz.
       [frq,bnd] =  v_erb2frq(erb) also calculates the ERB bandwidths

        Note that erb values will be clipped to 43.032 which corresponds to infinite frequency.
        The inverse function is v_frq2erb.

## CROSS-REFERENCE INFORMATION

This function calls:

- v_xticksi V_XTIXKSI labels the x-axis of a plot using SI multipliers S=(AH)
- v_yticksi V_YTIXKSI labels the y-axis of a plot using SI multipliers S=(AH)

This function is called by:

- v_filtbankm V_FILTBANKM determine matrix for a linear/mel/erb/bark-spaced v_filterbank [X,IL,IH]=(P,N,FS,FL,FH,W)
- v_gammabank V_GAMMABANK gammatone filter bank [b,a,fx,bx,gd]=(n,fs,w,fc,bw,ph,k)
- v_melbankm V_MELBANKM determine matrix for a mel/erb/bark-spaced filterbank [X,MN,MX]=(P,N,FS,FL,FH,W)
- v_spgrambw V_SPGRAMBW Draw spectrogram [T,F,B]=(s,fs,mode,bw,fmax,db,tinc,ann)

## SOURCE CODE

    0001 function [frq,bnd] = v_erb2frq(erb)
    0002 %V_ERB2FRQ  Convert ERB frequency scale to Hertz FRQ=(ERB)
    0003 %    frq = v_erb2frq(erb) converts a vector of ERB-rate values
    0004 %    to the corresponding frequencies in Hz.
    0005 %   [frq,bnd] =  v_erb2frq(erb) also calculates the ERB bandwidths
    0006 %
    0007 %    Note that erb values will be clipped to 43.032 which corresponds to infinite frequency.
    0008 %    The inverse function is v_frq2erb.
    0009
    0010 %   The erb scale is measured using the notched-noise method [3].
    0011 %
    0012 %    We have df/de = 6.23*f^2 + 93.39*f + 28.52
    0013 %    where the above expression gives the Equivalent Rectangular
    0014 %    Bandwidth (ERB)in Hz  of a human auditory filter with a centre
    0015 %    frequency of f kHz.
    0016 %
    0017 %    By integrating the reciprocal of the above expression, we
    0018 %    get:
    0019 %        e = k ln((f/p-1)/(f/q-1))/d
    0020 %
    0021 %    where p and q are the roots of the equation: -0.312 and -14.7
    0022 %      and d = (6.23*(p-q))/1000 = 0.08950404
    0023 %
    0024 %    from this we can derive:
    0025 %
    0026 %    f = k/(h-exp(d*e)) + c
    0027 %
    0028 %    where k = 1000 q (1 - q/p) = 676170.4
    0029 %          h = q/p = 47.06538
    0030 %          c = 1000q = -14678.49
    0031 %    and f is in Hz
    0032 %
    0033 % Note that the maximum permissible value of e is log(b)/c=43.032 since this gives f=inf
    0034 %
    0035 %    References:
    0036 %
    0037 %      [1] B.C.J.Moore & B.R.Glasberg "Suggested formula for
    0038 %          calculating auditory-filter bandwidth and excitation
    0039 %          patterns", J Acoust Soc America V74, pp 750-753, 1983
    0040 %      [2] O. Ghitza, "Auditory Models & Human Performance in Tasks
    0041 %          related to Speech Coding & Speech Recognition",
    0042 %          IEEE Trans on Speech & Audio Processing, Vol 2,
    0043 %          pp 115-132, Jan 1994
    0044 %     [3] R. D. Patterson. Auditory filter shapes derived with noise
    0045 %         stimuli. J. Acoust. Soc. Amer., 59: 640�654, 1976.
    0046 %
    0047
    0048 %      Copyright (C) Mike Brookes 1998
    0049 %      Version: $Id: v_erb2frq.m 10865 2018-09-21 17:22:45Z dmb $
    0050 %
    0051 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0052 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0053 %
    0054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0055 %   This program is free software; you can redistribute it and/or modify
    0056 %   it under the terms of the GNU Lesser General Public License as published by
    0057 %   the Free Software Foundation; either version 3 of the License, or
    0058 %   (at your option) any later version.
    0059 %
    0060 %   This program is distributed in the hope that it will be useful,
    0061 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0062 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0063 %   GNU Lesser General Public License for more details.
    0064 %
    0065 %   You can obtain a copy of the GNU Lesser General Public License from
    0066 %   https://www.gnu.org/licenses/ .
    0067 %
    0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0070 persistent u h k c d
    0071 if ~numel(u)
    0072     u=[6.23e-6 93.39e-3 28.52];
    0073     p=sort(roots(u));           % p=[-14678.5 -311.9]
    0074     d=1e-6*(6.23*(p(2)-p(1)));  % d=0.0895
    0075     c=p(1);                     % c=-14678.5
    0076     k = p(1) - p(1)^2/p(2);     % k=676170.4
    0077     h=p(1)/p(2);                % h=47.06538
    0078 end
    0079 frq = sign(erb).*(k./max(h-exp(d*abs(erb)),0)+c);
    0080 bnd=polyval(u,abs(frq));
    0081 if ~nargout
    0082     plot(erb,frq,'-x');
    0083     xlabel(['Frequency (' v_xticksi 'Erb-rate)']);
    0084     ylabel(['Frequency (' v_yticksi 'Hz)']);
    0085 end