Audio asynchronous sampling method and device and electronic equipment

By setting the alarm pointer during the asynchronous audio sampling process and calculating the error compensation value, the proportional error accumulation problem caused by different clock frequency sources is solved, the quality of the audio signal is improved, and data loss and lag are avoided.

CN119541566APending Publication Date: 2025-02-28FUZHOU ROCKCHIP SEMICON
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411525063.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In the process of asynchronous audio sampling, the proportional error accumulation caused by different clock frequency sources leads to loss of voice data and affects the quality of audio signal.

Method used

By setting a warning pointer in the first-in-first-out queue, if the data amount reaches the warning pointer, the error compensation value is calculated based on the direction of change of the data amount, and the proportional error is compensated, so that the data amount changes within a predetermined range, thereby adjusting the conversion force of the asynchronous sampling rate converter.

Benefits of technology

It effectively reduces the loss of voice data, improves the quality of audio signals, and avoids audio lag or loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119541566A_ABST
    Figure CN119541566A_ABST
Patent Text Reader

Abstract

The invention provides an audio asynchronous sampling method and device and electronic equipment. The method comprises the following steps: converting input audio data from a signal transmitting end to obtain converted audio data, and writing the converted audio data into a first-in first-out queue; reading the audio data from the first-in first-out queue, and outputting the read audio data as output audio data to a signal receiving end; if the data volume of the audio data in the first-in first-out queue reaches a warning pointer of the first-in first-out queue, obtaining an error compensation value according to the change direction of the data volume; and compensating a proportional error according to the error compensation value so that the data volume varies within a first predetermined range, the proportional error being a difference between the calculated clock frequency ratio and an actual clock frequency ratio, and the clock frequency ratio being a ratio of a first clock frequency of the signal transmitting end to a second clock frequency of the signal receiving end. According to the invention, the data volume in the first-in first-out queue can be quickly kept in a stable range.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of audio sampling, and in particular to an audio asynchronous sampling method and device, and electronic equipment. Background Art

[0002] In audio systems, for BT (Bluetooth) voice calls, AV Receiver (video and audio receiver), SoundBar (bar audio), ASR (speech recognition) and other scenarios, the clocks of the recording and playback devices are usually different frequencies and different sources, or the same frequency and different sources. Clocks from different sources cause differences in the clock frequencies of the signal transmitter and the signal receiver, and jitters with factors such as operating temperature and operating voltage.

[0003] The existing technology usually uses ASRC (Asynchronous Sample Rate Converter) to upsample and filter the pre-conversion voice signal, and then downsample it to obtain the converted voice signal. In this process, in addition to the upsampling multiple and the filter order, the ratio of the clock frequency between the signal transmitter and the signal receiver also affects the conversion performance. The existing technology usually samples the clocks of the signal transmitter and the signal receiver respectively through the local high-frequency clock, divides them and then filters to obtain the ratio. However, since there must be an error between the calculated ratio and the actual ratio, the accumulation of errors will cause the loss of voice data and thus affect the quality of the voice signal. Summary of the invention

[0004] The present invention provides an audio asynchronous sampling method and device, and electronic equipment, which can improve the quality of sampled voice signals.

[0005] In one aspect of the present invention, an audio asynchronous sampling method is provided. The method comprises: converting input audio data from a signal transmitting end to obtain converted audio data, and writing the converted audio data into a first-in-first-out queue; reading audio data from the first-in-first-out queue, and outputting the read audio data as output audio data to a signal receiving end; if the data volume of the audio data in the first-in-first-out queue reaches the alarm pin of the first-in-first-out queue, obtaining an error compensation value according to the direction of change of the data volume; and compensating a proportional error according to the error compensation value, so that the data volume changes within a first predetermined range, wherein the proportional error is the difference between the calculated clock frequency ratio and the actual clock frequency ratio, and the clock frequency ratio is the ratio of the first clock frequency of the signal transmitting end to the second clock frequency of the signal receiving end.

[0006] In another aspect of the present invention, an audio asynchronous sampling device is provided. The device includes: an input module, configured to convert input audio data from a signal transmitting end to obtain converted audio data, and write the converted audio data into a first-in-first-out queue; an output buffer module, including the first-in-first-out queue, and configured to read audio data from the first-in-first-out queue, and output the read audio data as output audio data to a signal receiving end; and a ratio detection module, configured to: calculate the ratio of the first clock frequency of the signal transmitting end to the second clock frequency of the signal receiving end as a clock frequency ratio; detect the data volume of the audio data in the first-in-first-out queue, if the data volume reaches the warning ring of the first-in-first-out queue, then obtain an error compensation value according to the change direction of the data volume; compensate for the ratio error according to the error compensation value, so that the data volume changes within a first predetermined range, and the ratio error is the difference between the calculated clock frequency ratio and the actual clock frequency ratio.

