Fundamental frequency detection method, device and equipment of stringed instrument and medium

By preprocessing and cache update of string instrument signals, combined with cepspectral analysis and linear frequency modulation Z-transformation algorithm, the optimal fundamental frequency is determined, which solves the problem of large error in the low-frequency band detection of string instruments in the prior art, and realizes high-precision fundamental frequency detection.

CN119889257AActive Publication Date: 2025-04-25ZHUHAI WEIKE TECH DEV CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510070685.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-16
Publication Date
2025-04-25
Estimated Expiration
2045-01-16

AI Technical Summary

Technical Problem

The current technology has a large error in the low-frequency band of fundamental frequency detection in string instrument tuning, which cannot meet the high-precision requirements.

Method used

By acquiring and preprocessing the current frame signal, it is updated to the preset cache, and the effective signal is detected by using the preset detection strategy to perform windowing processing. Then, fast Fourier transform and absolute value calculation are performed. If the frequency corresponding to the maximum amplitude is less than the preset frequency, the crudely estimated fundamental frequency is obtained by cepspectral analysis. The number and frequency of harmonics are determined based on the fundamental frequency and harmonic frequency intervals, and the optimal fundamental frequency is determined using a linear frequency modulation Z-transformation algorithm and iterative algorithm.

Benefits of technology

It reduces the detection error in the low-frequency band, improves the accuracy and robustness of fundamental frequency detection, and meets the high-precision requirements of string instrument tuning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119889257A_ABST
    Figure CN119889257A_ABST
Patent Text Reader

Abstract

The invention provides a fundamental frequency detection method and device for a stringed musical instrument, equipment and a medium. The method comprises the following steps: updating a target frame signal obtained by preprocessing to a preset cache; if the target frame signal in the updated cache is detected to be an effective signal by using a preset detection strategy, windowing the target frame signal, and performing fast Fourier transform and absolute value operation on the windowed signal; if it is determined that the first frequency with the maximum amplitude in the first frequency spectrum information is smaller than the preset frequency, the first frequency is processed through cepstrum analysis, and a first fundamental frequency is obtained; determining the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval; calculating the first fundamental frequency and the harmonic frequency of each harmonic wave by using a preset linear frequency modulation Z transformation algorithm to obtain the maximum harmonic frequency of each harmonic wave; and the optimal fundamental frequency is determined according to the preset iterative algorithm, the preset loss function and the maximum harmonic frequency of each harmonic, so that the detection error of the low-frequency band is reduced, and the fundamental frequency detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of audio signal processing, and in particular to a fundamental frequency detection method, device, equipment and medium for a stringed instrument. Background Art

[0002] In many natural signals (such as human voices and musical instruments), the sound wave signal emitted by the sound source is usually a combination of a series of harmonic frequencies; among them, the lowest frequency among the harmonic frequencies is called the fundamental frequency. Fundamental frequency detection (F0 detection for short) is a key technology in audio signal processing and is widely used in speech processing, music information retrieval, instrument tuning and other fields. However, the fundamental frequency detection in string instrument tuning is very different from the fundamental frequency detection requirements of speech signals, mainly reflected in the wider frequency range, the multiple relationship of harmonics, the high-precision frequency detection requirements and the harmonic offset phenomenon. Therefore, the fundamental frequency detection in the string instrument tuning algorithm needs to meet higher requirements in terms of accuracy, harmonic processing and frequency range to ensure accuracy and robustness.

[0003] At present, most mature fundamental frequency detection algorithms are mainly aimed at speech signals, such as the time domain-based autocorrelation algorithm and its improved algorithms (such as the YIN algorithm and the pYIN algorithm), and the frequency domain-based fast Fourier transform (FFT) method (such as the spectrum peak detection method, the harmonic summation method, the harmonic product spectrum method, etc.). However, these fundamental frequency detection methods have limitations in the application of string instrument tuning, especially in the low frequency band, where the error is large and cannot meet the high-precision requirements of string instrument tuning. Summary of the invention

[0004] The embodiments of the present application provide a fundamental frequency detection method, device, equipment and medium for a stringed instrument, aiming to solve the problem that the prior art has a large detection error in the low frequency band and cannot meet the high-precision requirements for tuning the stringed instrument.

[0005] In a first aspect, an embodiment of the present application provides a method for detecting a fundamental frequency of a stringed instrument, the method comprising:

[0006] Acquire a current frame signal, and preprocess the current frame signal to obtain a target frame signal;

[0007] Updating the target frame signal into a preset buffer to obtain an updated buffer;

[0008] If the target frame signal in the updated buffer is detected as a valid signal by using a preset detection strategy, windowing is performed on the signal in the updated buffer to obtain a windowed signal;

[0009] Performing fast Fourier transform and absolute value operation on the windowed signal to obtain first spectrum information;

[0010] If it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is less than the preset frequency, the first frequency spectrum information is processed by using cepstrum analysis to obtain a roughly estimated first fundamental frequency;

[0011] Determining the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval;

