An audio coding method based on dynamic sampling

CN120913573BActive Publication Date: 2026-07-10LINKER

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LINKER
Filing Date
2025-08-06
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing dynamic sampling technology suffers from switching jitter, aliasing distortion, and uneven switching points, resulting in low compression efficiency and degraded sound quality.

Method used

A multi-feature fusion decision mechanism is adopted, which comprehensively analyzes the signal by instantaneous amplitude, short-time energy, short-time average amplitude and short-time zero-crossing rate, dynamically adjusts the sampling rate, and performs adaptive filtering and interpolation processing at the decoding end to smooth the sampling rate switching.

Benefits of technology

It achieves more stable sampling rate switching, improves compression efficiency, ensures the continuity of sound quality and a natural listening experience, reduces the computational burden on encoding equipment, and enhances the robustness and applicability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120913573B_ABST
    Figure CN120913573B_ABST
Patent Text Reader

Abstract

The application discloses an audio coding method based on dynamic sampling. The encoding method comprises the following steps: firstly, the real-time complexity of a signal is accurately judged by comprehensively analyzing the multi-dimensional time domain characteristics of the signal and combining a dynamically updated threshold; then, the current optimal target sampling rate is adaptively determined according to the judgment result; finally, the discretized signal is resampled to generate data segments with different sampling rates, and the data segments are packaged and stored. The decoding method comprises the following steps: when decoding and playing, the switching point of the sampling rate is monitored in real time. When the sampling rate is switched, a reasonable processing window length is adaptively determined, and the data in the window is subjected to smoothing filtering or interpolation processing, so that seamless smooth transition between the data segments with different sampling rates is realized. Through the multi-feature fusion decision and the adaptive smoothing processing at the decoding end, the compression efficiency is effectively improved, the switching jitter and the playing burst noise are avoided, and the audio quality is significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of audio technology, and in particular to an audio encoding and decoding method based on dynamic sampling. Background Technology

[0002] Current mainstream digital audio processing technologies, such as CD quality or formats like MP3 and AAC, typically encode and store audio signals using a fixed sampling rate. While this approach is simple to implement, it has inherent drawbacks: to accommodate the most complex parts of the signal (such as transients or high-frequency overtones in music), a consistently high sampling rate (e.g., 44.1kHz or 48kHz) must be used. However, audio signals often contain a large amount of relatively simple content, such as silence, steady vowels, or low-frequency instrument sounds. Processing this simple content with a high sampling rate results in significant data redundancy, increasing storage and transmission costs.

[0003] To address this issue, the industry has proposed dynamic sampling rate (or variable sampling rate) technology. Its core idea is to dynamically adjust the sampling rate based on the real-time characteristics of the signal: using a high sampling rate for complex parts of the signal and a low sampling rate for simpler parts. However, existing dynamic sampling techniques still suffer from one or more of the following technical problems:

[0004] Switching jitter and sound quality degradation: Early dynamic sampling techniques relied on a single signal feature (such as amplitude threshold) to determine the sampling rate switching. This simple criterion is easily affected by signal energy fluctuations, causing the sampling rate to switch back and forth frequently and unnecessarily near the critical point (i.e., switching jitter). This not only affects compression efficiency but may also introduce audible switching noise, reducing the listening experience.

[0005] Aliasing distortion risk: If effective and high-quality anti-aliasing filtering is not performed during the process of reducing the sampling rate from a high sampling rate to a low sampling rate, the high-frequency components in the original signal will be incorrectly folded into the low-frequency region, resulting in severe aliasing distortion. This distortion is irreversible and will permanently damage the sound quality.

[0006] Unsmooth transition points: During decoding and playback, waveform discontinuities can easily occur at the junctions of data blocks with different sampling rates, resulting in pops / pops. How to smoothly handle these "seams," especially when signal characteristics are complex and variable, is a major challenge for current technologies. Existing solutions typically employ fixed transition methods, lacking adaptability to signal content and struggling to achieve the optimal balance between preserving sound quality and achieving smoothness.

[0007] Therefore, there is an urgent need for a more intelligent and refined dynamic sampling encoding and decoding method that can not only accurately determine the signal complexity to select the appropriate sampling rate, but also perform refined processing at each stage of encoding and decoding, especially at the moment of sampling rate switching, so as to significantly improve compression efficiency while maximizing the subjective and objective quality of audio. Summary of the Invention