[0007] In another aspect of the present invention, an electronic device is provided, which includes a memory and a processor, wherein the memory is configured to store an executable program; and the processor is configured to execute the program to perform the above-mentioned audio asynchronous sampling method.

[0008] According to the technical solution of the present invention, during the data transmission process between the signal transmitting end and the signal receiving end, a warning needle is set in the first-in-first-out queue serving as a transit. If the data volume in the first-in-first-out queue reaches the warning needle, it means that the difference between the calculated clock frequency ratio obtained by the current prediction and the actual clock frequency ratio is large, resulting in a large difference between the adjustment amount and the actual required adjustment amount; making it impossible for the data volume in the first-in-first-out queue to be maintained at a stable level. At this time, an error compensation value is obtained according to the direction of change of the data volume, and the proportional error is compensated by the error compensation value, and the adjustment operation performed according to the proportional error is amplified, so as to quickly keep the data volume in the first-in-first-out queue within a stable range, so that the signal receiving end can continuously read the data in the first-in-first-out queue, and avoid audio freeze or loss caused by data accumulation or data exhaustion in the first-in-first-out queue. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] Figure 1 is a flowchart of an audio asynchronous sampling method according to an embodiment of the present invention; Figure 2 Flow chart of the application process of the audio asynchronous sampling method according to an embodiment of the present invention Figure 3 A block diagram of an ASRC environment according to an embodiment of the present invention; Figure 4 Schematic diagram of FIFO waterline changes according to an embodiment of the present invention Figure 5 is a block diagram of an audio asynchronous sampling device according to an embodiment of the present invention; Figure 6 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0010] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.

[0011] In the existing technology, the clocks of the audio signal transmitter and the signal receiver are not the same, so an asynchronous sampling rate converter needs to be introduced for conversion, or the time frequency of the signal transmitter needs to be directly adjusted through an asynchronous first-in-first-out queue. This method requires the clock of the signal transmitter to be adjustable, and the adjustment process also requires the introduction of software, which makes it difficult to control the intensity of the adjustment.

[0012] In order to solve at least the above technical problems, the present disclosure provides an audio asynchronous sampling method. According to the present disclosure, by adding a warning needle in the first-in-first-out queue, if the amount of data in the first-in-first-out queue reaches the warning needle, it means that the conversion strength of the asynchronous sampling rate converter is insufficient, and it is necessary to generate a corresponding error compensation value to compensate for the proportional error, so as to guide the asynchronous sampling rate converter to increase the conversion strength. In this way, according to the embodiments of the present disclosure, the range of the proportional error can be controlled to ensure the quality of audio asynchronous sampling.

[0013] There is such a correlation between the amount of data in the FIFO of the asynchronous sampling rate converter ASRC and the error ratio △Ratio. When △Ratio is less than 0, the amount of FIFO data will gradually increase until the FIFO is full. When △Ratio is greater than 0, the amount of FIFO data will gradually decrease until the FIFO becomes empty.

[0014] According to the present disclosure, by setting upper and lower warning lines for FIFO to dynamically adjust △Ratio to compensate for errors, the error is controlled within a preset range. According to the present disclosure, through negative feedback adjustment, the frequency of ASRC writing data to FIFO is adjusted to ensure that the data in FIFO changes within a predetermined range, and the FIFO will not be empty or full, resulting in duplication or discarding of audio data. In addition, Ratio ratio error compensation will only occur when the FIFO data volume reaches the upper warning ring needle or the lower warning ring needle. At other times, the sampling rate conversion is performed at a fixed Ratio ratio to ensure the continuity of the voice signal. The method disclosed in the present disclosure can effectively improve the audio quality of the receiving end in the presence of errors.

[0015] The module corresponding to this solution is a submodule of ASRC, which is set inside the conversion ratio detection module RatioDetect.

[0016] Hereinafter, the technical solution according to the present disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.

[0017] Figure 1 1 is a flow chart showing an audio asynchronous sampling method 100 according to an embodiment of the present disclosure. Figure 1 , the method 100 includes the following steps 101 to 106.

