# A Neural Parametric Singing Synthesizer Modeling Timbre and Expression from Natural Songs +
## Appendix B Details Tuning Postprocessing  
The principal idea behind the tuning correction postprocessing is simple; apply the difference between the perceived pitch of a note, given its predicted F0 contour, and the pitch of the corresponding note in the score. However, robustly estimating the perceived pitch of a note from the corresponding F0 contour is nontrivial. In singing voice there are many factors that affect F0, but may not influence the perceived note pitch. These factors include vibratos, scoops, releases, transitions, microprosody due to consonants and so on. Therefore, simple estimators, such as directly taking the mean of the framewise F0 over the note duration, will typically yield poor results. To obtain a more robust estimate of the perceived note pitch, \(\overline{F0}\), we compute a weighted average of the predicted F0 over the note's duration,  
\[\overline{F0}=\frac{\sum_{i}F0_{i}w_{i}}{\sum_{i}w_{i}}\,, \tag{17}\]  
where \(F0_{i}\) and \(w_{i}\) correspond to the \(i\)-th frame within a given note of the predicted F0 vector and weighting vector respectively. To simplify notation, throughout this section \"F0\" refers to log F0 in semitones. The weighting vector in Equation (17) is composed of a number of different factors that correspond to different heuristics designed to make the estimate more robust,  
\[w=w_{e}w_{d}w_{p}w_{t}\,. \tag{18}\]  
The first of these factors, \(w_{e}\), is a weighting to reduce the influence of the edges of the note, where most of the transition effects will typically be located. We compute \(w_{e}\) as a Tukey window with \(\alpha=0.5\). That is, we apply a cosine-taper weighting along the first and last 25% of the note duration. The second factor, \(w_{d}\), is a weighting depending on the derivative of the F0 contour. The idea is that the portion of the note where F0 is mostly flat will contribute more to the perceived pitch than portions where F0 fluctuates due to transitions or microprosody. We first estimate the derivative by convolving the signal with a 3 rd order 1 st derivative Savitzky-Golay FIR filter, \(s_{d}\), with a length of 11 frames (55 milliseconds),  
\[dF0=F0\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,  
where the constants were obtained empirically. The third factor, \(w_{p}\), is a weighting depending on the phoneme corresponding to each frame \(p_{i}\),  
\[w_{p,i}= \begin{cases}2,&\text{for $p_{i}\in\{\text{{\em vowel},\text{{\em syllable}\text{\em consonant}}\}$}}\\ 0,&\text{for $p_{i}\in\{\text{{\em silence},\text{\em pause},\text{\em breath}}\}$}\\ 1,&\text{otherwise.}\end{cases}  \tag{10}\]  
The idea is that frames corresponding to vowels typically contribute more to the perceived pitch than consonants, which often contain microprosody effects. The last factor, \(w_{t}\), is a weighting depending on the distance from the target pitch, based on the assumption that detuning in the perceived pitch will typically be caused by relatively small deviations. Other factors, such as scoops or microprosody, may cause relatively big deviations, but these tend not to contribute to the perceived detuning. We use a pitch deviation of \(\pm 1\) semitone as a threshold,  
\[w_{t,i}= \begin{cases}1,&\text{for $|F0_{tar}-F0_{i}|\leq 1$}\\ 1/|F0_{tar}-F0_{i}|,&\text{otherwise.}\end{cases}  \tag{11}\]  
Finally, the required amount of pitch correction, \(cF0\), is computed for each frame in a note as follows,  
\[cF0_{i}=F0_{tar}-\overline{F0}\,, \tag{12}\]  
where \(F0_{tar}\) is the note's target pitch, as is written in the score. For rests, we do not apply any correction, \(cF0_{i}=0\). These framewise correction vectors are then concatenated for all notes and rests in the sequence. As the resulting vector may be discontinuous, we smooth it by zero-phase filtering with a Gaussian window with a length of 30 frames (150 milliseconds). As the above method computes a notewise correction, it is based on the assumption that the detuning will be approximately constant along a note.