[0008] This invention primarily addresses the technical problems of existing technologies, such as switching jitter, aliasing distortion risks, and uneven switching points, by providing an audio encoding and decoding method based on dynamic sampling.

[0009] The present invention addresses the aforementioned technical problems primarily through the following technical solution: an audio encoding and decoding method based on dynamic sampling, comprising an encoding process and a decoding process, wherein the encoding process is as follows:

[0010] S1: Discretize the analog audio signal to obtain a discretized audio signal. Perform time-domain analysis on the discretized audio signal to obtain the instantaneous amplitude A. n Short-term energy E n Short-term average amplitude M n and short-time zero-crossing rate Z n Discretization is essentially a form of sampling, but the sampling frequency is much higher than that of ordinary audio, such as 192kHz.

[0011] S2: Update the short-time energy threshold and short-time zero-crossing rate threshold according to the following formula:

[0012] E th (n) =θE th (n-1) +(1-θ)E n Z th (n) =θZ th (n-1) +(1-θ)Z n ;

[0013] In the formula, E th (n) E is the current short-term energy threshold. th (n-1) Z is the short-time energy threshold of the previous time step. th (n) Z is the current short-time zero-crossing rate threshold. th (n-1) The threshold for the short-term zero-crossing rate at the previous moment is θ, where θ is the forgetting factor.

[0014] S3: The current sampling rate is determined using the following formula:

[0015] ;

[0016] In the formula, f s (n) f is the sampling rate selected at time n. max f mid and f base They represent three sampling rates: high, medium, and basic. th (n) Z is the current short-time energy threshold. th (n) A is the current short-time zero-crossing rate threshold. th M is the instantaneous amplitude threshold. th α is the short-time average amplitude threshold, β is the first adjustment coefficient, γ is the second adjustment coefficient, and γ is the third adjustment coefficient.

[0017] S4: Resample the discretized audio signal according to the sampling rate determined in step S3 to generate a sampled data stream;

[0018] S5: Continuously monitor the sampling rate determined in step S3. When the sampling rate changes, cut the sampled data stream before the change into an audio segment.

[0019] S6: For each audio segment, encode it according to its corresponding sampling rate and encapsulate it into a data frame containing segment markers, sampling rate information, data length, encoded data and check bits; the format of the encoded audio data is: 4 bytes segment marker + 4 bytes sampling rate + 4 bytes encoded data length + several bytes of encoded data + 2 bytes check bits;

[0020] S7: Concatenate all data frames sequentially and add a file header and footer to obtain the final encoded audio file;

[0021] The decoding process involves extracting the data from each segment of the audio file according to the segment markers, and then decoding and playing it according to the corresponding sampling rate.

[0022] Preferably, during the decoding process, when the sampling rate switches from a higher sampling rate f_high to a lower sampling rate f_new, the following processing is performed:

[0023] The last few milliseconds (h milliseconds) of the higher sampling rate audio data and the first few milliseconds (h milliseconds) of the lower sampling rate audio data are input into an anti-aliasing low-pass filter with a cutoff frequency lower than f_new / 2 to obtain the filtered data. The order of the low-pass filter is:

[0024] ;

[0025] In the formula, A_stop is 60dB, A_pass is 1dB, w_stop is 0.5f_new, w_pass is 0.45f_new, and f_new is the lower sampling rate.

[0026] The data length (2h milliseconds) input to the anti-aliasing low-pass filter is determined as follows:

[0027] If the audio data before and after the switching point is a strongly periodic signal, and the fundamental frequency period is T_pitch, then 2h milliseconds is twice T_pitch, that is, data of one fundamental frequency period length is input into the low-pass filter before and after the switching point.

[0028] If the audio data before and after the switching point is a transient signal, then h=1, that is, 1 millisecond of data is input into the low-pass filter before and after the switching point;

[0029] If the audio data before and after the switching point is neither a strongly periodic signal nor a transient signal, then h=10, meaning that 10 milliseconds of data are input into the low-pass filter before and after the switching point.

[0030] By controlling different input lengths for different signal types, sound quality can be preserved to the greatest extent and a smooth sound can be achieved, making it highly adaptable.

[0031] The method for determining strong periodic signals is as follows:

[0032] (1) Framing and windowing: Divide the audio signal x(n) into overlapping frames (e.g., frame length 30ms, overlap 50%); apply a window function (e.g., Hamming window) to each frame to obtain x_w(n).