[0018] In step 101 , input audio data from a signal transmitting end is converted to obtain converted audio data, and the converted audio data is written into a first-in-first-out queue (FIFO).

[0019] In some embodiments, converting the input audio data from the signal transmitting end to obtain the converted audio data includes: upsampling, filtering and downsampling the input audio data to obtain the converted audio data. In this way, the audio data from the signal transmitting end is simply converted to improve the quality of the audio data.

[0020] In some embodiments, writing the converted audio data into a first-in-first-out queue comprises: writing the converted audio data into the first-in-first-out queue at a writing frequency determined based on the ratio of the first clock frequency to the calculated clock frequency. In this way, asynchronous sampling is achieved when the first clock frequency of the signal transmitting end and the second clock frequency of the signal receiving end are different.

[0021] In step 102, audio data is read from the FIFO queue, and the read audio data is output to a signal receiving end as output audio data.

[0022] In some embodiments, reading audio data from the FIFO queue includes: reading from the FIFO queue at the second clock frequency. In this way, combined with the aforementioned method of writing data into the FIFO queue, the signal receiving end can receive data from the signal sending end without changing its own second clock frequency.

[0023] In some embodiments, reading audio data from the FIFO queue includes: after writing the FIFO queue, when the data volume reaches a set value within the first predetermined range, starting to read audio data from the FIFO queue. In this way, after a certain amount of audio data is accumulated, reading is enabled, which facilitates the control of the data volume, avoids the problem of no data reading due to too little data in the FIFO queue, and enables a relatively smooth transition of the subsequent adjustment process.

[0024] In some embodiments, the warning ring needle includes an upper warning ring needle and a lower warning ring needle, and the set value is (AB) / 2+B, where A represents the value corresponding to the upper warning ring needle, and B represents the value corresponding to the lower warning ring needle. In this way, after a certain amount of data is written, it is read by the signal receiving end. Even if there is a proportional error, the error compensation is required only after the upper warning ring needle or the lower warning ring needle is touched, thereby delaying the time of the first adjustment; because the audio may be discontinuous at the moment of adjustment, the quality of the sampled audio is reduced, and poor quality audio is avoided at the beginning of audio sampling. In addition, the direction of change of the data volume can be confirmed based on whether the amount of data in the first-in-first-out queue reaches the upper warning ring pin or the lower warning ring pin. If it reaches the lower warning ring pin, it means that the data volume has decreased compared to when it is open for reading, that is, the proportional error is a positive value, resulting in the reading speed being too fast relative to the writing speed; if it reaches the upper warning ring pin, it means that the data volume has increased compared to when it is open for reading, that is, the proportional error is a negative value, resulting in the reading speed being too slow relative to the writing speed; by setting the upper and lower warning ring pins, there is no need to separately determine the direction of change of the data volume, and you only need to know whether the upper warning ring pin or the lower warning ring pin is triggered to determine the proportional error situation.

[0025] In step 103, if the data volume of the audio data in the FIFO queue reaches the warning pin of the FIFO queue, an error compensation value is obtained according to the change direction of the data volume.

[0026] In some embodiments, if the amount of data in the FIFO queue reaches the upper warning ring needle, a positive first error compensation value is obtained; and if the amount of data in the FIFO queue reaches the lower warning ring needle, a negative second error compensation value is obtained. In this way, if the amount of data in the FIFO queue reaches the upper warning ring needle, it means that the amount of data in the FIFO queue begins to accumulate. Since the clock frequency ratio for calculating the proportional error is the ratio of the clock frequency of the signal transmitting end to the clock frequency of the signal receiving end, it means that the current proportional error used for correction still cannot balance the problem of too fast writing well. Since the calculated clock frequency ratio is less than the actual clock frequency ratio, that is, the actual proportional error is less than 0, the amount of data written into the FIFO queue exceeds the amount of data read out of the FIFO queue. Then, by setting the positive first error compensation value, the currently obtained proportional error is corrected, so that the amount of data in the FIFO queue is reduced to leave the upper warning ring needle. Similarly, if the amount of data in the first-in-first-out queue reaches the lower warning ring needle, it means that the calculated clock frequency ratio is greater than the actual clock frequency ratio, that is, the actual proportional error is greater than 0, causing the data in the first-in-first-out queue to be consumed too quickly, and the amount of data written to the first-in-first-out queue is less than the amount of data read from the first-in-first-out queue. By setting a negative second error compensation value, the current proportional error is corrected, so that the amount of data in the first-in-first-out queue increases and leaves the lower warning ring needle.

[0027] In some embodiments, step 103 may include: obtaining a preset compensation unit value; obtaining the first error compensation value and the second error compensation value by taking the compensation unit value as an absolute value. In this way, the error compensation value used for each adjustment is obtained after adjusting the positive and negative values ​​according to the compensation unit value, and there is no need to calculate the specific error compensation value to be set each time. It is only necessary to perform compensation each time according to the compensation unit value, which saves computing resources and speeds up the adjustment efficiency.

[0028] In step 104, the proportional error is compensated according to the error compensation value so that the data amount varies within a first predetermined range, wherein the proportional error is the difference between the calculated clock frequency ratio and the actual clock frequency ratio, and the clock frequency ratio is the ratio of the first clock frequency of the signal sending end to the second clock frequency of the signal receiving end.

[0029] In some embodiments, step 104 may include: adjusting the write frequency of the first-in-first-out queue according to the compensated proportional error to control the data volume to remain within the first predetermined range. Since after receiving the input audio of the signal transmitting end, it is necessary to convert it and then write it into the first-in-first-out queue, the write speed in the first-in-first-out queue can be adjusted, that is, the first clock frequency here refers to the actual frequency of data written into the first-in-first-out queue. The signal receiving end reads data directly from the first-in-first-out queue, so the read frequency is the clock frequency of the signal receiving end itself, which cannot be adjusted, that is, in the present disclosure, the write frequency is actually adjusted by the obtained proportional error to change the actual clock frequency ratio to avoid the accumulation of proportional errors.

[0030] In some embodiments, step 104 may include: (1) adjusting the proportional error according to the error compensation value so that the proportional error remains within a second predetermined range; (2) adjusting the write frequency of writing to the first-in-first-out queue according to the adjusted proportional error; (3) maintaining the read frequency of reading from the first-in-first-out queue. In this way, the proportional error is adjusted according to the error compensation value, and the calculated proportional error is adjusted according to the actual data storage situation in the first-in-first-out queue, so that the proportional error remains within the second predetermined range, and the write frequency of writing data to the first-in-first-out queue is adjusted according to the adjusted proportional error, and the read frequency of reading from the first-in-first-out queue is maintained, thereby specifically realizing the stability of the proportional error. That is, the present application obtains an actual proportional error response through the change of the amount of data in the first-in-first-out queue. If the data in the first-in-first-out queue reaches the upper warning ring needle, it means that the actual proportional error is less than 0, resulting in data accumulation, and it is necessary to increase the write frequency of the first-in-first-out queue by increasing the proportional error; if it reaches the lower warning ring needle, it means that the actual proportional error is greater than 0, resulting in a fast data consumption speed, and it is necessary to reduce the write frequency of the first-in-first-out queue by reducing the proportional error.

[0031] In some embodiments, after compensating the proportional error according to the error compensation value, the method may further include: if the amount of data in the first-in-first-out queue reaches the upper warning ring pin, increasing the upper warning ring pin by 1 to obtain a new upper warning ring pin; if the amount of data in the first-in-first-out queue reaches the lower warning ring pin, decreasing the lower warning ring pin by 1 to obtain a new lower warning ring pin; if the amount of data in the first-in-first-out queue further reaches the new upper warning ring pin or the new lower warning ring pin, obtaining a further error compensation value according to the direction of change of the data amount; compensating the proportional error according to the further error compensation value, so that the proportional error remains within the second predetermined range, and the data amount returns to the first predetermined range. In this way, after compensating for the proportional error, the triggered upper warning ring needle or lower warning ring needle will also be adjusted. After compensating for the proportional error, the adjustment result is not immediately effective, and because the adjustment strength is controlled, each compensation for the proportional error is based on a preset compensation unit value, so there may be a situation where the adjustment strength is insufficient. If the triggered warning ring needle is kept unchanged, it is possible that the warning ring needle will be triggered multiple times in a short period of time during the adjustment process, resulting in over-adjustment before the previous adjustment takes effect and the next adjustment is made, resulting in erroneous updating of the proportional error.

[0032] In some embodiments, after compensating the proportional error according to the error compensation value, the method may further include: sending the compensated proportional error to an asynchronous sampling rate converter, so that the asynchronous sampling rate converter adjusts the frequency of writing to the first-in-first-out queue according to the compensated proportional error. In this way, the asynchronous sampling rate converter adjusts the writing frequency by the compensated proportional error, and when the reading frequency of the signal receiving end remains unchanged, the water level in the first-in-first-out queue can be adjusted, so that the water level in the first-in-first-out queue is maintained between the warning rings.

