CN110636349A - Audio synchronous playing method for wireless equipment - Google Patents

Audio synchronous playing method for wireless equipment Download PDF

Info

Publication number
CN110636349A
CN110636349A CN201910769037.3A CN201910769037A CN110636349A CN 110636349 A CN110636349 A CN 110636349A CN 201910769037 A CN201910769037 A CN 201910769037A CN 110636349 A CN110636349 A CN 110636349A
Authority
CN
China
Prior art keywords
clock
value
resampling
module
wireless device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201910769037.3A
Other languages
Chinese (zh)
Other versions
CN110636349B (en
Inventor
童伟峰
张亮
徐明亮
肖奕峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Heng Xuan Technology (shanghai) Co Ltd
Original Assignee
Heng Xuan Technology (shanghai) Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Heng Xuan Technology (shanghai) Co Ltd filed Critical Heng Xuan Technology (shanghai) Co Ltd
Priority to CN201910769037.3A priority Critical patent/CN110636349B/en
Publication of CN110636349A publication Critical patent/CN110636349A/en
Application granted granted Critical
Publication of CN110636349B publication Critical patent/CN110636349B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/41Structure of client; Structure of client peripherals
    • H04N21/4104Peripherals receiving signals from specially adapted client devices
    • H04N21/4122Peripherals receiving signals from specially adapted client devices additional display device, e.g. video projector
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/4302Content synchronisation processes, e.g. decoder synchronisation
    • H04N21/4305Synchronising client clock from received content stream, e.g. locking decoder clock with encoder clock, extraction of the PCR packets
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/4302Content synchronisation processes, e.g. decoder synchronisation
    • H04N21/4307Synchronising the rendering of multiple content streams or additional data on devices, e.g. synchronisation of audio on a mobile phone with the video output on the TV screen

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Synchronisation In Digital Transmission Systems (AREA)

Abstract

The invention provides a method for synchronously playing audio of wireless equipment, which comprises the following steps: synchronizing the receiving and transmitting clocks of the slave wireless equipment of the master wireless equipment; the master wireless device records a first clock value of a first counting clock at the triggering moment and a second clock value of the first counting clock at the coming moment of a first playing clock, and sends the first clock value and the second clock value to the slave wireless device; the slave wireless device records a third clock value of the second counting clock at the triggering moment and a fourth clock value of the second counting clock at the coming moment of the second playing clock, compares the first clock value, the second clock value, the difference value between the first clock value and the second clock value with the third clock value, the fourth clock value, the difference value between the third clock value and the fourth clock value, and adjusts the sampling value of the second resampling module. The invention sends the parameters of the resampling module of the master wireless device to the slave wireless device, and adjusts the clock and the resampling parameters of the slave wireless device, thereby realizing the accurate synchronization of the master wireless device and the slave wireless device.

Description

Audio synchronous playing method for wireless equipment
Technical Field
The invention relates to the technical field of wireless communication, in particular to a method for synchronously playing audio of wireless equipment.
Background
With the social progress and the improvement of the living standard of people, the earphone becomes an indispensable living article for people. Traditional wired earphones are connected with intelligent equipment (such as a smart phone, a notebook computer, a tablet computer and the like) through wires, so that the actions of a wearer can be limited, and the traditional wired earphones are very inconvenient in sports occasions. Meanwhile, the winding and pulling of the earphone cord, as well as the stethoscope effect, all affect the user experience. The common Bluetooth headset cancels the connection between the headset and the intelligent device, but the connection still exists between the left ear and the right ear. True wireless stereo headphones are produced at the same time.
One implementation of the existing true wireless headset is that the smart device performs data transmission (which may be music, voice, or data packets, etc.) with the left and right headsets through bluetooth. For example, stereo music is played, and the intelligent device transmits the music to the left and right earphones respectively. However, the left and right earphones belong to two subsystems respectively, are realized in two sets of different chips and are provided with independent clock systems. Therefore, in the existing true wireless earphone system, the left ear and the right ear are difficult to realize good synchronization. Therefore, for example, when music is played, the music of the left ear and the music of the right ear are difficult to be played simultaneously accurately, and the quality of the music is greatly influenced. For another example, when a voice call is made, it is difficult to play the voices of the left and right ears accurately at the same time.
Because the intelligent device, the wireless left earphone and the wireless right earphone are respectively independent subsystems and respectively have independent crystal and clock systems, even under the condition that the receiving and transmitting clocks are synchronous, the situation of asynchronous playing can also occur along with the time.
Therefore, in order to solve the above problems in the prior art, there is a need for a method for audio synchronized playback of a wireless device, in which a clock system of a slave wireless device and resampling of the slave wireless device are adjusted by sending a resampling parameter of a master wireless device to the slave wireless device, so that the master device and the slave device realize accurate audio synchronized playback.
Disclosure of Invention
The invention aims to provide a method for synchronously playing audio of wireless equipment, which comprises the following steps:
a first receive clock of the master wireless device synchronized with a second receive clock of the slave wireless device;
the primary wireless device receives audio data, the first sampling module samples the received audio data,
the first resampling module resamples the sampled data of the first sampling module, the resampled data is played by a first playing clock according to the frequency of the playing clock,
the first receiving clock is triggered according to fixed N periods, a hardware trigger signal is generated, a first clock value of a first counting clock at the triggering moment is recorded, and a second clock value of the first counting clock at the coming moment of a first playing clock is recorded later;
the master wireless device sends a first clock value of the first counting clock, a second clock value of the first counting clock or a difference value of the first clock value and the second clock value to the slave wireless device;
receiving audio data from the wireless device, the second sampling module samples the received audio data,
the second resampling module resamples the sampling data of the second sampling module, and the resampled data is played by a second playing clock according to the frequency of the playing clock;
the second receiving clock is triggered according to the fixed N periods, a hardware trigger signal is generated, a third clock value of the second counting clock at the triggering moment is recorded, and a fourth clock value of the second counting clock at the coming moment of the second playing clock is recorded;
and after receiving the first clock value of the first counting clock, the second clock value of the first counting clock or the difference value of the first clock value and the second clock value from the wireless equipment, comparing the first clock value with the third clock value, the difference value of the first clock value and the second clock value with the difference value of the third clock value and the fourth clock value, and adjusting the sampling value of the second resampling module.
Preferably, the first resampling module resamples according to the following method:
defining a first resampling ratio rate0 ═ f _ audio0/f _ codec0, where rate0 is a first resampling ratio initial value, f _ audio0 is a nominal sampling rate of the first sampling module, and f _ codec0 is a nominal playing frequency of the first playing clock;
defining a first resampling ratio rate with an initial value of rate 0;
accumulating the first resampling ratios: acc (acrylic acid)n+1=accn+ rate + offset, where accn+1The value of the first resampling ratio after being accumulated n times, offset is the offset complement value of the first resampling module, n is 1,2, …,
the first resampling module outputs a resampled sample value every time the accumulated value of the first resampling ratio is accumulated.
Preferably, the resampled sample value output by the first resampling module is obtained by interpolating sample data before resampling.
Preferably, the resampled sample value output by the first resampling module is obtained by interpolating two adjacent sample data before resampling.
Preferably, the resampled sample value output by the first resampling module is obtained by interpolating a plurality of sample data before resampling.
Preferably, the second resampling module resamples according to the following method:
and defining a second resampling ratio which is the same as the first resampling ratio, wherein the second resampling module outputs a resampled sampling value every time the accumulated value of the second resampling ratio is accumulated.
Preferably, the resampled sample value output by the second resampling module is obtained by interpolating the sample data before resampling.
Preferably, the resampled sample value output by the second resampling module is obtained by interpolating the two adjacent sample data before resampling.
Preferably, the resampled sample value output by the second resampling module is obtained by interpolating a plurality of sample data before resampling.
Preferably, the sampling value of the second resampling module is adjusted by:
adjusting the accumulated value of the second resampling ratio:
acc2i=acci(count1-count2) x rate/M + (delta2-delta1) x rate/M, wherein, acciAccumulate the value i times for the first resampling ratio, acc2iAccumulating the ith value for the second resampling ratio, rate being the first resampling ratio, count1 being the first clock value of the first count clock, count2 being the third clock value of the second count clock, M being the division number between the second count clock and the second play clock, delta2 being the difference between the third clock value and the fourth clock value, delta1 being the difference between the first clock value and the second count clock value;
the second resampling module outputs a resampled sample value every time the accumulated value of the second resampling ratio is accumulated.
The invention provides a method for synchronously playing audio of wireless equipment, which is characterized in that the receiving and sending clocks of a master wireless equipment and a slave wireless equipment are synchronized, based on the synchronization, the parameters of a resampling module of the master wireless equipment are sent to the slave wireless equipment, meanwhile, a counting clock is introduced into the master wireless equipment and the slave wireless equipment to count the playing clocks, the clocks of the slave wireless equipment are adjusted by using the playing clock difference of the master wireless equipment and the slave wireless equipment, and the resampling parameters of the slave wireless equipment are adjusted by using the resampling parameters of the master wireless equipment, so that the accurate synchronization of the master wireless equipment and the slave wireless equipment is realized.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Drawings
Further objects, features and advantages of the present invention will become apparent from the following description of embodiments of the invention, with reference to the accompanying drawings, in which:
figure 1 schematically illustrates a diagram of one embodiment of a master wireless device establishing a connection with a slave wireless device in accordance with the present invention.
Fig. 2 is a flow chart illustrating a method for audio synchronized playback of a wireless device according to the present invention.
Fig. 3 shows a schematic diagram of the clock system of the master-slave line device of the present invention.
Fig. 4 shows a schematic diagram of the synchronization of the master wireless device transceiving clocks with the slave wireless device in accordance with the present invention.
Fig. 5 shows a timing diagram of the master wireless device and slave wireless device triggering the playout clock of the present invention.
Detailed Description
The objects and functions of the present invention and methods for accomplishing the same will be apparent by reference to the exemplary embodiments. However, the present invention is not limited to the exemplary embodiments disclosed below; it can be implemented in different forms. The nature of the description is merely to assist those skilled in the relevant art in a comprehensive understanding of the specific details of the invention.
Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the drawings, the same reference numerals denote the same or similar parts, or the same or similar steps.
The present invention is described in detail below with reference to specific embodiments, in which the master wireless device and the slave wireless device may be a wireless bluetooth headset or a wireless bluetooth speaker.
In some embodiments, the smart device establishes a wireless connection with a master wireless device, the master wireless device establishes a wireless connection with a slave wireless device, the smart device transmits audio data to the master wireless device, and the master wireless device forwards the audio data to the slave wireless device. In still other embodiments, the smart device establishes a wireless connection with the master wireless device, and the slave wireless device monitors audio data sent by the smart device to the master wireless device, and specifically, a person skilled in the art may select the slave wireless device according to different application scenarios.
One embodiment of the present invention, as shown in fig. 1, of a master wireless device establishing a connection with a slave wireless device, is schematically illustrated by the following steps:
and S101, establishing wireless connection between the main line equipment and the intelligent equipment.
Step S102, the master wireless device sends the wireless connection parameters to the slave wireless device.
The master wireless device establishes a wireless connection (e.g., a bluetooth link connection) with the smart device, and the master wireless device transmits wireless connection parameters established with the smart device, such as smart device address, connection encryption information, connection keys, frequency hopping information, and the like, to the slave wireless device.
Step S103, receiving wireless connection parameters from the wireless device.
The slave wireless device may then receive data for the wireless connection between the master wireless device and the smart device using the wireless connection parameters.
Referring to fig. 2, a flow chart of a method for synchronously playing audio of a wireless device according to the present invention is shown, and according to an embodiment of the present invention, a method for synchronously playing audio of a wireless device includes the following steps:
in step S201, the master wireless device and the slave wireless device first perform transmission/reception clock synchronization.
First, a clock system of a master-slave wireless device provided by the present invention is explained, as shown in fig. 3, a clock system schematic diagram of a master-slave wireless device of the present invention is shown, the master wireless device 100 includes a transceiving clock for receiving audio data sent from an intelligent device, an implementation of the present invention exemplarily takes a receiving clock as an example, and the master wireless device includes a first receiving clock 101. Likewise, the slave wireless device 200 includes a second receive clock 201 for receiving audio data transmitted from the master wireless device 100 or the smart device.
In the present invention, the clock used for receiving the wireless signal may also be the same source clock of the receiving clock, for example, the clock frequency is P times of the receiving clock, where P is a positive integer. The two clocks are divided by the same clock, so-called homologous clocks, and the division multiples may be different.
According to an embodiment of the present invention, the master wireless device 100 further comprises a first sampling module 102, a resampling module 103, and a first playout clock 104, and the slave wireless device further comprises a second sampling module 202, a second resampling module 203, and a second playout clock.
According to the present invention, the master wireless device and the slave wireless device firstly perform clock synchronization for transmitting and receiving, and the first receiving clock 101 of the master wireless device 100 and the second receiving clock 201 of the slave wireless device 200 are synchronized in this embodiment, as shown in fig. 4, the slave wireless device 200 performs conversion processing on the received radio frequency signal to obtain a timing synchronization signal, a timing synchronization error and a carrier synchronization error. Specifically, a radio frequency signal is received from the radio frequency front end 203 of the wireless device, a digital signal is obtained by sampling through a digital-to-analog converter, and a timing synchronization signal, a timing synchronization error and a carrier synchronization error of the wireless device are obtained by synchronizing and demodulating the digital signal.
The radio frequency signal is received from the radio frequency front end of the wireless device 200, digital signals are obtained through digital-to-analog conversion, and the digital signals are synchronized and demodulated to obtain timing synchronization signals, timing synchronization errors and carrier synchronization errors.
The timing synchronization error and/or carrier synchronization error of the slave wireless device 200 adjusts the crystal oscillation frequency via the phase locked loop such that the second receive clock frequency of the slave wireless device is at the same frequency as the first receive clock frequency of the master wireless device 100. At the same time, the start time of the timing synchronization signal is synchronized with the start time of the slot at which the master wireless device transmits the audio signal to the slave wireless device.
The demodulation signal after the crystal oscillation frequency is adjusted by the phase-locked loop is fed back to the radio frequency front end and the frequency divider. Through the above signal synchronization processing, the master wireless device 100 and the slave wireless device 200 achieve the reception clock synchronization, that is, the first reception clock 101 and the second reception clock 102 achieve the synchronization.
In this embodiment, the crystal oscillation frequency is adjusted by the phase-locked loop for both the timing synchronization error and the carrier synchronization error, and in some embodiments, the crystal oscillation frequency is adjusted by the phase-locked loop for any one of the timing synchronization error and the carrier synchronization error.
The wireless connection may be a bluetooth connection or a bluetooth low energy connection.
Step S202, the primary wireless device receives audio data.
According to an embodiment of the present invention, the primary wireless device receives audio data, decompresses the received data, and buffers in a buffer.
The first sampling module 102 samples the received audio data, and the first receiving clock 101 operates at a higher frequency, for example, up to 1MHz/s, and the sampling rate of the decompressed audio data is usually 44.1KHz/s, or 48KHz/s, or 96KHz/s, or 192 KHz/s. The invention samples the decompressed audio data through a first sampling module, for example, the first sampling module samples at a sampling rate of 44k.1hz/s, and this sampling indicates that the audio data at the sampling rate can be obtained, for example, the audio data is read from a memory.
The playing clock is used for playing the audio frequency of the sampled data according to the playing clock.
For the first playback clock 104, it may be divided by a crystal clock, for example, in some embodiments, the crystal clock has a nominal frequency of 26MHz/s, and the first playback clock is divided by 512 times the crystal clock, resulting in 50.078125 KHz/s.
The sampling rate (e.g. 44.1KHz/s) of the first sampling module 102 and the playing frequency (50.078125KHz/s) of the first playing clock 104 are two different clocks, and the audio data is played according to the playing clock after the data sampled by the first sampling module is resampled, the sampling rate of the first sampling module 102 is converted into the playing clock frequency of the first playing clock 104.
According to the embodiment of the present invention, the data sampled by the first sampling module 102 is buffered in the buffer, the first resampling module 103 resamples the sampled data of the first sampling module 102, and the resampled data is played by the first playing clock 104 according to the playing clock frequency.
Fig. 5 shows a timing diagram of the master wireless device 100 and the slave wireless device 200 triggering the playout clock of the present invention, which is triggered by the first receive clock in a fixed N number of cycles to generate a hardware trigger signal to trigger the first playout clock according to an embodiment of the present invention. For example, when a certain period of the first receiving clock is over, a trigger signal is sent to trigger the first playing clock to start playing audio at the beginning of the next period.
According to the embodiment of the invention, the first receiving clock generates a hardware trigger signal according to a fixed N periods, triggers the first playing clock, records a first clock value of the first counting clock at the triggering moment and a second clock value of the first counting clock at the coming moment of the first playing clock.
In the invention, the first counting clock is obtained by crystal clock frequency division, for example, the nominal frequency of the crystal clock is 26MHz/s, and the first counting clock is obtained by crystal clock 8 frequency division, so that the first counting clock is 3.25 MHz/s. In the invention, in order to improve the synchronous playing precision of the master wireless equipment and the slave wireless equipment, the clock frequency of the counting clock is generally higher and is far greater than the playing clock frequency. For example, the first count clock is 3.25 MHz/s; the first playback clock is 50.078125 KHz/s.
According to the embodiment of the present invention, the first resampling module 103 resamples the data sampled by the first sampling module 102 according to the following method:
a first resampling ratio initial value rate0 is defined as f _ audio0/f _ codec0, where rate0 is the first resampling ratio initial value, f _ audio0 is the nominal sampling rate of the first sampling module, and f _ codec0 is the nominal playing frequency of the first playing clock.
A first resampling ratio rate is defined, with an initial value of rate 0. Because the sampling rate of the first sampling module and its nominal sampling rate, and the playing clock frequency of the first playing clock and its nominal playing clock frequency have slight deviation, so that rate and rate0 can have slight deviation, the invention adopts the defined first resampling ratio to perform the first resampling ratio accumulation.
Accumulating the first resampling ratios: acc (acrylic acid)n+1=accn+ rate + offset, where accn+1The value of the first resampling ratio after being accumulated n times, offset is the offset complement value of the first resampling module, n is 1,2, …,
the first resampling module outputs a resampled sample value every time the accumulated value of the first resampling ratio is accumulated.
In some embodiments, the first accumulated initial value acc may be 0, or may be another value, which is selected according to actual situations.
The resampled sampling value output by the first resampling module is obtained by interpolation of sampling data before resampling.
In one embodiment, the resampled sample value output by the first resampling module is obtained by interpolating sample data of two adjacent samples before resampling.
For example, the N1 th sampling value before resampling and the N1+1 th sampling value before resampling are interpolated to obtain the resample value output by the first resampling module after nth accumulation. Specifically, the calculation can be performed by the following interpolation method:
y ═ audio _ N × (1-acc _ F) + audio _ N +1 xcac _ F, where Y is the resample value output by the first resampling module after the nth accumulation, audio _ N is the N1 th sample value before resampling, N1+1 th sample value before audio _ N +1 resampling, and acc _ F is the fractional part of the value after the first resampling ratio is accumulated N times.
In the invention, the first resampling ratio is accumulated for N times to obtain the value accNIts integer part is acc _ N and its fractional part is acc _ F. The sampling point participating in the resampling operation before resampling is determined by acc _ N, i.e. acc _ N equals N1 as described above.
For example, the sampled value before resampling is processed by an X-time upsampling filter, and the I1 th upsampled value after the X-time upsampling filter is interpolated with the I1+1 th upsampled value before resampling, so as to obtain the resample value output by the first resampling module after I-time accumulation. Specifically, the calculation can be performed by the following interpolation method:
y ═ audio _ osX _ I × (1-osX _ F) + audio _ osX _ I +1 × osX _ F, where Y' is the resample value output by the first resampling module after the nth accumulation, audio _ osX _ I is the I1 th upsample value after X times upsampling filter, audio _ osX _ I +1 is the I1+1 th upsample value after X times upsampling filter, osX _ I ═ accn+1Integer part of X, osX _ F ═ accn+1Fractional part of X, accn+1The values after n times are accumulated for the first resampling ratio.
The sampling point after the X-fold upsampling filter participating in the resampling operation is determined by osX _ I, i.e., osX _ I equals to I1 as described above.
X is a positive integer, such as 4, 8, 16, etc. The larger X, the higher the accuracy of the resampled audio data.
In another embodiment, the resampled sample values output by the first resampling module 103 are interpolated from a plurality of sample data before resampling.
For example, the N2 th sampling value before resampling, the N2+1 th sampling value before resampling, and the N2+2 th sampling value before resampling are interpolated to obtain the resample value output by the first resampling module after nth accumulation. The specific calculation process is the same as the interpolation method of the two sampling values, and the fractional part of the value obtained by accumulating the first resampling ratio for N times is used for interpolation, which is not described herein again.
For the resampling process, since the actual sampling rate of the first sampling module has a slight deviation from the nominal sampling rate of the first sampling module, the actual playing frequency of the first playing clock has a slight deviation from the nominal playing frequency of the first playing clock, for example, in some embodiments, the nominal sampling rate of the first sampling module has a deviation within about 100ppm from the actual sampling rate of the first sampling module; the nominal play frequency of the first play clock is within about 100ppm of the actual play frequency of the first play clock.
The above deviation may often cause too much or too little data in the buffer after the first sampling module samples, i.e. too much or too little data before the first resampling module resamples. According to the invention, when the first resampling module carries out resampling, the offset supplement recharging of the first resampling module is introduced in the accumulation process of the first resampling ratio, and the data of the buffer can not overflow or be too little by adjusting the offset supplement recharging.
Specifically, in some embodiments, a deviation of the nominal sampling rate of the first sampling module from the actual sampling rate of the first sampling module, and/or a deviation of the nominal playout frequency of the first playout clock from the actual playout frequency of the first playout clock, results in a deviation of the first resample actual rate from the calculated first resample rate 0.
In one embodiment, rate0 is maintained. When the actual first resampling ratio is greater than rate0, which results in an increasing data in the buffer, i.e. an increasing data before resampling, the offset is made greater than 0 by adjusting the offset compensation value offset. Adding up the first resampling ratio n times to obtain the value acc by adjusting the offset compensation valuen+1Increase, thereby facilitating the increased accn+1The data before resampling is interpolated.
When the actual first resampling rate is less than rate0, the data in the buffer is decreased continuously, that is, the data before resampling is decreased continuously, and the offset is made smaller than 0 by adjusting and offsetting the complementary offset. Adding up the first resampling ratio n times to obtain the value acc by adjusting the offset compensation valuen+1Decrease, thereby facilitating the reduced accn+1The data before resampling is interpolated.
In another embodiment, the offset is kept equal to 0, and when the first resampling actual ratio is greater than rate0, the data in the buffer is increased, that is, the data before resampling is increased, and at this time, the rate is adjusted to slightly increase, so that the value acc of the first resampling ratio after accumulating n times is enabledn+1Increase, thereby facilitating the increased accn+1The data before resampling is interpolated. When the actual first resampling rate is lower than rate0, the data in the buffer is decreased, that is, the data before resampling is decreased, and at this time, the rate is adjusted to be slightly decreased, so that the value acc after accumulating the first resampling rate for n timesn+1Decrease, thereby facilitating the reduced accn+1The data before resampling is interpolated.
In another embodiment. When the actual first resampling ratio is larger than the rate0, the data in the buffer is increased, that is, the data before resampling is increased, and then the rate is adjustede value and offset value, so that the first resampling ratio is accumulated for n times to obtain the value accn+1Increase, thereby facilitating the increased accn+1The data before resampling is interpolated. When the actual first resampling rate is lower than rate0, the data in the buffer is decreased, that is, the data before resampling is decreased, and then the value acc of the first resampling rate after accumulating n times is adjusted by adjusting the rate value and the offset valuen+1Decrease, thereby facilitating the reduced accn+1The data before resampling is interpolated.
The offset supplement value of the first resampling module is introduced in the accumulation process of the first resampling ratio, and the offset supplement value or/and the resampling ratio rate are adjusted, so that on one hand, the data of the buffer cannot overflow or be too little, on the other hand, the time delay of the first playing clock for playing the audio signal is reduced, and the time delay is kept stable.
After the resampling, the data output by the first resampling module is played through the first playing clock.
Step S203, the master wireless device transmits the parameters to the slave wireless device.
According to an embodiment of the present invention, the master wireless device 100 sends the resampled parameters in step S202 to the slave wireless device 200, including the master wireless device sending the first clock value of the first count clock, the second clock value of the first count clock or the difference between the first clock value and the second clock value to the slave wireless device, and sending the first resampling ratio rate, the value acc accumulated by the first resampling module each time, to the slave wireless devicen+1The first accumulated initial value acc and the offset supplemental value offset of the first resampling module are sent to the slave wireless device.
After the parameters sent from the wireless device 200 according to the master line device: in one embodiment, the value acc of the second resampling module after each accumulation may be determined according to the first clock parameter, and the first fractional part interpolation parameter, the first integer part parameter of the resampling of the first resampling modulen+1Or/and a second resampling module rate. In another embodiment, the first clock parameter may be based on, and the first resampling ratio rate, value acc after each accumulation of the first resampling modulen+1And the second resampling module is carried out by the first accumulation initial value acc and the offset compensation value offset of the first resampling module.
Step S204, receiving audio data from the wireless device.
According to an embodiment of the present invention, audio data is received from a wireless device, the received data is decompressed and buffered in a buffer.
The second sampling module 202 samples the received audio data and the second receiving clock 201 operates at a higher frequency, e.g. up to 1MHz/s, and the sampling rate for the decompressed data is typically 44.1KHz/s, or 48KHz/s, or 96KHz/s, or 192 KHz/s. The invention samples the data through a second sampling module, for example, the second sampling module samples according to a sampling rate of 44.1 KHz/s.
The second resampling module 203 resamples the sampled data of the second sampling module 202, and the resampled data is played according to the playing frequency by the second playing clock.
The playing clock is used for playing the audio frequency of the sampled data according to the playing clock.
For the second playback clock, the second playback clock is obtained by dividing the crystal clock, for example, in some embodiments, the nominal frequency of the crystal clock is 26MHz/s, and the second playback clock is obtained by dividing the crystal clock by 512 times, so that the second playback clock is 50.078125 KHz.
The sampling rate (e.g. 44.1KHz/s) of the second sampling module 202 and the playing clock frequency (50.078125KHz/s) of the second playing clock 204 are two different clocks, and the audio clock data is played according to the playing clock after the data sampled by the second sampling module is resampled, the sampling rate of the second sampling module is converted into the playing frequency of the second playing clock.
According to the embodiment of the present invention, the data sampled by the second sampling module 202 is buffered in the buffer, the second resampling module 203 resamples the sampled data of the second sampling module, and the resampled data is played according to the playing frequency by the first playing clock 204.
Returning to fig. 5, the timing diagrams of the master wireless device and the slave wireless device triggering the broadcast clocks of the present invention, according to an embodiment of the present invention, the second receiving clock is triggered by a fixed N number of cycles, and a hardware trigger signal is generated to trigger the second broadcast clock. For example, when a certain period of the second receiving clock is over, a trigger signal is sent to trigger the second playing clock to start playing the audio at the beginning of the next period. According to the embodiment of the invention, the second receiving clock is triggered according to the fixed N periods, the hardware trigger signal is generated to trigger the second playing clock, the third clock value of the second counting clock at the triggering moment is recorded, and the fourth clock value of the second counting clock at the coming moment of the second playing clock is recorded. In the invention, the second counting clock is obtained by crystal clock frequency division, for example, the nominal frequency of the crystal clock is 26MHz/s, and the second counting clock is obtained by crystal clock frequency division of 64 times, so that the first counting clock is 3.25 MHz.
The master wireless device has already sent the resampled parameters to the slave wireless device, and in one embodiment, the slave wireless device may determine the value acc each time the second resampling module accumulates according to the first clock parameter, and the resampled first fractional portion interpolation parameter, the first integer portion parameter of the first resampling modulen+1Or/and a second resampling module rate. In another embodiment, the value acc of each accumulation of the first resampling module may be according to the first clock parameter and the first resampling ratio raten+1And the second resampling module is carried out by the first accumulation initial value acc and the offset compensation value offset of the first resampling module.
The second resampling module resamples according to the following method:
and defining a second resampling ratio which is the same as the first resampling ratio, wherein the second resampling module outputs a resampled sampling value every time the accumulated value of the second resampling ratio is accumulated.
In some embodiments, the resampled sample values output by the second resampling module are interpolated from the sample data before resampling. In other embodiments, the resampled sample value output by the second resampling module is interpolated from the two adjacent sample data before resampling. In still other embodiments, the resampled sample values output by the second resampling module are interpolated from a plurality of sample data before resampling.
The resampling process of the second resampling module and the interpolation process of the first resampling module adopt the same fractional part interpolation method to perform interpolation, which is specifically explained in detail in step S202 and is not described herein again.
After the resampling, the data output by the second resampling module 203 starts to be played by the second playing clock 204
Since the first receiving clock 101 and the second receiving clock 102 have been synchronized in step S201, the master wireless device 100 triggers in accordance with the first receiving clock for a fixed number N of cycles, generates a hardware trigger signal, and records a second clock value of the first counting clock when the first playing clock arrives later, and the slave wireless device 200 triggers in accordance with the second receiving clock for a fixed number N of cycles, generates a hardware trigger signal, and records a fourth clock value of the second counting clock when the second playing clock arrives later. The first playing clock and the second playing clock can play audio approximately synchronously at the beginning.
In one embodiment, the first and second playback clocks may be triggered to start playing the audio data at the same time, for example, at the same receiving clock value.
However, when the master wireless device and the slave wireless device play audio simultaneously, and one of the samples output by the first resampling module and the second resampling module is different, a delay between the first playing clock and the second playing clock, which is usually about 20us (if the playing clock frequency is 50.078125KHz/s), will gradually increase the delay of the first playing clock and the second playing clock playing the audio signal as time goes on, so that the two wireless devices lose synchronous playing.
The master wireless device records a first clock value of a first counting clock, a second clock value of the first counting clock or a difference value of the first clock value and the second clock value, and sends the first clock value and the second clock value to the slave wireless device.
In some embodiments, the master wireless device of the present invention transmits a first clock value of a first count clock and a second clock value of the first count clock to the slave wireless device, and the slave wireless device calculates a difference between the first clock value and the second clock value.
In other embodiments, the master wireless device calculates a difference between the first clock value and the second clock value, and transmits the clock value of the first count clock and the second clock value of the first count clock to the slave wireless device.
The slave wireless device records a third clock value of the second count clock, a fourth clock value of the second count clock, or a difference between the third clock value and the fourth clock value.
And comparing the first clock value with the third clock value, comparing the difference value of the first clock value with the second clock value with the difference value of the third clock value with the fourth clock value, and adjusting the sampling value of the second resampling module.
In some embodiments, the sampling value of the second resampling module is adjusted by:
adjusting the accumulated value of the second resampling ratio:
acc2i=acci(count1-count2) x rate/M + (delta2-delta1) x rate/M, wherein, acciAccumulate the value i times for the first resampling ratio, acc2iAccumulating the ith value for the second resampling ratio, rate being the first resampling ratio, count1 being the first clock value of the first count clock, count2 being the third clock value of the second count clock, M being the division number between the second count clock and the second playback clock, delta2 being the difference between the third clock value and the fourth clock value, delta1 being the difference between the first clock value and the second count clock value
The second resampling module outputs a resampled sample value every time the accumulated value of the second resampling ratio is accumulated.
The invention adjusts the second playing clock of the slave wireless equipment by the resampling parameter of the master wireless equipment and the clock number of the first playing clock, thereby ensuring that the first playing clock and the second playing clock are kept synchronous accurately.
The invention provides a method for synchronously playing audio of wireless equipment, which is characterized in that the receiving and sending clocks of a master wireless equipment and a slave wireless equipment are synchronized, based on the synchronization, the parameters of a resampling module of the master wireless equipment are sent to the slave wireless equipment, meanwhile, a counting clock is introduced into the master wireless equipment and the slave wireless equipment to count the playing clocks, the clocks of the slave wireless equipment are adjusted by using the playing clock difference of the master wireless equipment and the slave wireless equipment, and the resampling parameters of the slave wireless equipment are adjusted by using the resampling parameters of the master wireless equipment, so that the accurate synchronous playing of the master wireless equipment and the slave wireless equipment is realized.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

Claims (10)

1. A method for synchronized audio playback in a wireless device, the method comprising the steps of:
a first receive clock of the master wireless device synchronized with a second receive clock of the slave wireless device;
the primary wireless device receives audio data, the first sampling module samples the received audio data,
the first resampling module resamples the sampled data of the first sampling module, the resampled data is played by a first playing clock according to the frequency of the playing clock,
the first receiving clock is triggered according to fixed N periods, a hardware trigger signal is generated, a first clock value of a first counting clock at the triggering moment is recorded, and a second clock value of the first counting clock at the coming moment of a first playing clock is recorded later;
the master wireless device sends a first clock value of the first counting clock, a second clock value of the first counting clock or a difference value of the first clock value and the second clock value to the slave wireless device;
receiving audio data from the wireless device, the second sampling module samples the received audio data,
the second resampling module resamples the sampling data of the second sampling module, and the resampled data is played by a second playing clock according to the frequency of the playing clock;
the second receiving clock is triggered according to the fixed N periods, a hardware trigger signal is generated, a third clock value of the second counting clock at the triggering moment is recorded, and a fourth clock value of the second counting clock at the coming moment of the second playing clock is recorded;
and after receiving the first clock value of the first counting clock, the second clock value of the first counting clock or the difference value of the first clock value and the second clock value from the wireless equipment, comparing the first clock value with the third clock value, the difference value of the first clock value and the second clock value with the difference value of the third clock value and the fourth clock value, and adjusting the sampling value of the second resampling module.
2. The method of claim 1, wherein the first resampling module resamples by:
defining a first resampling ratio rate0 ═ f _ audio0/f _ codec0, where rate0 is a first resampling ratio initial value, f _ audio0 is a nominal sampling rate of the first sampling module, and f _ codec0 is a nominal playing frequency of the first playing clock;
defining a first resampling ratio rate with an initial value of rate 0;
accumulating the first resampling ratios: acc (acrylic acid)n+1=acc n+ rate + offset, where accn+1The value of the first resampling ratio after being accumulated n times, offset is the offset complement value of the first resampling module, n is 1,2, …,
the first resampling module outputs a resampled sample value every time the accumulated value of the first resampling ratio is accumulated.
3. The method of claim 2, wherein the resampled values from the first resampling module are interpolated from the sampled data prior to resampling.
4. The method of claim 2 or 3, wherein the resampled values from the first resampling module are interpolated from the sampled data from two adjacent samples before resampling.
5. A method according to claim 2 or 3, wherein the resampled values from the first resampling module are interpolated from the plurality of sample data before resampling.
6. The method of claim 1, wherein the second resampling module resamples the samples as follows:
and defining a second resampling ratio which is the same as the first resampling ratio, wherein the second resampling module outputs a resampled sampling value every time the accumulated value of the second resampling ratio is accumulated.
7. The method of claim 6, wherein the resampled values from the second resampling module are interpolated from the sampled data prior to resampling.
8. The method of claim 6 or 7, wherein the resampled values from the second resampling module are interpolated from the sampled data from two neighboring samples before resampling.
9. The method of claim 6 or 7, wherein the resampled values from the second resampling module are interpolated from the plurality of sample data prior to resampling.
10. The method of claim 1, wherein the sampling value of the second resampling module is adjusted by:
adjusting the accumulated value of the second resampling ratio:
acc2i=acci+(count1-count2)×rate/M+(delta2-delta1)×
rate/M, wherein, acciAccumulate the value i times for the first resampling ratio, acc2iAccumulating the ith value for the second resampling ratio, rate being the first resampling ratio, count1 being the first clock value of the first count clock, count2 being the third clock value of the second count clock, M being the division number between the second count clock and the second play clock, delta2 being the difference between the third clock value and the fourth clock value, delta1 being the difference between the first clock value and the second clock value;
the second resampling module outputs a resampled sample value every time the accumulated value of the second resampling ratio is accumulated.
CN201910769037.3A 2019-08-20 2019-08-20 Audio synchronous playing method for wireless equipment Active CN110636349B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910769037.3A CN110636349B (en) 2019-08-20 2019-08-20 Audio synchronous playing method for wireless equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910769037.3A CN110636349B (en) 2019-08-20 2019-08-20 Audio synchronous playing method for wireless equipment

Publications (2)

Publication Number Publication Date
CN110636349A true CN110636349A (en) 2019-12-31
CN110636349B CN110636349B (en) 2022-01-18

Family

ID=68970525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910769037.3A Active CN110636349B (en) 2019-08-20 2019-08-20 Audio synchronous playing method for wireless equipment

Country Status (1)

Country Link
CN (1) CN110636349B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110636600A (en) * 2019-08-20 2019-12-31 恒玄科技(上海)有限公司 Audio synchronous playing method for wireless equipment
CN112235705A (en) * 2020-10-13 2021-01-15 恒玄科技(上海)股份有限公司 Double-ear hearing aid
CN112787742A (en) * 2021-03-16 2021-05-11 芯原微电子(成都)有限公司 Clock synchronization method and device, wireless earphone and readable storage medium
WO2024046120A1 (en) * 2022-09-02 2024-03-07 华为技术有限公司 Communication apparatus, and communication synchronization method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100042239A1 (en) * 2004-06-25 2010-02-18 Moore Jeffrey C Techniques For Providing Audio For Synchronized Playback By Multiple Devices
CN103414957A (en) * 2013-07-30 2013-11-27 广东工业大学 Method and device for synchronization of audio data and video data
CN107454510A (en) * 2017-07-10 2017-12-08 珠海市杰理科技股份有限公司 Audio sync player method of the bluetooth to case, system
CN108415685A (en) * 2018-07-12 2018-08-17 恒玄科技(上海)有限公司 Wireless Bluetooth headsets realize the method being precisely played simultaneously
CN109521988A (en) * 2017-09-18 2019-03-26 炬芯(珠海)科技有限公司 A kind of audio plays synchronous method and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100042239A1 (en) * 2004-06-25 2010-02-18 Moore Jeffrey C Techniques For Providing Audio For Synchronized Playback By Multiple Devices
CN103414957A (en) * 2013-07-30 2013-11-27 广东工业大学 Method and device for synchronization of audio data and video data
CN107454510A (en) * 2017-07-10 2017-12-08 珠海市杰理科技股份有限公司 Audio sync player method of the bluetooth to case, system
CN109521988A (en) * 2017-09-18 2019-03-26 炬芯(珠海)科技有限公司 A kind of audio plays synchronous method and device
CN108415685A (en) * 2018-07-12 2018-08-17 恒玄科技(上海)有限公司 Wireless Bluetooth headsets realize the method being precisely played simultaneously

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110636600A (en) * 2019-08-20 2019-12-31 恒玄科技(上海)有限公司 Audio synchronous playing method for wireless equipment
CN110636600B (en) * 2019-08-20 2022-01-18 恒玄科技(上海)股份有限公司 Audio synchronous playing method for wireless equipment
CN112235705A (en) * 2020-10-13 2021-01-15 恒玄科技(上海)股份有限公司 Double-ear hearing aid
CN112787742A (en) * 2021-03-16 2021-05-11 芯原微电子(成都)有限公司 Clock synchronization method and device, wireless earphone and readable storage medium
WO2024046120A1 (en) * 2022-09-02 2024-03-07 华为技术有限公司 Communication apparatus, and communication synchronization method and system

Also Published As

Publication number Publication date
CN110636349B (en) 2022-01-18

Similar Documents

Publication Publication Date Title
CN110636349B (en) Audio synchronous playing method for wireless equipment
CN110636600B (en) Audio synchronous playing method for wireless equipment
US11375312B2 (en) Method, device, loudspeaker equipment and wireless headset for playing audio synchronously
US11546682B2 (en) Method and system for synchronous audio playback of TWS earphones
US10809969B2 (en) Systems and methods for audio playback
CN108415685B (en) Wireless Bluetooth headsets realize the method being precisely played simultaneously
US8320410B2 (en) Synchronization of media data streams with separate sinks using a relay
JP2014180005A (en) Synchronization of signals for multiple data sinks
CN110838854A (en) Bluetooth wireless device and method for using the same
WO2022094835A1 (en) Audio synchronization playback method, apparatus, device, and storage medium
CN105047209A (en) Bluetooth audio playing synchronization method and apparatus and Bluetooth audio playing apparatus
CN109521988B (en) Audio playing synchronization method and device
CN108170398B (en) Apparatus and method for synchronizing speakers
WO2022179246A1 (en) Audio playback method, device and system
CN107239253B (en) Wireless local area network player, system and method for synchronizing playing speed
CN112953600B (en) Bluetooth system and communication method thereof
CN106209343B (en) Synchronize the broadcasting of the digital signal sent to multiple movable audio frequency terminals
CN113473425A (en) Bluetooth low-delay transmission method for audio signals based on PC-SPDIF connection
CN113329382A (en) Bluetooth-based time point synchronizing method, device and system
CN113613221A (en) TWS master device, TWS slave device, audio device and system
CN115604810A (en) Synchronous playing method, system and storage medium for wireless audio equipment
CN210839593U (en) Clock synchronization device
WO2024046120A1 (en) Communication apparatus, and communication synchronization method and system
WO2023273591A1 (en) Audio synchronization method, audio playing device and storage medium
US11979705B2 (en) Bluetooth earphone adaptive audio playback speed

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 201306 room 904, No. 800, Huanhu West 2nd Road, Lingang New Area, China (Shanghai) pilot Free Trade Zone, Pudong New Area, Shanghai

Applicant after: Hengxuan Technology (Shanghai) Co., Ltd

Address before: 200135 Shanghai 647 free trade pilot area, 171 Pudong New Area Road, 1 buildings, 6 rooms

Applicant before: Heng Xuan Technology (Shanghai) Co., Ltd.

SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant