Programmer Guide/Command Reference/EVAL/hz2cent: Difference between revisions

From STX Wiki
Jump to navigationJump to search
(initial import)
 
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:hz2cent, cent2hz}}
=====hz2cent=====
Convert the elements of ''x'' from Hertz to Cent and vice versa.
;Usage: <code>hz2cent(<var>x</var> {, <var>ref</var> {, <var>ofs</var>}})</code>
:<code>log2lin(<var>x</var> {, <var>ref</var> {, <var>ofs</var>}})</code>
:;<var>x</var>: a scalar, vector or matrix
:;<var>ref</var>: the reference frequency in Hz; must be a positive number (default=440)
:;<var>fac</var>: a shift value in Cent; must be a number (default=0)
;Result: The result ''r'' has the same type as ''x'' and contains the converted elements of ''x''. The following conversion algorithms are used:
::*'''hz2cent''': ''r''<sub>i,j</sub> = 1200 * log<sub>2</sub>(''x''<sub>i,j</sub> / ''ref'') + ''ofs''
''fac'' * log<sub>10</sub>(''x''<sub>i,j</sub> / ''ref'')
::*'''cent2hz''': ''r''<sub>i,j</sub> = ''ref'' * 2 ^ ((''x''<sub>i,j</sub> - ''ofs'') / 1200)
;See also: [[../hz2mel|hz2mel, mel2hz]], [[../hz2erb|hz2erb, erb2hz]], [[../hz2bark|hz2bark, bark2hz]], [[../hth|hth]], [[../log2lin|lin2log, log2lin]]


Hertz to Cent conversion where <var>x</var> -> 1200 * log2(<var>x</var> / <var>ref</var>) + <var>ofs</var>
[[../#Functions|<function list>]]


=====Usage:=====


<code>hz2cent(<var>x</var>, <var>ref</var>, <var>ofs</var>)</code>
Example:
 
<pre>
=====Parameters:=====
#hz  := eval vv(100, 200, 440, 880)
 
#cent1 := eval hz2cent($#hz)
;<var>ofs</var>
#cent2 := eval 1200 * ld($#hz / 440) // this is a the same as #cent1
 
</pre>
:The default is <code>0</code>.
 
;<var>ref</var>
 
:The default is <code>440</code>.

Latest revision as of 11:54, 21 April 2011

Convert the elements of x from Hertz to Cent and vice versa.

Usage
hz2cent(x {, ref {, ofs}})
log2lin(x {, ref {, ofs}})
x
a scalar, vector or matrix
ref
the reference frequency in Hz; must be a positive number (default=440)
fac
a shift value in Cent; must be a number (default=0)
Result
The result r has the same type as x and contains the converted elements of x. The following conversion algorithms are used:
  • hz2cent: ri,j = 1200 * log2(xi,j / ref) + ofs

fac * log10(xi,j / ref)

  • cent2hz: ri,j = ref * 2 ^ ((xi,j - ofs) / 1200)
See also
hz2mel, mel2hz, hz2erb, erb2hz, hz2bark, bark2hz, hth, lin2log, log2lin

<function list>


Example:

#hz  := eval vv(100, 200, 440, 880)
#cent1 := eval hz2cent($#hz)
#cent2 := eval 1200 * ld($#hz / 440) // this is a the same as #cent1

Navigation menu

Personal tools