[0012] Analyzing the first fundamental frequency and the harmonic frequency of each harmonic using a preset linear frequency modulation Z-transform algorithm to obtain a maximum frequency value of each harmonic;

[0013] The optimal fundamental frequency is determined according to a preset iterative algorithm, a preset loss function and a maximum frequency value of each harmonic.

[0014] In a second aspect, an embodiment of the present application provides a method for detecting a fundamental frequency of a stringed instrument, the device comprising:

[0015] A current frame signal acquisition unit, used to acquire a current frame signal and pre-process the current frame signal to obtain a target frame signal;

[0016] A cache updating unit, used for updating the target frame signal into a preset cache to obtain an updated cache;

[0017] A windowing unit, configured to perform windowing processing on the signal in the updated buffer to obtain a windowed signal if the target frame signal in the updated buffer is detected as a valid signal using a preset detection strategy;

[0018] A frequency domain conversion unit, used for performing a fast Fourier transform and an absolute value operation on the windowed signal to obtain first spectrum information;

[0019] a fundamental frequency estimation unit, configured to process the first frequency spectrum information by using cepstrum analysis to obtain a roughly estimated first fundamental frequency if it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is less than a preset frequency;

[0020] a harmonic determination unit, configured to determine the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval;

[0021] a maximum frequency acquisition unit, which analyzes the first fundamental frequency and the harmonic frequency of each harmonic by using a preset linear frequency modulation Z-transform algorithm to obtain a maximum frequency value of each harmonic;

[0022] The fundamental frequency acquisition unit is used to determine the optimal fundamental frequency according to a preset iterative algorithm, a preset loss function and the maximum frequency value of each harmonic.

[0023] In a third aspect, an embodiment of the present application further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the fundamental frequency detection method of a string instrument described in the first aspect is implemented.

[0024] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the fundamental frequency detection method of a string instrument described in the first aspect above.

[0025] The embodiment of the present application provides a fundamental frequency detection method, apparatus, device and medium for a string instrument, which updates a target frame signal obtained by preprocessing to a preset cache; if the target frame signal in the updated cache is detected as a valid signal using a preset detection strategy, it is windowed, and the windowed signal is subjected to fast Fourier transform and absolute value operation; if it is determined that the first frequency with the maximum amplitude in the first spectrum information is less than the preset frequency, it is processed using cepstrum analysis to obtain a first fundamental frequency; and the number of harmonics and the harmonic frequency of each harmonic are determined according to the first fundamental frequency and a preset harmonic frequency interval; the first fundamental frequency and the harmonic frequency of each harmonic are calculated using a preset linear frequency modulation Z transform algorithm to obtain the maximum harmonic frequency of each harmonic; the optimal fundamental frequency is determined according to a preset iterative algorithm, a preset loss function and the maximum harmonic frequency of each harmonic, thereby reducing the detection error in the low frequency band and improving the accuracy of fundamental frequency detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0027] Figure 1 A schematic diagram of a flow chart of a fundamental frequency detection method for a stringed instrument provided in an embodiment of the present application;

[0028] Figure 2 A waveform diagram of an input signal in a fundamental frequency detection method for a stringed instrument provided in an embodiment of the present application;

[0029] Figure 3 A waveform diagram of the output frequency in the fundamental frequency detection method of a stringed instrument provided in an embodiment of the present application;

[0030] Figure 4 A schematic block diagram of a fundamental frequency detection device for a stringed instrument provided in an embodiment of the present application;

[0031] Figure 5 A schematic block diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] 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 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.

[0033] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0034] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0035] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0036] See also Figure 1-3 , Figure 1 A schematic diagram of a flow chart of a fundamental frequency detection method for a stringed instrument provided in an embodiment of the present application; Figure 2 This is a rendering of an input signal in the fundamental frequency detection method of a stringed instrument provided in an embodiment of the present application; Figure 3 This is a diagram showing the effect of the output frequency in the fundamental frequency detection method for a string instrument provided in an embodiment of the present application; the fundamental frequency detection method for a string instrument is applied to a server.

[0037] like Figure 1-3 As shown, the method includes steps S110-S180.

[0038] S110, acquiring a current frame signal, and preprocessing the current frame signal to obtain a target frame signal.

[0039] The preprocessing of the current frame signal to obtain the target frame signal includes:

[0040] Using a first filter to perform noise filtering on the current frame signal to obtain a first signal;

[0041] Performing high-frequency filtering on the first signal using a low-pass filter to obtain a second signal;

[0042] The second signal is downsampled to obtain the target frame signal.

