# Closed-Loop Cognitive-Driven Gain Control of Competing Sounds Using Auditory Attention Decoding
## 2 Methods
### Correlation Coefficient Generation
The set of parameters to be estimated in this window is given by \(\mathbf{\Omega}=\big{\{}\mathbb{z}_{k^{*}-K_{P},k^{*}+K_{A}},\mathbb{\eta}_{k ^{*}-K_{P},k^{*}+K_{A}},\delta_{a},\mu_{a},\delta_{u},\mu_{a}\big{\}}\). The maximum a posteriori (MAP) estimate is obtained by maximizing the log-posterior function, i.e.,

\[\mathbf{\hat{\Omega}}=\underset{\mathbf{\Omega}}{\text{arg max }}\ell(\mathbf{\Omega}|\phi_{1,k},\phi_{2,k},k=k^{*}-K_{P}:k^{*}+K_{A}), \tag{42}\]

which can be computed iteratively using the Expectation Maximization (EM) algorithm as in Reference [9; 30]. Using the estimated variable \(\mathbb{z}_{k}\), the probability \(p_{k}=P(d_{k}=1)\) of attending to speaker 1 at time instance \(k\) is obtained using (34). These probabilities are segmented into non-overlapping windows of length \(K_{\text{NOL}}\), i.e.,

\[\mathbf{p}_{i}=\Big{[}p_{(i-1)K_{\text{NOL}}+1}\ p_{(i-1)K_{\text{NOL}}+2}\ \cdots\ p_{iK_{\text{NOL}}}\Big{]}^{T}, \tag{43}\]

and the probability of attending to speaker 1 in window \(i\) is then computed as the mean of the probabilities, i.e.,

\[z_{k}=c_{0}z_{k-1}+w_{k}. \tag{35}\]0

with \(\hat{d}_{i}\) the attention state in window \(i\). The probability of attending to speaker 2 in window \(i\) is computed as

\[z_{k}=c_{0}z_{k-1}+w_{k}. \tag{35}\]1

Based on these probabilities, it is decided that the participant attended to speaker 1 if \(P\Big{(}\hat{d}_{i}=1\Big{)}>P\Big{(}\hat{d}_{i}=2\Big{)}\), or attended to speaker 2 otherwise. The probabilistic attention measure of the attended speaker \(\hat{p}_{a,i}\) in window \(i\) is, hence, determined as

\[ \begin{cases}\hat{p}_{a,i}=P\Big{(}\hat{d}_{i}=1\Big{)},&\text{if }P\Big{(}\hat{d}_{i}=1 \Big{)}>P\Big{(}\hat{d}_{i}=2\Big{)}\\ \hat{p}_{a,i}=P\Big{(}\hat{d}_{i}=2\Big{)},&\text{otherwise}.\end{cases}  \tag{46}\]

The probabilistic attention measure of the unattended speaker \(\hat{p}_{a,i}\) is determined as \(\hat{p}_{u,i}=1-\hat{p}_{a,i}\). The process flow of AAD using the SSM is depicted in Figure 4.

The AAD algorithm using the SSM was implemented and run using MATLAB (MATLAB 1 of RAAD in Figure 2). The hyperparameters in (35) and (37) were set to \(c_{0}=1\), \(a_{0}=2.008\) and \(b_{0}=0.2016\), similarly as in Reference [9]. The hyperparameters \(\bar{\gamma}_{a}\), \(\bar{v}_{a}\) and \(\bar{\mu}_{a}\) in (39) were set by fitting a gamma and a normal distribution to the absolute values of the correlation coefficients of the (oracle) attended speaker obtained from the calibration phase. Similarly, the hyperparameters \(\bar{\gamma}_{u}\), \(\bar{v}_{u}\), and \(\bar{\mu}_{u}\) in (41) were set by fitting a gamma and a normal distribution to the absolute values of the correlation coefficients of the (oracle) unattended speaker obtained from the calibration phase. The SSM parameter set \(\mathbf{\Omega}\) was estimated using the EM algorithm as in Reference [9] with 20 iterations. On the one hand, for the LW-SSM algorithm using a large overlapping correlation window (i.e., \(K_{\text{COR}}=960\) samples, 1 sample shift), a small SSM window of length \(K_{\text{SSM}}=1\) sample (corresponding to \(\frac{1}{64}\) s) with \(K_{P}=0\) and \(K_{A}=0\) was used. On the other hand, for the SW-SSM algorithm using a small non-overlapping correlation window (i.e., \(K_{\text{COR}}=16\) samples), a large SSM window of length \(K_{\text{SSM}}=60\) samples (corresponding to 15 s) with \(K_{P}=53\) (corresponding to 13.25 s) and \(K_{A}=6\) (corresponding to 1.50 s) was used as in Reference [9]. The length of the window \(K_{\text{NOL}}\) in (43) was set such that both algorithms generated the probabilistic attention measure of the attended speaker \(\hat{p}_{a,i}\) in (46) every 0.25 s. This means that for the LW-SSM algorithm a window of length \(K_{\text{NOL}}=16\) samples was used, while, for the SW-SSM algorithm, a window of length \(K_{\text{NOL}}=1\) sample was used. Each participant's own data were used for hyperparameter and parameter setting, as well as for decoding.