CN115083427B - Audio resampling method, audio processing device and storage medium - Google Patents
Audio resampling method, audio processing device and storage medium Download PDFInfo
- Publication number
- CN115083427B CN115083427B CN202210644539.5A CN202210644539A CN115083427B CN 115083427 B CN115083427 B CN 115083427B CN 202210644539 A CN202210644539 A CN 202210644539A CN 115083427 B CN115083427 B CN 115083427B
- Authority
- CN
- China
- Prior art keywords
- initial
- sampling
- audio
- parameters
- sampling frequency
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 69
- 238000012952 Resampling Methods 0.000 title claims abstract description 51
- 238000012545 processing Methods 0.000 title claims abstract description 21
- 238000005070 sampling Methods 0.000 claims abstract description 209
- 238000007667 floating Methods 0.000 claims abstract description 55
- 238000006243 chemical reaction Methods 0.000 claims description 31
- 238000013178 mathematical model Methods 0.000 claims description 23
- 230000007704 transition Effects 0.000 claims description 9
- 238000009825 accumulation Methods 0.000 claims description 7
- 238000013139 quantization Methods 0.000 claims description 7
- 238000004590 computer program Methods 0.000 claims description 5
- 238000004364 calculation method Methods 0.000 abstract description 17
- 230000000694 effects Effects 0.000 abstract description 4
- 230000009286 beneficial effect Effects 0.000 abstract description 3
- 210000005069 ears Anatomy 0.000 abstract description 3
- 230000008901 benefit Effects 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 4
- OCUUDCWEKWOMFA-UHFFFAOYSA-N imidazol-1-yl-dimethyl-propan-2-ylsilane Chemical compound CC(C)[Si](C)(C)N1C=CN=C1 OCUUDCWEKWOMFA-UHFFFAOYSA-N 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 230000002349 favourable effect Effects 0.000 description 2
- 238000001914 filtration Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000013459 approach Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000007493 shaping process Methods 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
- 230000007723 transport mechanism Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G10—MUSICAL INSTRUMENTS; ACOUSTICS
- G10L—SPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
- G10L21/00—Speech or voice signal processing techniques to produce another audible or non-audible signal, e.g. visual or tactile, in order to modify its quality or its intelligibility
- G10L21/003—Changing voice quality, e.g. pitch or formants
- G10L21/007—Changing voice quality, e.g. pitch or formants characterised by the process used
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/70—Reducing energy consumption in communication networks in wireless communication networks
Landscapes
- Engineering & Computer Science (AREA)
- Quality & Reliability (AREA)
- Computational Linguistics (AREA)
- Signal Processing (AREA)
- Health & Medical Sciences (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Human Computer Interaction (AREA)
- Physics & Mathematics (AREA)
- Acoustics & Sound (AREA)
- Multimedia (AREA)
- Compression, Expansion, Code Conversion, And Decoders (AREA)
Abstract
The invention discloses an audio resampling method, audio processing equipment and a storage medium, which are used for improving an audio sampling method based on linear interpolation, and selecting two initial audio samples corresponding to sample selection parameters for resampling a certain target audio sample by calculating the sample selection parameters. Meanwhile, a plurality of sampling weight parameters corresponding to the plurality of sample selection parameters one by one are obtained through calculation under the decimal-based method. In an actual processor operation, a plurality of sampling weight parameters obtained by a decimal method are processed in the form of integers, so that floating point operation is converted into fixed point operation. Compared with the traditional hardware, the audio resampling method provided by the embodiment of the invention reduces the calculated amount by a plurality of times by adopting a filter, ensures that the sound quality effect after processing meets the hearing requirement of human ears in actual use, and is beneficial to being applied to the small embedded system to reduce the cost.
Description
Technical Field
The present invention relates to the field of audio sampling technologies, and in particular, to an audio resampling method, an audio processing device, and a storage medium.
Background
In a multimedia audio/video system, it is sometimes necessary to resample audio to output, and resample input audio at one frequency to audio at another frequency to output. Resampling techniques are processes from one set of digital signals to another set of digital signals and may be implemented in specialized hardware. At present, signal acquisition instruments put into use in China all have resampling functions realized by a hardware method. The vibration signal is obtained by the sensor, and is subjected to low-pass filtering by the filter circuit and then is subjected to digital extraction by the hardware circuit. This approach, which relies on hardware filtering decimation, is inflexible and expensive to use. Meanwhile, the current software method is adopted to carry out audio resampling, and for a small embedded system, the CPU (Central processing Unit) has very limited computing resources, for example, the running frequency of the CPU of some small embedded devices is very low, and the audio resampling cannot be carried out.
Disclosure of Invention
The present invention aims to solve at least one of the technical problems existing in the prior art. Therefore, the invention provides an audio resampling method, which solves the problems that the current audio resampling is inflexible to use, expensive in price and difficult to apply to a small embedded system by means of software due to the fact that the current audio resampling is dependent on hardware.
The present invention also provides a computer readable storage medium for performing the above-described audio processing apparatus and audio resampling method.
An audio resampling method according to an embodiment of the first aspect of the invention, the method comprising:
acquiring an initial sampling frequency and a plurality of initial audio samples, wherein the initial audio samples represent samples obtained by audio sampling at the initial sampling frequency;
determining the number of target audio samples according to the initial sampling frequency, the number of initial audio samples and a preset target sampling frequency, wherein the target audio samples represent samples determined according to the target sampling frequency;
obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters corresponding to the sampling weight parameters one by one according to the initial sampling frequency, the number of the target audio samples and the target sampling frequency, wherein each sampling weight parameter represents the weight of the initial audio sample required by the corresponding target audio sample, and the sample selection parameters represent the serial numbers of the initial audio samples;
and obtaining a plurality of target audio samples according to a plurality of sampling weight parameters, a plurality of sample selection parameters and a plurality of initial audio samples.
The audio resampling method provided by the embodiment of the invention has at least the following beneficial effects:
the embodiment of the invention improves the audio sampling method based on linear interpolation, and particularly determines the relation among parameters according to the initial sampling frequency, the number of target audio samples and the target sampling frequency, and calculates and obtains a plurality of sample selection parameters under the integer-based method by taking a formula as a constraint, wherein the sample selection parameters represent the serial numbers of the initial audio samples. Thus, the sample selection parameters are calculated, so that two initial audio samples corresponding to the sample selection parameters are selected for resampling for a certain target audio sample. Meanwhile, under the decimal-based method, a plurality of sampling weight parameters corresponding to a plurality of sample selection parameters one by one are obtained through calculation according to the same formula. Specifically, in an actual processor operation, a plurality of sampling weight parameters obtained by the decimal method are processed in the form of integers, so that floating point operation is converted into fixed point operation. For a small embedded system incapable of floating point operation, the calculated amount of the audio resampling method is only 10M to 20M DMIPS, and compared with the calculated amount of 100M DMIPS for the audio resampling of a filter adopted in a traditional hardware mode, the method has the advantage that the processing requirement on a CPU is remarkably reduced. The CPU calculation amount is reduced, the sound quality effect after the audio resampling can be well ensured, and the hearing requirement of human ears in the use of actual products can be met, so that the method is favorable for being well applied to a small embedded system, and the design cost of the products is reduced.
According to some embodiments of the invention, the plurality of target audio samples are constrained by a first relational mathematical model of:
X=(x 0 ,x 1 ,…,x n ),
Y=(y 0 ,y 1 ,…,y m ),
wherein X represents a plurality of the initial audio samples, Y represents a plurality of the target audio samples, n represents the number of the initial audio samples, m represents the number of the target audio samples, Y i Represents the ith said target audio sample, coe i Representing the ith said sampling weight parameter,represents the a i Initial audio sample, ++>Represents the b th i A initial audio samples, a i And b i Representing two adjacent ones of said sample selection parameters.
According to some embodiments of the present invention, the obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters according to the initial sampling frequency, the number of target audio samples, and the target sampling frequency includes the following steps:
obtaining a plurality of floating conversion parameters according to the initial sampling frequency, the number of the target audio samples and the target sampling frequency;
and taking a decimal part and an integer part of each floating conversion parameter respectively to obtain a plurality of sampling weight parameters and a plurality of sample selection parameters which are in one-to-one correspondence.
According to some embodiments of the invention, the plurality of floating conversion parameters, the plurality of sampling weight parameters, the plurality of sample selection parameters are each constrained by a second relational mathematical model:
μ i =(i×f x )/f y ,
coef i =frac(μ i ),
a i =int(μ i ),
wherein f x Representing the initial sampling frequency, f y Represents the target sampling frequency, mu i Representing the ith said floating transition parameter, coef i Represents the i-th said sampling weight parameter, frac (μ i ) Representing the taking of the decimal fraction, int (mu) of the ith said floating transition parameter i ) Representing the integer part of the ith floating conversion parameter.
According to some embodiments of the invention, the taking the fractional part and the integer part for each of the floating conversion parameters to obtain a plurality of the sampling weight parameters and a plurality of the sample selection parameters in a one-to-one correspondence includes the steps of:
setting initial values of the sampling weight parameter and the sample selection parameter to be 0;
calculating to obtain a first sampling weight parameter and a first sample selection parameter according to the second relation mathematical model;
based on the accumulation operation, and according to the first sampling weight parameter and the first sample selection parameter, a plurality of sampling weight parameters and a plurality of sample selection parameters are sequentially obtained.
According to some embodiments of the invention, the initial sampling frequency and the target sampling frequency are both binary floating point numbers, and the first sampling weight parameter and the first sample selection parameter are obtained through calculation according to the second relational mathematical model, including the following steps:
performing shift operation of shifting the initial sampling frequency by k bits to obtain a quantized sampling frequency, wherein k represents quantization precision;
converting the quantized sampling frequency into an overlength integer and dividing the overlength integer by the target sampling frequency to obtain integer floating integer conversion parameters;
performing shift operation of shifting k bits to the integer floating conversion parameter to obtain the sample selection parameter of the integer;
decimal number 2 k -1 converting into binary numbers to obtain decimal place-taking codes;
and performing AND operation on the integer floating integer conversion parameter and the decimal place-taking code to obtain the sampling weight parameter of the integer.
According to some embodiments of the invention, the step of sequentially obtaining a plurality of the sampling weight parameters and a plurality of the sample selection parameters based on the accumulation operation and according to the first sampling weight parameter and the first sample selection parameter comprises the steps of:
accumulating i of the first sample selection parameters to obtain a first temporary value;
accumulating the i first sampling weight parameters to obtain a second temporary value;
if the second temporary value is smaller than 1, taking the first temporary value as an ith sampling weight parameter, and taking the second temporary value as the ith sampling weight parameter;
if the second temporary value is greater than 1, adding the integer part of the second temporary value to the first temporary value to obtain a third temporary value, taking the decimal part of the second temporary value to obtain a fourth temporary value, taking the third temporary value as the ith sampling weight parameter, and taking the fourth temporary value as the ith sampling weight parameter.
According to some embodiments of the invention, the obtaining the number of target audio samples according to the initial sampling frequency, the number of initial audio samples, and the target sampling frequency includes the steps of:
obtaining a quantity offset value of the target audio sample according to a third relation mathematical model;
rounding down the number offset value to obtain the number of target audio samples;
wherein the third relational mathematical model is:
m′=(n×f y )/f x ,
wherein m' represents the number offset value, n represents the number of initial audio samples, f x Representing the initial sampling frequency, f y Representing the target sampling frequency.
An audio processing device according to an embodiment of the second aspect of the present invention comprises a memory, a processor and a computer program stored on the memory and executable on the processor, which processor, when executing the computer program, implements an audio resampling method as described in the embodiment of the first aspect. The audio processing device adopts all the technical schemes of the audio resampling method of the above embodiment, so that the audio processing device has at least all the beneficial effects brought by the technical schemes of the above embodiment.
A computer readable storage medium according to an embodiment of the third aspect of the present invention stores computer executable instructions for performing the audio resampling method as described in the embodiment of the first aspect. Since the computer-readable storage medium adopts all the technical solutions of the audio resampling method of the above embodiments, it has at least all the advantageous effects brought by the technical solutions of the above embodiments.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the invention will become apparent and may be better understood from the following description of embodiments taken in conjunction with the accompanying drawings in which:
FIG. 1 is a flow chart of an audio resampling method according to an embodiment of the invention;
FIG. 2 is a flow chart of obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters according to an embodiment of the present invention;
FIG. 3 is a flow chart of taking a fractional part and an integer part for each floating transition parameter to obtain a plurality of sampling weight parameters and a plurality of sample selection parameters in accordance with an embodiment of the present invention;
FIG. 4 is a flow chart of a calculation to obtain a first sample weight parameter and a first sample selection parameter in accordance with an embodiment of the present invention;
FIG. 5 is a flow chart of obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters based on an accumulation operation according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention.
In the description of the present invention, the description of first, second, etc. is for the purpose of distinguishing between technical features only and should not be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, it should be understood that the direction or positional relationship indicated with respect to the description of the orientation, such as up, down, etc., is based on the direction or positional relationship shown in the drawings, is merely for convenience of describing the present invention and simplifying the description, and does not indicate or imply that the apparatus or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as limiting the present invention.
In the description of the present invention, unless explicitly defined otherwise, terms such as arrangement, installation, connection, etc. should be construed broadly and the specific meaning of the terms in the present invention can be determined reasonably by a person skilled in the art in combination with the specific content of the technical solution.
The following description of the embodiments of the present invention will be made with reference to the accompanying drawings, in which it is apparent that the embodiments described below are some, but not all embodiments of the invention.
Referring to fig. 1, a flowchart of an audio resampling method according to an embodiment of the invention is shown, and the audio resampling method includes, but is not limited to, the following steps:
step S100, obtaining an initial sampling frequency and a plurality of initial audio samples, and determining a target sampling frequency, wherein the initial audio samples represent samples obtained by audio sampling under the initial sampling frequency, and the target sampling frequency represents sampling frequencies required by audio resampling;
it is understood that audio sampling refers to discrete sampling of a continuous analog signal to obtain a digital signal for ease of digital signal processing. A section of audio is sampled at an initial sampling frequency to obtain a plurality of initial audio samples, and audio resampling is carried out on the basis of the initial audio samples, so that a required sampling frequency, namely a target sampling frequency, needs to be determined. Thus, to obtain the target audio sample after audio resampling, under the conventional linear interpolation based method, three known quantities are first obtained: an initial sampling frequency, a plurality of initial audio samples, a target sampling frequency. Meanwhile, the audio resampling method of the embodiment of the invention is typically applied to the situation that the target sampling frequency is smaller than the initial sampling frequency, namely, the high sampling frequency is changed into the low sampling frequency.
Step S200, according to the initial sampling frequency, the number of initial audio samples and the target sampling frequency, the number of target audio samples is obtained, and the target audio samples represent samples determined according to the target sampling frequency;
since the initial sampling frequency, the plurality of initial audio samples, and the target sampling frequency are obtained in step S100, the number of the obtained target audio samples may be calculated according to the relationship between the three, that is, it may be determined how many target audio samples may be obtained at the target sampling frequency at the time of audio resampling.
Step S300, according to the initial sampling frequency, the number of target audio samples and the target sampling frequency, obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters corresponding to the sampling weight parameters one by one, wherein each sampling weight parameter represents the weight of the initial audio sample required by the corresponding target audio sample, and the sample selection parameters represent the serial numbers of the initial audio samples;
it should be noted that, for the conventional linear interpolation algorithm to perform audio resampling, when the first target audio sample is obtained, two initial audio samples that are initially adjacent are first used for calculation, and when the subsequent target audio samples are calculated, two adjacent initial audio samples are sequentially selected according to the sequence numbers for calculation. In step S300 of the embodiment of the present invention, instead of sequentially selecting two adjacent initial audio samples for calculation, a sample selection parameter is calculated and obtained according to the relation constraint of the initial sampling frequency, the number of target audio samples, and the target sampling frequency, and one initial audio sample is determined and another initial audio sample adjacent to the initial audio sample is simultaneously selected according to the sequence number of the initial audio sample represented by the sample selection parameter, and meanwhile, a plurality of sampling weight parameters corresponding to the plurality of sample selection parameters one by one can be obtained according to the relation constraint of the initial sampling frequency, the number of the target audio samples, and the target sampling frequency, and the sampling weight parameters can be understood as being equivalent to the weight coefficients in the linear interpolation algorithm. Thus, the calculated sampling weight parameters and sample selection parameters provide a prerequisite for subsequent calculations to obtain a plurality of target audio samples.
Step S400, obtaining a plurality of target audio samples according to a plurality of sampling weight parameters, a plurality of sample selection parameters and a plurality of initial audio samples.
It can be understood that, based on step S300, for a certain target audio sample, the two adjacent initial audio samples and the proportion weights occupied by the two adjacent initial audio samples are determined, that is, according to the sampling weight parameter and the sample selection parameter, the proportion weights can be obtained by calculation using the related formulas of audio resampling. Further, with the plurality of initial audio samples, a plurality of target audio samples may be calculated accordingly.
According to the audio resampling method, an audio sampling method based on linear interpolation is improved, specifically, according to an initial sampling frequency, the number of target audio samples and the target sampling frequency, the relation among parameters is determined, a formula is used as a constraint, a plurality of sample selection parameters are obtained through calculation based on an integer method, and the sample selection parameters represent sequence numbers of the initial audio samples. Thus, the sample selection parameters are calculated, so that two initial audio samples corresponding to the sample selection parameters are selected for resampling for a certain target audio sample. Meanwhile, under the decimal-based method, a plurality of sampling weight parameters corresponding to a plurality of sample selection parameters one by one are obtained through calculation according to the same formula. Specifically, in an actual processor operation, a plurality of sampling weight parameters obtained by the decimal method are processed in the form of integers, so that floating point operation is converted into fixed point operation. For a small embedded system incapable of floating point operation, the calculated amount of the audio resampling method is only 10M to 20M DMIPS, and compared with the calculated amount of 100M DMIPS for the audio resampling of a filter adopted in a traditional hardware mode, the method has the advantage that the processing requirement on a CPU is remarkably reduced. The CPU calculation amount is reduced, the sound quality effect after the audio resampling can be well ensured, and the hearing requirement of human ears in the use of actual products can be met, so that the method is favorable for being well applied to a small embedded system, and the design cost of the products is reduced.
In some embodiments of the invention, the plurality of target audio samples are constrained by a first relational mathematical model of:
X=(x 0 ,x 1 ,…,x n ),
Y=(y 0 ,y 1 ,…,y m ),
wherein X represents a plurality of initial audio samples, Y represents a plurality of target audio samples, n represents the number of initial audio samples, m represents the number of target audio samples, Y i Represents the i-th target audio sample, coe i Representing the i-th sampling weight parameter,represents the a i Initial audio sample, ++>Represents the b th i A initial audio samples, a i And b i Representing two adjacent sample selection parameters.
It will be appreciated that, according to the first relational mathematical model, it can be seen that for one target audio sample, it is obtained by adding two adjacent initial audio samples in the proportion allocated by the sampling weight parameter, respectively, and for two adjacent initial audio samples, the selection is made according to the sample selection parameter, wherein the target audio sample, the initial audio sample, and the sample selection parameter correspond to each other.
In some embodiments of the present invention, as shown in fig. 2, according to an initial sampling frequency, a number of target audio samples, and a target sampling frequency, a plurality of sampling weight parameters and a plurality of sample selection parameters are obtained in a one-to-one correspondence, including the steps of:
step S310, obtaining a plurality of floating conversion parameters according to the initial sampling frequency, the number of target audio samples and the target sampling frequency;
step S320, taking the decimal part and the integer part of each floating conversion parameter respectively to obtain a plurality of sampling weight parameters and a plurality of sample selection parameters which are in one-to-one correspondence.
It will be appreciated that the plurality of sampling weight parameters and the plurality of sample selection parameters, which are in one-to-one correspondence, are calculated from the initial sampling frequency, the number of target audio samples, and the target sampling frequency under the same relationship. Specifically, first, an intermediate-amount floating conversion parameter is calculated, a sampling weight parameter is obtained by taking a decimal part of the floating conversion parameter, and a sample selection parameter is obtained by taking an integer part of the floating conversion parameter. For the conventional linear interpolation algorithm, the proportion of the target audio sample to the initial audio sample and the sequence numbers of the two selected adjacent initial audio samples are irrelevant, so that the audio resampling method of the embodiment of the invention obviously improves the linear interpolation algorithm and enhances the correlation degree during audio resampling to a certain extent.
In some embodiments of the invention, the plurality of floating transition parameters, the plurality of sampling weight parameters, the plurality of sample selection parameters are each constrained by a second relational mathematical model of:
μ i =(i×f x )/f y ,
coef i =frac(μ i ),
a i =int(μ i ),
wherein f x Represents the initial sampling frequency, f y Represents the target sampling frequency, mu i Representing the ith floating transition parameter, coef i Represents the i-th sampling weight parameter, frac (μ i ) Representing the taking of the decimal fraction, int (μ) for the ith floating transition parameter i ) Representing the integer part of the ith floating transition parameter.
It will be appreciated that the above formula is a representation of step S310 and step S320 in a specific mathematical relationship, so that a plurality of sampling weight parameters and a plurality of sample selection parameters, which are in one-to-one correspondence, can be calculated by the above formula.
In some embodiments of the present invention, as shown in fig. 3, taking a fractional part and an integer part for each floating conversion parameter, respectively, to obtain a plurality of sampling weight parameters and a plurality of sample selection parameters in a one-to-one correspondence, includes the steps of:
step S321, setting initial values of sampling weight parameters and sample selection parameters to be 0;
step S322, calculating and obtaining a first sampling weight parameter and a first sample selection parameter according to a second relation mathematical model;
step S323, based on the accumulation operation, sequentially obtains a plurality of sampling weight parameters and a plurality of sample selection parameters according to the first sampling weight parameter and the first sample selection parameter.
It will be appreciated that according to a second relational mathematical model: mu (mu) i =(i×f x )/f y It can be seen that the calculation in the formula is a multiply-divide calculation, and in practice, the efficiency of the CPU of the embedded system in processing the multiply calculation is relatively worse than that in processing the add, so that it is necessary to convert the multiply operation into the add operation as much as possible at the time of compiling. For calculating each sampling weight parameter and each sample selection parameter, the embodiment of the invention firstly calculates the first floating conversion parameter, namely mu 1 To obtain a first sampling weight parameter and a first sample selection parameter, i.e. coef 1 And a 1 The method comprises the steps of carrying out a first treatment on the surface of the And for each subsequent sampling weight parameter and each sample selection parameter, the sampling weight parameters and the sampling selection parameters are obtained successively in an accumulation mode, so that multiplication operation is converted into addition operation, and the processing efficiency of the processor is improved to a certain extent.
In some embodiments of the present invention, as shown in fig. 4, the initial sampling frequency and the target sampling frequency are both binary floating point numbers, and the first sampling weight parameter and the first sample selection parameter are obtained by calculation according to the second relational mathematical model, which comprises the following steps:
step S3221, performing shift operation of shifting the initial sampling frequency by k bits to obtain a quantized sampling frequency, wherein k represents quantization accuracy;
step S3222, converting the quantized sampling frequency into an overlength integer and dividing the overlength integer by the target sampling frequency to obtain integer floating integer conversion parameters;
step S3223, shift operation of shifting k bits to the integer floating conversion parameter is carried out to obtain the integer sample selection parameter;
step S3224, decimal number 2 k -1 converting into binary numbers to obtain decimal place-taking codes;
in step S3225, the integer floating conversion parameter and the decimal place-taking code are and-operated to obtain the integer sampling weight parameter.
It will be appreciated that in practice, some processors may process high-level languages, such as C language, whose data may be binary floating point numbers, and for miniaturized embedded systems, binary floating point numbers cannot be processed, so that the CPU of the miniaturized embedded system may perform data processing by converting the binary floating point numbers into binary integers.
Specifically, taking quantization precision of 14bits as an example, shifting the initial sampling frequency of a binary floating point number to the left by 14bits, namely shifting the 14-bit decimal part from high to low in the initial sampling frequency to an integer, so as to obtain the quantized sampling frequency. For decimal, this is equivalent to a 14 th power of 2 increase in the initial sampling frequency, so the quantization accuracy represents the extent of the quantization size of this process.
Converting the quantized sampling frequency into an overlength integer to remove unquantized low-order decimal places in the original initial sampling frequency, and then according to the formula: mu (mu) 1 =f x /f y And calculating to obtain the floating conversion parameters of the shaping number. The floating conversion parameter of integer numbers is shifted to the right by 14bits, namely, 14-bit decimal numbers shifted to the left after quantization processing are removed, so that integer parts of the floating conversion parameter, namely, sample selection parameters, are obtained.
Decimal number 2 14 -1 is converted into a binary number, in fact a binary number with 14bits all being 1 is obtained, which is taken as a decimal place-taking code, and the last 14bits of the same floating conversion parameter are subjected to AND operation, so that the decimal part of the initial sampling frequency can be obtained. I.e. the sampling weight parameter.
Therefore, according to the above steps, the floating point operation is converted into the fixed point operation for the processor, and the floating point operation can be well applied to a small embedded system which cannot process the floating point operation.
In some embodiments of the present invention, as shown in fig. 5, based on the accumulation operation and according to the first sampling weight parameter and the first sample selection parameter, a plurality of sampling weight parameters and a plurality of sample selection parameters are sequentially obtained, comprising the steps of:
step S3231, accumulating the i first sample selection parameters to obtain a first temporary value;
step S3232, accumulating the i first sampling weight parameters to obtain a second temporary value;
step S3233, if the second temporary value is less than 1, the first temporary value is used as the ith sampling weight parameter, and the second temporary value is used as the ith sampling weight parameter;
in step S3234, if the second temporary value is greater than 1, the integer portion of the second temporary value is added to the first temporary value to obtain a third temporary value, the second temporary value is divided into decimal portions to obtain a fourth temporary value, the third temporary value is used as the i-th sampling weight parameter, and the fourth temporary value is used as the i-th sampling weight parameter.
It will be appreciated that in the case of multiple coefs 1 And a plurality of a 1 When the sampling weight parameters are accumulated to obtain the corresponding sampling weight parameters and sample selection parameters, because the sampling weight parameters and the sample selection parameters are the decimal part and the integer part of the floating conversion parameters, when the accumulated sampling weight parameters are accumulated, when a plurality of decimal accumulated results are larger than 1, the integer part of the sampling weight parameters at the moment is removed, and the integral part is added into the sample selection parameters in a 'carry' mode.
In some embodiments of the present invention, the number of target audio samples is obtained from the initial sampling frequency, the number of initial audio samples, and the target sampling frequency, comprising the steps of:
obtaining a quantity offset value of the target audio sample according to the third relation mathematical model;
rounding down the digital offset value to obtain a number of target audio samples;
wherein the third relational mathematical model is:
m′=(n×f y )/f x ,
where m' represents the number offset value, n represents the number of initial audio samples, f x Represents the initial sampling frequency, f y Representing the target sampling frequency.
It will be appreciated that since the sampling frequency may be in fractional part, an estimate of the number of target audio samples, i.e., a number offset value, is first determined using a third relational mathematical model, and then the number offset value is rounded down to determine the final number of samples for the target sampling frequency.
In some embodiments of the invention, the sample selection parameter b i And sample selection parameter a i The relationship between is constrained by the following fourth relationship mathematical model:
where n represents the number of initial audio samples.
It will be appreciated that the fourth relational mathematical model represents the selection of parameter b for the sample i And sample selection parameter a i Is two adjacent sample selection parameters, and when a is calculated i When the number is equal to the initial number of audio samples, a is selected correspondingly i = i Two initial audio samples of =.
In addition, an embodiment of the present invention also provides an audio processing apparatus, the control device including: memory, a processor, and a computer program stored on the memory and executable on the processor. The processor and the memory may be connected by a bus or other means.
The memory, as a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory remotely located relative to the processor, the remote memory being connectable to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The non-transitory software program and instructions required to implement the audio resampling method of the above embodiments are stored in the memory, and when executed by the processor, the audio resampling method of the above embodiments is performed, for example, the method steps S100 to S400 in fig. 1, the method steps S310 to S320 in fig. 2, the method steps S321 to S323 in fig. 3, the method steps S3221 to S3225 in fig. 4, and the method steps S3231 to S3234 in fig. 5 described above are performed.
The above described apparatus embodiments are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Furthermore, an embodiment of the present invention provides a computer-readable storage medium storing computer-executable instructions that are executed by a processor or controller, for example, by one of the processors in the above-described air conditioner embodiment, which may cause the processor to perform the audio resampling method in the above-described embodiment, for example, to perform the method steps S100 to S400 in fig. 1, the method steps S310 to S320 in fig. 2, the method steps S321 to S323 in fig. 3, the method steps S3221 to S3225 in fig. 4, and the method steps S3231 to S3234 in fig. 5 described above.
Those of ordinary skill in the art will appreciate that all or some of the steps, systems, and methods disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of one of ordinary skill in the art without departing from the spirit of the present invention.
Claims (7)
1. A method of audio resampling, the method comprising:
acquiring an initial sampling frequency and a plurality of initial audio samples, wherein the initial audio samples represent samples obtained by audio sampling at the initial sampling frequency;
determining the number of target audio samples according to the initial sampling frequency, the number of initial audio samples and a preset target sampling frequency, wherein the target audio samples represent samples determined according to the target sampling frequency;
obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters corresponding to the sampling weight parameters one by one according to the initial sampling frequency, the number of the target audio samples and the target sampling frequency, wherein each sampling weight parameter represents the weight of the initial audio sample required by the corresponding target audio sample, and the sample selection parameters represent the serial numbers of the initial audio samples;
obtaining a plurality of target audio samples according to a plurality of sampling weight parameters, a plurality of sample selection parameters and a plurality of initial audio samples;
a plurality of the target audio samples are constrained by a first relational mathematical model:
X=(x 0 ,x 1 ,…,x n ),
Y=(y 0 ,y 1 ,…,y m ),
wherein X represents a plurality of the initial audio samples, Y represents a plurality of the target audio samples, n represents the number of the initial audio samples, m represents the number of the target audio samples, Y i Representing the ith said target audio sample, coef i Representing the ith said sampling weight parameter,represents the a i Initial audio sample, ++>Represents the b th i A initial audio samples, a i And b i Representing two adjacent ones of said sample selection parameters;
the method comprises the steps of obtaining a plurality of sampling weight parameters and a plurality of sample selection parameters which are in one-to-one correspondence according to the initial sampling frequency, the number of target audio samples and the target sampling frequency, and comprises the following steps:
obtaining a plurality of floating conversion parameters according to the initial sampling frequency, the number of the target audio samples and the target sampling frequency;
taking a decimal part and an integer part of each floating conversion parameter respectively to obtain a plurality of sampling weight parameters and a plurality of sample selection parameters which are in one-to-one correspondence;
the plurality of floating conversion parameters, the plurality of sampling weight parameters, and the plurality of sample selection parameters are respectively constrained by the following second relational mathematical model:
μ i =(i×f x )/f y ,
coef i =frac(μ i ),
a i =int(μ i ),
wherein f x Representing the initial sampling frequency, f y Represents the target sampling frequency, mu i Representing the ith said floating transition parameter, coef i Represents the i-th said sampling weight parameter, frac (μ i ) Representing the taking of the decimal fraction, int (mu) of the ith said floating transition parameter i ) Representing the integer part of the ith floating conversion parameter.
2. The audio resampling method according to claim 1, wherein said taking a fractional part and an integer part for each of said floating conversion parameters, respectively, to obtain a plurality of said sampling weight parameters and a plurality of said sample selection parameters in a one-to-one correspondence, comprises the steps of:
setting initial values of the sampling weight parameter and the sample selection parameter to be 0;
calculating to obtain a first sampling weight parameter and a first sample selection parameter according to the second relation mathematical model;
based on the accumulation operation, and according to the first sampling weight parameter and the first sample selection parameter, a plurality of sampling weight parameters and a plurality of sample selection parameters are sequentially obtained.
3. The audio resampling method of claim 2, wherein said initial sampling frequency and said target sampling frequency are both binary floating point numbers, and said calculating according to said second relational mathematical model obtains a first sampling weight parameter and a first sample selection parameter, comprising the steps of:
performing shift operation of shifting the initial sampling frequency by k bits to obtain a quantized sampling frequency, wherein k represents quantization precision;
converting the quantized sampling frequency into an overlength integer and dividing the overlength integer by the target sampling frequency to obtain integer floating integer conversion parameters;
performing shift operation of shifting k bits to the integer floating conversion parameter to obtain the sample selection parameter of the integer;
decimal number 2 k -1 converting into binary numbers to obtain decimal place-taking codes;
and performing AND operation on the integer floating integer conversion parameter and the decimal place-taking code to obtain the sampling weight parameter of the integer.
4. The audio resampling method according to claim 2, wherein said adding operation is based on said first sampling weight parameter and said first sample selection parameter to sequentially obtain a plurality of said sampling weight parameters and a plurality of said sample selection parameters, comprising the steps of:
accumulating i of the first sample selection parameters to obtain a first temporary value;
accumulating the i first sampling weight parameters to obtain a second temporary value;
if the second temporary value is smaller than 1, taking the first temporary value as an ith sampling weight parameter, and taking the second temporary value as the ith sampling weight parameter;
if the second temporary value is greater than 1, adding the integer part of the second temporary value to the first temporary value to obtain a third temporary value, taking the decimal part of the second temporary value to obtain a fourth temporary value, taking the third temporary value as the ith sampling weight parameter, and taking the fourth temporary value as the ith sampling weight parameter.
5. The audio resampling method according to claim 1, wherein said obtaining a number of target audio samples from said initial sampling frequency, said number of initial audio samples, said target sampling frequency, comprises the steps of:
obtaining a quantity offset value of the target audio sample according to a third relation mathematical model;
rounding down the number offset value to obtain the number of target audio samples;
wherein the third relational mathematical model is:
m′=(n×f y )/f x ,
wherein m' represents the number offset value, n represents the number of initial audio samples, f x Representing the initial sampling frequency, f y Representing the target sampling frequency.
6. An audio processing apparatus comprising: memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the audio resampling method according to any of the claims 1 to 5 when executing the computer program.
7. A computer readable storage medium storing computer executable instructions for performing the audio resampling method of any one of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210644539.5A CN115083427B (en) | 2022-06-09 | 2022-06-09 | Audio resampling method, audio processing device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210644539.5A CN115083427B (en) | 2022-06-09 | 2022-06-09 | Audio resampling method, audio processing device and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115083427A CN115083427A (en) | 2022-09-20 |
CN115083427B true CN115083427B (en) | 2023-06-16 |
Family
ID=83252148
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210644539.5A Active CN115083427B (en) | 2022-06-09 | 2022-06-09 | Audio resampling method, audio processing device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115083427B (en) |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH0677768A (en) * | 1992-08-25 | 1994-03-18 | Kowa Co | Sampling rate converting method for digital audio data |
JP2010033406A (en) * | 2008-07-30 | 2010-02-12 | Sony Corp | Image processing device, image device, and image processing method |
CN106134514B (en) * | 2010-05-14 | 2013-10-23 | 航天恒星科技有限公司 | Sampling rate converting method based on Farrow Structure Filter and device |
CN104123943B (en) * | 2013-04-28 | 2017-05-31 | 安凯(广州)微电子技术有限公司 | A kind of method and apparatus of audio signal resampling |
CN106972840B (en) * | 2017-02-28 | 2020-05-05 | 深圳市鼎阳科技股份有限公司 | Sampling rate conversion method and device |
CN109889692B (en) * | 2019-02-21 | 2021-05-04 | 无锡中感微电子股份有限公司 | Television signal resampling processing method and device |
CN109976660B (en) * | 2019-02-25 | 2022-08-12 | 安徽白鹭电子科技有限公司 | Random signal sampling rate reconstruction method based on linear interpolation and data sampling system |
CN113630212B (en) * | 2021-08-05 | 2024-03-19 | 深圳市思码逻辑技术有限公司 | Downsampling method and downsampling device for digital signals |
-
2022
- 2022-06-09 CN CN202210644539.5A patent/CN115083427B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN115083427A (en) | 2022-09-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102597948B (en) | The method and apparatus of the block floating point compression of signal data | |
JP4875041B2 (en) | Data compression system and method | |
CN108091166B (en) | Method, device, equipment and storage medium for predicting number change of available parking spaces | |
CN112990438B (en) | Full-fixed-point convolution calculation method, system and equipment based on shift quantization operation | |
CN113783962B (en) | Data acquisition system and method based on edge calculation | |
CN113132723A (en) | Image compression method and device | |
US8593321B2 (en) | Computation apparatus and method, quantization apparatus and method, and program | |
CN115083427B (en) | Audio resampling method, audio processing device and storage medium | |
CN113869599A (en) | Fish epidemic disease development prediction method, system, equipment and medium | |
CN117095685B (en) | Concurrent department platform terminal equipment and control method thereof | |
CN111930673B (en) | Heterogeneous intelligent processing quantization device, quantization method, electronic equipment and storage medium | |
CN112561050B (en) | Neural network model training method and device | |
US20100082717A1 (en) | Computation apparatus and method, quantization apparatus and method, and program | |
CN111383157A (en) | Image processing method and device, vehicle-mounted operation platform, electronic equipment and system | |
CN115188389B (en) | End-to-end voice enhancement method and device based on neural network | |
CN115374989A (en) | Load prediction method, device, equipment and computer readable storage medium | |
CN112152633A (en) | Vibration signal compression method and device | |
CN115034351A (en) | Data processing method, convolutional neural network training method and device and FPGA | |
CN116825130B (en) | Deep learning model distillation method, device, equipment and medium | |
CN117176301B (en) | Digital cyclic sampling coding method and system for medium wave intelligent transmitter | |
CN114413883B (en) | Satellite attitude determination precision improving method, storage medium and electronic equipment | |
CN110764696B (en) | Vector information storage and updating method and device, electronic equipment and storage medium | |
CN115120251A (en) | Electroencephalogram signal self-adaptive compression reconstruction method and device | |
JP4528924B2 (en) | Quantization step parameter initial value determination device, quantization step parameter initial value determination method, and quantization step parameter initial value determination program | |
CN114298306A (en) | Neural network model training and calculating method, electronic device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |