Disclosure of Invention
The invention mainly aims to provide a method, equipment, a device and a storage medium for generating harmonic waves of sound signals, and aims to solve the problem that the existing harmonic wave generation method cannot control harmonic wave distortion and simultaneously give consideration to real-time performance of harmonic wave generation.
In order to achieve the above object, the present invention provides a harmonic generation method of a sound signal, the harmonic generation method of a sound signal including:
acquiring middle and low frequency components of a sound signal;
performing transformation processing on the middle-low frequency components to obtain phase values and amplitude values of all frequency points of the middle-low frequency band;
obtaining an amplitude value and a frequency value of a base frequency point based on the amplitude value of each frequency point of the medium-low frequency band;
based on the frequency value of the fundamental frequency point, acquiring the position of a frequency multiplication point on a spectrogram, and further determining the phase value and the amplitude value of the frequency multiplication point;
processing the phase value and the amplitude value of the frequency multiplication point to obtain an initial harmonic signal;
and carrying out band-pass filtering on the initial harmonic signal to obtain a target harmonic signal so as to obtain the target harmonic signal in the sound signal in high real-time.
Optionally, the transforming the low-frequency component to obtain a phase value and an amplitude value of each frequency point of the low-frequency band includes:
Performing Fourier transform processing on the middle-low frequency components to obtain frequency domain expressions corresponding to the middle-low frequency components;
obtaining a spectrogram of the middle-low frequency component based on a frequency domain expression corresponding to the middle-low frequency component;
and obtaining the phase value and the amplitude value of each frequency point of the middle and low frequency band based on the spectrogram of the middle and low frequency components.
Optionally, the obtaining the amplitude value and the frequency value of the base frequency point based on the amplitude value of each frequency point of the middle-low frequency band includes:
the amplitude values of all the frequency points of the middle and low frequency bands are arranged in size to obtain an amplitude value sequence;
taking the maximum amplitude value in the amplitude value sequence as the amplitude value of the fundamental frequency point;
and taking the frequency value of the frequency point corresponding to the maximum amplitude value in the spectrogram as the frequency value of the fundamental frequency point based on the amplitude value of the fundamental frequency point.
Optionally, the processing the phase value and the amplitude value of the frequency multiplication point to obtain an initial harmonic signal includes:
the frequency multiplication point and the amplitude value of the frequency point before and after the frequency multiplication point are replaced by the fundamental frequency point and the amplitude value of the frequency point before and after the fundamental frequency point, and the amplitude value of the frequency multiplication point after adjustment, the amplitude value of the frequency point before adjustment and the amplitude value of the frequency point after adjustment are obtained;
Adjusting the phase value of the frequency point before and after the frequency multiplication point to obtain the adjusted phase value of the previous frequency point and the adjusted phase value of the next frequency point;
obtaining a frequency point data sequence according to the amplitude value of the adjusted frequency multiplication point, the amplitude value of the adjusted previous frequency point and the amplitude value of the adjusted next frequency point, the phase value of the adjusted previous frequency point and the phase value of the adjusted next frequency point;
and carrying out inverse Fourier transform on the frequency point data sequence to obtain an initial harmonic signal.
Optionally, replacing the frequency point amplitude value of the frequency multiplication point with the frequency point amplitude value of the fundamental frequency point;
the amplitude value of the previous frequency point of the frequency doubling point is replaced by the amplitude value of the previous frequency point of the fundamental frequency point;
and replacing the amplitude value of the next frequency point of the frequency multiplication point with the amplitude value of the next frequency point of the fundamental frequency point.
Optionally, the adjusting the phase value of the frequency point before and after the frequency point to obtain the adjusted phase value of the previous frequency point and the adjusted phase value of the next frequency point includes: acquiring a phase value of a frequency multiplication point in a previous frame, a phase value of a frequency multiplication point before the frequency multiplication point and a phase value of a frequency multiplication point after the frequency multiplication point;
acquiring a phase value of a frequency multiplication point in a current frame, a phase value of a frequency point before the frequency multiplication point and a phase value of a frequency point after the frequency multiplication point;
Subtracting the phase value of the frequency multiplication point in the current frame from the phase value of the frequency multiplication point in the previous frame to obtain a target phase difference value;
the result of adding the phase value of the frequency point before the frequency point in the previous frame and the target phase difference value is used as the adjusted synthesized phase value of the frequency point before;
and adding the phase value of the frequency point behind the frequency point in the previous frame with the target phase difference value to obtain the adjusted synthesized phase value of the frequency point behind the frequency point.
Optionally, the acquiring the low-frequency component of the sound signal includes:
acquiring an input signal;
and performing low-pass filtering on the input signal to obtain a middle-low frequency component, wherein the middle-low frequency component at least comprises a frequency multiplication point signal component of which the base frequency signal component is adjacent to a base frequency point.
In order to achieve the above object, the present invention also provides a harmonic generation device for an acoustic signal, the harmonic generation device comprising:
the acquisition module is used for acquiring the middle-low frequency components of the sound signal;
the transformation module is used for carrying out transformation processing on the middle-low frequency components to obtain phase values and amplitude values of all frequency points of the middle-low frequency band;
the acquisition module is further used for acquiring an amplitude value and a frequency value of a base frequency point based on the amplitude value of each frequency point of the medium-low frequency band;
The acquisition module is further used for determining the position of the frequency multiplication point on the spectrogram based on the frequency value of the fundamental frequency point, and further determining the phase value and the amplitude value of the frequency multiplication point;
the processing module is used for processing the phase value and the amplitude value of the frequency multiplication point to obtain an initial harmonic signal;
and the band-pass filtering module is used for carrying out band-pass filtering on the initial harmonic signal to obtain a target harmonic signal so as to realize high real-time acquisition of the target harmonic signal in the sound signal.
In addition, in order to achieve the above object, the present invention also proposes a harmonic generation apparatus of an acoustic signal, the apparatus comprising: the device comprises a memory, a processor and a harmonic generation program of the sound signal, wherein the harmonic generation program of the sound signal is stored in the memory and can be operated on the processor, and the harmonic generation program of the sound signal is configured to realize the steps of the harmonic generation method of the sound signal.
In order to achieve the above object, the present invention provides a storage medium having stored thereon a harmonic generation program of an acoustic signal, which when executed by a processor, implements the steps of the harmonic generation method of an acoustic signal.
According to the method, the medium-low frequency components of the sound signal are obtained, then the characteristic value of each frequency point of the medium-low frequency band is extracted, the relevant frequency point is determined through the characteristic value, the characteristic value of the relevant frequency point is adjusted, and the target harmonic is obtained through calculation and filtering. The whole process only needs one sampling, simultaneously reduces the calculated amount and time, and improves the real-time performance. The characteristic values participating in calculation are adjusted, so that harmonic distortion can be effectively controlled, harmonic distortion control in harmonic generation is realized, and meanwhile, the real-time performance of harmonic generation is improved.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic diagram of a harmonic generation device for sound signals of a hardware operation environment according to an embodiment of the present invention.
As shown in fig. 1, the harmonic generation device of the sound signal may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WIreless-FIdelity (WI-FI) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) Memory or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
It will be appreciated by those skilled in the art that the structure shown in fig. 1 does not constitute a limitation of the harmonic generation apparatus of sound signals, and may include more or fewer components than shown, or may combine certain components, or a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and a harmonic generation program of a sound signal may be included in the memory 1005 as one type of storage medium.
In the harmonic generation device of the sound signal shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the harmonic generation apparatus of the sound signal of the present invention may be provided in the harmonic generation apparatus of the sound signal, which invokes the harmonic generation program of the sound signal stored in the memory 1005 through the processor 1001, and performs the harmonic generation method of the sound signal provided by the embodiment of the present invention.
Example 1:
referring to fig. 2, fig. 2 is a flowchart of an embodiment 1 of a method for generating harmonics of an acoustic signal according to the present invention.
In this embodiment, the method for generating harmonics of a sound signal includes the steps of:
Step S10: the mid-low frequency components of the sound signal are acquired.
In this embodiment, the execution subject may be a harmonic generation device of a sound signal, or may be another device that can achieve the same or similar functions, and this embodiment is not limited thereto.
It is understood that the low-frequency component is a signal generated at the output end of the low-pass filter after the input signal flows into the low-pass filter to filter out the high-frequency signal component.
It should be understood that, since the harmonic generation devices should be equipped with low-pass filters, the input signals can be filtered, and before the input signals flow into the low-pass filters, parameters of the low-pass filters can be modulated according to actual needs, so as to adjust the frequency range of the middle-low frequency components flowing out of the low-pass filters.
Optionally, the step of acquiring the middle-low frequency component of the sound signal specifically includes: acquiring an input signal; and performing low-pass filtering on the input signal to obtain a middle-low frequency component, wherein the middle-low frequency component at least comprises a frequency multiplication point signal component of which the base frequency signal component is adjacent to a base frequency point.
It should be noted that, in the implementation of the method, if the low-pass filtering threshold is set to be lower than the fundamental frequency of the input signal, the filter will filter out all the components with frequencies higher than the threshold, including fundamental frequency and all harmonic multiples, which means that no signal component will be obtained in the signal output from the filter.
It will be appreciated that because the low pass filter is designed to reject signals above a certain frequency by signals below that frequency, if the cut-off frequency of the filter is below the fundamental frequency of the signal, the whole signal will be filtered out, because the frequency spectrum of the whole signal lies above the cut-off frequency of the filter, and therefore, if the threshold of the filter is below the fundamental frequency, no effective signal component will be obtained.
It should be noted that, according to a generally common knowledge, the audible sound signal frequency range of humans is about 20 Hz to 20,000 Hz (or 20 kHz). This means that the normal hearing range is approximately within this frequency range, and that the specific frequency ranges for medium and low frequencies can be briefly divided according to the following example.
The following are examples of some common sound frequencies and corresponding fundamental frequencies:
20 The Hz is as follows: humans are generally unable to perceive these low frequency sounds, but can perceive their vibrations, in which range the fundamental frequency may be several hertz, depending on the nature and source of the sound. For example, the fundamental frequency of a seismic or low musical instrument such as a megabass may be around a few hertz.
20 Hz to 200 Hz: this is the low audio range, such as bass music and heavy machinery sounds, where the fundamental frequency is typically around 20 Hz, corresponding to the lowest frequency that can be perceived by humans. For example, the fundamental frequency of bass drums is typically between about 30-80 Hz.
200 Hz to 2 kHz: this is the mid-audio range, including the speech sounds of most people and the sounds of instruments, where the fundamental frequency is typically around 200 Hz. The fundamental frequency of the speech sounds of most people is approximately between 100-200 and Hz.
2 kHz to 20 kHz: this is the high audio range, including most birds' squeal, metallic impact and sharp whistle, where the fundamental frequency is typically around 2 kHz. For example, the fundamental frequency of the chirp of most birds may be on the order of a few kilohertz.
It should be appreciated that these fundamental frequency ranges are based on the general law of common sounds and are not applicable to all sounds. The range of fundamental frequencies of a particular sound may vary depending on its source, nature, and other factors.
It should be noted that, in the subsequent step of the method, a signal component including a frequency multiplication point where the fundamental frequency signal component is close to a fundamental frequency point is used, so that at least a portion of the signal should be retained in the intermediate and low frequency components obtained after the low-pass filtering, and a certain requirement should be met for a specific parameter of the low-pass filter, for example, a lower limit value should exist for a cut-off frequency of the low-pass filter, so as to ensure that the obtained intermediate and low frequency components include the signal component required in the subsequent step.
It should be appreciated that part of the information of the preset target harmonic signal is known, for example, in an actual scene, a sound signal component with twice the fundamental frequency in a section of sound signal is required, then the frequency of the target harmonic signal is twice the fundamental frequency, according to the existing sound signal, by actual experience when playing, the range of the fundamental frequency of the sound signal can be approximately deduced according to the above example, the range of the target harmonic signal can be indirectly obtained, and the approximate range of the cut-off frequency of the low-pass filter can be determined according to the two ranges, so that the proper cut-off frequency setting of the filter is ensured, and the unnecessary high-frequency component is suppressed while the required signal component is reserved. And correspondingly adjusting relevant parameters of the filter according to requirements to obtain reasonable middle-low frequency components.
Step S20: and carrying out transformation processing on the middle-low frequency components to obtain phase values and amplitude values of all frequency points of the middle-low frequency band.
The transformation process may be a transformation process based on fourier transformation, a transformation process based on laplace transformation, or a transformation process based on other time-frequency analysis of signals that can achieve the same or similar functions, and the present embodiment is not limited thereto.
It will be appreciated that the transformation of the mid-low frequency components results in a set of complex values, each of which represents the amplitude and phase information of the mid-low frequency components at a different frequency. The set of complex values may be represented as a spectrogram or a spectral matrix, wherein the horizontal axis represents frequency values and the vertical axis represents amplitude values, wherein the phase values of the frequency points are angles corresponding to the complex values.
It will be appreciated that the mid-low frequency component is the portion of the sample that has a lower frequency, a longer period of vibration, or a slower change after passing through the low pass filter when the input signal is sampled and converted to discrete samples. The medium and low frequency components may be signals having a larger amplitude or signals having a smaller amplitude. Thus, the amplitude of the mid-low frequency component is not necessarily low, but rather its corresponding frequency is low relative to the frequencies of the other components of the overall input signal.
Step S30: and obtaining the amplitude value and the frequency value of the fundamental frequency point based on the amplitude value of each frequency point of the medium-low frequency band.
It should be noted that, since the fundamental frequency point refers to a fundamental frequency or a lowest frequency component in a signal, the fundamental frequency point generally shows a distinct peak on an energy distribution. On the spectrum or energy spectrum, there is a higher energy concentration at the frequency position corresponding to the fundamental frequency point, forming a prominent peak. Therefore, according to the frequency distribution of the spectrogram, the spectrogram corresponding to each frequency point of the middle-low frequency band can be directly obtained, and according to the amplitude value corresponding to the coordinate axis, the point with the largest amplitude value is the fundamental frequency point.
It will be appreciated that, based on the found position of the fundamental frequency point on the spectrogram, the abscissa of the fundamental frequency point can be determined, where the abscissa corresponds to the frequency value of the fundamental frequency point and the ordinate corresponds to the amplitude value of the fundamental frequency point.
Step S40: and based on the frequency value of the fundamental frequency point, acquiring the position of the frequency multiplication point on a spectrogram, and further determining the phase value and the amplitude value of the frequency multiplication point.
It should be noted that, because the frequency multiplication point and the fundamental frequency point are in integral multiple relation in frequency, when the frequency value of the fundamental frequency point is determined, the frequency value of the frequency multiplication point, the frequency multiplication point or any specific multiple required can be correspondingly determined according to the requirement, and because the frequency spectrogram corresponding to the frequency point, the amplitude value of the ordinate can be determined according to the frequency value corresponding to the abscissa in the coordinate axis, when the frequency value of the frequency multiplication point is known, the amplitude value of the frequency multiplication point can be further determined. Since the phase value and the amplitude value of each frequency point have been determined in advance in the previous step, when the position of the frequency multiplication point on the spectrogram is determined, the phase value of the frequency multiplication point can be directly determined.
Step S50: and processing the phase value and the amplitude value of the frequency multiplication point to obtain an initial harmonic signal.
It should be noted that, based on the frequency value of the fundamental frequency point, the frequency value of the frequency multiplication point is obtained, and the phase value and the amplitude value of the frequency multiplication point are processed, wherein the processed object is the phase value of the frequency multiplication point and the amplitude value of the frequency multiplication point, and the frequency points are adjusted, so that the adjustment of the phase value and the amplitude value is beneficial to the fidelity of the calculation result in the subsequent step and the control of the generated harmonic distortion.
The processing mode of the amplitude value and the phase value of the frequency multiplication point includes operations of replacing, increasing, decreasing, signal transformation and the like of the target value, and the processed data is used as a frequency point characteristic value which participates in calculation subsequently.
It can be understood that the processing manner is replaced data, the physical characteristics of the data are still unchanged, for example, the phase value data of the frequency point is adjusted, the adjustment result is still a phase value, the phase value is used as a new phase value of the frequency point for subsequent calculation and processing, and similarly, the amplitude value of the frequency point is adjusted, and the adjustment result is still an amplitude value.
It should be noted that, the processing result obtained by processing the phase value and the amplitude value of the frequency multiplication point refers to an initial harmonic signal including a fundamental frequency signal, a target harmonic signal and other frequency band signals.
Step S60: and carrying out band-pass filtering on the initial harmonic signal to obtain a target harmonic signal.
It should be noted that, the purpose of the bandpass filtering is to filter out the fundamental frequency signal component and the high frequency signal component that may exist in the initial harmonic signal, and in a specific implementation, according to the characteristic value of the target harmonic signal and the frequency value of the fundamental frequency obtained in the previous step, a device or equipment that performs the bandpass filtering function may be modulated appropriately, so that the harmonic distortion of the target harmonic signal obtained by the bandpass filtering is controlled, so as to improve the quality of the target harmonic signal.
It will be appreciated that the signal type of the target harmonic signal is the same as the signal type of the input signal, for example, when the input signal is an audio signal, the obtained target harmonic signal is still an audio signal after the above steps, that is, the harmonic generation of the method does not change the signal type of the input signal.
In this embodiment, the characteristic value in the sound signal is obtained, the relevant frequency point is determined by the characteristic value, the relevant characteristic value is adjusted, and the target harmonic is obtained through calculation and filtering. The whole process only needs one sampling, simultaneously reduces the calculated amount and time, and improves the real-time performance. The characteristic values participating in calculation are adjusted, so that harmonic distortion can be effectively controlled, harmonic distortion control in harmonic generation is realized, and meanwhile, the real-time performance of harmonic generation is improved.
Example 2:
referring to fig. 3, fig. 3 is a flowchart illustrating an embodiment 2 of a method for generating harmonics of an acoustic signal according to the present invention.
Based on the above embodiment 1, the method for generating harmonics of a sound signal according to the present embodiment, the step S20 includes:
step S201: and carrying out Fourier transform processing on the middle-low frequency components to obtain a frequency domain expression corresponding to the middle-low frequency components.
It should be noted that fourier transform is a mathematical transform that converts a function from the time domain to the frequency domain. By fourier transformation we can decompose a signal into a superposition of sine and cosine functions of a series of different frequencies. Fourier transforms can be used to analyze the spectral characteristics of the signal, from which the frequency components present in the signal and their intensities are derived. This is very useful for many applications such as audio signal processing, image processing, communication systems, etc.
It can be understood that the superposition of a series of sine and cosine functions of different frequencies obtained by fourier transform is the frequency domain expression corresponding to the middle and low frequency components.
Step S202: and obtaining a spectrogram of the middle-low frequency component based on the frequency domain expression corresponding to the middle-low frequency component.
It can be understood that according to the frequency domain expression of the middle-low frequency component, the frequency value is taken as an abscissa axis, the amplitude value is taken as an ordinate, and a spectrogram of the middle-low frequency component can be drawn;
the spectrogram of the middle-low frequency component is represented as a series of discrete points on a coordinate system, and the abscissa value of each point meets the frequency domain expression of the middle-low frequency component.
Step S203: and obtaining the phase value and the amplitude value of each frequency point of the middle and low frequency band based on the spectrogram of the middle and low frequency components.
It should be noted that, each frequency point in the middle-low frequency component includes its own amplitude value and frequency value, the phase value of the frequency point itself is not directly expressed, and can be obtained by a certain calculation, and the following calculation method is given:
let us assume that we have a frequency domain signal X, which consists of N complex values (X0, X1, …, X N-1), where X k represents the amplitude and phase information at the kth frequency point;
first, we can calculate the frequency value of each frequency bin:
frequency value [ k ] =k/n×fs;
wherein k represents an index value (0 < = k < = N-1) of the current frequency point, N represents a total sample number, and Fs represents a sampling rate;
then we can calculate the phase value for each frequency bin:
Phase value [ k ] =atan2 (imag (X [ k ])), real (X [ k ]));
wherein real (Xk) represents the real part of the kth frequency point and imag (Xk) represents the imaginary part of the kth frequency point.
The above exemplary calculation method calculates the phase value of each frequency point in the frequency domain signal, and stores the phase value in the phase value array, where the frequency value of each frequency point corresponds to one phase value.
It can be understood that the ordinate of each frequency point is the amplitude value of the frequency point, and the amplitude value of the frequency point can be directly obtained from the position of the frequency point on the spectrogram.
The process of obtaining the phase value and the amplitude value of the frequency point in the above steps is to obtain the phase value and the amplitude value of each frequency point in the middle and low frequency bands for each frequency point in the middle and low frequency bands.
Example 3:
referring to fig. 4, fig. 4 is a flowchart of an embodiment 3 of a method for generating harmonics of an acoustic signal according to the present invention.
Based on the above embodiment 1, the method for generating harmonics of a sound signal according to the present embodiment, the step S30 includes:
step S301: and arranging the amplitude values of all the frequency points of the middle and low frequency bands to obtain an amplitude value sequence.
It should be noted that, the same amplitude values may appear in the amplitude value sequence to form a parallel arrangement, where the same amplitude values are not in the same order, but are in the same order.
Step S302: and taking the maximum amplitude value in the amplitude value sequence as the amplitude value of the fundamental frequency point.
It should be noted that: this is because the fundamental frequency point is the main component of the periodically repeated signal. For periodic signals, the amplitude of the signal has the greatest shift at the fundamental frequency point and a periodically repeating shape is formed by the superposition of different harmonic components. Therefore, the frequency component corresponding to the fundamental frequency point generally has the highest amplitude.
Step S303: and taking the frequency value of the frequency point corresponding to the maximum amplitude value in the spectrogram as the frequency value of the fundamental frequency point based on the amplitude value of the fundamental frequency point.
It will be appreciated that: in the spectrogram, the amplitude value corresponds to an ordinate, the frequency point corresponding to the maximum amplitude value is the frequency value of the fundamental frequency point, and the corresponding ordinate is the amplitude value of the fundamental frequency point.
Example 4:
referring to fig. 5, fig. 5 is a flowchart of an embodiment 4 of a method for generating harmonics of an acoustic signal according to the present invention.
Based on the above embodiment 1, the method for generating harmonics of a sound signal according to the present embodiment, the step S50 includes:
step S501: and replacing the frequency multiplication point and the amplitude value of the frequency point before and after the frequency multiplication point with the fundamental frequency point and the amplitude value of the frequency point before and after the fundamental frequency point to obtain the amplitude value of the frequency multiplication point after adjustment, the amplitude value of the frequency point before adjustment and the amplitude value of the frequency point after adjustment.
It should be noted that, the previous frequency point amplitude value of the frequency multiplication point is replaced by the previous frequency point amplitude value of the fundamental frequency point, and the next frequency point amplitude value of the frequency multiplication point is replaced by the next frequency point amplitude value of the fundamental frequency point, where the previous frequency point and the next frequency point both refer to a frequency point closest to the corresponding frequency point, for example, no other frequency point exists between the fundamental frequency point and the previous frequency point of the fundamental frequency point.
It should be noted that, the above-mentioned replacement relation of the replacement object is one-to-one correspondence, the amplitude value of the frequency multiplication point is replaced, the result of the replacement is the amplitude value of the fundamental frequency point, the amplitude value of the frequency multiplication point before is replaced, the replacement object is the amplitude value of the frequency multiplication point before is replaced, the amplitude value of the frequency multiplication point after is replaced, and the replacement object is the amplitude value of the frequency multiplication point after is replaced.
Optionally, replacing the frequency point amplitude value of the frequency multiplication point with the frequency point amplitude value of the fundamental frequency point; the amplitude value of the previous frequency point of the frequency doubling point is replaced by the amplitude value of the previous frequency point of the fundamental frequency point; and replacing the amplitude value of the next frequency point of the frequency multiplication point with the amplitude value of the next frequency point of the fundamental frequency point.
Step S502: and adjusting the phase value of the frequency point before and after the frequency multiplication point to obtain the adjusted phase value of the previous frequency point and the adjusted phase value of the next frequency point.
The adjustment of the phase value of the frequency point before and after the frequency point is performed based on the phase change of the frequency point, and the phase values of the frequency point before and after the frequency point are adjusted according to the phase change of the frequency point, so that the phase changes of the frequency point before and after the frequency point are identical to the phase change of the frequency point.
Further, the adjusting the phase value of the frequency point before and after the frequency point to obtain the adjusted phase value of the previous frequency point and the adjusted phase value of the next frequency point includes: acquiring a phase value of a frequency multiplication point in a previous frame, a phase value of a frequency multiplication point before the frequency multiplication point and a phase value of a frequency multiplication point after the frequency multiplication point; acquiring a phase value of a frequency multiplication point in a current frame, a phase value of a frequency point before the frequency multiplication point and a phase value of a frequency point after the frequency multiplication point; subtracting the phase value of the frequency multiplication point in the current frame from the phase value of the frequency multiplication point in the previous frame to obtain a target phase difference value; the result of adding the phase value of the frequency point before the frequency point in the previous frame and the target phase difference value is used as the adjusted synthesized phase value of the frequency point before; and adding the phase value of the frequency point behind the frequency multiplication point in the previous frame and the target phase difference value to obtain a result which is used as the adjusted synthesized phase value of the frequency point behind the frequency multiplication point.
It should be noted that, in the stage of performing fourier transform on the middle-low frequency component, the phase of each frequency point in the middle-low frequency band can be obtained, the obtained phase value can be used as the analysis phase of each frequency point, based on the phase value of each frequency point in the middle-low frequency band, the phase value of the frequency doubling point, the phase value of the frequency point before the frequency doubling point and the phase value of the frequency point after the frequency doubling point in the current frame can be determined, and the expected phase change of each frequency point analysis phase of the current frame signal and each frequency point analysis phase of the previous frame signal at each frequency point is in direct proportion to the index value of the frequency point, that is, the expected phase change is a fixed value; the analysis phase of each frequency point of the current frame signal is correspondingly subtracted from the analysis phase of each frequency point of the previous frame signal, so that the actual phase change of each frequency point can be obtained.
It can be understood that the frequency spectrum leakage causes deviation between the actual phase change and the expected phase change of each frequency point, the actual phase change of each frequency point is subtracted from the expected phase change of each frequency point correspondingly, so that the phase deviation of each frequency point can be obtained, and the phase deviation of each frequency point and the expected phase change of each frequency point are added correspondingly, so that the phase increment of each frequency point can be obtained.
It can be understood that when the signal is restored to the time domain in the synthesis stage, the synthesis phase of each frequency point of the previous frame signal is correspondingly added with the phase increment of each frequency point, so that the synthesis phase of each frequency point of the current frame signal can be obtained, and the analysis phase of the current frame signal at the frequency multiplication point is subtracted from the synthesis phase of the current frame signal at the frequency multiplication point, so that the target phase difference value can be obtained; and respectively adding the analysis phase values of the previous frequency point and the next frequency point of the current frame frequency multiplication point and the target phase difference value to obtain the adjusted synthesis phase value of the previous frequency point and the adjusted synthesis phase value of the next frequency point.
Step S503: and obtaining a frequency point data sequence according to the amplitude value of the adjusted frequency multiplication point, the amplitude value of the adjusted previous frequency point, the amplitude value of the adjusted next frequency point, the phase value of the adjusted previous frequency point and the phase value of the adjusted next frequency point.
The frequency point data is generated according to the amplitude value of the adjusted frequency multiplication point, the amplitude value and the phase value of the adjusted frequency point, the frequency point data comprises the amplitude value and the phase value of the frequency point, and the frequency point data sequences are arranged according to the sequence from low frequency to high frequency, so that the frequency point data sequences are obtained;
it should be understood that the frequency point data sequence at least includes data of the amplitude value of the adjusted frequency doubling point, the amplitude value and the phase value of the frequency point before and after the adjusted frequency doubling point, the phase value of the frequency doubling point, and the phase value and the amplitude value of the base frequency point and the frequency point before and after the base frequency point;
it will be appreciated that the frequency point data sequence has a direct relationship with the number of frequency doubling points, for example, the frequency point data sequence has the following related data for each frequency doubling point: the amplitude value of the adjusted frequency doubling point, the amplitude value of the adjusted previous frequency point, the amplitude value of the adjusted next frequency point, the phase value of the frequency doubling point, the phase value of the adjusted previous frequency point and the phase value of the adjusted next frequency point.
Step S504: and carrying out inverse Fourier transform on the frequency point data sequence to obtain an initial harmonic signal.
It should be noted that, the initial harmonic signal includes a fundamental frequency signal portion, an unnecessary low frequency portion, and a noise signal portion, and may be filtered by signal processing such as filtering, to output a pure target harmonic signal.
In the embodiment, the characteristics of amplitude, phase and the like of the harmonic signals are changed on the signal processing level, so that the sound signals participating in operation are characterized by more balanced frequency spectrum, richer harmonic structures and the like, the quality and the perception effect of the sound signals are improved, and the harmonic distortion is effectively controlled.
Referring to fig. 6, fig. 6 is a block diagram showing the structure of an embodiment 1 of the harmonic generation device for an acoustic signal according to the present invention.
As shown in fig. 6, a harmonic generation device for an acoustic signal according to an embodiment of the present invention includes:
an acquisition module 10 is configured to acquire low-frequency components of the sound signal.
The transformation module 20 is configured to perform a transformation process on the low-frequency component to obtain a phase value and an amplitude value of each frequency point of the low-frequency component.
The obtaining module 10 is further configured to obtain an amplitude value and a frequency value of the base frequency point based on the amplitude value of each frequency point of the middle-low frequency band.
The processing module 30 is configured to obtain a frequency value of a frequency multiplication point based on the frequency value of the fundamental frequency point; and processing the phase value and the amplitude value of the frequency multiplication point to obtain an initial harmonic signal.
The band-pass filtering module 40 is configured to perform band-pass filtering on the initial harmonic signal to obtain a target harmonic signal, so as to obtain a target harmonic signal in the sound signal in high real-time.
In the embodiment, when harmonic generation of a sound signal is performed, middle-low frequency components of the sound signal are acquired; performing transformation processing on the middle-low frequency components to obtain phase values and amplitude values of all frequency points of the middle-low frequency band; obtaining an amplitude value and a frequency value of a base frequency point based on the amplitude value of each frequency point of the medium-low frequency band; obtaining a frequency value of a frequency multiplication point based on the frequency value of the fundamental frequency point; processing the phase value and the amplitude value of the frequency multiplication point to obtain an initial harmonic signal; and carrying out band-pass filtering on the initial harmonic signal to obtain a target harmonic signal so as to obtain the target harmonic signal in the sound signal in high real-time.
In an embodiment, the transforming module 20 is further configured to perform fourier transform processing on the middle-low frequency component to obtain a frequency domain expression corresponding to the middle-low frequency component; obtaining a spectrogram of the middle-low frequency component based on a frequency domain expression corresponding to the middle-low frequency component; and obtaining the phase value and the amplitude value of each frequency point of the middle and low frequency band based on the spectrogram of the middle and low frequency components.
In an embodiment, the obtaining module 10 is further configured to perform size arrangement on the amplitude values of the frequency points of the middle-low frequency band to obtain an amplitude value sequence; taking the maximum amplitude value in the amplitude value sequence as the amplitude value of the fundamental frequency point; and taking the frequency of the frequency point corresponding to the maximum amplitude value as the frequency value of the fundamental frequency point based on the amplitude value of the fundamental frequency point.
In an embodiment, the processing module 30 is further configured to obtain a frequency multiplication point based on the frequency value of the fundamental frequency point; the frequency multiplication point and the amplitude value of the frequency point before and after the frequency multiplication point are replaced by the fundamental frequency point and the amplitude value of the frequency point before and after the fundamental frequency point, and the amplitude value of the frequency multiplication point after adjustment, the amplitude value of the frequency point before adjustment and the amplitude value of the frequency point after adjustment are obtained; adjusting the phase value of the frequency point before and after the frequency multiplication point to obtain the adjusted phase value of the previous frequency point and the adjusted phase value of the next frequency point; obtaining a frequency point data sequence according to the amplitude value of the adjusted frequency multiplication point, the amplitude value of the adjusted previous frequency point and the amplitude value of the adjusted next frequency point, the phase value of the adjusted previous frequency point and the phase value of the adjusted next frequency point; and carrying out inverse Fourier transform on the frequency point data sequence to obtain an initial harmonic signal.
In an embodiment, the processing module 30 is further configured to replace a frequency point amplitude value of the frequency multiplication point with a frequency point amplitude value of the fundamental frequency point; the amplitude value of the previous frequency point of the frequency doubling point is replaced by the amplitude value of the previous frequency point of the fundamental frequency point; and replacing the amplitude value of the next frequency point of the frequency multiplication point with the amplitude value of the next frequency point of the fundamental frequency point.
In an embodiment, the processing module 30 is further configured to obtain a phase value of the frequency multiplication point in the previous frame, a phase value of the frequency multiplication point previous to the frequency multiplication point, and a phase value of the frequency multiplication point next to the frequency multiplication point; acquiring a phase value of a frequency multiplication point in a current frame, a phase value of a frequency point before the frequency multiplication point and a phase value of a frequency point after the frequency multiplication point; subtracting the phase value of the frequency multiplication point in the current frame from the phase value of the frequency multiplication point in the previous frame to obtain a target phase difference value; the result of adding the phase value of the frequency point before the frequency point in the previous frame and the target phase difference value is used as the adjusted synthesized phase value of the frequency point before; and adding the phase value of the frequency point behind the frequency multiplication point in the previous frame and the target phase difference value to obtain a result which is used as the adjusted synthesized phase value of the frequency point behind the frequency multiplication point.
In an embodiment, the acquiring module 10 is further configured to acquire an input signal; and performing low-pass filtering on the input signal to obtain a middle-low frequency component, wherein the middle-low frequency component at least comprises a frequency multiplication point signal component of which the base frequency signal component is adjacent to a base frequency point.
In addition, the embodiment of the present invention also proposes a storage medium having stored thereon a harmonic generation program of a sound signal, which when executed by a processor, implements the steps of the harmonic generation method of a sound signal as described above.
Because the storage medium adopts all the technical schemes of all the embodiments, the storage medium has at least all the beneficial effects brought by the technical schemes of the embodiments, and the description is omitted here.
It should be understood that the foregoing is illustrative only and is not limiting, and that in specific applications, those skilled in the art may set the invention as desired, and the invention is not limited thereto.
It should be noted that the above-described working procedure is merely illustrative, and does not limit the scope of the present invention, and in practical application, a person skilled in the art may select part or all of them according to actual needs to achieve the purpose of the embodiment, which is not limited herein.
In addition, technical details not described in detail in the present embodiment may refer to the method for generating harmonics of a sound signal provided in any embodiment of the present invention, which is not described herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of embodiments, it will be clear to a person skilled in the art that the above embodiment method may be implemented by means of software plus a necessary general hardware platform, but may of course also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) as described above, comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.