6.2.5 CMMakerFromFFTwithFlag

6.2.5.1 Module Overview

From the multi-channel complex spectrum that is output from the MultiFFT  node, generate the correlation matrix for a sound source when specified by the input flag.

6.2.5.2 Requested Files

None.

6.2.5.3 Usage

In what case is the node used?

The scenario for usage is same as CMMakerFromFFT  node; for details refer to the CMMakerFromFFT  node. The main difference is in the calculation of the correlation matrix. In the CMMakerFromFFT  node, the correlation matrix is updated at a fixed period (PERIOD), but in this node it is possible to generate a correlation matrix for a specified section according to the flag value obtained from the input terminal.

Typical Examples

Figure. 6.18 shows the usage example of CMMakerFromFFTwithFlag  node. The INPUT input terminal is connected to the complex spectrum of the input signal calculated from a MultiFFT  node. The type is Matrix<complex<float> >  type. ADDER_FLAG is int  type or bool  type of input, and controls the events related to the correlation matrix calculation. Event control details are given in the Module details section. This node calculates and outputs the correlation matrix between channels for each frequency bin from the complex spectrum of the input signal. The output type is Matrix<complex<float> >  type, but to handle a correlation matrix, convert the three dimensional complex array to a two dimensional complex array and then output.

\includegraphics[width=.8\textwidth ]{fig/modules/CMMakerFromFFTwithFlag}
Figure 6.18: Network Example using CMMakerFromFFTwithFlag 

6.2.5.4 I/O and property setting of the node

Table 6.19: Parameter list of CMMakerFromFFTwithFlag 

Parameter

Type

Default

Unit

Description

DURATION_TYPE

string 

FLAG_PERIOD

 

Flag-based or Frame-period-based generation

WINDOW

int 

50

 

Number of averaged frames for a CM

PERIOD

int 

50

 

Frame rate for renewing the correlation matrix

WINDOW_TYPE

string 

FUTURE

 

Frame selection to normalize CM

MAX_SUM_COUNT

int 

100

 

Maximum number of normalized frames of a CM

ENABLE_ACCUM

bool 

false

 

Enable averaging with past correlation matrix

ENABLE_DEBUG

bool 

false

 

ON/OFF of debugging information output

Input

INPUT

: Matrix<complex<float> >  type, the complex spectrum expression of an input signal with size $M \times ( NFFT / 2 + 1)$.

ADDER_FLAG

: int  type or bool  type. Controls the events related to correlation matrix calculation. Refer to the Module Description section for event control details.

Output

OUTPUT

: Matrix<complex<float> >  type. A correlation matrix for each frequency bin. An $M$-th order complex square array correlation matrix outputs $NFFT/2 + 1$ items. Matrix<complex<float> >  contains rows corresponding to frequency ($NFFT/2 + 1$ rows), and columns containing the complex correlation matrix ($M * M$ columns across).

OPERATION_FLAG

: bool  type. This outputs trueif the correlation matrix from OUTPUT is updated. Otherwise false. This port is invisible by the default. To visualize it, see Fig. 6.28 in LocalizeMUSIC .

Parameter

DURATION_TYPE

: string  type. Default value is FLAG_PERIOD. This changes the algorithm for renewing and averaging a correlation matrix. If DURATION_TYPE=FLAG_PERIOD, it renews/averages a correlation matrix based on the value of ADDER_FLAG. If DURATION_TYPE=FRAME_PERIOD, it renews/averages a correlation matrix based on a constant frame period. Refer to the Module Description section for event control details.

WINDOW

: int  type. Default value is 50. This parameter is active when DURATION_TYPE=FRAME_PERIOD. Specifies the number of average smoothed frames when calculating the correlation-matrix. The node generates a correlation matrix for each frame from the complex spectrum of the input signal and outputs a new correlation matrix by averaging the frames that are specified in WINDOW. The correlation matrix calculated at the end is output between the PERIOD frames. If this value is increased, the correlation matrix is stabilized but the calculation cost becomes high.

PERIOD

: int  type. Default value is 50. This parameter is active when DURATION_TYPE=FRAME_PERIOD. Specifies the frame rate for renewing the correlation-matrix. The node generates a correlation matrix for each frame from the complex spectrum of the input signal and outputs a new correlation matrix by averaging the frames that are specified in WINDOW. The correlation matrix calculated at the end is output between the PERIOD frames. If this value is increased, the time resolution of correlation matrix is improved but the calculation cost becomes high.

WINDOW_TYPE

: string  type. FUTURE is the default value. The selection of used smoothing frames for correlation matrix calculation. Let $f$ be the current frame. If FUTURE, frames from $f$ to $f+WINDOW-1$ will be used for the normalization. If MIDDLW, frames from $f-(WINDOW/2)$ to $f+(WINDOW/2)+(WINDOW\% 2)-1$ will be used for the normalization. If PAST, frames from $f-WINDOW+1$ to $f$ will be used for the normalization.

MAX_SUM_COUNT

: int  type. Default value is 100. This parameter is active when DURATION_TYPE=FLAG_PERIOD. Specifies the maximum number of average smoothed frames when calculating the correlation-matrix. This node can control the number of average smoothed frames of a correlation matrix by ADDER_FLAG. For this reason, if the ADDER_FLAG is always 1, only addition of correlation matrix is performed and there will be no output at all. Thus, when it reaches the maximum count of average smoothed frames by correctly setting the MAX_SUM_COUNT, the correlation matrix will be output forcefully. To turn OFF this feature specify MAX_SUM_COUNT = 0.

ENABLE_ACCUM

: bool  type. Default value is false. This parameter is active when DURATION_TYPE=FLAG_PERIOD. This enables averaging a corrlation matrix with current one and past one together.

ENABLE_DEBUG

: bool  type. Default value is false. When true, the frame number is output to the standard output at the time of generating the correlation matrix.

6.2.5.5 Module Description

The algorithm for the CMMakerFromFFT  node and correlation matrix calculation is the same. Refer to the Module description of the CMMakerFromFFT  node for details. The difference with CMMakerFromFFT  node is that the average smoothed frames of a correlation matrix can be controlled with the ADDER_FLAG input terminal flag.

In the CMMakerFromFFT  node, the correlation matrix was computed with the following formula with the number of frames specified by PERIOD.

  \begin{equation} \label{eq:CMMakerFromFFTwithFlag_ Rn} {\boldsymbol R}’(\omega ,f) = \frac{1}{{\rm PERIOD}}\sum _{i=W_ i}^{W_ f}{\boldsymbol R}(\omega ,f+i) \end{equation}   (4)

where the frames used for the averaging can be changed by WINDOW_TYPE. If WINDOW_TYPE=FUTURE, $W_ i = 0$ and $W_ f = {\rm WINDOW}-1$. If WINDOW_TYPE=MIDDLE, $W_ i = {\rm WINDOW}/2$ and $W_ f = {\rm WINDOW}/2+{\rm WINDOW}\% 2-1$. If WINDOW_TYPE=PAST, $W_ i = -{\rm WINDOW}+1$ and $W_ f = 0$.

When DURATION_TYPE=FLAG_PERIOD, this node generates a correlation matrix based on the value of the ADDER_FLAG as follows.

Here, ${\boldsymbol R}_{out}(\omega ,f)$ is the correlation matrix that is output from the OUTPUT terminal. In other words, the new correlation matrix will be stored in ${\boldsymbol R}_{out}(\omega ,f)$ in phase C).

When DURATION_TYPE=FRAME_PERIOD, this node renews the correlation matrix only when ADDER_FLAG is 1 (or true) based on eq. ().