A method for extracting musical fundamental frequency based on multiple correlation calculation
Through multiple correlation calculations and pitch template matching, the problems of real-time pitch detection and bass frequency loss in the existing technology are solved, accurate fundamental frequency extraction of music with complex frequency components is achieved, and octave accuracy and signal characteristics are improved. appear.
Patent Information
- Application Number
- CN202110975783.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-24
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2041-08-24
AI Technical Summary
It is difficult to achieve real-time pitch detection with existing technology, especially in string music with complex frequency components. The frequency loss and octave problems in the bass area are difficult to solve, and the existing algorithm is difficult to transplant into real-time detection tasks.
Using the fundamental frequency extraction method of musical sounds based on multiple correlation calculations, the standard spectrogram is obtained through Fourier transform and preprocessing, and the pitch template is used to calculate the frequency and energy matching. Combined with the odd and even harmonic ratio, the pitch template and signal are judged matching degree to extract the fundamental frequency.
It achieves accurate fundamental frequency extraction of music with complex frequency components under real-time and non-real-time conditions, improves octave accuracy, is suitable for bass frequency extraction, reduces noise interference, and enhances the appearance of signal frequency characteristics.
Smart Images

Figure CN113782060B
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of audio signal processing, and in particular relates to a method for extracting musical sound fundamental frequencies based on multiple correlation calculations. Background Art
[0002] Fundamental frequency extraction is also known as pitch estimation and pitch detection. It is one of the key technologies for audio and music analysis tasks. The goal of musical frequency extraction is to output the pitch frequency value of the current frame signal in real time or non-real time when the input is a music audio signal. Musical frequency extraction has many application directions and important uses in the field of music analysis, and is also a prerequisite for many advanced audio analysis tasks, such as automatic music notation, melody recognition, content-based music retrieval, etc.
[0003] Prior art, such as the patent application CN2018103904699, provides a method for extracting the main melody of music. After performing a constant Q transformation on the signal, the method uses a particle filter method to determine the estimated sequence of pitches, and extracts the final pitch sequence components from the sequence. This method can improve the accuracy of pitch estimation, but because it needs to be optimized using dynamic programming, the algorithm is difficult to transplant to real-time pitch estimation tasks, and octave errors in the bass range are difficult to avoid.
[0004] Another prior art is the public document with patent application number CN2016800176646, which provides a method for determining the characteristics of harmonic signals, estimating the first pitch in an audio signal by calculating the signal frequency change rate, and determining the second pitch of the signal by correlation calculation. This solution requires collecting multiple frames of signals to calculate the signal change rate, and is difficult to apply to fundamental frequency extraction tasks with complex frequency components.
[0005] Therefore, in the prior art, most fundamental frequency extraction algorithms focus on non-real-time pitch detection, and most of them are based on Western musical instruments. On the one hand, due to the characteristics of the algorithm, non-real-time detection algorithms are difficult to directly transplant into real-time detection tasks; on the other hand, the octave problem and bass fundamental frequency loss problem in the pitch estimation task are difficult to be solved in a targeted manner. In addition, there are very few fundamental frequency extraction algorithms for string music with complex frequency components (especially string music represented by folk music). Therefore, for musical sound signals with complex frequency components, bass frequency loss, and octave aliasing, the present invention proposes a musical sound fundamental frequency extraction method that can be used for real-time and non-real-time multiple correlation calculations. Summary of the invention
[0006] The purpose of the present application is to provide a method for extracting musical fundamental frequencies based on multiple correlation calculations, which is suitable for real-time and non-real-time fundamental frequency extraction and has a high extraction accuracy.
[0007] In order to achieve the above purpose, the technical solution adopted by this application is:
[0008] A method for extracting fundamental frequency of musical sound based on multiple correlation calculation, the method for extracting fundamental frequency of musical sound based on multiple correlation calculation comprising:
[0009] Step 1: Perform Fourier transform on the audio frame acquired in real time to obtain the original spectrum;
[0010] Step 2: preprocessing the original spectrum to obtain a standard spectrum;
[0011] Step 3, obtaining a pitch template based on the standard data spectrum according to the inherent relationship between pitch and frequency;
[0012] Annotation 4: Obtain a low-dimensional spectrogram based on the standard spectrogram and the pitch template;
[0013] Step 5: Calculate the comprehensive matching degree between the low-dimensional spectrogram and the pitch template based on multiple correlations:
[0014] Step 51, calculating the comprehensive frequency matching degree between the low-dimensional spectrogram and the pitch template;
[0015] Step 52, calculating the energy matching degree vector between the low-dimensional spectrogram and the pitch template;
[0016] Step 53, calculating the frequency confidence vector between the low-dimensional spectrogram and the pitch template;
[0017] Step 54, calculating the odd-even harmonic ratio between the low-dimensional spectrogram and the pitch template;
[0018] Step 55: Obtain the comprehensive matching degree according to the calculated comprehensive frequency matching degree, energy matching degree vector, frequency confidence degree vector and odd-even harmonic ratio as follows:
[0019]
[0020] Where ξ is the comprehensive matching degree, β is the comprehensive frequency matching degree, λ is the odd-even harmonic ratio, η j is the jth element of the energy matching vector, θ j is the jth element of the frequency confidence vector, e jr is the energy value corresponding to the jth frequency point in the pitch template, and K is the number of frequency points in the pitch template;
[0021] Step 6: If the comprehensive matching degree ξ is greater than the threshold τ, it is determined that the low-dimensional spectrum diagram is consistent with the pitch template, and the fundamental frequency value corresponding to the pitch template is used as the fundamental frequency extracted for the audio frame acquired in real time; otherwise, return to step 3 to continue execution.
[0022] Several optional methods are also provided below, but they are not intended to be additional limitations on the above-mentioned overall solution, but are merely further supplements or preferences. Under the premise that there are no technical or logical contradictions, each optional method can be combined with the above-mentioned overall solution separately, and multiple optional methods can also be combined.
[0023] Preferably, the preprocessing of the original spectrum to obtain a standard spectrum comprises:
[0024] Step 21: Take the original spectrum F′={(f′ i ,e′ i )|i=1,2,...,N}∈R N , where N is the number of frequency points in the original spectrum, f′ i is the frequency of the i-th frequency point in the original spectrum, e′ i is the frequency f′ i The energy value at
[0025] Step 22: traverse the sequence F′ to mark the energy maximum points, set the energy values of the non-extreme points in the sequence and the energy maximum points whose energy values are lower than the energy threshold to zero, and after setting to zero, scale each energy value according to the total energy of 100 to obtain the maximum sequence F′ peak ;
[0026] Step 23: Calculate the mean sequence F′ based on the preset ideal template mean ;
[0027] Step 24: Take sequence F' peak , F′ peak / F′ mean , F′ peak / (F′ mean ) 2 The maximum energy value corresponding to the intermediate frequency point replaces the maximum value sequence F′ peak The energy value of the frequency point at the corresponding position in the , and the final maximum value sequence is obtained as the standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N , where f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at .
[0028] Preferably, the step of obtaining a low-dimensional spectrogram according to a standard spectrogram and a pitch template comprises:
[0029] Step 41: Obtain standard spectrum graph F peak ={(f i ,ei )|i=1,2,...,N}∈R N and Pitch Template F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N, where N is the number of frequency points in the standard spectrum diagram, f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at, K is the number of frequency points in the pitch template, f jr is the frequency of the jth frequency point in the pitch template, e jr is the frequency f jr The energy value at
[0030] Step 42, traverse the pitch template, for the frequency f in the pitch template jr If we can find the frequency f in the standard spectrum diagram i Satisfy f jr -ε r <f i <f jr +ε r , ε r is the preset condition parameter, then (f i ,e i ) is added to the sequence F as the jth element; if no frequency f that satisfies the condition can be found i , then add (0,0) as the jth element to the sequence F, and after the traversal is completed, the sequence F = {(f j ,e j )|j=1,2,...,K}∈R K As a low-dimensional spectrogram.
[0031] Preferably, the step of calculating the comprehensive frequency matching degree between the low-dimensional spectrum graph and the pitch template comprises:
[0032] Step 511, calculate the frequency matching degree as follows:
[0033]
[0034] In the formula, β fr is the frequency matching degree, F is the low-dimensional spectrum graph F = {(f j ,e j )|j=1,2,...,K}∈R K , where K is the number of frequency points in the low-dimensional spectrum graph, f j is the frequency of the jth frequency point in the low-dimensional spectrum, e j is the frequency f j The energy value atpeak The standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N , where N is the number of frequency points in the standard spectrum diagram, f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at
[0035] Step 512, calculate the odd-even octave matching degree as follows:
[0036] Take any odd or even octave template of the pitch template as in, is the frequency of the jth frequency point in the odd-even octave template, For frequency The energy value at is:
[0037]
[0038] In the formula, is the odd-even octave matching degree, ε r is the preset condition parameter, F r For the pitch template F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N, where f jr is the frequency of the jth frequency point in the pitch template, e jr is the frequency f jr The energy value at
[0039] Step 513, the comprehensive frequency matching degree between the low-dimensional spectrum graph and the pitch template is calculated according to the frequency matching degree and the odd-even octave matching degree as follows:
[0040]
[0041] In the formula, β is the comprehensive frequency matching degree, C fr is a constant, and α1 is the first adjustable parameter.
[0042] Preferably, calculating the energy matching vector between the low-dimensional spectrogram and the pitch template includes:
[0043]
[0044] Where η j is the jth element of the energy matching vector, and the energy matching vector is denoted as η={η1,η2,...,η K}∈RK , e j is the frequency f of the jth frequency point in the low-dimensional spectrum j The energy value at jr is the frequency f of the jth frequency point in the pitch template jr The energy value at , α2 is the second adjustable parameter, α3 is the third adjustable parameter, 1<α3<α2.
[0045] Preferably, the calculating of the frequency confidence vector between the low-dimensional spectrogram and the pitch template comprises:
[0046]
[0047] In the formula, θ j is the jth element of the frequency confidence vector, and the frequency confidence vector is θ=[θ1,θ2,...,θ k ]∈R K , e j-1 is the frequency f of the j-1th frequency point in the low-dimensional spectrum graph j-1 The energy value at j+1 is the frequency f of the j+1th frequency point in the low-dimensional spectrum graph j+1 The energy value at max is the maximum energy in the low-dimensional spectrum graph, α4 is the fourth adjustable parameter, α5 is the fifth adjustable parameter, α6 is the sixth adjustable parameter, and α7 is the seventh adjustable parameter.
[0048] Preferably, the calculating of the odd-even harmonic ratio between the low-dimensional spectrogram and the pitch template comprises:
[0049]
[0050] Where λ is the odd-even harmonic ratio, e j′ is the energy value of the even-numbered frequency in the low-dimensional spectrum, that is, j′ is the even-numbered item in j, e j″ is the energy value of the odd-numbered frequency in the low-dimensional spectrum, that is, j″ is the odd-numbered item in j, j = 1, 2, ..., K.
[0051] The method for extracting the fundamental frequency of musical sound based on multiple correlation calculation provided by the present application uses preprocessing to equalize frequency energy and reduce interference to purify the frequency components; then multiple correlation calculations in frequency and energy are performed with the constructed pitch template to determine whether the fundamental frequency of the measured signal is consistent with the expected fundamental frequency. This method can highlight the frequency characteristics of the signal, improve the octave accuracy, and is suitable for the fundamental frequency extraction task in the bass range with dense frequency intervals and more harmonic loss, and is more conducive to improving the accuracy of extracting the fundamental frequency of musical sound with complex frequency components. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1A flowchart of a method for extracting fundamental frequency of musical sound based on multiple correlation calculations of the present application;
[0053] Figure 2 For this application, the spectrum diagram before and after preprocessing is taken as an example of pitch F4;
[0054] Figure 3 This application takes pitch A3 as an example of the spectrum before and after preprocessing. DETAILED DESCRIPTION
[0055] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0057] In one of the embodiments, for a musical sound signal with complex frequency components, lost bass frequencies, and octave aliasing, this embodiment proposes a fundamental frequency extraction method that can be used for real-time or non-real-time multiple correlation calculations.
[0058] like Figure 1 As shown, the method for extracting musical tone fundamental frequency based on multiple correlation calculation of this embodiment includes:
[0059] Step 1: Perform Fourier transform on the audio frame acquired in real time to obtain the original spectrum.
[0060] The original spectrum (Spectrum) F′={(f′ i ,e′ i )|i=1,2,...,N}∈R N , that is, F′={(f′1,e′1),(f′2,e′2),...,(f′ N ,e′ N )}∈R N , where N is the number of frequency points in the original spectrum, f′ i is the frequency of the i-th frequency point in the original spectrum, e′ i is the frequency f′ i The energy value at .
[0061] Step 2: preprocess the original spectrum to obtain a standard spectrum.
[0062] This embodiment proposes a preprocessing method based on mean smoothing and normalization scaling, which uses energy screening to filter out noise on the one hand, and balances and normalizes the spectrum energy on the other hand, which can boost the frequency components with insignificant energy. Specifically, the following steps are included:
[0063] Step 21: Take the original spectrum F′={(f′ i ,e′ i )|i=1,2,...,N}∈R N , according to its data recording method, the original spectrum F′ can be regarded as a sequence F′.
[0064] Step 22: traverse the sequence F′ to mark the energy maximum points, set the energy values of the non-extreme points in the sequence and the energy maximum points whose energy values are lower than the energy threshold to zero, and after setting to zero, scale each energy value uniformly according to the total energy of 100 to obtain the maximum sequence F′ peak .
[0065] Step 23: Calculate the mean sequence F′ based on the preset ideal template mean The ideal template here is equivalent to the pitch template. Take multiple ideal templates, add the energy values of the frequency points at corresponding positions in the multiple ideal templates, and take the average value as the energy value in the mean sequence.
[0066] Step 24: Take sequence F' peak , F′ peak / F′ mean , F′ peak / (F′ mean ) 2 The maximum energy value corresponding to the intermediate frequency point replaces the maximum value sequence F′ peak The energy value of the frequency point at the corresponding position in the , and the final maximum value sequence is obtained as the standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N , where f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at .
[0067] like Figure 2 and Figure 3 As shown, Figure 2 , Figure 3The spectrograms of pitches F4 and A3 before and after preprocessing are shown respectively. The upper part is the original spectrogram before preprocessing, and the lower part is the standard spectrogram after preprocessing. It can be seen that through preprocessing, some noise interference with small energy is filtered out. And the spectrum energy is balanced. The frequency components with small energy in the original spectrum are raised (as shown in the dotted box).
[0068] Step 3: Obtain a pitch template based on the standard data spectrum according to the inherent relationship between pitch and frequency.
[0069] Find the fundamental frequency f according to the correspondence between the pitch template and the frequency 1r Up to k times frequency f kr . Pre-select the standard data spectrum of the template pitch, which has p segments, and calculate the frequency point f 1r ,f 2r ,...,f kr The average energy value at the point is normalized to obtain the energy value template e 1r ,e 2r ,...,e kr . The pitch template is F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N, that is, F r ={(f 1r ,e 1r ),(f 2r ,e 2r ),...,(f Kr ,e Kr )}∈R K , K is the number of frequency points in the pitch template, f jr is the frequency of the jth frequency point in the pitch template, e jr is the frequency f jr The energy value at .
[0070] Note 4: Obtain a low-dimensional spectrogram based on the standard spectrogram and the pitch template.
[0071] Step 41: Obtain standard spectrum graph F peak ={(f i ,e i )|i=1,2,...,N}∈R N and Pitch Template F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N.
[0072] Step 42, traverse the pitch template, for the frequency f in the pitch template jrIf we can find the frequency f in the standard spectrum diagram i Satisfy f jr -ε r <f i <f jr +ε r , ε r is the preset condition parameter, then (f i ,e i ) is added to the sequence F as the jth element; if no frequency f that satisfies the condition can be found i , then add (0,0) as the jth element to the sequence F, and after the traversal is completed, the sequence F = {(f j ,e j )|j=1,2,...,K}∈R K As a low-dimensional spectrogram.
[0073] Step 5: Calculate the comprehensive matching degree between the low-dimensional spectrogram and the pitch template based on multiple correlations.
[0074] Step 51: Calculate the comprehensive frequency matching degree between the low-dimensional spectrum graph and the pitch template.
[0075] This embodiment proposes a comprehensive frequency matching calculation method for calculating the frequency matching degree between the measured sequence (i.e., the low-dimensional spectrum) and the pitch template sequence. On the one hand, the frequency matching degree is used to determine the matching degree with the pitch template; on the other hand, the odd and even octave matching degree is calculated to improve the octave accuracy. The specific calculation steps are as follows:
[0076] Step 511, calculate the frequency matching degree as follows:
[0077]
[0078] In the formula, β fr is the frequency matching degree, F is the low-dimensional spectrum graph F = {(f j ,e j )|j=1,2,...,K}∈R K , where K is the number of frequency points in the low-dimensional spectrum graph, f j is the frequency of the jth frequency point in the low-dimensional spectrum, e j is the frequency f j The energy value at peak The standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N , where N is the number of frequency points in the standard spectrum diagram, f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency fi The energy value at .
[0079] Step 512, calculate the odd-even octave matching degree as follows:
[0080] One fundamental frequency corresponds to one pitch. If two fundamental frequencies are even multiples, then the two pitches are even octaves apart; if two fundamental frequencies are odd multiples, then the two pitches are odd octaves apart.
[0081] Take any odd or even octave template of the pitch template as in, is the frequency of the jth frequency point in the odd-even octave template, For frequency The energy value at .
[0082] The calculation method for odd-even octave matching is: the frequency difference between all the octave pitches in the tested sequence and the octave pitch is less than ε r , and the energy sum at the extreme point that does not belong to the ideal pitch frequency sequence, and all the frequencies in the measured sequence whose difference from the ideal frequency is less than or equal to ε r The ratio of the energy at the extreme point of and , that is:
[0083]
[0084] In the formula, is the odd-even octave matching degree, F r For the pitch template F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N, where f jr is the frequency of the jth frequency point in the pitch template, e jr is the frequency f jr The energy value at .
[0085] Step 513, the comprehensive frequency matching degree between the low-dimensional spectrum graph and the pitch template is calculated according to the frequency matching degree and the odd-even octave matching degree as follows:
[0086]
[0087] In the formula, β is the comprehensive frequency matching degree, C fr is a constant, α1 is the first adjustable parameter. The adjustable parameters in this embodiment are preset constants and can be adjusted according to actual needs. The "first", "second", etc., which are limited, are only used to distinguish the adjustable parameters taken under different calculations, and are not used as limitations on the values of the adjustable parameters themselves.
[0088] Step 52: Calculate the energy matching degree vector between the low-dimensional spectrogram and the pitch template.
[0089] This embodiment proposes an energy matching degree calculation method for calculating the energy matching degree between the sequence under test and the pitch template sequence. The calculated energy matching degree is used as the weight of each element of the sequence under test.
[0090]
[0091] Where η j is the jth element of the energy matching vector, and the energy matching vector is denoted as η={η1,η2,...,η K}∈R K , e j is the frequency f of the jth frequency point in the low-dimensional spectrum j The energy value at jr is the frequency f of the jth frequency point in the pitch template jr The energy value at , α2 is the second adjustable parameter, α3 is the third adjustable parameter, 1<α3<α2.
[0092] Step 53: Calculate the frequency confidence vector between the low-dimensional spectrogram and the pitch template.
[0093]
[0094] In the formula, θ j is the jth element of the frequency confidence vector, and the frequency confidence vector is θ=[θ1,θ2,...,θ k ]∈R K , e j-1 is the frequency f of the j-1th frequency point in the low-dimensional spectrum graph j-1 The energy value at j+1 is the frequency f of the j+1th frequency point in the low-dimensional spectrum graph j+1 The energy value at max is the maximum energy in the low-dimensional spectrum, α4 is the fourth adjustable parameter, α5 is the fifth adjustable parameter, α6 is the sixth adjustable parameter, α7 is the seventh adjustable parameter, and sgn(·) is the sign function. When j is 1, the corresponding e0 in the formula and when j is K, the corresponding e K+1 For the elements that do not exist in the low-dimensional spectrum graph, in this embodiment, the values of these two elements are set to 1.
[0095] Step 54: Calculate the odd-even harmonic ratio between the low-dimensional spectrum graph and the pitch template.
[0096] The odd-even harmonic ratio proposed in this embodiment is used to calculate the ratio of the energy sum of the odd-numbered harmonics to the energy sum of the even-numbered harmonics in the measured sequence. The more balanced the ratio is, the more similar the measured sequence is to the template pitch sequence.
[0097]
[0098] Where λ is the odd-even harmonic ratio, e j′ is the energy value of the even-numbered frequency in the low-dimensional spectrum, that is, j′ is the even-numbered item in j, e j″ is the energy value of the odd-numbered frequency in the low-dimensional spectrum, that is, j″ is the odd-numbered item in j, j = 1, 2, ..., K.
[0099] Step 55: Obtain the comprehensive matching degree according to the calculated comprehensive frequency matching degree, energy matching degree vector, frequency confidence degree vector and odd-even harmonic ratio as follows:
[0100]
[0101] Where ξ is the comprehensive matching degree, β is the comprehensive frequency matching degree, λ is the odd-even harmonic ratio, η j is the jth element of the energy matching vector, θ j is the jth element of the frequency confidence vector, e jr is the energy value corresponding to the jth frequency point in the pitch template, and K is the number of frequency points in the pitch template.
[0102] It should be noted that, in this embodiment, for example, N means the number of frequency points in the original spectrum diagram, or the number of frequency points in the standard spectrum diagram, etc. There is no contradiction here. It means that N itself is a quantifier, and the number of elements in the original spectrum diagram and the standard spectrum diagram is N, so N corresponds to different descriptions.
[0103] Step 6: If the comprehensive matching degree ξ is greater than the threshold τ, it is determined that the low-dimensional spectrum diagram is consistent with the pitch template, and the fundamental frequency value corresponding to the pitch template is used as the fundamental frequency extracted for the audio frame acquired in real time; otherwise, return to step 3 to continue execution.
[0104] The method for extracting the fundamental frequency of musical sound in this embodiment uses preprocessing to equalize frequency energy and reduce interference to purify the frequency components; then, multiple correlation calculations in frequency and energy are performed with the constructed pitch template to determine whether the fundamental frequency of the measured signal is consistent with the expected fundamental frequency. This method can highlight the frequency characteristics of the signal, improve the octave accuracy, and is suitable for the fundamental frequency extraction task in the bass range with dense frequency intervals and more harmonic loss, which is more conducive to improving the accuracy of extracting the fundamental frequency of musical sound with complex frequency components.
[0105] It should be noted that this embodiment uses real-time fundamental frequency extraction as an example for explanation. For non-real-time fundamental frequency extraction, it is only necessary to divide the entire song into frames, and the fundamental frequency extraction can be achieved based on the same steps. The extraction method of this embodiment is not only applicable to the fundamental frequency extraction of ordinary musical sound signals, but also has excellent extraction effects for musical sound signals with complex frequency components, bass frequency loss, and octave aliasing.
[0106] experiment:
[0107] In order to verify the effectiveness of the method for extracting the fundamental frequency of musical sound of this embodiment, taking the Guzheng music with relatively complex frequency components as an example, the experimental group is set to be the musical sound extraction method of this application, and the control group is set to be the existing NNLS method and PYIN method. The test results are as follows:
[0108] Table 1 Extraction results comparison table
[0109]
[0110] In Table 1, all the tracks are in the key of D, with a quarter note as one beat. "Looking for a Friend" is an introductory track for children, with a small number of notes, a small pitch range, and a uniform and slow rhythm. "A Moonlit Night on a Spring River" and "A Laugh in the Sea" are tracks for adults. Compared with introductory tracks for children, they have a large number of notes, a large pitch range, and different note durations.
[0111] The algorithms NNLS (non-negative least squares) and PYIN (probabilistic YIN) in the control group are relatively mature and widely used methods in the field of fundamental frequency extraction, and are quite representative algorithms in non-real-time fundamental frequency extraction. As can be seen from Table 1, in simple children's introductory repertoires, both the method of the present invention and the comparative method have shown extremely high accuracy rates; and in adult repertoires with relatively increased difficulty, the method of the present invention effectively improves the accuracy rate and reduces the false detection rate and missed detection rate.
[0112] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0113] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for extracting musical fundamental frequency based on multiple correlation calculation, characterized in that: The method for extracting musical tone fundamental frequency based on multiple correlation calculation comprises: Step 1: Perform Fourier transform on the audio frame acquired in real time to obtain the original spectrum; Step 2: preprocessing the original spectrum to obtain a standard spectrum; Step 3, obtaining a pitch template based on the standard data spectrum according to the inherent relationship between pitch and frequency; Annotation 4: Obtain a low-dimensional spectrogram based on the standard spectrogram and the pitch template; Step 5: Calculate the comprehensive matching degree between the low-dimensional spectrogram and the pitch template based on multiple correlations: Step 51, calculating the comprehensive frequency matching degree between the low-dimensional spectrogram and the pitch template; Step 52, calculating the energy matching degree vector between the low-dimensional spectrogram and the pitch template; Step 53, calculating the frequency confidence vector between the low-dimensional spectrogram and the pitch template; Step 54, calculating the odd-even harmonic ratio between the low-dimensional spectrogram and the pitch template; Step 55: The comprehensive matching degree is obtained according to the calculated comprehensive frequency matching degree, energy matching degree vector, frequency confidence degree vector and odd-even harmonic ratio as follows: Where ξ is the comprehensive matching degree, β is the comprehensive frequency matching degree, λ is the odd-even harmonic ratio, η j is the jth element of the energy matching vector, θ j is the jth element of the frequency confidence vector, e jr is the energy value corresponding to the jth frequency point in the pitch template, and K is the number of frequency points in the pitch template; Step 6: If the comprehensive matching degree ξ is greater than the threshold τ, it is determined that the low-dimensional spectrum diagram is consistent with the pitch template, and the fundamental frequency value corresponding to the pitch template is used as the fundamental frequency extracted for the audio frame acquired in real time; otherwise, return to step 3 to continue execution.
2. The method for extracting musical tone fundamental frequency based on multiple correlation calculation as claimed in claim 1, characterized in that: The preprocessing of the original spectrum to obtain a standard spectrum includes: Step 21, take the original spectrum F′={(f i ′,e′ i )|i=1,2,...,N}∈R N , where N is the number of frequency points in the original spectrum, f i ′ is the frequency of the i-th frequency point in the original spectrum, e′ i is the frequency f i Energy value at ′; Step 22: traverse the sequence F′ to mark the energy maximum points, set the energy values of the non-extreme points in the sequence and the energy maximum points whose energy values are lower than the energy threshold to zero, and after setting to zero, scale each energy value according to the total energy of 100 to obtain the maximum sequence F′ peak ; Step 23: Calculate the mean sequence F′ based on the preset ideal template mean ; Step 24: Take sequence F' peak , F′ peak / F′ mean , F′ peak / (F′ mean ) 2 The maximum energy value corresponding to the intermediate frequency point replaces the maximum value sequence F′ peak The energy value of the frequency point at the corresponding position in the , and the final maximum value sequence is obtained as the standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N , where f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at .
3. The method for extracting musical tone fundamental frequency based on multiple correlation calculation as claimed in claim 1, characterized in that: The step of obtaining a low-dimensional spectrogram according to the standard spectrogram and the pitch template includes: Step 41: Obtain standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N and Pitch Template F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N, where N is the number of frequency points in the standard spectrum diagram, f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at, K is the number of frequency points in the pitch template, f jr is the frequency of the jth frequency point in the pitch template, e jr is the frequency f jr The energy value at Step 42, traverse the pitch template, for the frequency f in the pitch template jr If we can find the frequency f in the standard spectrum diagram i Satisfy f jr -ε r <f i <f jr +ε r , ε r is the preset condition parameter, then (f i ,e i ) is added to the sequence F as the jth element; if no frequency f that satisfies the condition can be found i , then add (0,0) as the jth element to the sequence F, and after the traversal is completed, the sequence F = {(f j ,e j )|j=1,2,...,K}∈R K As a low-dimensional spectrogram.
4. The method for extracting musical tone fundamental frequency based on multiple correlation calculation as claimed in claim 1, characterized in that: The calculating of the comprehensive frequency matching degree between the low-dimensional spectrogram and the pitch template comprises: Step 511, calculate the frequency matching degree as follows: In the formula, β fr is the frequency matching degree, F is the low-dimensional spectrum graph F = {(f j ,e j )|j=1,2,...,K}∈R K , where K is the number of frequency points in the low-dimensional spectrum graph, f j is the frequency of the jth frequency point in the low-dimensional spectrum, e j is the frequency f j The energy value at peak The standard spectrum F peak ={(f i ,e i )|i=1,2,...,N}∈R N , where N is the number of frequency points in the standard spectrum diagram, f i is the frequency of the ith frequency point in the standard spectrum, e i is the frequency f i The energy value at Step 512, calculate the odd-even octave matching degree as follows: Take any odd or even octave template of the pitch template as in, is the frequency of the jth frequency point in the odd-even octave template, For frequency The energy value at is: In the formula, is the odd-even octave matching degree, ε r is the preset condition parameter, F r For the pitch template F r ={(f jr ,e jr )|j=1,2,...,K}∈R K , K<N, where f jr is the frequency of the jth frequency point in the pitch template, e jr is the frequency f jr The energy value at Step 513, the comprehensive frequency matching degree between the low-dimensional spectrum graph and the pitch template is calculated according to the frequency matching degree and the odd-even octave matching degree as follows: In the formula, β is the comprehensive frequency matching degree, C fr is a constant, and α1 is the first adjustable parameter.
5. The method for extracting musical tone fundamental frequency based on multiple correlation calculation as claimed in claim 1, characterized in that: Calculate the energy matching vector between the low-dimensional spectrogram and the pitch template, including: Where η j is the jth element of the energy matching vector, and the energy matching vector is denoted as η={η1,η2,...,η K }∈R K , e j is the frequency f of the jth frequency point in the low-dimensional spectrum j The energy value at jr is the frequency f of the jth frequency point in the pitch template jr The energy value at , α2 is the second adjustable parameter, α3 is the third adjustable parameter, 1<α3<α2.
6. The method for extracting musical tone fundamental frequency based on multiple correlation calculation as claimed in claim 1, characterized in that: The step of calculating a frequency confidence vector between a low-dimensional spectrogram and a pitch template comprises: In the formula, θ j is the jth element of the frequency confidence vector, and the frequency confidence vector is θ=[θ1,θ2,...,θ k ]∈R K , e j-1 is the frequency f of the j-1th frequency point in the low-dimensional spectrum graph j-1 The energy value at j+1 is the frequency f of the j+1th frequency point in the low-dimensional spectrum graph j+1 The energy value at max is the maximum energy in the low-dimensional spectrum graph, α4 is the fourth adjustable parameter, α5 is the fifth adjustable parameter, α6 is the sixth adjustable parameter, and α7 is the seventh adjustable parameter.
7. The method for extracting musical tone fundamental frequency based on multiple correlation calculation as claimed in claim 1, characterized in that: The calculating of the odd-even harmonic ratio between the low-dimensional spectrum graph and the pitch template comprises: Where λ is the odd-even harmonic ratio, e j′ is the energy value of the even-numbered frequency in the low-dimensional spectrum, that is, j′ is the even-numbered item in j, e j″ is the energy value of the odd-numbered frequency in the low-dimensional spectrum, that is, j″ is the odd-numbered item in j, j = 1, 2, ..., K.