[0043] In this embodiment, before obtaining each frame of the initial signal, the input signal to be processed, that is, the audio stream signal (such as Figure 2 As shown, the horizontal axis represents time (t), and the vertical axis represents the size of the audio stream signal, that is, the amplitude m). For example: use a microphone to obtain or directly input the recorded audio data; and perform frame processing on the audio stream signal to be processed according to a preset frame algorithm to obtain each frame of the initial signal; wherein the length of each frame of the initial signal is usually 20 to 50 milliseconds. After the audio stream signal is framed, the current frame signal is obtained from each frame of the initial signal, and the current frame signal is subjected to noise filtering processing using a first filter to filter out the white noise in the current frame signal, thereby obtaining the first signal; wherein the first filter can be a Wiener filter or an adaptive filter. In addition, the string instrument in this embodiment is preferably a piano, wherein, since the audio sampling of most pianos is 44.1kHz or 48kHz, and the frequency range of the piano is 27.5Hz to 4186Hz, and the Nyquist sampling theorem: the sampling frequency should be greater than or equal to twice the highest frequency in the analog signal spectrum, the sampling rate is at least 8372Hz; and in order to reduce the aliasing effect after the low-pass filter, the sampling rate is reduced by 5 times, and the audio sampling of the piano is reduced from 44.1kHz to 8820Hz. 48kHz is reduced to 9600Hz. Specifically, firstly, a low-pass filter with a normalized sampling rate of 0.2 is used to remove high-frequency noise in the first signal to obtain a second signal; and the second signal is downsampled to prevent the aliasing effect that occurs when the signal is downsampled, thereby obtaining a more reliable and efficient target frame signal.

[0044] S120: Update the target frame signal into a preset buffer to obtain an updated buffer.

[0045] In this embodiment, the preprocessed target frame signal is stored in a preset cache to facilitate subsequent signal processing; this embodiment specifically adds the target frame signal to the tail of the preset cache and simultaneously removes data with a length equal to that of the target frame signal from the head of the preset cache. Thereafter, each input target frame signal is stored at the tail of the preset cache and the same amount of data as the target frame signal at the head of the preset cache is discarded, thereby obtaining an updated cache to keep the signal in the preset cache continuous and up-to-date.

[0046] S130: If it is detected by a preset detection strategy that the target frame signal in the updated buffer is a valid signal, a windowing process is performed on the signal in the updated buffer to obtain a windowed signal.

[0047] In this embodiment, after obtaining the updated cache, the current target frame signal in the updated cache is detected using a preset detection strategy to distinguish white noise from a valid signal; wherein the preset detection strategy is preferably a short-time average energy method in this embodiment; specifically, by presetting the number of signal frames to be detected as M and the preset average energy threshold STE ev ; Then the i-th frame signal (ie, the target frame signal) is calculated to obtain the short-time average energy value corresponding to the i-th frame signal; and the short-time average energy value STE of the i-th frame signal is compared. i The short-time average energy value of each frame signal before the i-th frame signal, if STE i-M <STE i-(M-1) <…… <STE i-1 <STE i , it is determined to be the starting segment of a valid signal; in addition, if the starting segment of a valid signal has been detected and STE occurs i-M ≈STE i-(M-1) ≈……≈STE i-1 ≈STE i ≈STE ev , it is determined to be the end segment of the valid signal; and it is indicated that the i-th frame signal is a valid signal. At this time, the signal in the updated buffer is subjected to windowing processing, that is, a window function is added to obtain a windowed signal; wherein the window function can be a Hamming window, a Hanning window or a Blackman window, etc., so that the spectrum leakage is reduced by windowing processing and the accuracy of spectrum estimation is improved.

[0048] In one embodiment, after obtaining the updated cache, the method further includes:

[0049] If the preset signal detection strategy is used to detect that the target frame signal in the updated cache is white noise, the next frame signal of the current frame signal is obtained, the current frame signal is updated based on the next frame signal, and the step of preprocessing the current frame signal to obtain the target frame signal is returned.

[0050] In this embodiment, the preset detection strategy is preferably a short-time average energy method; specifically, by setting the number of signal frames to be detected to M and the preset average energy threshold STE ev ; wherein, the i-th frame signal (ie, the target frame signal) in the updated cache is detected using a preset detection strategy, and the i-th frame signal short-time average energy value STE is compared iThe short-time average energy value of each frame signal before the i-th frame signal, if STE i-M ≈STE i-(M-1) ≈……≈STE i-1 ≈STE i , it is determined to be white noise; at this time, the next frame signal of the current frame signal is obtained to continuously update the current frame signal, and the step of preprocessing the current frame signal to obtain the target frame signal is returned to repeat, so as to timely identify and eliminate white noise and avoid wasting resources on useless signals.

[0051] S140, performing fast Fourier transform and absolute value operation on the windowed signal to obtain first spectrum information.

[0052] In this embodiment, the windowed signal is first subjected to a fast Fourier transform to convert it from the time domain to the frequency domain to obtain a Fourier transform result, and the absolute value of the Fourier transform result is taken to obtain the first spectrum information of the windowed signal; wherein the first spectrum information includes the amplitude information of the spectrum; thereby facilitating the subsequent search for the spectrum peak from the amplitude information in the first spectrum information, and then obtaining the first frequency corresponding to the spectrum peak.

[0053] In one embodiment, after step S140, the following steps are performed:

[0054] If it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is greater than a preset frequency, the first frequency is used as the optimal fundamental frequency.