[0033] (2) Calculate the autocorrelation function: Calculate the autocorrelation function R(τ) of the processed signal frame x_w(n);

[0034] (3) Normalized autocorrelation function: In order to eliminate the influence of energy magnitude on the judgment, the autocorrelation function needs to be normalized. The method is: R'(τ)=R(τ) / R(0);

[0035] Where R(0) is the total energy of the signal frame and also the maximum value of the autocorrelation function, so the range of the normalized R'(τ) is between [-1, 1].

[0036] (4) Finding the optimal candidate period: Within the range of [τ_min, τ_max], find the maximum peak value of the normalized autocorrelation function R'(τ). Let this maximum peak value be R_peak, and its corresponding delay (position) be τ_pitch; for an audio signal with a sampling rate of 48kHz, in order to effectively detect the fundamental frequency of human voice, the lowest frequency of the search range can be set to 60Hz, and the highest frequency can be set to 500Hz, and the corresponding period search range [τ_min, τ_max] (in terms of sampling points) is [96, 800];

[0037] (5) Joint judgment and output: The found maximum peak value R_peak is compared with the preset periodic intensity threshold Th_tonal (e.g., Th_tonal=0.85);

[0038] If R_peak > Th_tonal, then the signal frame is a strongly periodic signal, and the fundamental frequency period is τ_pitch.

[0039] The method for determining transient signals is as follows:

[0040] (1) Divide the audio signal into several very short (no more than 5ms) sub-frames, for example, a 20ms frame of data is further subdivided into 8 2.5ms sub-frames;

[0041] (2) Calculate the energy E_sub(i) of each subframe:

[0042] (3) Find the ratio of the maximum energy subframe to the minimum energy subframe within a frame, E_ratio=max(E_sub) / min(E_sub);

[0043] (4) If E_ratio is greater than the threshold Th_energy_ratio (for example, Th_energy_ratio=100, that is, the instantaneous change in energy exceeds 100 times), then the signal is determined to be a transient signal.

[0044] Preferably, during decoding and playback, when switching from a lower sampling rate f_new to a higher sampling rate f_high, the high-frequency components are recovered by interpolation for the last few milliseconds (g milliseconds) of the audio data at the lower sampling rate:

[0045] ;

[0046] Where R = f_high / f_new is the interpolation factor; S sampled [n] represents the interpolated signal, S original [m] represents the signal before interpolation, and sinc is the normalization function.

[0047] The length of the audio data to be interpolated (in milliseconds) is 10-20 milliseconds.

[0048] Filtering and interpolation are performed on the signal only during decoding, not during encoding. This is mainly to avoid sudden jumps in the signal when the sampling rate changes. Filtering and interpolation actually replace a portion of the data, making the transition when the signal sampling rate changes more smoothly.

[0049] Preferably, the high sampling rate is 48kHz, the medium sampling rate is 44.1kHz, and the basic sampling rate is 24kHz.

[0050] Preferably, in step S1, the instantaneous amplitude is calculated as follows: The continuous signal s(t) is discretized into s[m], and the signal envelope is extracted using Hilbert transform:

[0051] ;

[0052] Where H{s(t)} is defined as:

[0053] ;

[0054] For convolution operation; PV represents Cauchy principal value, used to handle singularities of the integral at τ=t, and the kernel function 1 / πt is the impulse response of the Hilbert transform.

[0055] As a preferred option, the instantaneous amplitude threshold A th and short-time average amplitude threshold M th Through global analysis, the first adjustment coefficient α was determined to be 1.5, the second adjustment coefficient β to be 0.8, and the third adjustment coefficient γ to be 2.0.

[0056] As a preferred option, the forgetting factor θ is 0.9.

[0057] The substantial effects of this invention are: (1) accurate decision-making, stable switching, and higher compression efficiency: This invention adopts a multi-feature fusion decision-making mechanism, which analyzes the signal by comprehensively considering four dimensions: instantaneous amplitude, short-time energy, short-time average amplitude, and short-time zero-crossing rate. Compared with schemes that rely on a single feature, it can more accurately identify different types of audio content such as transient, strong periodic (stable strong signal), and silence. Combined with dynamically updated thresholds, it effectively avoids sampling rate jitter caused by temporary fluctuations in signal energy, making the switching of the sampling rate more stable and reasonable, thereby achieving higher compression efficiency while ensuring sound quality.

