Scheduling method for recording and playback of double helix structures
The double helix scheduling method addresses synchronization issues in audio processing by using N frame caches and callback functions to reduce jitter and ensure consistent frame lengths, enhancing audio quality and module stability.
Patent Information
- Application Number
- JP2024083110
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2024-05-10
- Filing Date
- 2024-05-22
- Publication Date
- 2025-08-06
- Estimated Expiration
- 2044-05-22
AI Technical Summary
Existing audio processing methods in computer multimedia systems suffer from increased latency and jitter noise due to system jitter and oscillator aging, which affect the synchronization of recording and playback, especially in duplex audio communication and sound source localization.
A scheduling method employing a double helix structure with N frame caches for recording and playback, utilizing callback functions and multi-threading to synchronize signals passively and dynamically, reducing jitter through sequential and parallel processing.
The method effectively synchronizes recording and playback signals, reducing time length jitter and ensuring consistent frame lengths, thereby improving audio quality and stability of signal processing modules.
Smart Images

Figure 0007719539000002 
Figure 0007719539000003 
Figure 0007719539000004
Abstract
Description
[Technical Field]
[0001] The present invention relates to the technical field of multimedia communication, and particularly to a scheduling method for recording and playing back a double helix structure. [Background technology]
[0002] In the field of computer multimedia technology, sound cards are one of the most important peripheral devices. In addition to board-integrated sound cards, standalone sound cards are often integrated in the form of PCI cards. When a computer processes real-time audio, scheduling is performed between the operating system and the sound card via DMA. That is, the sound card and DMA exchange data bidirectionally (read and write) via hardware interrupts, and the operating system and DMA exchange data bidirectionally. This frees the CPU from the need to respond to sound card hardware interrupts and improves the scheduling efficiency of the operating system.
[0003] However, this processing method has the disadvantage of increasing latency during recording and playback. The cache managed by DMA is called the core state cache, and the memory used by the operating system to exchange it is called the application state cache. The application state cache must not be too small; otherwise, continuous recording and playback would be impossible. However, the larger the application state cache, the greater the system latency. In platforms with operating systems, such as computers, processing audio reads and writes from a sound card requires a certain amount of latency. However, scheduling jitter, along with the aging of the sound card's crystal oscillator, creates jitter noise inherent in digital systems, which can have a detrimental effect on recording and playback. For example, large jitter amplitude can destroy the time uniformity of audio sampling, resulting in distortion of the audio's physical frequency. In more severe cases, it can cause audible discontinuities in the audio's time domain. In general, the size of the application state cache can somewhat "eliminate" this jitter effect, especially if the cache is long enough.
[0004] However, when faced with a scenario such as duplex audio communication, due to the operating principle of the acoustic echo cancellation module, the echo cancellation process for the recorded signal must be performed with the cooperation of the playback signal as a reference. In this case, how to "eliminate" the asynchronism of the duplex audio caused by system jitter is an important guarantee for recording and playback. In practice, when one signal is used as a reference for the other, a certain degree of synchronization must be guaranteed. Similarly, the same problem occurs when localizing a sound source by taking into account multiple collected microphone signals. Summary of the Invention [Problem to be solved by the invention]
[0005] In response to the above-mentioned problems in the prior art, the present invention aims to provide a scheduling method for recording and playback with a double helix structure, which can passively and dynamically synchronize the two signals, recording and playback, under the operating principle of the sound card's preemption pattern. [Means for solving the problem]
[0006] The present invention provides the following technical solution: A scheduling method for recording and playing back a double helix structure, comprising: Step 1: Prepare N frame caches for recording and playback, respectively; Step 2: adding N recording caches to the sound card, and starting recording, and writing N playback caches to the sound card one by one; Step 3: In the recording callback function, write the playback cache to the sound card; Step 4: Adding a recording cache in the playback callback function; and step 5 of ending the recording and playback.
[0007] Furthermore, the specific instructions in step 2 are all serial.
[0008] Furthermore, in step 2 above, the recording cache is empty or needs to be written, and the playback cache can be written to the sound card after being filled by the network or a read file.
[0009] Furthermore, the specific process of step 3 is as follows: In the recording callback function, write the cache for code i in the N playback cache queue to the sound card, increment i from 0 by 1, and reset it to 0 if i is equal to N.
[0010] Furthermore, the specific process of step 4 is as follows: In the playback callback function, add a cache with code j in the N recording cache queue, increment j from 0 by 1, and reset it to 0 if i is equal to N.
[0011] Furthermore, in steps 3 and 4, before writing the cache of code i in the N playback cache queues to the sound card and adding the cache of code j in the N recording cache queues, respectively, one sub-thread is turned on to establish multi-thread recording and playback scheduling.
[0012] Furthermore, when processing real-time playback signals, the cache for code i in step 3 needs to be retrieved and processed before being added to the playback cache queue, and the processing result needs to be saved; When processing real-time recording signals, the cache of code j in step 4 needs to be processed before it is written to the sound card.
[0013] Furthermore, in steps 3 and 4, the recording callback function and the playback callback function write the playback cache to the sound card or add the recording cache, respectively. After adding the recording cache or writing the cache to the sound card is completed, the corresponding recording callback function and playback callback function can be called. Until recording and playback are completed, the calling of the recording callback function and playback callback function, writing the playback cache to the sound card in the recording callback function, and adding the recording cache in the playback callback function are repeated. [Effects of the Invention]
[0014] By adopting the above technology, the beneficial effects of the present invention compared to the prior art are as follows: In this invention, when the recording frame time is the recording callback + writing to the cache on the sound card, the playback frame time is the playback callback + adding the recording cache, which plays a role of neutralization and averaging, reduces the time length jitter, and dynamically matches it. Under the working principle of the sound card preemption pattern, the two signals of recording and playback can be passively and dynamically synchronized. [Brief explanation of the drawings]
[0015] [Figure 1] 1 is a system block diagram of the overall method of the present invention. [Figure 2] This is a schematic diagram showing the principle of repeating the calling of the recording callback function and the playback callback function, writing the playback cache to the sound card in the recording callback function, and adding the recording cache to the playback callback function in steps 3 and 4 of the present invention. [Figure 3] FIG. 1 is a comparative schematic diagram of the recording and playback timeline and DNA structure of the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0016] In order to more clearly understand the objectives, technical solutions and advantages of the present invention, the present invention will be described in more detail below in conjunction with the specification drawings and examples. It should be understood that the specific embodiments described herein are only used to illustrate the present invention and are not used to limit the present invention.
[0017] Rather, the present invention encompasses alternatives, modifications, equivalent methods, and technical solutions falling within the spirit and scope of the present invention as defined by the appended claims. Furthermore, in order to provide a better understanding of the present invention generally, certain details are set forth in the following detailed description of the invention. Those skilled in the art will be able to fully understand the present invention without these details.
[0018] Referring to Figure 1-3, Example 1 The scheduling method for recording and playing back the double helix structure is Step 1: Prepare N frame caches for recording and playback, respectively; Step 2: Add N recording caches to the sound card, start recording, and write N playback caches to the sound card one by one; the specific sub-steps of step 2 are all sequential, and the recording caches are either empty or need to be written, and the playback caches can be written to the sound card after being filled by the network or read file; Step 3 in the recording callback function: write the cache of code i in the N playback cache queue to the sound card, increment i from 0 by 1, and reset i to 0 if i is equal to N; Step 4 in the playback callback function adds a cache of code j in the N recording cache queue, increments j from 0 by 1, and resets it to 0 if i is equal to N; and step 5 of terminating the recording and playback; In steps 3 and 4, if the signal processing module processes the real-time recording and playback signals, such as filtering before playback, noise reduction after recording, or echo cancellation, it can retrieve and process the cache i in step 3 before adding it to the recording cache queue and save the processing result, which is pre-playback processing, or it can process the cache j in step 4 before writing it to the sound card, which is post-recording filtering.
[0019] In steps 3 and 4, the recording callback function and the playback callback function respectively write the playback cache to the sound card or add the recording cache. After the recording cache is added or the cache is written to the sound card, the corresponding recording callback function and playback callback function can be called. Until recording and playback are completed, the calling of the recording callback function and the playback callback function, the writing of the playback cache to the sound card in the recording callback function, and the addition of the recording cache in the playback callback function are repeated.
[0020] Example 2 The difference between this embodiment and the first embodiment is as follows.
[0021] In steps 3 and 4, before writing the cache of code i in the N playback cache queues to the sound card and adding the cache of code j in the N recording cache queues, respectively, one sub-thread is turned on to establish multi-thread recording and playback scheduling.
[0022] The two callback functions are blocking and cannot run for too long, making it easier to insert signal processing filtering modules when performing the "add recording cache" and "write cache to sound card" operations in a multi-threaded pattern.
[0023] The following table shows an example of the execution result, where the recording frame length and playback frame length in the programming specifications are 20 milliseconds (ms).
[0024] [Table 1]
[0025] As can be seen from the five experiments in the table above, due to the presence of scheduling jitter, the average frame length is not exactly 20 milliseconds, and the synchronization between recording and playback is improved compared to the normal pattern. The consistency between the number of recording frames and the number of playback frames is much better than the normal pattern (where the difference in the total number of frames is 14 frames). This synchronization between the two can be seen, and this consistency in the number of frames affects the performance of signal processing filtering modules. In particular, modules such as acoustic echo cancellation do not reduce or increase the update frequency of the echo filter, and the number of recording frames is approximately the same as the number of playback frames, ensuring the stability of the filter effect.
[0026] In this invention, "add recording cache," "write cache to sound card," "recording callback," and "playback callback" correspond to four pairs of ATCG bases, and their sequence progressive combination changes are completely consistent with the function call patterns on the two timelines of recording and playback, so this method is called "double-helix recording and playback scheduling."
[0027] The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
[0028] (Addendum) (Appendix 1) 1. A scheduling method for recording and playing back a double helix structure, comprising: Step 1: Prepare N frame caches for recording and playback, respectively; Step 2: adding N recording caches to the sound card, and starting recording, and writing N playback caches to the sound card one by one; Step 3: In the recording callback function, write the playback cache to the sound card; Step 4: Adding a recording cache in the playback callback function; and (5) terminating the recording and playback.
[0029] (Appendix 2) The scheduling method for recording and playing back a double helix structure according to claim 1, wherein the specific instructions in step 2 are all serial.
[0030] (Appendix 3) The scheduling method for recording and playback of a double helix structure described in Appendix 2, characterized in that in step 2, the recording cache is empty or needs to be written, and the playback cache can be written to the sound card after being filled by the network or read file.
[0031] (Appendix 4) The specific process of step 3 is as follows: 2. The scheduling method for recording and playback of a double helix structure described in Appendix 1, characterized in that in the recording callback function, the cache of code i in the N playback cache queues is written to the sound card, i is incremented from 0 by 1, and if i is equal to N, it is reset to 0.
[0032] (Appendix 5) The specific process of step 4 is as follows: 5. The scheduling method for recording and playback of a double helix structure according to claim 4, characterized in that in the playback callback function, add a cache of code j in the N recording cache queues, increment j from 0 by 1, and reset it to 0 if i is equal to N.
[0033] (Appendix 6) In the scheduling method for recording and playback with a double helix structure described in Appendix 5, in steps 3 and 4, before writing the cache of code j in the N playback cache queues to the sound card and adding the cache of code i in the N recording cache queues, respectively, one sub-thread is turned on to establish a multi-thread recording and playback scheduling.
[0034] (Appendix 7) When processing real-time playback signals, the cache for code i in step 3 must be retrieved and processed before being added to the playback cache queue, and the processing result must be saved; A scheduling method for recording and playing back a double helix structure as described in Appendix 5, characterized in that when processing a real-time recording signal, the cache of code j in step 4 needs to be processed before writing it to the sound card.
[0035] (Appendix 8) The scheduling method for recording and playback of a double helix structure described in Appendix 5, wherein in steps 3 and 4, the recording callback function and the playback callback function respectively write the playback cache to the sound card or add the recording cache; after adding the recording cache or writing the cache to the sound card is completed, the corresponding recording callback function and playback callback function can be called; and until recording and playback are completed, the calling of the recording callback function and playback callback function, writing the playback cache to the sound card in the recording callback function, and adding the recording cache in the playback callback function are repeated.
Claims
1. 1. A scheduling method for recording and playing back a double helix structure, comprising: Step 1: preparing N frame caches for recording and playback respectively; Step 2: adding N recording caches to the sound card and starting recording, and writing N playback caches to the sound card one by one; Step 3 in the recording callback function writes the playback cache to the sound card; Step 4: adding a recording cache in the playback callback function; Step 5 of terminating the recording and playback; a recording callback function for writing a playback cache to the sound card and a playback callback function for adding a recording cache to the sound card, respectively, and after the recording cache is added or the recording cache is written to the sound card, the corresponding recording callback function and playback callback function can be called; and the calling of the recording callback function and playback callback function, the writing of the playback cache to the sound card in the recording callback function, and the adding of the recording cache in the playback callback function are repeated until the recording and playback are completed.
2. 2. The method for scheduling recording and playback of a double helix structure according to claim 1, wherein the specific command in step 2 is to sequentially add to the recording cache and write to the playback cache according to the code order of the cache.
3. 3. The scheduling method for recording and playing back with a double helix structure according to claim 2, wherein in step 2, the recording cache is empty or needs to be written, and the playing cache can be written to the sound card after being filled with playback data of a predetermined frame length via a network or a read file.
4. The specific process of step 3 is as follows:
2. The scheduling method for recording and playing back of a double helix structure according to claim 1, characterized in that in the recording callback function, the cache of code i in the N playback cache queues is written to the sound card, i is incremented by 1 from 0, and if i is equal to N, it is reset to 0.
5. The specific process of step 4 is as follows:
5. The scheduling method for recording and playing back of a double helix structure according to claim 4, characterized in that in the playback callback function, add a cache of code j in the N recording cache queues, increment j from 0 by 1, and reset it to 0 if i is equal to N.
6. A scheduling method for recording and playing back a double helix structure, comprising: Step 1: preparing N frame caches for recording and playback respectively; Step 2: adding N recording caches to the sound card and starting recording, and writing N playback caches to the sound card one by one; Step 3 in the recording callback function writes the playback cache to the sound card; Step 4: adding a recording cache in the playback callback function; Step 5 of terminating the recording and playback; The specific process of step 3 is as follows: In the recording callback function, write the cache of code i in the N playback cache queue to the sound card, increment i from 0 by 1, and reset i to 0 if i is equal to N; The specific process of step 4 is as follows: In the playback callback function, add a cache for code j in the N recording cache queue, increment j from 0 by 1, and reset it to 0 if i is equal to N; In step 3 and step 4, before writing the cache of code j in the N playback cache queues to the sound card and adding the cache of code i in the N recording cache queues, respectively, one sub-thread is turned on to establish a multi-thread recording and playback scheduling.
7. A scheduling method for recording and playback of a double helix structure, comprising: Step 1: preparing N frame caches for recording and playback respectively; Step 2: adding N recording caches to the sound card and starting recording, and writing N playback caches to the sound card one by one; Step 3 in the recording callback function writes the playback cache to the sound card; Step 4: adding a recording cache in the playback callback function; Step 5 of terminating the recording and playback; The specific process of step 3 is as follows: In the recording callback function, write the cache of code i in the N playback cache queue to the sound card, increment i from 0 by 1, and reset i to 0 if i is equal to N; The specific process of step 4 is as follows: In the playback callback function, add a cache for code j in the N recording cache queue, increment j from 0 by 1, and reset it to 0 if i is equal to N; When processing real-time playback signals, the cache for code i in step 3 must be retrieved and processed before being added to the playback cache queue, and the processing result must be saved; A scheduling method for recording and playing back with a double helix structure, characterized in that when processing real-time recording signals, the cache of code j in step 4 needs to be processed before being written to the sound card.
Citation Information
Patent Citations
Multi-channel audio processing method and system
CN109451417A
Recording device and method, reproducing device and method, recording medium and program
JP2004102647A
Determining the presence of an earpiece in a user's ear
JP2019523581A