[0055] In this embodiment, in order to roughly estimate the signal frequency, after performing fast Fourier transform and absolute value operation on the windowed signal to obtain first spectrum information, the first spectrum information is traversed to determine the maximum amplitude (i.e., maximum peak) in the first spectrum information, thereby determining the strongest frequency component; and the first frequency corresponding to the maximum amplitude obtained by traversal is compared with the preset frequency. When it is determined that the first frequency corresponding to the maximum amplitude in the first spectrum information is greater than the preset frequency, it means that there are no harmonics in the first spectrum information but only one peak. The frequency corresponding to the peak is the signal fundamental frequency. Then, the rough frequency estimation detection is terminated, and the first frequency is used as the optimal fundamental frequency.

[0056] S150: If it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is less than a preset frequency, the first frequency spectrum information is processed by using cepstrum analysis to obtain a roughly estimated first fundamental frequency.

[0057] In this embodiment, after obtaining the first spectrum information, the first spectrum information is traversed to determine the maximum amplitude (i.e., the maximum peak) in the first spectrum information, thereby determining the strongest frequency component; and the first frequency corresponding to the maximum amplitude obtained by traversal is compared with the preset frequency. When it is determined that the first frequency corresponding to the maximum amplitude in the first spectrum information is less than the preset frequency, it means that there are harmonics of the first frequency corresponding to the maximum amplitude in the first spectrum information, which means that in addition to the main frequency component corresponding to the first frequency at the maximum amplitude, there are also components with integer multiples of its frequency. At this time, the first spectrum information is processed by using cepstrum analysis to identify periodic components, thereby obtaining a roughly estimated first fundamental frequency.

[0058] In one embodiment, the processing the first frequency spectrum information by using cepstrum analysis to obtain a roughly estimated first fundamental frequency includes:

[0059] Performing a fast Fourier transform operation on the first spectrum information to obtain a transformation result;

[0060] and performing an absolute value operation on the transformation result to obtain second spectrum information;

[0061] The second frequency spectrum information is traversed to determine a maximum amplitude, and a frequency corresponding to the maximum amplitude is used as the first fundamental frequency.

[0062] In this embodiment, the process of using cepstrum analysis to process the first spectrum information to obtain a roughly estimated first fundamental frequency first performs a fast Fourier transform operation on the first spectrum information to obtain a transformation result including cepstrum information; then an absolute value operation is performed on the transformation result to calculate the second spectrum information; in addition, the second spectrum information is traversed to find the maximum amplitude corresponding to the second spectrum information, and the second frequency corresponding to the maximum amplitude is used as the roughly estimated first fundamental frequency.

[0063] S160. Determine the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval.

[0064] In this embodiment, in order to facilitate more accurate calculation of the optimal fundamental frequency in the subsequent process, this embodiment determines the number of harmonics through the first fundamental frequency and the preset harmonic frequency interval; wherein, harmonic refers to a sine wave whose frequency is an integer multiple of the fundamental frequency, so that the number of existing harmonics can be inferred through the known first fundamental frequency and the preset harmonic frequency interval, and then the approximate harmonic frequency of each harmonic can be obtained.

[0065] For example, the preset harmonic frequency interval is 0-4800Hz, and the first fundamental frequency f1=1000Hz, then the remaining continuous maximum peaks in the preset harmonic frequency interval are f2=2000Hz, f3=3000Hz, f4=4000Hz, the number of harmonics n=4, and the harmonic frequencies corresponding to each harmonic are f1=1000Hz, f2=2000Hz, f3=3000Hz, and f4=4000Hz respectively.

[0066] S170: Analyze the first fundamental frequency and the harmonic frequency of each harmonic using a preset linear frequency modulation Z-transform algorithm to obtain a maximum frequency value of each harmonic.

[0067] In this embodiment, in order to determine more accurate harmonic frequencies, after determining the number of harmonics and the harmonic frequency corresponding to each harmonic, a linear frequency modulation Z transform (Cirp-Z, CZT) algorithm is used to perform spectral analysis on the first fundamental frequency and the harmonic frequency corresponding to each harmonic to determine the maximum frequency value corresponding to each harmonic position, that is, the actual frequency of each harmonic.

[0068] S180, determining an optimal fundamental frequency according to a preset iterative algorithm, a preset loss function, and a maximum frequency value of each harmonic.

[0069] In this embodiment, after obtaining the maximum frequency value of each harmonic, the optimal fundamental frequency is determined by a preset iterative algorithm, a preset loss function and the maximum frequency value of each harmonic. It should be firstly clarified that for stringed instruments, such as piano, guitar, bass, guzheng, etc., the sound-generating units are all made by the tight rigid strings on the instruments, which vibrate under external force. Considering the bending stiffness and internal damping of the strings, the strings with a length of L can be expressed as:

[0070]

[0071] Where μ represents the linear density of the string, R(ω) represents the damping coefficient, T represents the tension of the string, E represents the Young's modulus, S represents the cross-sectional area, κ represents the radius of gyration, and d represents the x (x, t) represents the external excitation force applied to the string, which is a function of space and time.