[0033] In some embodiments, the method may further include: in response to the data volume returning to the first predetermined range, setting the new upper warning ring needle or the new lower warning ring needle to return to the initial value. In this way, after the data volume returns to the first predetermined range, the upper warning ring needle and the lower warning ring needle are automatically reset to the initial value, avoiding the unlimited expansion of the upper warning ring needle and the lower warning ring needle, and ensuring the timeliness of triggering the proportional error adjustment.

[0034] Hereinafter, application scenarios of the audio asynchronous sampling method and apparatus, and electronic device according to embodiments of the present invention will be described by way of examples.

[0035] Figure 2 2 is a flowchart showing the application process of the audio asynchronous sampling method according to an embodiment of the present invention, including the following steps 202 to 208.

[0036] In this scenario, assuming that the clock frequency of the signal transmitter is F1 and the clock frequency of the signal receiver is F2, the converted voice data is written to the FIFO during the writing process. The conversion here is the ASRC (Asynchronous Sampling Rate Converter), which first upsamples and filters the pre-conversion voice signal, and then downsamples it to obtain the converted voice signal. During the reading process, the signal receiver reads the voice data from the FIFO at the frequency F2. Through periodic tracking in the ASRC, ΔRatio < 0.23ppm (parts per million) can be controlled.

[0037] Step 202: sequentially set a write pointer, a read pointer, an upper alarm ring pin A and a lower alarm ring pin B in the first-in first-out queue FIFO.

[0038] Step 204, before error compensation starts, write C audio data into the FIFO, A<C<B.

[0039] In some embodiments, when the written audio data reaches C, the reading of the first-in-first-out queue is opened, C=(AB) / 2+B.

[0040] Step 206, when the amount of data in the FIFO reaches the upper alarm pin A, the error compensation ΔRatio'=ΔRatio+0.23 is triggered, the upper alarm pin A'=A+1 is updated, and the lower alarm pin B=B is updated, where 0.23ppm is the preset compensation unit value. Here, the theoretical accuracy of ΔRatio that can be detected in the Ratio Detect module in ASRC is used as the compensation unit value. This accuracy value can ensure high audio quality and will not be ignored during the adjustment process, ensuring that the compensated proportional error can change the adjustment value. The total harmonic distortion plus noise (THD+N) of 24-bit wide audio reaches below -125dB. The specific conversion process of ASRC is a prior art and will not be repeated here. That is, when the upper alarm pin A is reached, it means that the actual ΔRatio is less than 0 at this time, causing the amount of data in the FIFO to shift toward the upper alarm pin A until it reaches the upper alarm pin A, so it is necessary to increase ΔRatio to reduce the error at this time.

[0041] Step 208, when the FIFO data volume reaches the lower alarm pin B, error compensation is triggered, ΔRatio'=ΔRatio-0.23 is updated, the lower alarm pin B'=B-1 is updated, and the upper alarm pin A=A is updated. The decrease of ΔRatio means that the frequency of the filter module Filter of ASRC writing data to the Output FIFO will increase, while the frequency of the receiving end reading data from the Output FIFO is fixed, which is the receiving end clock frequency, so the FIFO waterline will gradually rise.

[0042] Setting the lower alarm mark to -1 can prevent the FIFO data volume from hitting the lower alarm mark multiple times in a short period of time, which would result in incorrect updates of ΔRatio. Because ΔRatio is known, the FIFO filling waterline to the upper alarm mark or the lower alarm mark is a slow accumulation process, and the FIFO waterline will gradually rise as ΔRatio increases. Theoretically, -1 is sufficient. Setting it to other values ​​would waste storage resources.

[0043] If the compensation force is sufficient at this time, ΔRatio'<0, the waterline in the FIFO, that is, the amount of data, will move to the position of the upper warning ring, and finally trigger step S204; if the compensation force is not enough at this time, the waterline in the FIFO will continue to slowly shift to the lower warning ring B'. When the FIFO waterline reaches the lower warning ring, step S205 will continue to be triggered, and ΔRatio''=ΔRatio'-0.23 will be updated, and the lower warning ring B''=B'-1 will be updated. This cycle will be repeated until the compensation force is sufficient.

