# Singing Transcription from Polyphonic Music Using Melody Contour Filtering
## 2 Melody Extraction
### Melody Contour Filtering
#### 2.5.2 Contour Filtering  
Energy characteristics in contours are regarded as the main feature in melody searching. In this section, the interfering contour are largely eliminated first; afterwards, the unique melody contour are determined within each minimum frame. Under the segmentation of \(\widehat{\varOmega}_{E}\) (which can be regarded as filtering all the peak points in the corresponding frame and temporarily identifying them as non-voice frames), we conduct edge searching on the graph again.  
We calculate the average energy \(\overline{E}_{l}\) of the peak point of the salience graph and calculate the average energy \(\overline{E}_{l}=E_{l}/len(l)\) of each contour. The contour energy \(\overline{E}_{l}<\overline{E}_{k}\) is filtered, and the remaining contours are shown in Figure 4. Next, we need to select the final contours with the most obvious features in each region from \(\widehat{\varOmega}_{E}\).  
Obviously, there are multiple contours between adjacent breakpoints (shown in Figure 4), including accompaniment contours, singing voice contours, and octave contours. We selected the range between two neighboring breakpoints in \(\widehat{\varOmega}_{E}\) to facilitate the comparison of the same melody contours and ensure the fundamental frequency of the human voice. In the previous construction of a salience function, we included the downward superposition of high-order harmonics, which increases the energy of the fundamental frequency with an abundant octave frequency to the maximum extent. Our proposed contour filtering algorithm is as follows:  
1. Compare the size of each contour \(E_{l}\) in the region \(\left(\widetilde{\varOmega}_{k},\ \widetilde{\varOmega}_{k+1}\right)\) to find the contour \(\widetilde{E}_{l}\) with the maximum energy (shown in Figure 5, the red lines);
2. Set the head and the tail from \(\widetilde{E}_{l}\) as \(i,j\) to filter the remaining peak points in the region \(\left(\widetilde{\varOmega}_{i},\ \widetilde{\varOmega}_{j}\right)\);
3. If either the head \(i\) or tail \(j\) end of their distance between the boundaries \(\left(\widetilde{\varOmega}_{k},\ \widetilde{\varOmega}_{k+1}\right)\) is greater than the note threshold \(\alpha\), contour filtering will be conducted on the region \(\left(\widetilde{\varOmega}_{k},\ \widetilde{\varOmega}_{i}\right)\vee\left( \widetilde{\varOmega}_{j},\ \widetilde{\varOmega}_{k+1}\right)\) to find the next largest contour \(\widetilde{E}_{lp}\).
4. Otherwise, the melody contour searching ends in this area and the method proceeds to the next region \(\left(\widetilde{\varOmega}_{k+1},\ \widetilde{\varOmega}_{k+2}\right)\).
5. Repeat the above steps until all searches for the entire map are completed.  
Figure 3: Sliding window filtering used for searching for the maximum energy difference to obtain breakpoints. The red box is our sliding window of 50 min length.  
In the above algorithm, the regions are calculated in sections, which are filtered according to the strength of the contour energy, and multiple non-overlapping contour searches are performed on the remaining regions to determine the unique singing melody. The preprocessing of the contour filters most of the interference information, and multiple edge searches do not degrade the performance of the program.