Wireless audio device synchronous playback method, system and storage medium
By establishing wireless clock synchronization between the master and slave devices of true wireless headphones, setting cumulative values and generating hardware signals to record clock parameters, the problem of inconsistent headphone playback delay is solved, and high-precision synchronized playback and low power consumption are achieved.
Patent Information
- Application Number
- CN202211230926.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2042-09-30
AI Technical Summary
Since the left and right earphones of true wireless earphones each have independent clock systems, the playback delay is inconsistent, making it difficult to achieve high-precision synchronous playback, affecting the user experience.
By establishing wireless clock synchronization between the master wireless device and the slave wireless device, setting the accumulated value and generating a hardware signal to record the wireless clock parameters, the master device sends the clock parameters to the slave device to achieve synchronous playback.
It achieves high-precision synchronous playback of multiple wireless audio devices, reduces device power consumption and improves user experience.
Smart Images

Figure CN115604810B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of wireless communication technology, and in particular to a method, system and storage medium for synchronous playback of wireless audio devices. Background Art
[0002] With the advancement of society and the improvement of people's living standards, headphones have become an indispensable daily necessity. Compared with traditional headphones that connect to smart devices through wires, true wireless headphones eliminate the connection between the headphones and smart devices and the connection between the left and right ears, thus avoiding the entanglement and pulling of the headphone wires and the stethoscope effect. True wireless headphones are implemented by the smart device transmitting data (which can be music, voice, or data packets) to the left and right headphones via Bluetooth.
[0003] However, because the left and right earbuds of smart devices and true wireless earbuds belong to different subsystems and have independent clock systems, the playback delays of the left and right earbuds become inconsistent over time, making it difficult to achieve good playback synchronization. As a result, when playing music or making voice calls, the audio content played by the left and right earbuds cannot be played simultaneously, affecting the user experience. Summary of the Invention
[0004] The embodiment of the present application aims to provide a method, system and storage medium for synchronous playback of wireless audio devices, so as to achieve high-precision synchronous playback of multiple wireless audio devices.
[0005] In a first aspect, the present invention provides a method for synchronous playback of wireless audio devices, the method comprising: establishing wireless clock synchronization between a master wireless device and a slave wireless device; generating a first hardware signal when a first accumulated value of the master wireless device satisfies a preset condition, and recording a first wireless clock parameter corresponding to the wireless clock when the first hardware signal is generated; wherein the first accumulated value is accumulated in the following manner: each time a first clock cycle passes, a preset value is added to the first accumulated value, wherein the preset value is one-Nth of a resampling ratio of the master wireless device, where N is a positive integer; and generating a second accumulated value when a second accumulated value of the slave wireless device satisfies the preset condition. a second hardware signal, and recording a second wireless clock parameter corresponding to the wireless clock when the second hardware signal is generated; wherein the second accumulated value is accumulated in the following manner: after each first clock cycle, a preset value is added to the second accumulated value, wherein the preset value is one-Nth of the resampling ratio of the slave wireless device, where N is a positive integer; the resampling ratio of the slave wireless device is the same as the resampling ratio of the master wireless device; the master wireless device sends the first wireless clock parameter to the slave wireless device; and the slave wireless device achieves synchronized playback with the master wireless device based on the first wireless clock parameter and the second wireless clock parameter.
[0006] In the above scheme, wireless clock synchronization is first established between a master wireless device and a slave wireless device. A first accumulated value is set on the master wireless device. Each time a first clock cycle passes, one-Nth of the resampling ratio is added to the first accumulated value. When the first accumulated value meets a preset condition, a first hardware signal is generated and a first wireless clock parameter of the wireless clock corresponding to the first hardware signal is recorded. Similarly, a second accumulated value is set on the slave wireless device. Each time a first clock cycle passes, one-Nth of the resampling ratio is added to the second accumulated value. When the second accumulated value meets the same preset condition, a second hardware signal is generated and a second wireless clock parameter of the wireless clock corresponding to the second hardware signal is recorded. The master wireless device transmits the first wireless clock parameter to the slave wireless device. The slave wireless device compares the wireless clock times corresponding to the received first wireless clock parameter and the second wireless clock parameter, achieving high-precision synchronized playback between the master and slave wireless devices.
[0007] In an optional embodiment, establishing wireless clock synchronization between the master wireless device and the slave wireless device includes: the master wireless device obtaining a wireless clock signal of a first device and establishing wireless clock synchronization with the first device; the slave wireless device obtaining a wireless clock signal of the first device and establishing wireless clock synchronization with the first device.
[0008] In the above solution, both the master wireless device and the slave wireless device achieve wireless clock synchronization with the first device, thereby achieving wireless clock synchronization between the master wireless device and the slave wireless device.
[0009] In an optional embodiment, establishing wireless clock synchronization between the master wireless device and the slave wireless device includes: the slave wireless device acquiring the wireless clock signal of the master wireless device and establishing wireless clock synchronization with the master wireless device; or the master wireless device acquiring the wireless clock signal of the slave wireless device and establishing wireless clock synchronization with the slave wireless device.
[0010] In the above solution, the wireless clock signal of the master wireless device or the slave wireless device is used as a standard, and wireless clock synchronization is achieved through wireless signal transmission between the master wireless device and the slave wireless device.
[0011] In an optional embodiment, the slave wireless device achieves synchronized playback with the master wireless device based on the first wireless clock parameter and the second wireless clock parameter, including: when the time corresponding to the first wireless clock parameter is later than the time corresponding to the second wireless clock parameter, reducing the accumulated value of the resampling ratio; when the time corresponding to the first wireless clock parameter is earlier than the time corresponding to the second wireless clock parameter, increasing the accumulated value of the resampling ratio.
[0012] In an optional embodiment, determining that the first accumulated value of the master wireless device satisfies a preset condition includes: when an integer portion of the first accumulated value is increased by a first fixed value, a decimal portion of the first accumulated value is greater than a second fixed value, wherein the first fixed value is a positive integer and the second fixed value is greater than or equal to 0 and less than 1. Correspondingly, determining that the second accumulated value of the slave wireless device satisfies the preset condition includes: when the integer portion of the second accumulated value is increased by the first fixed value, a decimal portion of the second accumulated value is greater than the second fixed value.
[0013] In an optional embodiment, the master wireless device generates the first hardware signal in the following manner: every time a first clock cycle passes, the master wireless device generates the first hardware signal by the formula: acc1 i+1 =acc1 i +rate1 / N calculates the current first accumulated value; wherein, the acc1 i+1 is the value of the first accumulated value after i accumulations, the acc1 i is the value after i-1 accumulation of the first accumulated value, and rate1 is the resampling ratio of the master wireless device; when acc1i+1 meets the preset condition, the first hardware signal is generated; accordingly, the slave wireless device generates the second hardware signal in the following manner: every time the first clock cycle passes, the formula: acc2 i+1 =acc2 i +rate2 / N calculates the current second accumulated value; where acc2 i+1 is the value of the second accumulated value after i accumulations, acc2 i is the value of the second accumulated value after i-1 accumulations, rate2 is the resampling ratio of the slave wireless device; when acc2 i+1 When the preset condition is met, the second hardware signal is generated.
[0014] In an optional embodiment, the master wireless device generates the first hardware signal in the following manner: every second clock cycle, by the formula: acc3 i+1 =acc3 i +rate1 calculates the third accumulated value; wherein, the acc3 i+1is the value of the third accumulated value after i accumulations, the rate1 is the resampling ratio of the master wireless device, and the second clock period is N times the first clock period; when the integer part of the third accumulated value is increased by the first fixed value, the formula: M1 = [(1 + A - acc3_F) * N / rate1] + 1 is used to determine that the first hardware signal is generated after M1 first clock periods; wherein A is the second fixed value, and acc3_F is the decimal part of the third accumulated value; accordingly, the slave wireless device generates the second hardware signal in the following manner: after each second clock period, the formula: acc4 i+1 =acc4 i +rate2 calculates the fourth accumulated value; wherein, the acc4 i+1 is the value of the fourth accumulated value after i accumulations, the rate2 is the resampling ratio of the slave wireless device, and the second clock period is N times the first clock period; when the integer part of the fourth accumulated value is increased by the first fixed value, the formula: M2 = [(1 + A - acc3_F) * N / rate2] + 1 is used to determine that the second hardware signal is generated after M2 first clock periods; wherein A is the second fixed value, and acc4_F is the decimal part of the fourth accumulated value.
[0015] In the above scheme, it is not necessary to accumulate the first accumulated value once in each first clock cycle, but to accumulate the third accumulated value once in each second time period (the second time period is N times the first time period). Then, according to the above formula, it can be determined that the first hardware signal is generated after M1 first time periods have passed, which greatly reduces the number of operations and thus reduces the power consumption of the master wireless device.
[0016] In a second aspect, the present invention provides a wireless audio device synchronous playback system, the system comprising: a master wireless device and a slave wireless device, the master wireless device and the slave wireless device being configured to execute the method as described in any one of the aforementioned embodiments.
[0017] In an optional implementation, the master wireless device is a master earpiece of a wireless headset, and the slave wireless device is a slave earpiece of the wireless headset.
[0018] In a third aspect, the present invention provides a computer-readable storage medium having computer program instructions stored thereon. When the computer program instructions are read and executed by a computer, the method as described in any one of the aforementioned embodiments is executed. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A schematic diagram of the structure of a wireless audio device synchronous playback system provided in an embodiment of the present application;
[0021] Figure 2 This is a flowchart of a method for synchronous playback of wireless audio devices provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0023] In order to achieve high-precision synchronous playback of multiple wireless audio devices, the embodiments of the present application provide a method, system and storage medium for synchronous playback of wireless audio devices. After research and exploration, the inventors of the present application propose the following embodiments to solve the above problems.
[0024] The technical solution provided in the embodiments of the present application can be applied to various application scenarios involving synchronous playback of multiple wireless audio devices, such as: synchronous playback between the left and right earphones of a true wireless headset, synchronous playback between multiple wireless Bluetooth speakers, or synchronous playback between multiple true wireless headsets.
[0025] See also Figure 1 , Figure 1 This is a schematic diagram of the structure of a wireless audio device synchronous playback system provided in an embodiment of the present application. In this embodiment of the present application, the wireless audio device synchronous playback system 100 includes a master wireless device 101 and a slave wireless device 102. In a wireless audio device synchronous playback system 100, one master wireless device 101 is provided, and the number of slave wireless devices 102 can be one or more.
[0026] There are various ways for the master wireless device 101 and the slave wireless device 102 to obtain audio data, which are not specifically limited in the embodiments of the present application. For example, in some embodiments, the master wireless device 101 establishes a wireless connection with an audio source (which can be a smart device, such as a mobile phone, computer, etc.), the master wireless device 101 establishes a wireless connection with the slave wireless device 102, the audio source sends audio data to the master wireless device 101, and the master wireless device 101 forwards the audio data to the slave wireless device 102. In other embodiments, the master wireless device 101 establishes a wireless connection with an audio source, the master wireless device 101 establishes a wireless connection with the slave wireless device 102, the audio source sends audio data to the master wireless device 101, and the slave wireless device 102 monitors the audio data sent by the audio source to the master wireless device 101, thereby obtaining the audio data.
[0027] The master wireless device 101 may be a master earphone of a true wireless headset, and correspondingly, the slave wireless device 102 may be a slave earphone of the true wireless headset. The master wireless device 101 and the slave wireless device 102 may also be two wireless Bluetooth speakers.
[0028] See also Figure 2 , Figure 2 This is a flowchart of a method for synchronous playback of wireless audio devices provided in an embodiment of the present application. The method for synchronous playback of wireless audio devices can be applied to the above-mentioned synchronous playback system of wireless audio devices. The method includes:
[0029] Step 201: Wireless clock synchronization is established between the master wireless device and the slave wireless device.
[0030] Step 202: When the first accumulated value of the master wireless device meets a preset condition, a first hardware signal is generated, and a first wireless clock parameter of the wireless clock corresponding to the generation of the first hardware signal is recorded.
[0031] Step 203: When the second accumulated value of the slave wireless device meets a preset condition, a second hardware signal is generated, and a second wireless clock parameter corresponding to the wireless clock when the second hardware signal is generated is recorded.
[0032] Step 204: The master wireless device sends the first wireless clock parameter to the slave wireless device.
[0033] Step 205: The slave wireless device plays synchronously with the master wireless device based on the first wireless clock parameter and the second wireless clock parameter.
[0034] The above steps are described in detail below.
[0035] Step 201: Wireless clock synchronization is established between the master wireless device and the slave wireless device.
[0036] In the embodiment of the present application, the master wireless device and the slave wireless device each maintain their own wireless clock. In order to achieve synchronous playback between the master wireless device and the slave wireless device, wireless clock synchronization needs to be established between the master wireless device and the slave wireless device.
[0037] As an optional implementation, establishing wireless clock synchronization between the master wireless device and the slave wireless device may include the following:
[0038] The master wireless device obtains the wireless clock signal of the first device and establishes wireless clock synchronization with the first device; the slave wireless device obtains the wireless clock signal of the first device and establishes wireless clock synchronization with the first device.
[0039] In this embodiment of the present application, a master wireless device and a slave wireless device each establish wireless communication with a first device, obtain wireless clock information from the first device, and then, based on the obtained wireless clock information from the first device, establish wireless clock synchronization with the first device. Since both the master wireless device and the slave wireless device have achieved wireless clock synchronization with the first device, wireless clock synchronization is achieved between the master wireless device and the slave wireless device.
[0040] Specifically, the first device transmits a wireless signal to the master wireless device and the slave wireless device. The wireless signal includes a known signal sequence. Because the wireless signal has negligible air delay, the first device transmits the wireless signal and the master wireless device receives the wireless signal at the same time. Similarly, the first device transmits the wireless signal and the slave wireless device receives the wireless signal at the same time. The master wireless device and the first device have the same nominal wireless clock frequency. When wireless clock synchronization between the master wireless device and the first device is achieved through wireless signal transmission and reception, the master wireless device and the first device have the same wireless clock frequency. Similarly, the slave wireless device and the first device have the same nominal wireless clock frequency. When wireless clock synchronization between the slave wireless device and the first device is achieved through wireless signal transmission and reception, the slave wireless device and the first device have the same wireless clock frequency. The wireless clock frequencies of both the master wireless device and the slave wireless device are the same as the wireless clock frequency of the first device, thereby achieving the same wireless clock frequency between the master wireless device and the slave wireless device.
[0041] The master wireless device is provided with a master wireless clock timer, and the slave wireless device is provided with a slave wireless clock counter. The master wireless clock timer and the slave wireless clock timer increment by 1 during each wireless clock cycle. When the master wireless device and the slave wireless device receive a wireless signal transmitted by the first device, a difference Δcount between the count value of the master wireless clock timer and the count value of the slave wireless clock timer is determined, thereby achieving wireless clock synchronization.
[0042] As another optional implementation, establishing wireless clock synchronization between the master wireless device and the slave wireless device may include the following:
[0043] The slave wireless device obtains the wireless clock signal of the master wireless device and establishes wireless clock synchronization with the master wireless device; or the master wireless device obtains the wireless clock signal of the slave wireless device and establishes wireless clock synchronization with the slave wireless device. In the embodiments of the present application, the above content can be understood as two ways to establish wireless clock synchronization between the master wireless device and the slave wireless device.
[0044] The first method is to establish wireless communication between the master wireless device and the slave wireless device based on the wireless clock signal of the master wireless device. The slave wireless device obtains the wireless clock signal of the master wireless device and establishes wireless clock synchronization with the master wireless device.
[0045] Specifically, the master wireless device transmits a wireless signal to the slave wireless device. The wireless signal includes a known signal sequence. Because the wireless signal has negligible delay over the air, the master wireless device transmits the wireless signal and the slave wireless device receives the wireless signal at the same time. The master and slave wireless devices have the same nominal wireless clock frequency. When wireless clock synchronization is achieved between the master and slave wireless devices through wireless signal transmission and reception, the master and slave wireless devices achieve the same wireless clock frequency.
[0046] The second method is to establish wireless communication between the master wireless device and the slave wireless device based on the wireless clock signal of the slave wireless device. The master wireless device obtains the wireless clock signal of the slave wireless device and establishes wireless clock synchronization with the slave wireless device.
[0047] It can be understood that the second wireless clock synchronization method is similar to the first wireless clock synchronization method mentioned above. The only difference is that the first wireless clock synchronization method uses the wireless clock signal of the master wireless device as the standard, and the second wireless clock synchronization method uses the wireless clock signal of the slave wireless device as the standard. In order to keep the specification concise, it will not be elaborated here.
[0048] It should be noted that the method for establishing wireless communication between the above-mentioned master wireless device and the slave wireless device can be through Bluetooth (including classic Bluetooth protocol, Bluetooth Low Energy protocol (Bluetooth Low Energy, BLE), low-power audio standard (LE Audio) etc.) or WIFI protocol etc.
[0049] Step 202: When the first accumulated value of the master wireless device meets a preset condition, a first hardware signal is generated, and a first wireless clock parameter of the wireless clock corresponding to the generation of the first hardware signal is recorded.
[0050] In the embodiment of the present application, the first accumulated value is accumulated in the following manner: a preset value is added to the first accumulated value every first clock cycle, where the preset value is one-Nth of the resampling ratio of the master wireless device, where N is a positive integer. The inverse of the first clock cycle (i.e., the frequency of the first clock) is N times the sampling rate of the audio data output by the resampling module of the master wireless device, where N is an integer greater than 1.
[0051] To facilitate understanding of the above content, the working principle of the resampling module of the main wireless device is first introduced.
[0052] After receiving the audio data sent by the audio source, the main wireless device decompresses the audio data. The sampling rate of the decompressed audio data is f source Determined by the audio source, usually 44.1KHz, 48KHz, 88.2KHz, 96KHz, 128KHz, etc. The playback clock frequency f of the main wireless device b It is determined by the frequency division of the crystal or crystal oscillator clock of the main wireless device. Commonly used crystal or crystal oscillator clocks are 24MHz, 24.576MHz, 26MHz, etc. However, the playback clock frequency f of the main wireless device b and the decompressed audio data sampling rate f source Different, and often do not have an integer multiple relationship, so the decompressed audio data needs to go through a resampling module before playing, and the sampling rate is f source The audio data is converted into a sampling rate based on the wireless device playback clock frequency f b The audio data is then played through the main wireless device after the resampling module.
[0053] For example, assuming the crystal or oscillator clock of the master wireless device is 26MHz, the sampling rate of the decompressed audio data is f source The main wireless device's playback clock frequency is 48KHz. b Determined by the master wireless device's crystal clock divided by 512, i.e. f b =26MHz / 512=50.78125KHz. Therefore, a resampling module is required to convert the audio data with a sampling rate of 48KHz into audio data with a sampling rate of 50.78125KHz.
[0054] During the resampling process, the resampling ratio rate1 is defined as: rate1 = f source / f b .
[0055] In the embodiment of the present application, the frequency f1 of the first clock is the sampling rate of the audio data output by the resampling module of the master wireless device (ie, the above-mentioned f bN is a positive integer greater than 1, such as 128, 256, 384, 512, etc. The frequency f1 of the first clock is also determined by dividing the crystal or crystal oscillator clock of the master wireless device. Thus, the first clock and the playback clock corresponding to the first clock period are obtained by dividing the same clock source (i.e., the crystal or crystal oscillator clock of the master wireless device), and the frequency of the first clock is N times the frequency of the playback clock.
[0056] The master wireless device defines a first accumulated value acc1. Each first clock cycle, a preset value is added to the first accumulated value acc1. The preset value is one-Nth of the master wireless device's resampling ratio, i.e., rate1 / N. When the first accumulated value acc1 satisfies a preset condition, a first hardware signal is generated, and a first wireless clock parameter corresponding to the wireless clock generated when the first hardware signal is generated is recorded.
[0057] In the embodiment of the present application, after the master wireless device generates the first hardware signal, it records the first wireless clock parameter corresponding to the wireless clock when the first hardware signal is generated. The first wireless clock parameter is used to indicate that the time when the master wireless device generates the first hardware signal is the time corresponding to the wireless clock.
[0058] Specifically, as can be seen from the foregoing, the master wireless device is provided with a master wireless clock counter that increments by 1 during each wireless clock cycle. The current count value of the master wireless clock counter when the first hardware signal is generated is used as a first wireless clock parameter. This first wireless clock parameter represents the time corresponding to the wireless clock at which the master wireless device generates the first hardware signal.
[0059] As an optional implementation manner, determining whether the first accumulated value of the master wireless device meets a preset condition includes:
[0060] When the integer part of the first accumulated value increases by the first fixed value, the decimal part of the first accumulated value is greater than the second fixed value.
[0061] In this embodiment of the present application, the first fixed value is a positive integer, and the second fixed value is greater than or equal to 0 and less than 1. During each first clock cycle, the master wireless device adds a preset value to the first accumulated value. When the integer portion of the first accumulated value increases by the first fixed value, and the fractional portion of the first accumulated value is greater than the second fixed value, the master wireless device determines that the first accumulated value meets a preset condition, and the master wireless device needs to generate a first hardware signal at that moment, and records the first wireless clock parameter of the wireless clock corresponding to the generation of the first hardware signal. The master wireless device then continues to add the preset value to the first accumulated value during each first clock cycle. When the first accumulated value increases by the first fixed value again, and the fractional portion of the first accumulated value is again greater than the second fixed value, the master wireless device determines that the first accumulated value meets the preset condition again, and the master wireless device needs to generate a second first hardware signal at that moment, and records the first wireless clock parameter of the wireless clock corresponding to the generation of the second first hardware signal, and repeats this cycle.
[0062] For example, the first fixed value is 1, the second fixed value is 0.3, and the initial value of the first accumulated value is 0. After each first clock cycle, the master wireless device adds a preset value to the first accumulated value. When the first accumulated value is accumulated to a value greater than 0.3 for the first time, it is determined that the first accumulated value meets the preset condition; when the first accumulated value is accumulated to a value greater than 1.3 for the first time, it is determined that the first accumulated value meets the preset condition again; when the first accumulated value is accumulated to a value greater than 2.3 for the first time, it is determined that the first accumulated value meets the preset condition again, and the cycle continues.
[0063] The embodiment of the present application does not specifically limit the first fixed value, and the first fixed value can be any positive integer, such as 1, 2, 3, etc.
[0064] The embodiment of the present application does not specifically limit the second fixed value. The first fixed value can be any value greater than or equal to 0 and less than 1, such as 0, 0.1, 0.2, 0.3, etc.
[0065] The embodiment of the present application does not specifically limit the initial value of the first accumulated value. The initial value of the first accumulated value can be 0 or other values, such as 1, 2, etc.
[0066] In the embodiment of the present application, there are multiple ways for the master wireless device to generate the first hardware signal. Two specific implementation methods for generating the first hardware signal are provided below.
[0067] As an optional implementation manner, the master wireless device generates the first hardware signal in the following manner:
[0068] Every time the first clock cycle passes, the formula: acc1 i+1 =acc1 i +rate1 / N calculates the current first accumulated value; where acc1 i+1is the value of the first accumulated value after i accumulations, acc1 i is the value after i-1 accumulation of the first accumulated value, rate1 is the resampling ratio of the main wireless device; when acc1 i+1 When a preset condition is met, a first hardware signal is generated.
[0069] In the embodiment of the present application, the master wireless device executes acc1 once in each first clock cycle. i+1 =acc1 i +rate1 / N, calculate and determine the first accumulated value in the current first clock cycle, and judge the first accumulated value. If the first accumulated value meets the preset condition, generate a first hardware signal.
[0070] For example, the first fixed value is 1, the second fixed value is 0.3, rate1=f source / f b , f source is 48KHz, f b is 50.78125KHz, N is 512, rate1 / N=0.001846153846154, the frequency f1 of the first clock is f b The initial value of the first accumulated value acc1 is 0. In each first clock cycle, the first accumulated values are: 0.001846153846154, 0.003692307692308, 0.005538461538462, ..., 1.000615384615385, 1.002461538461539, ..., 2.001230769230769, 2.003076923076923, .... When the first accumulated value acc1 is greater than 0.3 for the first time, a first hardware signal is generated; when the first accumulated value acc1 is greater than 1.3 for the first time, a first hardware signal is generated; when the first accumulated value acc1 is greater than 2.3 for the first time, a first hardware signal is generated, and so on.
[0071] As another optional implementation, the master wireless device generates the first hardware signal in the following manner:
[0072] Every second clock cycle, by the formula: acc3 i+1 =acc3 i +rate1 calculates the third accumulated value; where acc3 i+1 is the value of the third accumulated value after i accumulations, rate1 is the resampling ratio of the master wireless device, and the second clock period is N times the first clock period;
[0073] When the integer part of the third accumulated value increases by the first fixed value, the formula: M1 = [(1+A-acc3_F)*N / rate1]+1 is used to determine that the first hardware signal is generated after M1 first clock cycles; where A is the second fixed value and acc3_F is the decimal part of the third accumulated value.
[0074] In the embodiment of the present application, the second clock cycle is the playback clock cycle of the main wireless device, that is, the aforementioned playback clock frequency f b The master wireless device executes acc3 once per play clock cycle. i+1 =acc3 i +rate1, calculate and determine the third accumulated value in the current second clock cycle, and judge the third accumulated value. If the integer part of the third accumulated value increases by the first fixed value, then calculate and determine that the first hardware signal is generated after M1 first clock cycles according to the formula M1 = [(1+A-acc3_F)*N / rate1]+1. It should be noted that the decimal part of the calculated M1 is ignored, and only the integer part is taken.
[0075] For example, the first fixed value is 1, the second fixed value is 0.3, rate1=f source / f b , f source is 48KHz, and the frequency f corresponding to the second clock cycle is bThe frequency is 50.78125 kHz, N is 512, the second clock cycle is 512 times the first clock cycle, rate1 = 0.945230769230769, and the initial value of the third accumulated value acc3 is 0. During each second clock cycle, the third accumulated value is: 0.945230769230769, 1.890461538461538, 2.835692307692308, 3.780923076923077, 4.726153846153846, ... Since the second clock cycle is 512 times the first clock cycle, when the third accumulated value is 1.890461538461538, M1 is calculated as 222 according to the above formula. That is, when the third accumulated value is 1.890461538461538, after 222 first clock cycles, the first accumulated value acc1 = 2.300307692307692, which is greater than 2.3 for the first time, generating a first hardware signal. Similarly, when the third accumulated value is 2.835692307692308, M1 is calculated as 252 according to the above formula. That is, when the third accumulated value is 2.835692307692308, after 252 first clock cycles, the first accumulated value acc1 = 3.300923076923077, which is greater than 3.3 for the first time, generating a first hardware signal. It can be seen that, through the above method, it is also possible to determine when the first accumulated value meets the preset condition, and then generate the first hardware signal at the corresponding moment.
[0076] In the above embodiment, it is not necessary to accumulate the first accumulated value once in each first clock cycle, but to accumulate the third accumulated value once in each second time period (the second time period is N times the first time period). Then, according to the above formula, it can be determined that the first hardware signal is generated after M1 first time periods have passed, which greatly reduces the number of operations and thus reduces the power consumption of the master wireless device.
[0077] Step 203: When the second accumulated value of the slave wireless device meets a preset condition, a second hardware signal is generated, and a second wireless clock parameter corresponding to the wireless clock when the second hardware signal is generated is recorded.
[0078] In the embodiment of the present application, the second accumulated value is accumulated in the following manner: a preset value is added to the second accumulated value every first clock cycle, where the preset value is one-Nth of the resampling ratio of the slave wireless device, where N is a positive integer. The frequency of the first clock is N times the sampling rate of the audio data output by the resampling module of the master wireless device, where N is an integer greater than 1.
[0079] It will be appreciated that to achieve synchronized playback, the master and slave wireless devices must have identical configuration parameters for their resampling modules, namely, the nominal playback clock frequency, nominal resampling ratio, and nominal first clock period. The second accumulated value acc2 defined by the slave wireless device is also identical to the first accumulated value acc1 defined by the master wireless device. Therefore, the execution process of step 203 is identical to the execution process of step 202 and, for the sake of brevity, will not be further elaborated here.
[0080] It should be noted that although the nominal playback clock frequency, nominal resampling ratio, and nominal first clock period of the master and slave wireless devices are identical, their actual playback clock frequency, actual resampling ratio, and actual first clock period are all generated by frequency division of the crystal or crystal oscillator on each device. Therefore, due to frequency deviation of the crystal or crystal oscillator on each device, there will be slight differences in the actual playback clock frequency, actual resampling ratio, and actual first clock period of the master and slave wireless devices. As audio playback time increases, these slight differences accumulate, causing the master and slave wireless devices to experience playback desynchronization. Therefore, adjustments must be made to the master and slave wireless devices to achieve synchronized playback.
[0081] As an optional implementation manner, determining whether the second accumulated value of the slave wireless device meets a preset condition includes:
[0082] When the integer part of the second accumulated value is increased by the first fixed value, the decimal part of the second accumulated value is greater than the second fixed value.
[0083] It can be understood that determining whether the second accumulated value of the slave wireless device meets the preset condition is the same as determining whether the first accumulated value of the master wireless device meets the preset condition, and is not described here for brevity.
[0084] As an optional implementation manner, the second hardware signal is generated from the wireless device in the following manner:
[0085] Every time the first clock cycle passes, the formula: acc2 i+1 =acc2 i +rate2 / N calculates the current second accumulated value; where acc2 i+1 is the value of the second accumulated value after i accumulations, acc2 i is the value of the second accumulated value after i-1 accumulations, rate2 is the resampling ratio of the wireless device; when acc2 i+1 When a preset condition is met, a second hardware signal is generated.
[0086] As another optional implementation, the second hardware signal is generated from the wireless device in the following manner:
[0087] Every second clock cycle, through the formula: acc4 i+1 =acc4 i +rate2 calculates the fourth accumulated value; where acc4 i+1 is the value of the fourth accumulated value after i accumulations, rate2 is the resampling ratio of the slave wireless device, and the second clock period is N times the first clock period;
[0088] When the integer part of the fourth accumulated value increases by the first fixed value, the second hardware signal is generated after M2 first clock cycles through the formula: M2 = [(1+A-acc3_F)*N / rate2]+1; where A is the second fixed value and acc4_F is the decimal part of the fourth accumulated value.
[0089] It can be understood that in the above two embodiments, the process of the slave wireless device generating the second hardware signal is the same as the process of the master wireless device generating the first hardware signal, and for the sake of brevity, it is not described here in detail.
[0090] It can be understood that there is no order relationship between the above steps 202 and 203, and the two steps are executed simultaneously.
[0091] Step 204: The master wireless device sends the first wireless clock parameter to the slave wireless device.
[0092] In the embodiment of the present application, after the master wireless device generates the first hardware signal and determines the first wireless clock parameter, the master wireless device sends the first wireless clock parameter to the slave wireless device via wireless communication.
[0093] Step 205: The slave wireless device plays synchronously with the master wireless device based on the first wireless clock parameter and the second wireless clock parameter.
[0094] In this embodiment of the present application, the slave wireless device receives the first wireless clock parameter sent by the master wireless device, and the slave wireless device determines its own corresponding second wireless clock parameter through step 203. Because the first hardware signal and the second hardware signal are generated in exactly the same manner, if the master wireless device and the slave wireless device maintain synchronized playback, the wireless clock moment corresponding to the first wireless clock parameter and the wireless clock moment corresponding to the second wireless clock parameter are consistent. The audio data to be played by the master and slave wireless devices can be the same audio data or two-channel stereo audio data; in short, it is audio data with the same sampling rate. However, although the nominal playback frequency of the master and slave wireless devices is the same, the actual playback frequency of the master and slave wireless devices is generated by the crystals or crystal oscillators of their respective devices, which often have some frequency deviation. Over time, the wireless clock moment corresponding to the first wireless clock parameter and the wireless clock moment corresponding to the second wireless clock parameter will gradually deviate, resulting in asynchrony between the audio data played by the master and slave wireless devices.
[0095] Therefore, after receiving the first wireless clock parameter sent by the master wireless device, the slave wireless device compares the moment of the wireless clock corresponding to the first wireless clock parameter with the moment of the wireless clock corresponding to the second wireless clock parameter. When the moment corresponding to the first wireless clock parameter is later than the moment corresponding to the second wireless clock parameter, the resampling ratio accumulated value is reduced; when the moment corresponding to the first wireless clock parameter is earlier than the moment corresponding to the second wireless clock parameter, the resampling ratio accumulated value is increased.
[0096] Specifically, as described above regarding wireless clock synchronization, during wireless clock synchronization, the count value of the master wireless clock timer is subtracted from the count value of the slave wireless clock timer at the same time to obtain Δcount. If the master wireless device and the slave wireless device have the same playback frequency, the master wireless device generates the first hardware signal and the slave wireless device generates the second hardware signal at the same time, i.e., the difference between the first wireless clock parameter and the second wireless clock parameter should be equal to Δcount. If the difference between the first wireless clock parameter and the second wireless clock parameter is greater than Δcount, it indicates that the time corresponding to the first wireless clock parameter is later than the time corresponding to the second wireless clock parameter. In this case, the accumulated resampling ratio value is reduced to adjust the time when the master wireless device generates the first hardware signal and the slave wireless device generates the second hardware signal, so that the difference between the first wireless clock parameter and the second wireless clock parameter is equal to Δcount. If the difference between the first wireless clock parameter and the second wireless clock parameter is less than Δcount, it means that the time corresponding to the first wireless clock parameter is earlier than the time corresponding to the second wireless clock parameter. In this case, the resampling ratio accumulated value is increased to adjust the time when the master wireless device generates the first hardware signal and the slave wireless device generates the second hardware signal so that the difference between the first wireless clock parameter and the second wireless clock parameter is equal to Δcount.
[0097] The cumulative value of the resampling ratio is expressed as: accX i+1 =accX i +rate1, where accX i+1 is the value of the resampling ratio after i times of accumulation, accX i The resampling ratio accumulated value is the value after i-1 accumulation. The master wireless device and the slave wireless device accumulate their respective resampling ratio accumulated values in each playback clock cycle. Each time the resampling ratio accumulated value is accumulated, the resampling module resamples the received audio data according to the resampling ratio accumulated value, outputs a resampled audio data, and then plays the resampled audio data.
[0098] In the embodiment of the present application, the master wireless device resamples the received audio data according to its own resampling ratio accumulation value, and outputs a resampled audio data in each playback clock cycle (ie, plays the resampled audio data).
[0099] The slave wireless device adjusts the resampling ratio accumulated value according to the above method, resamples the received audio data according to the adjusted resampling ratio accumulated value, and outputs a resampled audio data in each playback clock cycle, thereby achieving precise synchronous playback between the master wireless device and the slave wireless device.
[0100] An embodiment of the present application provides a method for synchronized playback of wireless audio devices. First, wireless clock synchronization is established between a master wireless device and a slave wireless device. A first accumulated value is set on the master wireless device. Each time a first clock cycle passes, one-Nth of the resampling ratio is added to the first accumulated value. When the first accumulated value satisfies a preset condition, a first hardware signal is generated and a first wireless clock parameter of the wireless clock corresponding to the first hardware signal is recorded. Similarly, a second accumulated value is set on the slave wireless device. Each time a first clock cycle passes, one-Nth of the resampling ratio is added to the second accumulated value. When the second accumulated value satisfies the same preset condition, a second hardware signal is generated and a second wireless clock parameter of the wireless clock corresponding to the second hardware signal is recorded. The master wireless device transmits the first wireless clock parameter to the slave wireless device. The slave wireless device compares the wireless clock times corresponding to the received first and second wireless clock parameters to achieve high-precision synchronized playback between the master and slave wireless devices.
[0101] Furthermore, because the frequency of the first clock is N times the playback clock frequency of the wireless audio device, the synchronized playback method provided in the embodiment of the present application utilizes a higher clock frequency compared to existing solutions for synchronized playback using the playback clock frequency of wireless audio devices, significantly improving synchronization accuracy. Furthermore, compared to existing solutions for synchronized playback using the playback clock frequency of wireless audio devices, which require transmitting not only the wireless clock parameters of the master wireless device but also the fractional portion of the accumulated resampling ratio value, the embodiment of the present application only requires transmitting the wireless clock parameters of the master wireless device, eliminating the need to transmit the fractional portion of the accumulated resampling ratio value. This reduces the amount of data transmitted between multiple wireless audio devices and mitigates the loss of synchronized playback accuracy caused by transmission errors and transmission delays.
[0102] In addition, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a computer, the steps of the method for synchronous playback of wireless audio devices in the above embodiment are executed.
[0103] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0104] In addition, the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0105] Furthermore, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0106] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0107] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any actual relationship or order between these entities or operations.
[0108] The above description is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, various modifications and variations of the present application are possible. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for synchronous playback of wireless audio devices, characterized in that: The method comprises: Establishing wireless clock synchronization between the master wireless device and the slave wireless device; When the first accumulated value of the master wireless device satisfies a preset condition, a first hardware signal is generated, and a first wireless clock parameter corresponding to the wireless clock when the first hardware signal is generated is recorded; wherein the first accumulated value is accumulated in the following manner: a preset value is added to the first accumulated value every time a first clock cycle passes, wherein the preset value is one-N of a resampling ratio of the master wireless device, where N is a positive integer; When the second accumulated value of the slave wireless device meets the preset condition, a second hardware signal is generated, and a second wireless clock parameter corresponding to the wireless clock when the second hardware signal is generated is recorded; wherein the second accumulated value is accumulated in the following manner: after each first clock cycle, a preset value is added to the second accumulated value, wherein the preset value is 1 / N of the resampling ratio of the slave wireless device, where N is a positive integer; and the resampling ratio of the slave wireless device is the same as the resampling ratio of the master wireless device; The master wireless device sends the first wireless clock parameter to the slave wireless device; The slave wireless device plays synchronously with the master wireless device based on the first wireless clock parameter and the second wireless clock parameter; The slave wireless device implements synchronous playback with the master wireless device based on the first wireless clock parameter and the second wireless clock parameter, including: when a time corresponding to the first wireless clock parameter is later than a time corresponding to the second wireless clock parameter, reducing a resampling ratio accumulated value; when a time corresponding to the first wireless clock parameter is earlier than a time corresponding to the second wireless clock parameter, increasing a resampling ratio accumulated value; Determining that the first accumulated value of the master wireless device satisfies a preset condition includes: when an integer portion of the first accumulated value is increased by a first fixed value, a decimal portion of the first accumulated value is greater than a second fixed value, wherein the first fixed value is a positive integer and the second fixed value is greater than or equal to 0 and less than 1. Correspondingly, determining that the second accumulated value of the slave wireless device satisfies the preset condition includes: when the integer portion of the second accumulated value is increased by the first fixed value, a decimal portion of the second accumulated value is greater than the second fixed value.
2. The method according to claim 1, characterized in that Establishing wireless clock synchronization between the master wireless device and the slave wireless device includes: The master wireless device obtains a wireless clock signal from the first device and establishes wireless clock synchronization with the first device; The slave wireless device obtains the wireless clock signal of the first device and establishes wireless clock synchronization with the first device.
3. The method according to claim 1, wherein Establishing wireless clock synchronization between the master wireless device and the slave wireless device includes: The slave wireless device obtains the wireless clock signal of the master wireless device and establishes wireless clock synchronization with the master wireless device; or The master wireless device obtains the wireless clock signal of the slave wireless device and establishes wireless clock synchronization with the slave wireless device.
4. The method according to claim 1, wherein The master wireless device generates a first hardware signal by: Every time the first clock cycle passes, the formula: acc1 i+1 =acc1 i +rate1 / N calculates the current first accumulated value; wherein, the acc1 i+1 is the value of the first accumulated value after i accumulations, the acc1 i is the value of the first accumulated value after i-1 accumulations, and rate1 is the resampling ratio of the master wireless device; When the acc1 i+1 When the preset condition is met, generating the first hardware signal; Accordingly, the slave wireless device generates the second hardware signal in the following manner: Every time the first clock cycle passes, the formula: acc2 i+1 =acc2 i +rate2 / N calculates the current second accumulated value; where acc2 i+1 is the value of the second accumulated value after i accumulations, acc2 i is the value of the second accumulated value after i-1 accumulations, and rate2 is the resampling ratio of the slave wireless device; When the acc2 i+1 When the preset condition is met, the second hardware signal is generated.
5. The method according to claim 1, wherein The master wireless device generates a first hardware signal by: Every second clock cycle, by the formula: acc3 i+1 =acc3 i +rate1 calculates the third accumulated value; wherein, the acc3 i+1 is the value of the third accumulated value after i accumulations, rate1 is the resampling ratio of the master wireless device, and the second clock period is N times the first clock period; When the integer part of the third accumulated value is increased by the first fixed value, determining that the first hardware signal is generated after M1 first clock cycles have passed, using the formula: M1= [(1+A-acc3_F)*N / rate1]+1; wherein A is the second fixed value, and acc3_F is the decimal part of the third accumulated value; Accordingly, the slave wireless device generates the second hardware signal in the following manner: Every second clock cycle, through the formula: acc4 i+1 =acc4 i +rate2 calculates the fourth accumulated value; wherein, the acc4 i+1 is the value of the fourth accumulated value after i accumulations, the rate2 is the resampling ratio of the slave wireless device, and the second clock period is N times the first clock period; When the integer part of the fourth accumulated value is increased by the first fixed value, the formula: M2=[(1+A-acc4_F)*N / rate2]+1 is used to determine that the second hardware signal is generated after M2 first clock cycles; wherein A is the second fixed value, and acc4_F is the decimal part of the fourth accumulated value.
6. A wireless audio device synchronous playback system, characterized in that: The system comprises: A master wireless device and a slave wireless device, wherein the master wireless device and the slave wireless device are configured to execute the method according to any one of claims 1 to 5.
7. The system according to claim 6, characterized in that The master wireless device is a master earpiece of the wireless headset, and the slave wireless device is a slave earpiece of the wireless headset.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are read and executed by a computer, the method according to any one of claims 1 to 5 is executed.
Citation Information
Patent Citations
Method for synchronously playing audios of wireless equipment
CN110636600A
Audio system and wireless earphone pair
CN112867138A