[0044] The error compensation method disclosed in the present invention adjusts the writing rate by compensating for the proportional error, ensuring that ΔRatio < 0.23ppm throughout the process, and the upper and lower alarm rings automatically return to the initial value, ensuring that the FIFO is not empty or full, resulting in voice data duplication or discarding. When the FIFO triggers the upper alarm ring, the lower alarm ring will automatically return to the initial value; when the lower alarm ring is triggered, the upper alarm ring will automatically return to the initial value, thereby achieving automatic return to the initial value and ensuring the timeliness of the trigger adjustment.

[0045] Figure 3 is a block diagram showing an ASRC environment according to an embodiment of the present invention, referring to Figure 3, the ASRC module includes a register Register, a filter module Filter, an output buffer module Output Buffer, and a conversion ratio detection module RatioDetect. The buffer is connected to the MCU and can accept the configuration content sent by the MCU. After starting according to the configuration content, it runs autonomously without the need for additional software installation for intervention. The input data Input data is input into the filter module, and the filter module filters according to the calculated clock frequency ratio (Ratio) and stores the data in the output buffer module and outputs it as output data Outputdata. The conversion ratio detection module receives the input clock signal, i.e., the clock signal Input clock of the signal sending end, and the output clock signal, i.e., the clock signal Output clock of the signal receiving end, calculates the clock frequency ratio Ratio and sends it to the filter module for data conversion of the filter module, and receives the occupancy rate Fill_level sent by the output buffer module at the same time. The increase of ΔRatio means that the frequency of writing data to the Output buffer (for example, FIFO can be used as Outputbuffer) of the ASRC filter module Filter will decrease, while the frequency of reading data from the Output FIFO at the receiving end is fixed, which is the receiving end clock frequency, so the FIFO waterline will gradually decrease. For the warning needle +1, it can avoid the FIFO data volume hitting the upper warning needle multiple times in a short period of time, resulting in the wrong update of the ratio error ΔRatio, because ΔRatio is known, which is mainly caused by the limitation of calculation accuracy and the jitter of input and output clocks due to environmental factors such as temperature during the actual tracking process. The movement of the FIFO filling waterline to the upper warning needle or the lower warning needle is a slow accumulation process, and the FIFO waterline will gradually decrease after ΔRatio increases. In theory, +1 is enough, and + other values ​​will waste storage resources.

[0046] Figure 4 Schematic diagram showing the change of FIFO waterline according to an embodiment of the present invention. Figure 4 If the compensation strength is sufficient at this time, ΔRatio'>0, the waterline in the FIFO, that is, the amount of data, will move to the position of the lower warning ring needle, and finally trigger step 205. If the compensation strength is not enough at this time, the waterline in the FIFO will continue to move slowly to the updated upper warning ring needle A'. When it reaches the upper warning ring needle, step 204 will be triggered again, and ΔRatio''=ΔRatio'+0.23 will be updated, and the upper warning ring needle A''=A'+1 will be updated. This cycle is repeated until the compensation strength is sufficient. The value updated each time is the same, and the adjustment strength is accumulated in sequence, which can avoid excessive adjustment caused by excessive one-time adjustment, and there is no need to calculate the updated value each time, which speeds up the process.

[0047] According to another aspect of the present invention, Figure 5is a block diagram showing an audio asynchronous sampling apparatus 300 according to an embodiment of the present invention. Figure 5 The audio asynchronous sampling device 300 includes an input module 302 , an output buffer module 304 and a ratio detection module 306 .

[0048] The input module 302 is configured to convert the input audio data from the signal sending end to obtain converted audio data, and write the converted audio data into a first-in-first-out queue.

[0049] In some embodiments, the input module 302 is configured to upsample, filter, and downsample the input audio data to obtain the converted audio data, and is configured to write to the first-in-first-out queue at a write frequency determined based on the ratio of the first clock frequency and the calculated clock frequency, and the output buffer module is configured to read from the first-in-first-out queue at the second clock frequency.

[0050] The output buffer module 304 includes the first-in-first-out queue, and is configured to read audio data from the first-in-first-out queue, and output the read audio data as output audio data to the signal receiving end.

[0051] The ratio detection module 306 is configured to calculate the ratio of the first clock frequency of the signal transmitting end to the second clock frequency of the signal receiving end as the clock frequency ratio. The ratio detection module 306 is configured to detect the data volume of the audio data in the first-in-first-out queue, and if the data volume reaches the warning ring of the first-in-first-out queue, an error compensation value is obtained according to the change direction of the data volume. The ratio detection module 306 is configured to compensate for the ratio error according to the error compensation value, so that the data volume changes within a first predetermined range, and the ratio error is the difference between the calculated clock frequency ratio and the actual clock frequency ratio.