[0058] (2) Adaptive smoothing at the decoding end for higher sound fidelity: This invention performs adaptive length smoothing processing on the switching point at the decoding end according to the signal type. By determining in real time whether the signal near the switching point is strongly periodic, transient, or other types, the window length of filtering or interpolation is dynamically adjusted (for example, an integer multiple of the fundamental frequency period is used for periodic signals, and an extremely short length is used for transient signals). Compared with a fixed-length transition scheme, this processing method can ensure the continuity of phase when processing stable signals and avoid blurring the sharpness of transient signals, thereby preserving the original sound quality to the greatest extent and achieving a seamless and natural listening experience.

[0059] (3) Simplified encoding, flexible decoding, balancing efficiency and quality: This invention places the complex tasks of anti-aliasing filtering and smooth transition at the decoding end, simplifying the encoding process and reducing the computational burden on encoding devices (especially real-time encoding devices). At the decoding end, smoothing algorithms of different complexities can be selected according to the processing capabilities of the playback device and the user's requirements for sound quality. This design philosophy of "simplified encoding and optimized decoding" provides high flexibility and scalability for implementing dynamic sampling technology on platforms with different performance levels.

[0060] (4) Improved robustness and applicability of the system: By introducing adaptive threshold updates and adaptive processing based on signal content, this invention has good adaptability to audio signals (such as speech, music, and ambient sound) from different sources and with different dynamic ranges. The system can automatically track the long-term statistical characteristics of the signal without the need for manual parameter adjustments for specific audio, which greatly improves the robustness and universality of the method. Attached Figure Description

[0061] Figure 1 This is a flowchart of an audio encoding process based on dynamic sampling according to the present invention. Detailed Implementation

[0062] The technical solution of the present invention will be further described in detail below through embodiments and in conjunction with the accompanying drawings.

[0063] Example: An audio encoding and decoding method based on dynamic sampling, including an encoding process and a decoding process, such as... Figure 1 As shown, the encoding process is as follows:

[0064] S1: Discretize the analog audio signal to obtain a discretized audio signal. Perform time-domain analysis on the discretized audio signal to obtain the instantaneous amplitude A. n Short-term energy E n Short-term average amplitude M n and short-time zero-crossing rate Z nDiscretization is essentially a form of sampling, but the sampling frequency is much higher than that of ordinary audio.

[0065] S2: Update the short-time energy threshold and short-time zero-crossing rate threshold according to the following formula:

[0066] E th (n) =θE th (n-1) +(1-θ)E n Z th (n) =θZ th (n-1) +(1-θ)Z n ;

[0067] In the formula, E th (n) E is the current short-term energy threshold. th (n-1) Z is the short-time energy threshold of the previous time step. th (n) Z is the current short-time zero-crossing rate threshold. th (n-1) The threshold value for the short-term zero-crossing rate at the previous moment is θ, and θ is the forgetting factor (θ=0.9). This step can avoid the insensitivity of a fixed threshold to the dynamic range of the signal.

[0068] S3: The current sampling rate is determined using the following formula:

[0069] ;

[0070] In the formula, f s (n) f is the sampling rate selected at time n. max f mid and f base The sampling rates are high (48kHz), medium (44.1kHz), and basic (24kHz), respectively. th (n) Z is the current short-time energy threshold. th (n) A is the current short-time zero-crossing rate threshold. th M is the instantaneous amplitude threshold. th The short-time average amplitude threshold is defined by α as the first adjustment coefficient, β as the second adjustment coefficient, and γ as the third adjustment coefficient. High sampling rate: both energy and zero-crossing rate are high (transient signal), or the amplitude exceeds the threshold (avoid clipping). Medium sampling rate: the amplitude is high but the zero-crossing rate is low (stable strong signal). Basic sampling rate: low energy, low amplitude, or silent segment.

[0071] S4: Resample the discretized audio signal according to the sampling rate determined in step S3 to generate a sampled data stream;

[0072] S5: Continuously monitor the sampling rate determined in step S3. When the sampling rate changes, cut the sampled data stream before the change into an audio segment.

[0073] S6: For each audio segment, encode it according to its corresponding sampling rate and encapsulate it into a data frame containing segment markers, sampling rate information, data length, encoded data and check bits; the format of the encoded audio data is: 4 bytes segment marker + 4 bytes sampling rate + 4 bytes encoded data length + several bytes of encoded data + 2 bytes check bits;