[0072] When x When (x, t) is an impact signal of Fδ(t, t0)δ(x, x0) such as plucking, hitting, etc., the characteristics of the audio signal generated by the vibration of the string over time are expressed as:

[0073]

[0074] Where t is the vibration time of the string, R k represents the internal damping of the string, fk represents the kth order vibration frequency, y δ,k (t) represents the audio signal generated by the vibration of the string.

[0075] At the same time, the frequency of the nth-order harmonic can be expressed as:

[0076]

[0077] Where n is a positive integer, and the value of n is [1, ∞];

[0078] because and but

[0079] Where B is the correction factor, L is the length of the string, f0 is the fundamental frequency of the string, and f n Represents the frequency of the nth harmonic of the string.

[0080] In addition, suppose the nth harmonic observed from the spectrum is f n ′ , then the error ∈ n is the actual measured value f n ′ With the theoretical value f n The difference between:

[0081]

[0082] And, assuming the error ∈ n It follows a normal distribution with a mean of 0 and a variance of σ 2 ,Right now

[0083] ∈ n ~Ν(0,σ 2 );

[0084] This means that the harmonic frequency f we observed n It also follows a normal distribution, with a mean of The variance is σ 2 .

[0085] Based on the assumption of error, the likelihood function L(f0,B|f1 ′ ,f2 ′ ,…f k ′ ), where k is the order of the harmonic:

[0086]

[0087] And take the logarithm of the likelihood function to obtain the log-likelihood function l(f0,B):

[0088]

[0089] Because the constant term and σ 2 Regardless of f0 and B, maximizing L(f0,B) is equivalent to minimizing the error term, so the preset loss function can be expressed as:

[0090]