[0052] In some embodiments, the ratio detection module 306 is configured to adjust the write frequency of writing to the first-in-first-out queue according to the compensated ratio error, so that the input module writes to the first-in-first-out queue based on the write frequency to control the data volume to remain within the first predetermined range.

[0053] It should be understood that the input module 302, the output buffer module 304 and the ratio detection module 306 can be further configured to perform the corresponding steps in the method described in the above embodiment, which will not be repeated here. In addition, the beneficial effects of the above steps refer to the description of the audio asynchronous sampling method above, which will not be repeated here.

[0054] According to yet another aspect of the present invention, Figure 64 is a schematic diagram showing an electronic device 400 according to an embodiment of the present invention. Figure 6 The electronic device 400 includes a memory 402, a processor 404, and an executable program stored in the memory and executable on the processor. When the processor executes the executable program, the various steps of the audio asynchronous sampling method described above are implemented.

[0055] In summary, the audio asynchronous sampling method and device, and electronic device provided by the present invention. An error compensation method is set for ASRC, by setting a warning pin in the first-in-first-out queue. If the warning pin is reached, it means that the proportional error calculated by the current ASRC needs to be adjusted, so the error compensation value is obtained according to the direction of change of the data amount. Specifically, by setting an upper warning pin and a lower warning pin before performing the error compensation operation, when the amount of data in the first-in-first-out queue is between the upper warning pin and the lower warning pin, the reading of the first-in-first-out queue is opened, and the direction of change of the data amount can be judged according to whether the data amount reaches the upper warning pin or the lower warning pin. If the upper warning pin is reached, it means that the proportional error is less than 0, but the ASRC does not take the proportional error into account during the conversion process, and the error accumulation leads to the accumulation of data in the first-in-first-out queue, so it is necessary to compensate the proportional error through a positive error compensation value to guide the ASRC calculation. In addition, the processing method for reaching the lower alarm ring is similar, so that the proportional error is kept within a certain range, and the amount of data in the first-in-first-out queue is kept between the upper alarm ring and the lower alarm ring, avoiding the situation where the first-in-first-out queue is empty and the signal receiving end cannot receive the audio data, resulting in sound jamming, or the first-in-first-out queue is full and the signal sending end cannot store the audio data, resulting in sound data missing, thereby ensuring the quality of the audio. In addition, after the amount of data in the first-in-first-out queue reaches the upper alarm ring or the lower alarm ring, the upper alarm ring is increased by 1 or the lower alarm ring is decreased by 1, thereby avoiding the problem that the amount of data triggers the adjustment of reaching the upper alarm ring or the lower alarm ring multiple times before the adjustment takes effect, thereby making the adjustment force too large. The problem that the signal receiving end will repeat or discard voice data regularly introduced by the error ΔRatio is solved to ensure the quality of the voice signal. In addition, error compensation only occurs when the amount of data in the first-in-first-out queue reaches the upper alarm ring or the lower alarm ring, and the sampling rate conversion is performed at a fixed Ratio at other times to ensure the continuity of the voice signal.

[0056] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. An audio asynchronous sampling method, characterized in that: include: Converting input audio data from a signal transmitting end to obtain converted audio data, and writing the converted audio data into a first-in-first-out queue; Reading audio data from the first-in-first-out queue, and outputting the read audio data as output audio data to a signal receiving end; If the amount of audio data in the FIFO queue reaches the warning pin of the FIFO queue, an error compensation value is obtained according to the change direction of the data amount; as well as The proportional error is compensated according to the error compensation value so that the data amount changes within a first predetermined range, The ratio error is the difference between the calculated clock frequency ratio and the actual clock frequency ratio, and the clock frequency ratio is the ratio of the first clock frequency of the signal transmitting end to the second clock frequency of the signal receiving end.

2. The audio asynchronous sampling method according to claim 1, characterized in that: Compensating the proportional error according to the error compensation value so that the data amount changes within a first predetermined range includes: The write frequency of writing into the first-in-first-out queue is adjusted according to the compensated proportional error to control the data amount to remain within the first predetermined range.

3. The audio asynchronous sampling method according to claim 1, characterized in that: Compensating the proportional error according to the error compensation value so that the data amount changes within a first predetermined range includes: adjusting the proportional error according to the error compensation value so that the proportional error remains within a second predetermined range; Adjusting the writing frequency of writing into the FIFO queue according to the adjusted ratio error; and A read frequency is maintained for reading from the FIFO queue.