[0074] S7: Concatenate all data frames sequentially and add a file header and footer to obtain the final encoded audio file;

[0075] The encoding process after dynamic sampling requires segmented encoding, and the encoding format can be any existing encoding format (such as MP3, AAC, etc.). The dynamically sampled audio data can be viewed as audio frames, with each frame potentially having a different sampling rate. During encoding, the TAG markers need to be identified first, the data of the current frame needs to be read, and then encoded using traditional encoding methods. Finally, the segmented encoded audio data is assembled into a single file, resulting in a dynamically sampled audio encoded file.

[0076] The decoding process involves extracting the data from each segment of the audio file according to the segment markers, and then decoding and playing it according to the corresponding sampling rate.

[0077] For analog audio signals, taking a recording of human voice as an example, the audio signal produced when a person is speaking fluctuates more and more frequently, while the audio signal produced when a person is not speaking is relatively flat. Based on these two different situations, high-frequency sampling (such as 44100Hz, 48000Hz or higher) can be used for audio segments with large and dense signal fluctuations, while low-frequency sampling (such as 22050Hz, 24000Hz or lower) can be used for audio segments with small and flat signal fluctuations.

[0078] This requires time-domain analysis of the audio analog signal. The characteristics of the signal in the time domain can more directly analyze the changes in the audio waveform signal. The analysis mainly focuses on the characteristics of the signal such as instantaneous amplitude, short-time energy, short-time average amplitude, and short-time zero-crossing rate to capture the changes in the audio signal.

[0079] The instantaneous amplitude directly reflects the instantaneous value of the signal amplitude and is calculated as follows: The continuous signal s(t) is discretized into s[m], and the signal envelope is extracted using the Hilbert transform:

[0080] ;

[0081] Where H{s(t)} is defined as:

[0082] ;

[0083] For convolution operation; PV represents Cauchy principal value, used to handle singularities of the integral at τ=t, and the kernel function 1 / πt is the impulse response of the Hilbert transform.

[0084] Instantaneous amplitude threshold A th and short-time average amplitude threshold M th Global analysis determined that the first adjustment coefficient α is 1.5, the second adjustment coefficient β is 0.8, and the third adjustment coefficient γ is 2.0.

[0085] In regions where amplitude changes rapidly (such as musical percussion transients), increase the sampling rate to reduce distortion, and in stable regions, decrease the sampling rate to save resources.

[0086] Short-time energy can be used to represent the magnitude of a speech signal and suprasegmental information, and is calculated as follows:

[0087] ;

[0088] Where h(n) = ω(n) 2 E n This represents the short-time energy when a window function is applied starting at the nth point of the signal. The Hamming window is chosen as the window function here.

[0089] ;

[0090] If we use X w Let x(n) represent the signal after windowing, where the length of the window function is N. The short-time energy can be expressed as:

[0091] ;

[0092] Short-time energy calculations and analysis can determine information such as the magnitude of the current speech signal. However, due to the limitations of short-time energy, a short-time average amplitude value is still needed to measure the current signal change.

[0093] ;

[0094] The above indicators reflect the amplitude of changes in continuous speech signals. To analyze the input speech signal more accurately, an additional analysis method is added: short-time zero-crossing rate. This method is used to determine whether a segment of speech signal has reached the standard for increasing or decreasing the sampling rate. The analysis method for short-time zero-crossing is as follows:

[0095] ;

[0096] Here, the window size is 1 / 2N, meaning the zero-crossing rate is averaged over the window range. Considering that the non-zero range of w(nm) is nm≥0, nm≤N-1, the function can also be rewritten as:

[0097] ;

[0098] The above analysis uses four indicators—instantaneous signal amplitude, short-time energy, short-time average amplitude, and short-time zero-crossing rate—to measure the sampling rate that should be used.

[0099] During decoding, when the sampling rate switches from a higher sampling rate f_high to a lower sampling rate f_new, the following processing is performed:

[0100] The last few milliseconds (h milliseconds) of the higher sampling rate audio data and the first few milliseconds (h milliseconds) of the lower sampling rate audio data are input into an anti-aliasing low-pass filter with a cutoff frequency lower than f_new / 2 to obtain the filtered data. The order of the low-pass filter is:

[0101] ;