[0091] Therefore, the solution is obtained through the maximum frequency value of each harmonic and a preset iterative algorithm (for example, gradient descent or Newton's method), and the estimated value of the fundamental frequency is continuously adjusted to minimize the preset loss function, thereby achieving accurate estimation of the fundamental frequency, so that the estimated value of f0,B maximizes the log-likelihood function, thereby significantly improving the accuracy and robustness of the fundamental frequency estimation.

[0092] In one embodiment, the step S180 includes:

[0093] Acquire an initial parameter set; wherein the initial parameter set includes a preset cutoff threshold, an initial function value, an initial fundamental frequency parameter and an initial correction factor;

[0094] Calculate the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain a current function value;

[0095] If it is detected that the absolute value of the difference between the current function value and the initial function value is less than the preset cutoff threshold, the initial function value is updated based on the current function value, the initial fundamental frequency parameter and the initial correction factor are updated to obtain an updated correction factor and an updated fundamental frequency parameter, and the updated fundamental frequency parameter is used as the initial fundamental frequency parameter, and the updated correction factor is used as the initial correction factor, and the step of calculating the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain the current function value is returned to be executed;

[0096] Until the preset number of iterations is reached, or the absolute value of the difference between the current function value and the initial function value is greater than the preset cutoff threshold, the iteration is stopped and the optimal fundamental frequency is output.

[0097] In this embodiment, the preset iterative algorithm is a gradient descent method in this embodiment; determining the optimal fundamental frequency according to the preset iterative algorithm, the preset loss function and the maximum frequency value of each harmonic includes: first obtaining an initial parameter set; wherein the initial parameter set includes a preset cutoff threshold D, an initial function value loss pre , initial base frequency parameter f0 and initial correction factor B, also including iteration factor lr; preset cutoff threshold D, initial function value loss preThe values ​​of the initial fundamental frequency parameter f0, the initial correction factor B and the iteration factor lr can be set according to actual needs. The string instrument of this embodiment takes the piano as an example, and the range of the initial correction factor B is usually 2*10 -4 ~8*10 -4 The initial baseband parameter f0 can be f0 ′ , initial correction factor B = 1*10 -4 , initial function value loss pre =0, iteration factor lr=0.1, preset cutoff threshold D=1*10 -2 In addition, in the first iteration, the maximum frequency value f0 of each harmonic is ′ , f1 ′ ……f n ′ , the initial fundamental frequency parameter f0 and the initial correction factor B are calculated by the preset loss function to obtain the current function value loss; and the current function value loss and the preset function threshold loss are calculated. pre The absolute value of the difference between loss , the current function value loss and the preset function threshold loss pre The absolute value of the difference between loss Compare with the preset cutoff threshold; if the current function value loss is equal to the preset function threshold loss pre The absolute value of the difference between loss If the current function value is less than the preset cutoff threshold D, it means that the optimal solution has been reached. At this time, the calculation is terminated, and the initial fundamental frequency parameters and initial correction factors corresponding to the current function value are output, and the initial fundamental frequency parameters are output as the optimal fundamental frequency. pre The absolute value of the difference between loss If the value is greater than the preset cutoff threshold D, it means that the optimal solution has not been reached, then the iteration continues, and the initial function value is updated based on the current function value, and the initial fundamental frequency parameter and the initial correction factor are updated to obtain the updated correction factor and the updated fundamental frequency parameter, and the updated fundamental frequency parameter is used as the initial fundamental frequency parameter, and the updated correction factor is used as the initial correction factor, and the step of calculating the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain the current function value is returned and repeated; until the preset number of iterations is reached, or the absolute value of the difference between the current function value and the initial function value is greater than the preset cutoff threshold, then the iteration ends and the optimal fundamental frequency (such as Figure 3 As shown, the horizontal axis represents time (t) and the vertical axis represents fundamental frequency (HZ), so that the vibration characteristics of the strings can be more accurately described by the optimal fundamental frequency to ensure the accuracy of tuning of the string instrument.

[0098] The following formulas are used to update the initial baseband parameter f0 and the initial correction factor B to obtain an updated correction factor and an updated baseband parameter:

[0099]

[0100] Among them, f0 represents the initial fundamental frequency parameter, B represents the initial correction factor, lr represents the iteration factor, loss represents the current function value, n represents the number of harmonics, and the value of n is [1, k].

[0101] In addition, the step of calculating the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain the current function value is performed by calculating the current function value through the following formula:

[0102]

[0103] Among them, f′ n represents the maximum harmonic frequency of the nth harmonic, B represents the correction factor, f0 represents the initial fundamental frequency, n represents the number of harmonics, and the value of n is [1, k].

[0104] Therefore, this embodiment automatically calculates the optimal fundamental frequency parameters that minimize the preset loss function through a preset iterative algorithm, thereby providing a more accurate and reliable optimal fundamental frequency.

[0105] It can be seen from the above technical scheme that the target frame signal obtained by preprocessing is updated to the preset cache; if the preset detection strategy is used to detect that the target frame signal in the updated cache is a valid signal, it is windowed, and the windowed signal is subjected to fast Fourier transform and absolute value operation; if it is determined that the first frequency with the largest amplitude in the first spectrum information is less than the preset frequency, it is processed by cepstrum analysis to obtain the first fundamental frequency; and the number of harmonics and the harmonic frequency of each harmonic are determined according to the first fundamental frequency and the preset harmonic frequency interval; the first fundamental frequency and the harmonic frequency of each harmonic are calculated by the preset linear frequency modulation Z transform algorithm to obtain the maximum harmonic frequency of each harmonic; the optimal fundamental frequency is determined according to the preset iterative algorithm, the preset loss function and the maximum harmonic frequency of each harmonic, thereby reducing the detection error in the low frequency band and improving the accuracy of fundamental frequency detection.

[0106] The present application also provides a fundamental frequency detection device for a stringed instrument, which is used to perform any embodiment of the fundamental frequency detection method for a stringed instrument. Figure 2 , Figure 2 It is a schematic block diagram of a fundamental frequency detection device for a stringed instrument provided in an embodiment of the present application.

[0107] Among them, Figure 4 As shown, the fundamental frequency detection device 100 for a stringed instrument includes a current frame signal acquisition unit 110, a cache update unit 120, a windowing unit 130, a frequency domain conversion unit 140, a fundamental frequency estimation unit 150, a harmonic determination unit 160, a maximum frequency acquisition unit 170, and a fundamental frequency acquisition unit 180.

[0108] The current frame signal acquisition unit 110 is used to acquire the current frame signal and pre-process the current frame signal to obtain a target frame signal;

[0109] A cache updating unit 120, configured to update the target frame signal into a preset cache to obtain an updated cache;

[0110] A windowing unit 130, configured to perform windowing processing on the signal in the updated buffer to obtain a windowed signal if the target frame signal in the updated buffer is detected as a valid signal using a preset detection strategy;

[0111] A frequency domain conversion unit 140 is used to perform a fast Fourier transform and an absolute value operation on the windowed signal to obtain first spectrum information;

[0112] A fundamental frequency estimation unit 150 is configured to process the first frequency spectrum information by using cepstrum analysis to obtain a roughly estimated first fundamental frequency if it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is less than a preset frequency;

[0113] A harmonic determination unit 160, configured to determine the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval;

[0114] The maximum frequency acquisition unit 170 analyzes the first fundamental frequency and the harmonic frequency of each harmonic by using a preset linear frequency modulation Z-transform algorithm to obtain a maximum frequency value of each harmonic;

[0115] The fundamental frequency acquisition unit 180 is used to determine the optimal fundamental frequency according to a preset iterative algorithm, a preset loss function and a maximum frequency value of each harmonic.

[0116] In some embodiments, the baseband acquisition unit 180 is specifically used to:

[0117] Acquire an initial parameter set; wherein the initial parameter set includes a preset cutoff threshold, an initial function value, an initial fundamental frequency parameter and an initial correction factor;

[0118] Calculate the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain a current function value;

[0119] If it is detected that the absolute value of the difference between the current function value and the initial function value is less than the preset cutoff threshold, the initial function value is updated based on the current function value, the initial fundamental frequency parameter and the initial correction factor are updated to obtain an updated correction factor and an updated fundamental frequency parameter, and the updated fundamental frequency parameter is used as the initial fundamental frequency parameter, and the updated correction factor is used as the initial correction factor, and the step of calculating the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain the current function value is returned to be executed;

[0120] Until the preset number of iterations is reached, or the absolute value of the difference between the current function value and the initial function value is greater than the preset cutoff threshold, the iteration is stopped and the optimal fundamental frequency is output.

[0121] In some embodiments, in the step of obtaining the current function value, the current function value is obtained by the following formula:

[0122]

[0123] Where n represents the number of harmonics, f′ n represents the maximum harmonic frequency of the nth harmonic, B represents the correction factor, f0 represents the initial fundamental frequency, and the value of n is [1, k].

[0124] In some embodiments, when the fundamental frequency estimation unit 150 performs the step of processing the first frequency spectrum information by using cepstrum analysis to obtain a roughly estimated first fundamental frequency, it is specifically configured to:

[0125] Performing a fast Fourier transform operation on the first spectrum information to obtain a transformation result;

[0126] and performing an absolute value operation on the transformation result to obtain second spectrum information;

[0127] The second frequency spectrum information is traversed to determine a maximum amplitude, and a frequency corresponding to the maximum amplitude is used as the first fundamental frequency.

[0128] In some embodiments, the frequency domain conversion unit 140 is further used to:

[0129] If it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is greater than a preset frequency, the first frequency is used as the optimal fundamental frequency.

[0130] In some embodiments, when the current frame signal acquisition unit 110 performs the step of preprocessing the current frame signal to obtain the target frame signal, it is specifically used to:

[0131] Using a first filter to perform noise filtering on the current frame signal to obtain a first signal;

[0132] Performing high-frequency filtering on the first signal using a low-pass filter to obtain a second signal;

[0133] The second signal is downsampled to obtain the target frame signal.

[0134] In some embodiments, the cache updating unit 120 is further configured to:

[0135] If the preset signal detection strategy is used to detect that the target frame signal in the updated cache is white noise, the next frame signal of the current frame signal is obtained, the current frame signal is updated based on the next frame signal, and the step of preprocessing the current frame signal to obtain the target frame signal is returned.

[0136] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the fundamental frequency detection device and each unit of the above-mentioned string instrument can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.

[0137] The fundamental frequency detection device of the stringed instrument can be implemented in the form of a computer program. The computer program can be used in Figure 5 Runs on the computer device shown.

[0138] See also Figure 5 , Figure 5 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 is a server or a server cluster. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0139] See also Figure 5 The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a device bus 501 , wherein the memory may include a storage medium 503 and an internal memory 504 .

[0140] The storage medium 503 may store an operating system 5031 and a computer program 5032. When the computer program 5032 is executed, the processor 502 may execute a fundamental frequency detection method for a stringed instrument.

[0141] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .

[0142] The internal memory 504 provides an environment for the operation of the computer program 5032 in the storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute the fundamental frequency detection method of the string instrument.

[0143] The network interface 505 is used for network communication, such as providing data information transmission, etc. Those skilled in the art will understand that Figure 5 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0144] The processor 502 is used to run a computer program 5032 stored in the memory to implement the fundamental frequency detection method of a stringed instrument disclosed in the embodiment of the present application.

