Functions
Real-Time Phase Gradient Heap Integration

Functions

double phaseret_firwin2gamma (LTFAT_FIRWIN win, ltfat_int gl)
 
int rtpghi_init (double gamma, ltfat_int W, ltfat_int a, ltfat_int M, double tol, int do_causal, rtpghi_state **p)
 
int rtpghi_reset (rtpghi_state *p)
 
int rtpghi_set_causal (rtpghi_state *p, int do_causal)
 
int rtpghi_execute (rtpghi_state *p, const LTFAT_REAL s[], LTFAT_COMPLEX c[])
 
int rtpghi_done (rtpghi_state **p)
 
int rtpghioffline (const LTFAT_REAL s[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, double tol, int do_causal, LTFAT_COMPLEX c[])
 

Detailed Description

Algorithm Description

The implementation follows paper [6]

The gamma parameter for a window \( g\) can be computed as

\[ \gamma = C_g (\mathit{gl})^2 \]

where gl is a window length.

FIR window \( C_g \)
LTFAT_HANN, LTFAT_HANNING, NUTTALL10 0.25645
LTFAT_SQRTHANN, LTFAT_COSINE, LTFAT_SINE 0.41532
LTFAT_HAMMING 0.29794
LTFAT_NUTTALL01 0.29610
LTFAT_TRIA, LTFAT_TRIANGULAR, LTFAT_BARTLETT 0.27561
LTFAT_SQRTTRIA 0.48068
LTFAT_BLACKMAN 0.17954
LTFAT_BLACKMAN2 0.18465
LTFAT_NUTTALL, LTFAT_NUTTALL12 0.12807
LTFAT_OGG, LTFAT_ITERSINE 0.35744
LTFAT_NUTTALL20 0.14315
LTFAT_NUTTALL11 0.17001
LTFAT_NUTTALL02 0.18284
LTFAT_NUTTALL30 0.09895
LTFAT_NUTTALL21 0.11636
LTFAT_NUTTALL03 0.13369

For for a Gaussian window please see [6]

The Gaussian window will give the best result. LTFAT_BLACKMAN is also a good choice.

Function Documentation

double phaseret_firwin2gamma ( LTFAT_FIRWIN  win,
ltfat_int  gl 
)

Computes gamma parameter given window type and its length

Parameters
[in]winLTFAT Gabor window
[in]gtWindow length
Returns
gamma or NAN if win was not recognized
int rtpghi_done ( rtpghi_state **  p)

Destroy a RTPGHI Plan.

Parameters
[in]pRTPGHI Plan

Versions

phaseret_rtpghi_done_d(phaseret_rtpghi_state_d** p);

phaseret_rtpghi_done_s(phaseret_rtpghi_state_s** p);

int rtpghi_execute ( rtpghi_state *  p,
const LTFAT_REAL  s[],
LTFAT_COMPLEX  c[] 
)

Execute RTPGHI plan for a single frame

The function is intedned to be called for consecutive stream of frames as it reuses some data from the previous frames stored in the plan.

if do_causal is enebled, c is not lagging, else c is lagging by one frame.

Parameters
[in]pRTPGHI plan
[in]sTarget magnitude
[out]cReconstructed coefficients

Versions

phaseret_rtpghi_execute_d(phaseret_rtpghi_state_d* p, const double s[], ltfat_complex_d c[]);

phaseret_rtpghi_execute_s(phaseret_rtpghi_state_s* p, const float s[], ltfat_complex_s c[]);

int rtpghi_init ( double  gamma,
ltfat_int  W,
ltfat_int  a,
ltfat_int  M,
double  tol,
int  do_causal,
rtpghi_state **  p 
)

Create a RTPGHI state.

Parameters
[in]gammaWindow-specific constant Cg*gl^2
[in]WNumber of channels
[in]aHop size
[in]MNumber of frequency channels (FFT length)
[in]tolRelative coefficient tolerance.
[in]do_causalZero delay (1) or 1 frame delay (0) version of the alg.
[out]pRTPGHI state

Versions

phaseret_rtpghi_init_d(double gamma, ltfat_int W, ltfat_int a, ltfat_int M, double tol, int do_causal, phaseret_rtpghi_state_d** p);

phaseret_rtpghi_init_s(double gamma, ltfat_int W, ltfat_int a, ltfat_int M, double tol, int do_causal, phaseret_rtpghi_state_s** p);

Returns
See also
phaseret_firwin2gamma
int rtpghi_reset ( rtpghi_state *  p)

Reset RTPGHI state.

Resets RTPGHI state struct to the initial state

Parameters
[out]pRTPGHI state

Versions

phaseret_rtpghi_reset_d(phaseret_rtpghi_state_d* p);

phaseret_rtpghi_reset_s(phaseret_rtpghi_state_s* p);

Returns
int rtpghi_set_causal ( rtpghi_state *  p,
int  do_causal 
)

Change the version of the algorithm

Either to one-frame-delay version (do_causal==0) or to the no-delay version (do_causal anything else).

Note
This is not thread safe
Parameters
[in]pRTPGHI plan
[in]do_causalCausal flag

Versions

phaseret_rtpghi_set_causal_d(phaseret_rtpghi_state_d* p, int do_causal);

phaseret_rtpghi_set_causal_s(phaseret_rtpghi_state_s* p, int do_causal);

Returns
Status code
int rtpghioffline ( const LTFAT_REAL  s[],
double  gamma,
ltfat_int  L,
ltfat_int  W,
ltfat_int  a,
ltfat_int  M,
double  tol,
int  do_causal,
LTFAT_COMPLEX  c[] 
)

Do RTPGHI for a complete magnitude spectrogram and compensate delay

This function just creates a plan, executes it for each col in s and c and destroys it.

Parameters
[in]sMagnitude spectrogram M2 x N array
[in]gammaWindow-specific constant Cg*gl^2
[in]LTransform length (possibly zero-padded).
[in]WNumber of signal channels.
[in]aHop size
[in]MFFT length, also length of all the windows
[out]cReconstructed coefficients M2 x N array

Versions

phaseret_rtpghioffline_d(const double s[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, double tol, int do_causal, ltfat_complex_d c[]);

phaseret_rtpghioffline_s(const float s[], double gamma, ltfat_int L, ltfat_int W, ltfat_int a, ltfat_int M, double tol, int do_causal, ltfat_complex_s c[]);

See also
phaseret_firwin2gamma ltfat_dgtreal_phaseunlock