[0102] In the formula, A_stop is 60dB, A_pass is 1dB, w_stop is 0.5f_new, w_pass is 0.45f_new, and f_new is the lower sampling rate.

[0103] The data length (2h milliseconds) input to the anti-aliasing low-pass filter is determined as follows:

[0104] If the audio data before and after the switching point is a strongly periodic signal, and the fundamental frequency period is T_pitch, then 2h milliseconds is twice T_pitch, that is, data of one fundamental frequency period length is input into the low-pass filter before and after the switching point.

[0105] If the audio data before and after the switching point is a transient signal, then h=1, that is, 1 millisecond of data is input into the low-pass filter before and after the switching point;

[0106] If the audio data before and after the switching point is neither a strongly periodic signal nor a transient signal, then h=10, meaning that 10 milliseconds of data are input into the low-pass filter before and after the switching point.

[0107] By controlling different input lengths for different signal types, sound quality can be preserved to the greatest extent and a smooth sound can be achieved, making it highly adaptable.

[0108] The method for determining strong periodic signals is as follows:

[0109] (1) Framing and windowing: Divide the audio signal x(n) into overlapping frames (e.g., frame length 30ms, overlap 50%); apply a window function (e.g., Hamming window) to each frame to obtain x_w(n).

[0110] (2) Calculate the autocorrelation function: Calculate the autocorrelation function R(τ) of the processed signal frame x_w(n);

[0111] (3) Normalized autocorrelation function: In order to eliminate the influence of energy magnitude on the judgment, the autocorrelation function needs to be normalized. The method is: R'(τ)=R(τ) / R(0);

[0112] Where R(0) is the total energy of the signal frame and also the maximum value of the autocorrelation function, so the range of the normalized R'(τ) is between [-1, 1].

[0113] (4) Finding the optimal candidate period: Within the range of [τ_min, τ_max], find the maximum peak value of the normalized autocorrelation function R'(τ). Let this maximum peak value be R_peak, and its corresponding delay (position) be τ_pitch; for an audio signal with a sampling rate of 48kHz, in order to effectively detect the fundamental frequency of human voice, the lowest frequency of the search range can be set to 60Hz, and the highest frequency can be set to 500Hz, and the corresponding period search range [τ_min, τ_max] (in terms of sampling points) is [96, 800];

[0114] (5) Joint judgment and output: The found maximum peak value R_peak is compared with the preset periodic intensity threshold Th_tonal (e.g., Th_tonal=0.85);

[0115] If R_peak > Th_tonal, then the signal frame is a strongly periodic signal, and the fundamental frequency period is τ_pitch.

[0116] The method for determining transient signals is as follows:

[0117] (1) Divide the audio signal into several very short (no more than 5ms) sub-frames, for example, a 20ms frame of data is further subdivided into 8 2.5ms sub-frames;

[0118] (2) Calculate the energy E_sub(i) of each subframe:

[0119] (3) Find the ratio of the maximum energy subframe to the minimum energy subframe within a frame, E_ratio=max(E_sub) / min(E_sub);

[0120] (4) If E_ratio is greater than the threshold Th_energy_ratio (for example, Th_energy_ratio=100, that is, the instantaneous change in energy exceeds 100 times), then the signal is determined to be a transient signal.

[0121] During decoding and playback, when switching from a lower sampling rate to a higher sampling rate, the high-frequency components are recovered by interpolation from the last few milliseconds (g milliseconds) of the lower sampling rate audio data:

[0122] ;

[0123] Where R = f_high / f_new is the interpolation factor; S sampled [n] represents the interpolated signal, S original [m] represents the signal before interpolation, and sinc is the normalization function. Polynomial interpolation or FFT interpolation can also be used.

[0124] The length of the audio data to be interpolated (in milliseconds) is 10-20 milliseconds.

[0125] Filtering and interpolation are performed on the signal only during decoding, not during encoding. This is mainly to avoid sudden jumps in the signal when the sampling rate changes. Filtering and interpolation actually replace a portion of the data, making the transition when the signal sampling rate changes more smoothly.

[0126] The specific embodiments described herein are merely illustrative of the spirit of the invention. Those skilled in the art to which this invention pertains may make various modifications or additions to the described specific embodiments or use similar methods to substitute them, without departing from the spirit of the invention or exceeding the scope defined by the appended claims.