[0145] Those skilled in the art will understand that Figure 5 The embodiments of the computer device shown in the figure do not constitute a limitation on the specific composition of the computer device. In other embodiments, the computer device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. For example, in some embodiments, the computer device may only include a memory and a processor. In such embodiments, the structure and function of the memory and the processor are the same as those of the embodiment of the present invention. Figure 5 The embodiments shown are consistent and will not be described again here.

[0146] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0147] In another embodiment of the present application, a computer-readable storage medium is provided. The computer-readable storage medium may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the fundamental frequency detection method of a stringed instrument disclosed in the embodiment of the present application is implemented.

[0148] It will be clear to those skilled in the art that, for the convenience and simplicity of description, the specific working process of the above-described equipment, devices and units can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It will be appreciated by those of ordinary skill in the art that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to the function. Whether these functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0149] In the several embodiments provided in the present application, it should be understood that the disclosed equipment, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, and units with the same function may be combined into one unit. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices or units, or may be electrical, mechanical or other forms of connection.

[0150] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present application.

[0151] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0152] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a background server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a disk or an optical disk.

[0153] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for detecting the fundamental frequency of a stringed instrument, characterized in that: The method comprises: Acquire a current frame signal, and preprocess the current frame signal to obtain a target frame signal; Updating the target frame signal into a preset buffer to obtain an updated buffer; If the target frame signal in the updated buffer is detected as a valid signal by using a preset detection strategy, windowing is performed on the signal in the updated buffer to obtain a windowed signal; Performing fast Fourier transform and absolute value operation on the windowed signal to obtain first spectrum information; If it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is less than the preset frequency, the first frequency spectrum information is processed by using cepstrum analysis to obtain a roughly estimated first fundamental frequency; Determining the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval; Analyzing the first fundamental frequency and the harmonic frequency of each harmonic using a preset linear frequency modulation Z-transform algorithm to obtain a maximum frequency value of each harmonic; The optimal fundamental frequency is determined according to a preset iterative algorithm, a preset loss function and a maximum frequency value of each harmonic.