4. The audio asynchronous sampling method according to claim 1, characterized in that: Converting the input audio data from the signal transmitting end to obtain the converted audio data includes: upsampling, filtering and downsampling the input audio data to obtain the converted audio data, Writing the converted audio data into a first-in-first-out queue comprises: writing the converted audio data into the first-in-first-out queue at a writing frequency determined based on a ratio of the first clock frequency to the calculated clock frequency, Reading audio data from the first-in-first-out queue includes: reading from the first-in-first-out queue at the second clock frequency.

5. The audio asynchronous sampling method according to claim 1, characterized in that: The warning ring needle comprises an upper warning ring needle and a lower warning ring needle; The obtaining of the error compensation value according to the change direction of the data amount comprises: If the amount of data in the FIFO queue reaches the upper alarm ring, a positive first error compensation value is obtained; and If the amount of data in the FIFO queue reaches the lower alarm level, a negative second error compensation value is obtained.

6. The audio asynchronous sampling method according to claim 5, characterized in that: Obtaining the error compensation value according to the change direction of the data volume also includes: Obtaining a preset compensation unit value; and The first error compensation value and the second error compensation value are obtained by taking the compensation unit value as an absolute value.

7. The audio asynchronous sampling method according to claim 5, characterized in that: After compensating the proportional error according to the error compensation value, the method further comprises: If the amount of data in the FIFO queue reaches the upper warning ring pin, the upper warning ring pin is increased by 1 to obtain a new upper warning ring pin; If the amount of data in the FIFO queue reaches the lower alarm ring pin, the lower alarm ring pin is reduced by 1 to obtain a new lower alarm ring pin; If the amount of data in the FIFO queue further reaches the new upper warning ring needle or the new lower warning ring needle, a further error compensation value is obtained according to the change direction of the amount of data; and The proportional error is compensated according to the further error compensation value, so that the proportional error is maintained within a second predetermined range and the data volume returns to change within the first predetermined range.

8. The audio asynchronous sampling method according to claim 7, characterized in that: Also includes: In response to the data volume returning to within the first predetermined range, the new upper warning ring hand or the new lower warning ring hand is set to return to an initial value.

9. The audio asynchronous sampling method according to claim 1, characterized in that: Reading audio data from the first-in-first-out queue includes: After writing into the FIFO queue, when the data amount reaches a set value within the first predetermined range, the reading of audio data from the FIFO queue is started.

10. The audio asynchronous sampling method according to claim 9, characterized in that: The warning ring needle includes an upper warning ring needle and a lower warning ring needle, and the setting value is (AB) / 2+B. Wherein A represents the value corresponding to the upper warning ring needle, and B represents the value corresponding to the lower warning ring needle.

11. An audio asynchronous sampling device, characterized in that: include: An input module, configured to convert input audio data from a signal transmitting end to obtain converted audio data, and write the converted audio data into a first-in-first-out queue; an output buffer module, comprising the first-in-first-out queue, and configured to read audio data from the first-in-first-out queue, and output the read audio data as output audio data to a signal receiving end; as well as The ratio detection module is configured as follows: Calculating a ratio of a first clock frequency of the signal transmitting end to a second clock frequency of the signal receiving end as a clock frequency ratio; Detecting the data volume of the audio data in the FIFO queue, and if the data volume reaches the warning pin of the FIFO queue, obtaining an error compensation value according to the change direction of the data volume; The proportional error is compensated according to the error compensation value so that the data amount changes within a first predetermined range, and the proportional error is a difference between the calculated clock frequency ratio and the actual clock frequency ratio.

12. The audio asynchronous sampling device according to claim 11, characterized in that: The ratio detection module is configured as follows: The write frequency of writing into the FIFO queue is adjusted according to the compensated proportional error, so that the input module writes into the FIFO queue based on the write frequency to control the data amount to remain within the first predetermined range.

13. The audio asynchronous sampling device according to claim 11, characterized in that: The input module is configured to upsample, filter, and downsample the input audio data to obtain the converted audio data, and is configured to write the first-in-first-out queue at a writing frequency determined based on the ratio of the first clock frequency to the calculated clock frequency, The output buffer module is configured to read from the first-in-first-out queue at the second clock frequency.

14. An electronic device, characterized in that: include: a memory configured to store an executable program; as well as A processor is configured to execute the program to perform the audio asynchronous sampling method according to any one of claims 1 to 10.