[0127] Although this paper uses terms such as short-time energy, short-time zero-crossing rate, and adjustment coefficient frequently, the possibility of using other terms is not excluded. These terms are used merely for the convenience of describing and explaining the essence of this invention; interpreting them as any additional limitation would contradict the spirit of this invention.

Claims

1. An audio encoding and decoding method based on dynamic sampling, characterized in that, It includes an encoding process and a decoding process, wherein the encoding process is as follows: S1: Discretize the analog audio signal to obtain a discretized audio signal. Perform time-domain analysis on the discretized audio signal to obtain the instantaneous amplitude A. n Short-term energy E n Short-term average amplitude M n and short-time zero-crossing rate Z n ; S2: Update the short-time energy threshold and short-time zero-crossing rate threshold according to the following formula: E th (n) =θE th (n-1) +(1-θ)E n ;Z th (n) =θZ th (n-1) +(1-θ)Z n ; In the formula, E th (n) E is the current short-term energy threshold. th (n-1) Z is the short-time energy threshold of the previous time step. th (n) Z is the current short-time zero-crossing rate threshold. th (n-1) The threshold for the short-term zero-crossing rate at the previous moment is θ, where θ is the forgetting factor. S3: The current sampling rate is determined using the following formula: ; In the formula, f s (n) f is the sampling rate selected at time n. max f mid and f base They represent three sampling rates: high, medium, and basic. th (n) Z is the current short-time energy threshold. th (n) A is the current short-time zero-crossing rate threshold. th M is the instantaneous amplitude threshold. th α is the short-time average amplitude threshold, β is the first adjustment coefficient, γ is the second adjustment coefficient, and γ is the third adjustment coefficient. S4: Resample the discretized audio signal according to the sampling rate determined in step S3 to generate a sampled data stream; S5: Continuously monitor the sampling rate determined in step S3. When the sampling rate changes, cut the sampled data stream before the change into an audio segment. S6: For each audio segment, encode it according to its corresponding sampling rate and encapsulate it into a data frame containing segment markers, sampling rate information, data length, encoded data and check bits; S7: Concatenate all data frames sequentially and add a file header and footer to obtain the final encoded audio file; The decoding process involves extracting the data from each segment of the audio file according to the segment markers, and then decoding and playing it according to the corresponding sampling rate.

2. The audio encoding and decoding method based on dynamic sampling according to claim 1, characterized in that, During decoding, when the sampling rate switches from a higher sampling rate f_high to a lower sampling rate f_new, the following processing is performed: The last few seconds of the higher sampling rate audio data and the first few seconds of the lower sampling rate audio data are input into an anti-aliasing low-pass filter with a cutoff frequency lower than f_new / 2 to obtain the filtered data. The order of the low-pass filter is: ; In the formula, A_stop is 60dB, A_pass is 1dB, w_stop is 0.5f_new, w_pass is 0.45f_new, and f_new is the lower sampling rate.

3. An audio encoding / decoding method based on dynamic sampling according to claim 1 or 2, characterized in that, During decoding and playback, when switching from a lower sampling rate f_new to a higher sampling rate f_high, the high-frequency components of the last few seconds of the lower sampling rate audio data are recovered through interpolation: ; Where R = f_high / f_new is the interpolation factor; S sampled [n] represents the interpolated signal, S original [m] represents the signal before interpolation, and sinc is the normalization function.

4. The audio encoding and decoding method based on dynamic sampling according to claim 1, characterized in that, The high sampling rate is 48kHz, the medium sampling rate is 44.1kHz, and the basic sampling rate is 24kHz.

5. The audio encoding and decoding method based on dynamic sampling according to claim 1, characterized in that, In step S1, the instantaneous amplitude is calculated as follows: The continuous signal s(t) is discretized into s[m], and the signal envelope is extracted using Hilbert transform: ; Where H{s(t)} is defined as: ; For convolution operation; PV represents Cauchy principal value, used to handle singularities of the integral at τ=t, and the kernel function 1 / πt is the impulse response of the Hilbert transform.

6. The audio encoding and decoding method based on dynamic sampling according to claim 1, characterized in that, Instantaneous amplitude threshold A th and short-time average amplitude threshold M th Through global analysis, the first adjustment coefficient α was determined to be 1.5, the second adjustment coefficient β to be 0.8, and the third adjustment coefficient γ to be 2.

0.

7. The audio encoding and decoding method based on dynamic sampling according to claim 1, characterized in that, The forgetting factor θ is 0.9.