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

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
Convert phase spectrum.
Convert phase spectrum.
 
;Usage:<code>cvphase(<var>p</var>, <var>ifmt</var>,  <var>ipos</var>, <var>ibin</var>, <var>ofmt</var>, <var>opos</var>, <var>obin</var>, <var>nbin</var>,  <var>rev</var>, <var>sr</var>, <var>len</var>,  <var>hop</var>)</code>
;Usage:<code>cvphase(<var>p</var>, <var>ifmt</var>,  <var>ipos</var>, <var>ibin</var>, <var>ofmt</var>, <var>opos</var>, <var>obin</var>, <var>nbin</var>,  <var>orev</var>, <var>sr</var>, <var>len</var>,  <var>hop</var>)</code>
:;<var>p</var>: original phase spectrum at frame ''ipos'' and in the format ''ifmt''; ''p'' is a vector with ''n'' values
:<var>p</var>: original phase spectrum at frame ''ipos'' and in the format ''ifmt''; ''p'' is a vector with ''n'' values
:;<var>ifmt, ofmt</var>: input and output phase format ('''1''' = locked phase, '''2''' = normal phase (not locked))
:<var>ifmt, ofmt</var>: input and output phase format
:;<var>ipos, opos</var>: input and output frame index
::*'''0''' = differences
:;<var>ibin, obin</var>: input and output spectral bin
::*'''1''' = locked phase
:;<var>nbin</var>: number of spectral bins to convert
::*'''2''' = unlocked phase
:;<var>rev</var>:reverse output phase (0=no, 1=yes)
:<var>ipos, opos</var>: input and output frame index
:;<var>sr</var>:signal sampling rate in Hz; this argument is currently not used but must be supplied!
:<var>ibin, obin</var>: input and output spectral bin
:;<var>len, hop</var>:transformation length and hopsize (in samples) used for analysis and resynthesis
:<var>nbin</var>: number of spectral bins to convert
;Description: This function replaces the following macro code
:<var>rev</var>:reverse output phase (0=no, 1=yes)
<pre>
:<var>sr</var>:signal sampling rate
    [macro cvphase arg: #p #ifmt #ipos #ibin #ofmt #opos #obin #nbin #rev #sr #len #hop]
:<var>len</var>:transformation length (in samples) used for analysis and resynthesis
    #dp  := eval 2 * pi * $#hop / $#len
:<var>len</var>:hopsize (in samples) used for analysis and resynthesis
    #idt := eval $#ifmt == 2 ? 0 : $#dp * $#ipos
;Description:
    #odt := eval $#ofmt == 2 ? 0 : $#dp * $#opos
;Result:A vector ''r'' with ''nbin'' values, containing the converted phase values.
    #r := eval init($#nbin,1,0)
 
    for #i := 0 to $#i < $#nbin step #i := int $#i+1
        #z := eval ($#p[$#i] + pi + ($#i+$#ibin)*$#idt) % (2*pi)
        if $#rev == 1 #z := eval -$#z
        $#r[$#i] := eval ($#z - ($#i+$#obin)*$#odt) % (2*pi) - pi
    end
    exit 1 set $#r
</pre>
;Result:A vector ''r'' with ''nbin'' values, containing the converted phase values.  
:Note: The input and output phase values are in the range <code>-pi..pi</code>.
;See also: [[../hcomb|hcomb]], [[../optmm|optmm]], [[Programmer_Guide/BScript#MulAc|script application '''MulAc''']]
;See also: [[../hcomb|hcomb]], [[../optmm|optmm]], [[Programmer_Guide/BScript#MulAc|script application '''MulAc''']]


[[../#Functions|<function list>]]
[[../#Functions|<function list>]]

Latest revision as of 11:30, 21 April 2011

Convert phase spectrum.

Usage
cvphase(p, ifmt, ipos, ibin, ofmt, opos, obin, nbin, rev, sr, len, hop)
p
original phase spectrum at frame ipos and in the format ifmt; p is a vector with n values
ifmt, ofmt
input and output phase format (1 = locked phase, 2 = normal phase (not locked))
ipos, opos
input and output frame index
ibin, obin
input and output spectral bin
nbin
number of spectral bins to convert
rev
reverse output phase (0=no, 1=yes)
sr
signal sampling rate in Hz; this argument is currently not used but must be supplied!
len, hop
transformation length and hopsize (in samples) used for analysis and resynthesis
Description
This function replaces the following macro code
    [macro cvphase arg: #p #ifmt #ipos #ibin #ofmt #opos #obin #nbin #rev #sr #len #hop]
    #dp  := eval 2 * pi * $#hop / $#len
    #idt := eval $#ifmt == 2 ? 0 : $#dp * $#ipos
    #odt := eval $#ofmt == 2 ? 0 : $#dp * $#opos
    #r := eval init($#nbin,1,0)
    for #i := 0 to $#i < $#nbin step #i := int $#i+1
        #z := eval ($#p[$#i] + pi + ($#i+$#ibin)*$#idt) % (2*pi)
        if $#rev == 1 #z := eval -$#z
        $#r[$#i] := eval ($#z - ($#i+$#obin)*$#odt) % (2*pi) - pi
    end
    exit 1 set $#r
Result
A vector r with nbin values, containing the converted phase values.
Note: The input and output phase values are in the range -pi..pi.
See also
hcomb, optmm, script application MulAc

<function list>

Navigation menu

Personal tools