Disclosure of Invention
Based on the foregoing situation, the present invention is directed to provide an audio synchronization control method, an audio synchronization control apparatus, an audio device, and an audio system, which can reduce the number of times that a TWS master device and a TWS slave device need to interact due to audio synchronization.
In order to achieve the above object, an embodiment of the present invention provides an audio synchronization control method for an audio device, where the audio device includes a TWS master device and a TWS slave device, and the method includes:
s10: the TWS master device enters a first audio segment sampling state;
under the first audio segment sampling state, the TWS master device divides audio data into audio data segments with fixed sampling length and reference sampling time periods with continuous and same duration on a reference clock, and controls the sampling time of the audio data segments according to the divided reference sampling time periods so as to sample each audio data segment divided by the TWS master device in the corresponding reference sampling time period;
s20: after the TWS master device establishes Bluetooth connection with the TWS slave device, the TWS master device sends information of the reference sampling period divided by the TWS master device to the TWS slave device;
the TWS slave device synchronizing the reference clock of the TWS master device and entering a second audio segment sampling state;
in the second audio segment sampling state, the TWS slave device divides audio data into audio data segments with the fixed sampling length, then samples the divided audio data segments with the fixed sampling length, and after receiving information of the reference sampling period divided by the TWS master device on the reference clock, controls sampling time of the audio data segments according to the reference sampling period divided by the TWS master device, so that the audio data segments divided by the TWS slave device are respectively sampled in the corresponding reference sampling periods;
s30: the TWS master device determines a reference sampling period of the start of synchronous audio data, sends information of the reference sampling period of the start of the synchronous audio data to the TWS slave device, and then starts audio sampling of the synchronous audio data from the reference sampling period of the start of the synchronous audio data;
the TWS slave device performs audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data after receiving the information of the reference sampling period of the start of the synchronous audio data sent by the TWS master device.
In order to achieve the above object, the technical solution of the present invention further provides an audio synchronization control method for a TWS master device, where the method includes:
s110: the TWS master device enters an audio segment sampling state;
under the audio segment sampling state, the TWS master device divides audio data into audio data segments with fixed sampling length and reference sampling periods with continuous and same duration on a reference clock, and controls the sampling time of the audio data segments according to the divided reference sampling periods so as to enable the audio data segments divided by the TWS master device to be respectively sampled in the corresponding reference sampling periods, wherein the reference sampling periods corresponding to the audio data segments with different sampling times are different;
s120: after the TWS master device and the TWS slave device establish Bluetooth connection, the TWS master device sends information of reference sampling periods divided by the TWS master device to the TWS slave device, and the TWS slave device is enabled to adopt the reference sampling periods consistent with the TWS master device;
s130: the TWS master device determines a reference sampling period of the start of the synchronous audio data, transmits information of the reference sampling period of the start of the synchronous audio data to the TWS slave device, and then performs audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
Further, in the step S10 or the step S110, the controlling, by the TWS master device, the sampling time of the audio data segment according to the divided reference sampling period includes:
step S101: the TWS main equipment pre-estimates the sampling end time of the audio data segment;
step S102: and the TWS main equipment performs audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time period corresponding to the audio data segment so as to reduce the deviation between the actual sampling time period and the reference sampling time period of the audio data segment.
Further, in the step S10 or the step S110, the TWS master device executes the steps S101 to S102 once every preset time interval.
Further, the method comprises the steps of: the TWS master device further sets a sampling number for the audio data segment, so that a reference sampling time period (T0+ delta T (N-1), T0+ delta T N) corresponding to the audio data segment is determined through the sampling number, T0 is the audio starting sampling time of the TWS master device, delta T is a preset value, and N is the sampling number of the audio data segment.
In order to achieve the above object, the technical solution of the present invention further provides an audio synchronization control method for a TWS slave device, where the method includes:
s210: after the TWS slave device establishes a Bluetooth connection with the TWS master device, the TWS slave device synchronizes a reference clock of the TWS master device and enters a second audio segment sampling state;
in the second audio segment sampling state, the TWS slave device divides audio data into audio data segments with the fixed sampling length, then samples the divided audio data segments with the fixed sampling length, and controls sampling time of the audio data segments according to reference sampling time segments divided by the TWS master device after receiving information of the reference sampling time segments divided by the TWS master device on the reference clock, so that the audio data segments divided by the TWS slave device are respectively sampled in the corresponding reference sampling time segments, wherein the reference sampling time segments corresponding to the audio data segments with different sampling times are different;
s220: after receiving information of a reference sampling period of a start of synchronous audio data sent by the TWS master device, the TWS slave device starts audio sampling of the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
Further, in the step S20 or the step S210, the controlling, by the TWS slave device, the sampling time of the audio data segment according to the reference sampling period divided by the TWS master device includes:
step S201: the TWS slave equipment pre-estimates the sampling end time of the audio data segment;
step S202: and the TWS slave equipment performs audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time period corresponding to the audio data segment so as to reduce the deviation between the actual playing time period and the reference sampling time period of the audio data segment.
Further, in the step S20 or the step S210, the TWS slave device executes the steps S201 to S202 once every preset time interval.
Further, the method comprises the steps of: after receiving the information of the reference sampling period divided by the TWS master device on the reference clock, the TWS slave device further sets a sampling number for the audio data segment according to the information sent by the master device, so as to determine the reference sampling period (T0+ Δ T (N ' -1), T0+ Δ T N ') corresponding to the audio data segment by the sampling number, where T0 is the audio start sampling time of the TWS master device, Δ T is a preset value, and N ' is the sampling number.
Further, the audio data sampled by the TWS slave device is mute audio data before receiving information of a reference sampling period divided by the TWS master device on the reference clock.
In order to achieve the above object, an embodiment of the present invention further provides an audio synchronization control apparatus for a TWS master device, where the apparatus includes:
the control unit is used for controlling the TWS main equipment to enter an audio segmentation sampling state;
under the audio segment sampling state, the TWS master device divides audio data into audio data segments with fixed sampling length and reference sampling periods with continuous and same duration on a reference clock, and controls the sampling time of the audio data segments according to the divided reference sampling periods so as to enable the audio data segments divided by the TWS master device to be respectively sampled in the corresponding reference sampling periods, wherein the reference sampling periods corresponding to the audio data segments with different sampling times are different;
a sending unit, configured to send, to a TWS slave device, information of reference sampling periods divided by the TWS master device after the TWS master device establishes a bluetooth connection with the TWS slave device, so that the TWS slave device adopts a reference sampling period consistent with the TWS master device;
and the processing unit is used for determining a reference sampling period of the start of the synchronous audio data, transmitting the information of the reference sampling period of the start of the synchronous audio data to the TWS slave device, and then carrying out audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
In order to achieve the above object, the technical solution of the present invention further provides a TWS master device, including the audio synchronization control apparatus.
Further, the TWS master device is a master earphone in the paired Bluetooth earphones, or a master stereo in the paired Bluetooth stereo.
In order to achieve the above object, an embodiment of the present invention further provides an audio synchronization control apparatus for a TWS slave device, where the apparatus includes:
the control unit is used for synchronizing a reference clock of the TWS master device and controlling the TWS slave device to enter a second audio segment sampling state after the TWS slave device establishes Bluetooth connection with the TWS master device;
in the second audio segment sampling state, the TWS slave device divides audio data into audio data segments with the fixed sampling length, then samples the divided audio data segments with the fixed sampling length, and controls sampling time of the audio data segments according to reference sampling time segments divided by the TWS master device after receiving information of the reference sampling time segments divided by the TWS master device on the reference clock, so that the audio data segments divided by the TWS slave device are respectively sampled in the corresponding reference sampling time segments, wherein the reference sampling time segments corresponding to the audio data segments with different sampling times are different;
and the processing unit is used for carrying out audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data after receiving the information of the reference sampling period of the start of the synchronous audio data sent by the TWS master device.
In order to achieve the above object, the technical solution of the present invention further provides a TWS slave device, including the above audio synchronization control apparatus.
Further, the TWS slave device is a slave in a pair of bluetooth headsets or a slave in a pair of bluetooth speakers.
In order to achieve the above object, the present invention further provides an audio device, including the TWS master device and the TWS slave device.
In order to achieve the above object, the present invention further provides an audio system, including:
the audio device described above;
and the Bluetooth sound source equipment is used for providing audio data for the audio equipment.
In order to achieve the above object, the present invention further provides a readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the above method.
The audio synchronization control method provided by the invention comprises the steps that a TWS master device sets a division rule of a reference sampling period, controls each audio data segment divided by the TWS master device to sample in the corresponding reference sampling period, and after the TWS master device and the TWS slave device establish Bluetooth connection, the TWS master device sends the division rule of the reference sampling period to the TWS slave device, so that the TWS slave device controls the playing of the audio data segments according to the division rule of the reference sampling period adopted by the TWS master device, therefore, between the TWS master device and the TWS slave device, the audio data segments needing to be sampled at the same time can be sampled according to the same reference sampling period, namely when audio synchronization is needed, the TWS master device and the TWS slave device can sample synchronous audio data from the same reference sampling period, and then can control the sampling of the same audio data segment according to the same reference sampling period, therefore, the number of interaction required by the TWS master device and the TWS slave device due to audio synchronization can be reduced, the occupation of bandwidth is reduced, the audio synchronization between the TWS master device and the TWS slave device can be rapidly realized after the TWS slave device is accessed into a TWS network, and the synchronized audio can be output with smaller deviation when the TWS master device and the TWS slave device start audio synchronization.
Detailed Description
The present invention will be described below based on examples, but the present invention is not limited to only these examples. In the following detailed description of the present invention, certain specific details are set forth in order to avoid obscuring the nature of the present invention, well-known methods, procedures, and components have not been described in detail.
Further, those of ordinary skill in the art will appreciate that the drawings provided herein are for illustrative purposes and are not necessarily drawn to scale.
Unless the context clearly requires otherwise, throughout the description and the claims, the words "comprise", "comprising", and the like are to be construed in an inclusive sense as opposed to an exclusive or exhaustive sense; that is, what is meant is "including, but not limited to".
In the description of the present invention, it is to be understood that the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance. In addition, in the description of the present invention, "a plurality" means two or more unless otherwise specified.
Referring to fig. 1, fig. 1 is a flowchart of an audio synchronization control method of an audio device according to an embodiment of the present invention, where the audio device includes a TWS master device and a TWS slave device, and the method includes:
s10: the TWS master device enters a first audio segment sampling state;
under the first audio segment sampling state, the TWS master device divides audio data into audio data segments with fixed sampling length and reference sampling periods with continuous and same duration on a reference clock, and controls the sampling time of the audio data segments according to the divided reference sampling periods so as to sample the audio data segments divided by the TWS master device in the respective corresponding reference sampling periods, wherein the reference sampling periods corresponding to the audio data segments with different sampling times are different;
the reference clock may be a local clock of the TWS master device, or a local clock of a bluetooth sound source device that establishes a bluetooth connection with the TWS master device, and the TWS master device may use the reference clock as a TWS network clock between itself and the TWS slave device;
in the embodiment of the present invention, the audio data may be PCM (pulse code modulation) data, which may be audio data after audio decoding, or audio data obtained after audio decoding and audio processing, where the audio data may be from a bluetooth sound source device, or may be from a local place of a TWS main device;
for example, the TWS master device may divide the reference sampling period from the initial sampling time T0 after itself is turned on, that is, the first audio data segment as a sampling object corresponds to the reference sampling period (T0, T0+ Δ T), the second audio data segment as a sampling object corresponds to the reference sampling period (T0+ Δ T, T0+ Δ T2), and the third audio data segment as a sampling object corresponds to the reference sampling period (T0+ Δ T2, T0+ Δ T3) … …;
where Δ t is a preset value, which is a duration of each reference sampling period, and a sampling duration of each fixed-sampling-length audio data segment at a preset sampling rate (an audio sampling rate used by the TWS master device and the TWS slave device), for example, taking a sampling rate of 48k as an example, if Δ t is 2ms, each fixed-sampling-length audio data segment contains 96 sample data;
in the embodiment of the present invention, the magnitude of Δ t may be set as required, and it can be understood that the larger Δ t is, the larger the delay time is;
preferably, Δ t may be less than the sampling duration of audio data in a standard bluetooth audio packet, for example, Δ t may be any value between 2ms and 5ms, for example, 2.9 ms;
s20: after the TWS master device and the TWS slave device establish Bluetooth connection, the TWS master device sends information of the reference sampling period divided by the TWS master device to the TWS slave device, wherein after the TWS master device and the TWS slave device establish Bluetooth connection, the TWS master device can use the reference clock as a network clock for communication between the TWS master device and the TWS slave device;
after the TWS slave device establishes a Bluetooth connection with the TWS master device, the TWS slave device synchronizes the reference clock of the TWS master device and enters a second audio segment sampling state;
in the second audio segment sampling state, the TWS slave device divides audio data into audio data segments with the fixed sampling length, then samples the divided audio data segments with the fixed sampling length, and after receiving information of the reference sampling period divided by the TWS master device on the reference clock, controls sampling time of the audio data segments according to the reference sampling period divided by the TWS master device, so that the audio data segments divided by the TWS slave device are respectively sampled in the corresponding reference sampling periods, wherein the reference sampling periods corresponding to the audio data segments with different sampling times are different;
it is understood that the sample length (or data size) of each audio data segment divided by the TWS slave device is the same as that of each audio data segment divided by the TWS master device;
the information of the reference sampling period divided by the TWS master device to the TWS slave device may be information of any reference sampling period, for example, the information may be a start time and/or an end time of a reference sampling period, and since the reference sampling period is continuously divided and a duration Δ t of each reference sampling period is fixed (Δ t may be preset in the TWS slave device), after the TWS slave device obtains the start time and/or the end time of any reference sampling period divided by the TWS master device, the TWS slave device can know the information of each reference sampling period, so that the TWS master device does not need to send the information of each reference sampling period to the TWS slave device;
s30: the TWS master device determines a reference sampling period of the start of synchronous audio data, sends information of the reference sampling period of the start of the synchronous audio data to the TWS slave device, and then starts audio sampling of the synchronous audio data from the reference sampling period of the start of the synchronous audio data;
after receiving information of a reference sampling period of a start of synchronous audio data sent by the TWS master device, the TWS slave device starts audio sampling of the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
After the TWS master device and the TWS slave device control the playing of the audio data segments with the same reference sampling period, the TWS master device and the TWS slave device may sample the same synchronized audio data from the same reference sampling period, in which case, since the synchronized audio data are the same, the first audio data segments divided from the synchronized audio data by the TWS master device and the TWS slave device are the same and the corresponding reference sampling periods are also the same, and the second divided audio data segments are the same and the corresponding reference sampling periods are also the same … …, thereby realizing the audio synchronized playing between the TWS master device and the TWS slave device;
the audio synchronization control method provided by the embodiment of the invention comprises the steps that a TWS master device sets a division rule of a reference sampling period, controls each audio data segment divided by the TWS master device to sample in the corresponding reference sampling period, and after the TWS master device and a TWS slave device establish Bluetooth connection, the TWS master device sends the division rule of the reference sampling period to the TWS slave device, so that the TWS slave device controls the playing of the audio data segments according to the division rule of the reference sampling period adopted by the TWS master device, therefore, between the TWS master device and the TWS slave device, the audio data segments needing to be sampled at the same time can be sampled according to the same reference sampling period, namely when audio synchronization is needed, the TWS master device and the TWS slave device can sample synchronous audio data from the same reference sampling period and then control the sampling of the same audio data segments according to the same reference sampling period, therefore, the number of interaction required by the TWS master device and the TWS slave device due to audio synchronization can be reduced, the occupation of bandwidth is reduced, the audio synchronization between the TWS master device and the TWS slave device can be rapidly realized after the TWS slave device is accessed into a TWS network, and the synchronized audio can be output with smaller deviation when the TWS master device and the TWS slave device start audio synchronization.
For example, in the embodiment of the present invention, both the TWS master device and the TWS slave device may implement division of an audio data segment with a fixed sampling length on the audio data through a buffer with a fixed size of a storage space, where the size of the storage space of the buffer is the same as the size of the audio data segment with the fixed sampling length, and for the TWS master device and the TWS slave device, the audio data segment with the fixed sampling length may be written into the respective buffers, and after sampling of the audio data segment in the buffer is completed, the audio data segment with the next fixed sampling length is written into the buffers.
Preferably, in an embodiment, the TWS master device further sets a sample number to the audio data segment divided by itself, so as to determine a reference sample period (T0+ Δ T (N-1), T0+ Δ T N) corresponding to the audio data segment by the sample number, where T0 is an audio start sample time of the TWS master device, Δ T is a preset value, and N is the sample number, for example, the sample number may be a sample order of the audio data segment, and the sample number may be implemented by a counter, and whenever an audio data segment as a sample object in the TWS master device completes audio sampling, a count value of the counter of the TWS master device performs an add-1 operation;
for example, in an embodiment, in the above step S10, in the first audio segment sampling state, the TWS master device controlling the sampling time of the audio data segment according to the divided reference sampling period includes:
step S101: the TWS main equipment pre-estimates the sampling end time of the audio data segment;
for example, the TWS master device may estimate the sampling end time of the currently sampled audio data segment based on the actual sampling end time of the last audio data segment, or the TWS master device may estimate the sampling end time of the currently sampled audio data segment based on the current sampling condition of the currently sampled audio data segment (e.g., including the actual sampling start time of the audio data segment, the current time, and the sampled data amount of the audio data segment at the current time);
step S102: and the TWS main equipment performs audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time period corresponding to the audio data segment so as to reduce the deviation between the actual sampling time period and the reference sampling time period of the audio data segment.
Specifically, if the estimated sampling end time exceeds the end time of the reference sampling period corresponding to the audio data segment, the TWS master device may compress the audio data segment in a resampling manner (e.g., reduce the number of sampling points in the audio data segment), where the compression amount may be determined by a time difference between the two;
if the estimated sampling end time does not exceed the end time of the reference sampling period corresponding to the audio data segment, the TWS host device stretches the audio data segment in a resampling manner (e.g., increases the number of sampling points in the audio data segment), and the stretching amount may be determined by a time difference between the two.
Preferably, in the embodiment of the present invention, the TWS host device may perform the steps S101 to S102 once at preset time intervals, that is, the TWS host device does not need to perform audio resampling on each divided audio data segment according to its corresponding reference sampling period, and may perform the steps S101 to S102 once at intervals of multiple audio data segments, so as to reduce the operation load of the TWS host device.
For example, in an embodiment, in the step S20, the controlling, by the TWS slave device, the sampling time of the audio data segment according to the reference sampling period divided by the TWS master device in the second audio segment sampling state includes:
step S201: the TWS slave equipment pre-estimates the sampling end time of the audio data segment;
for example, the TWS slave device may estimate the sampling end time of the currently sampled audio data segment according to the actual sampling end time of the last audio data segment, or the TWS slave device may estimate the sampling end time of the current audio data segment according to the currently sampled condition information of the currently sampled audio data segment (e.g., including the actual sampling start time of the audio data segment, the current time, and the sampled data amount of the audio data segment at the current time);
step S202: the TWS slave equipment performs audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time period corresponding to the audio data segment so as to reduce the deviation between the actual playing time period and the reference sampling time period of the audio data segment;
specifically, if the estimated sampling end time exceeds the end time of the reference sampling period corresponding to the audio data segment, the TWS slave device may compress the audio data segment in a resampling manner (e.g., reduce the number of sampling points in the audio data segment), where the compression amount may be determined by a time difference between the two;
if the estimated sampling end time does not exceed the end time of the reference sampling period corresponding to the audio data segment, the TWS slave device may stretch the audio data segment in a resampling manner (e.g., increase the number of samples in the audio data segment), and the stretching amount may be determined by a time difference between the two.
Preferably, in the embodiment of the present invention, the TWS slave device may perform the steps S201 to S202 once at preset time intervals, that is, the TWS slave device does not need to perform audio resampling on each divided audio data segment according to its corresponding reference sampling period, and may perform the steps S201 to S202 once at intervals of multiple audio data segments, so as to reduce the operation load of the TWS slave device.
Preferably, for the TWS slave device, before receiving the information of the reference sampling period divided by the TWS master device on the reference clock, the audio data sampled by the TWS slave device is mute audio data (i.e. play mute audio) to improve the user experience.
After the TWS slave device and the TWS master device establish Bluetooth connection, audio data segments for realizing mute playing can be generated firstly, the sampling length of each audio data segment for realizing mute playing is still the fixed sampling length, the TWS slave device can perform audio sampling on the audio data segment for realizing mute playing to realize mute playing, after receiving information of reference sampling time segments divided by the TWS master device, the TWS slave device can determine the reference sampling time segment of the current time according to the information, then estimate the sampling end time of the audio data segment (the audio data segment for realizing mute playing) sampled currently, and perform audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time segment of the current time, so that the TWS slave device starts to control the sampling time of the audio data segment according to the reference sampling time segments divided by the TWS master device, and after receiving the information of the reference sampling period of the start of the synchronous audio data sent by the TWS master device, the TWS slave device starts audio sampling of the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
Preferably, in an embodiment, after receiving information of a reference sampling period divided by the TWS master device on the reference clock, the TWS slave device further sets a sampling number for the audio data segment divided by itself according to the information sent by the master device, so as to determine, by the sampling number, a reference sampling period (T0+ Δ T (N ' -1), T0+ Δ T × N ') corresponding to the audio data segment, where T0 is an audio start sampling time of the TWS master device, Δ T is a preset value, and N ' is a sampling number, where T0 may be obtained from the information of the reference sampling period sent by the TWS master device;
wherein, in the TWS slave device, the sampling number may be implemented by a counter, the TWS slave device may obtain T0 and a current count value of the counter after receiving information of a reference sampling period of the TWS master device, then set its own counter according to the obtained information, and then perform an operation of adding 1 to the count value of the counter of the TWS slave device each time an audio data segment as a sampling object in the TWS slave device completes audio sampling.
For example, the TWS master device may send a sampling number of any audio data segment thereof and a start time and/or an end time of a corresponding reference sampling period to the TWS master device, the TWS slave device obtains T0 after receiving the above information, and adjusts a sampling number set for its own audio data segment according to the information, and then the TWS slave device and the TWS master device sample audio data segments at the same time with the same number, and thus may obtain the same reference sampling period.
As shown in fig. 2, Q1, Q2, Q3, Q4, and Q5 are 5 audio data segments sequentially divided by the TWS host device according to the playing order, the reference sampling period corresponding to Q1 is a period from clock 1 to clock 2, the reference sampling period corresponding to Q2 is a period from clock 2 to clock 3, the reference sampling period corresponding to Q3 is a period from clock 3 to clock 4, the reference sampling period corresponding to Q4 is a period from clock 4 to clock 5, the reference sampling period corresponding to Q5 is a period from clock 5 to clock 6, and the sampling time of each audio data segment of the TWS host device is controlled according to the reference sampling period, so that each audio data segment of the TWS host device can be sampled substantially within the corresponding reference sampling period;
p1, P2, P3, P4, and P5 are 5 audio data segments sequentially divided by the TWS slave device according to the playing sequence, as shown in fig. 2, if the TWS slave device does not use the reference sampling period divided by the TWS master device, it can be seen that there is a large time deviation between the actual playing period of each audio data segment of the TWS slave device and the TWS master device;
after the TWS slave device receives the information of the reference sampling period divided by the TWS master device, it can determine the reference sampling period (i.e. the reference sampling period divided by the TWS master device and corresponding to the currently sampled audio data segment) of the current time according to the information, and then perform audio resampling on the currently sampled audio data segment according to the reference sampling period to reduce the deviation between the actual sampling period of the next audio data segment and the reference sampling period, so that the actual sampling periods of the audio data segment of the TWS slave device and the audio data segment of the TWS master device can substantially coincide, for example, referring to fig. 3, when the TWS slave device samples the audio data segment P2, it performs audio resampling according to the corresponding reference sampling period (i.e. the period of the clock 2 to the clock 3), so that the actual sampling periods of the following Q3 and P3 can substantially coincide (both in the periods of the clock 3 to the clock 4), the actual sampling periods of Q4 and P4 can substantially coincide (both at the period of clock 4 to clock 5), the actual sampling periods of Q5 and P5 can substantially coincide (both at the period of clock 5 to clock 6), … …;
thereafter, for the same way of synchronized audio data, the TWS master and the TWS slave may start sampling from the same reference sampling period.
The embodiment of the invention also provides an audio synchronization control method of the TWS main equipment, which comprises the following steps:
s110: the TWS master device enters an audio segment sampling state;
under the audio segment sampling state, the TWS master device divides audio data into audio data segments with fixed sampling length and reference sampling periods with continuous and same duration on a reference clock, and controls the sampling time of the audio data segments according to the divided reference sampling periods so as to enable the audio data segments divided by the TWS master device to be respectively sampled in the corresponding reference sampling periods, wherein the reference sampling periods corresponding to the audio data segments with different sampling times are different;
s120: after the TWS master device and the TWS slave device establish Bluetooth connection, the TWS master device sends information of reference sampling periods divided by the TWS master device to the TWS slave device, and the TWS slave device is enabled to adopt the reference sampling periods consistent with the TWS master device;
s130: the TWS master device determines a reference sampling period of the start of the synchronous audio data, transmits information of the reference sampling period of the start of the synchronous audio data to the TWS slave device, and then performs audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
Preferably, in an embodiment, in the step S110, the TWS master device controlling the sampling time of the audio data segment according to the divided reference sampling period includes:
step S101: the TWS main equipment pre-estimates the sampling end time of the audio data segment;
step S102: and the TWS main equipment performs audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time period corresponding to the audio data segment so as to reduce the deviation between the actual sampling time period and the reference sampling time period of the audio data segment.
The specific manner of steps S101 to S102 in step S110 may be the same as the specific manner of steps S101 to S102 in step S10, and is not described herein again;
preferably, in an embodiment, the TWS master performs steps S101-S102 once every preset time interval.
Preferably, in an embodiment, the TWS master device further sets a sample number to the audio data segment, so as to determine a reference sample period (T0+ Δ T (N-1), T0+ Δ T N) corresponding to the audio data segment by the sample number, where T0 is an audio start sampling time of the TWS master device, Δ T is a preset value, and N is the sample number.
The embodiment of the invention also provides an audio synchronization control method of the TWS slave equipment, which comprises the following steps:
s210: after the TWS slave device establishes Bluetooth connection with the TWS master device, the TWS slave device synchronizes a reference clock of the TWS master device and enters an audio segment sampling state;
in the audio segment sampling state, the TWS slave device divides audio data into audio data segments with fixed sampling length, then samples the divided audio data segments with fixed sampling length, and controls the sampling time of the audio data segments according to the reference sampling time segments divided by the TWS master device after receiving the information of the reference sampling time segments divided by the TWS master device on the reference clock, so that the audio data segments divided by the TWS slave device are respectively sampled in the corresponding reference sampling time segments, wherein the reference sampling time segments corresponding to the audio data segments with different sampling times are different;
s220: after receiving information of a reference sampling period of a start of synchronous audio data sent by the TWS master device, the TWS slave device starts audio sampling of the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
Preferably, in an embodiment, in the step S210, the controlling, by the TWS slave device, the sampling time of the audio data segment according to the reference sampling period divided by the TWS master device includes:
step S201: the TWS slave equipment pre-estimates the sampling end time of the audio data segment;
step S202: and the TWS slave equipment performs audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time period corresponding to the audio data segment so as to reduce the deviation between the actual playing time period and the reference sampling time period of the audio data segment.
The specific manner of steps S201 to S202 in step S210 may be the same as the specific manner of steps S201 to S202 in step S20, and is not described herein again;
preferably, in an embodiment, the TWS slave device performs steps S201-S202 once every preset time interval.
Preferably, in an embodiment, after receiving information of a reference sampling period divided by the TWS master device on the reference clock, the TWS slave device further sets a sampling number for the audio data segment divided by itself according to the information sent by the master device, so as to determine, by the sampling number, a reference sampling period (T0+ Δ T (N-1), T0+ Δ T × N) corresponding to the audio data segment, where T0 is an audio start sampling time of the TWS master device, Δ T is a preset value, and N is the sampling number.
Preferably, in an embodiment, the audio data sampled by the TWS slave device is mute audio data before receiving information of a reference sampling period divided by the TWS master device on the reference clock.
The embodiment of the invention also provides an audio synchronization control device of the TWS main equipment, which comprises:
the control unit is used for controlling the TWS main equipment to enter an audio segmentation sampling state;
under the audio segment sampling state, the TWS master device divides audio data into audio data segments with fixed sampling length and reference sampling periods with continuous and same duration on a reference clock, and controls the sampling time of the audio data segments according to the divided reference sampling periods so as to enable the audio data segments divided by the TWS master device to be respectively sampled in the corresponding reference sampling periods, wherein the reference sampling periods corresponding to the audio data segments with different sampling times are different;
a sending unit, configured to send, to a TWS slave device, information of reference sampling periods divided by the TWS master device after the TWS master device establishes a bluetooth connection with the TWS slave device, so that the TWS slave device adopts a reference sampling period consistent with the TWS master device;
and the processing unit is used for determining a reference sampling period of the start of the synchronous audio data, transmitting the information of the reference sampling period of the start of the synchronous audio data to the TWS slave device, and then carrying out audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data.
Preferably, in an embodiment, in the above audio synchronization control apparatus of a TWS host device, the control unit includes:
the pre-estimation unit is used for pre-estimating the sampling end time of the audio data segment;
and the resampling unit is used for carrying out audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time interval corresponding to the audio data segment so as to reduce the deviation between the actual sampling time interval and the reference sampling time interval of the audio data segment.
Preferably, in an embodiment, the audio synchronization control apparatus of the TWS master device further includes a number setting unit, configured to set a sample number to the audio data segment, so as to determine a reference sample period (T0+ Δ T (N-1), T0+ Δ T N) corresponding to the audio data segment by using the sample number, where T0 is an audio start sampling time of the TWS master device, Δ T is a preset value, and N is the sample number of the audio data segment.
The embodiment of the invention also provides TWS main equipment which comprises the audio frequency synchronous control device.
For example, the TWS master is the master in a pair of bluetooth headsets, or the master in a pair of bluetooth speakers.
The embodiment of the invention also provides an audio synchronization control device of TWS slave equipment, which comprises:
the control unit is used for synchronizing a reference clock of the TWS master device and controlling the TWS slave device to enter a second audio segment sampling state after the TWS slave device establishes Bluetooth connection with the TWS master device;
in the second audio segment sampling state, the TWS slave device divides audio data into audio data segments with the fixed sampling length, then samples the divided audio data segments with the fixed sampling length, and controls sampling time of the audio data segments according to reference sampling time segments divided by the TWS master device after receiving information of the reference sampling time segments divided by the TWS master device on the reference clock, so that the audio data segments divided by the TWS slave device are respectively sampled in the corresponding reference sampling time segments, wherein the reference sampling time segments corresponding to the audio data segments with different sampling times are different;
and the processing unit is used for carrying out audio sampling on the synchronous audio data from the reference sampling period of the start of the synchronous audio data after receiving the information of the reference sampling period of the start of the synchronous audio data sent by the TWS master device.
Preferably, in an embodiment, in the above audio synchronization control apparatus of a TWS slave device, the control unit includes:
the pre-estimation unit is used for pre-estimating the sampling end time of the audio data segment;
and the resampling unit is used for carrying out audio resampling on the audio data segment according to the time difference between the estimated sampling end time and the end time of the reference sampling time interval corresponding to the audio data segment so as to reduce the deviation between the actual playing time interval and the reference sampling time interval of the audio data segment.
Preferably, in an embodiment, the audio synchronization control apparatus of the TWS slave device further includes: and the number setting unit is used for setting a sampling number for the audio data segment according to the information sent by the master device after receiving the information of the reference sampling period divided by the TWS master device on the reference clock, so as to determine the reference sampling period (T0+ Δ T (N ' -1), T0+ Δ T N ') corresponding to the audio data segment by the sampling number, wherein T0 is the audio start sampling time of the TWS master device, Δ T is a preset value, and N ' is the sampling number.
The embodiment of the invention also provides TWS slave equipment which comprises the audio synchronization control device.
For example, the TWS slave device is a slave in a pair of bluetooth headsets, or a slave in a pair of bluetooth speakers.
The embodiment of the invention also provides audio equipment, the TWS master equipment and the TWS slave equipment.
An embodiment of the present invention further provides an audio system, including:
an audio device as described above;
and the Bluetooth sound source equipment is used for providing audio data for the audio equipment.
For example, the bluetooth sound source device includes a mobile phone, a tablet computer, a notebook computer or a video player.
The present invention also provides a readable storage medium, such as a chip, a usb disk, an optical disk, etc., on which a computer program is stored, wherein the computer program, when executed by a processor, implements any of the audio synchronization control methods described above.
The readable storage medium according to the embodiments of the present disclosure is not limited to the above-described embodiments, and may be, for example, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
It will be appreciated by those skilled in the art that the above-described preferred embodiments may be freely combined, superimposed, without conflict. The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures, for example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. The numbering of the steps herein is for convenience of description and reference only and is not intended to limit the order of the steps, which may be performed simultaneously or in any order without conflict.
It will be appreciated by those skilled in the art that the above-described preferred embodiments may be freely combined, superimposed, without conflict.
It will be understood that the embodiments described above are illustrative only and not restrictive, and that various obvious and equivalent modifications and substitutions for details described herein may be made by those skilled in the art without departing from the basic principles of the invention.