2. The method for detecting the fundamental frequency of a stringed instrument according to claim 1, characterized in that: The determining of the optimal fundamental frequency according to a preset iterative algorithm, a preset loss function and a maximum harmonic frequency at each harmonic includes: Acquire an initial parameter set; wherein the initial parameter set includes a preset cutoff threshold, an initial function value, an initial fundamental frequency parameter and an initial correction factor; Calculate the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain a current function value; If it is detected that the absolute value of the difference between the current function value and the initial function value is less than the preset cutoff threshold, the initial function value is updated based on the current function value, the initial fundamental frequency parameter and the initial correction factor are updated to obtain an updated correction factor and an updated fundamental frequency parameter, and the updated fundamental frequency parameter is used as the initial fundamental frequency parameter, and the updated correction factor is used as the initial correction factor, and the step of calculating the preset loss function according to the initial fundamental frequency parameter, the initial correction factor, and the maximum harmonic frequency at each harmonic to obtain the current function value is returned to be executed; Until the preset number of iterations is reached, or the absolute value of the difference between the current function value and the initial function value is greater than the preset cutoff threshold, the iteration is stopped and the optimal fundamental frequency is output.

3. The method for detecting the fundamental frequency of a stringed instrument according to claim 1, wherein: In the step of obtaining the current function value, the current function value is obtained by the following formula: Where n represents the number of harmonics, f′ n represents the maximum harmonic frequency of the nth harmonic, B represents the correction factor, f0 represents the initial fundamental frequency, and the value of n is [1, k].

4. The method for detecting the fundamental frequency of a stringed instrument according to claim 1, characterized in that: The step of processing the first frequency spectrum information by using cepstrum analysis to obtain a roughly estimated first fundamental frequency includes: Performing a fast Fourier transform operation on the first spectrum information to obtain a transformation result; and performing an absolute value operation on the transformation result to obtain second spectrum information; The second frequency spectrum information is traversed to determine a maximum amplitude, and a frequency corresponding to the maximum amplitude is used as the first fundamental frequency.

5. The method for detecting the fundamental frequency of a stringed instrument according to claim 1, characterized in that: After obtaining the first spectrum information, the method further includes: If it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is greater than a preset frequency, the first frequency is used as the optimal fundamental frequency.

6. The method for detecting the fundamental frequency of a stringed instrument according to claim 1, characterized in that: The preprocessing of the current frame signal to obtain a target frame signal includes: Using a first filter to perform noise filtering on the current frame signal to obtain a first signal; Performing high-frequency filtering on the first signal using a low-pass filter to obtain a second signal; The second signal is downsampled to obtain the target frame signal.

7. The method for detecting the fundamental frequency of a stringed instrument according to claim 1, characterized in that: After obtaining the updated cache, the method further includes: If the preset signal detection strategy is used to detect that the target frame signal in the updated cache is white noise, the next frame signal of the current frame signal is obtained, the current frame signal is updated based on the next frame signal, and the step of preprocessing the current frame signal to obtain the target frame signal is returned.

8. A fundamental frequency detection device for a stringed instrument, characterized in that: The device comprises: A current frame signal acquisition unit, used to acquire a current frame signal and pre-process the current frame signal to obtain a target frame signal; A cache updating unit, used for updating the target frame signal into a preset cache to obtain an updated cache; A windowing unit, configured to perform windowing processing on the signal in the updated buffer to obtain a windowed signal if the target frame signal in the updated buffer is detected as a valid signal using a preset detection strategy; A frequency domain conversion unit, used for performing a fast Fourier transform and an absolute value operation on the windowed signal to obtain first spectrum information; a fundamental frequency estimation unit, configured to process the first frequency spectrum information by using cepstrum analysis to obtain a roughly estimated first fundamental frequency if it is determined that the first frequency corresponding to the maximum amplitude in the first frequency spectrum information is less than a preset frequency; a harmonic determination unit, configured to determine the number of harmonics and the harmonic frequency of each harmonic according to the first fundamental frequency and a preset harmonic frequency interval; a maximum frequency acquisition unit, which analyzes the first fundamental frequency and the harmonic frequency of each harmonic by using a preset linear frequency modulation Z-transform algorithm to obtain a maximum frequency value of each harmonic; The fundamental frequency acquisition unit is used to determine the optimal fundamental frequency according to a preset iterative algorithm, a preset loss function and the maximum frequency value of each harmonic.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the fundamental frequency detection method of a stringed instrument according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the fundamental frequency detection method for a stringed instrument according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • High-precision and high-stability string instrument fundamental frequency detection method

    CN111613241A

  • Musical instrument timbre conversion method based on musical sound signal harmonic energy

    CN118430485A

  • Measuring method for fundamental frequency and measuring device

    JP1997015273A