Audio synchronous playback method, system and storage medium
By using the master playback device and the slave playback device for local time synchronization in a multi-room audio system, and utilizing the periodic audio synchronization signal of the reference clock device, the problem of low accuracy of audio synchronization playback in the existing technology is solved, and high-precision audio synchronization is achieved. Audio is played synchronously.
Patent Information
- Application Number
- CN202410468081.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-18
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-04-18
AI Technical Summary
The accuracy of audio synchronization playback achieved through device clock synchronization in existing multi-room audio systems is low, and there is often an audio delay that is perceptible to the human ear.
By introducing the master playback device and the slave playback device into the audio synchronization playback system, and using the reference clock device to send periodic audio synchronization signals, the master playback device and the slave playback device can perform local time synchronization, obtain the reference playback timestamp, and thereby adjust the playback progress. , improve the accuracy of synchronized playback.
It achieves time base synchronization between various playback devices, eliminates time deviations caused by hardware differences, improves the accuracy of audio synchronization playback, and achieves microsecond-level synchronization effects.
Smart Images

Figure CN118102434B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of audio control, and in particular to an audio synchronous playback method, system and storage medium. Background Art
[0002] With the development of science and technology and the improvement of people's living standards, multi-room audio systems have become the choice of more and more music lovers and audiophiles with high requirements for music quality. In order to ensure the user's audio-visual experience, multiple devices in the multi-room audio system need to play music synchronously.
[0003] At present, most multi-room audio systems use the WIFI clock synchronization standard protocol to perform clock synchronization and then achieve audio synchronization playback. However, the synchronization effect of this method is limited, there is often audio delay that can be perceived by the human ear, and the synchronization accuracy is low. Summary of the invention
[0004] The main purpose of the present invention is to provide an audio synchronous playback method, system and storage medium, which are used to solve the problem of low audio synchronous playback accuracy achieved only through device clock synchronization and improve the accuracy of synchronous playback.
[0005] A first aspect of the present invention provides an audio synchronous playback method, which is applied to an audio synchronous playback system, wherein the audio synchronous playback system includes a master playback device and a preset number of slave playback devices, and the audio synchronous playback method includes: when receiving a synchronous playback instruction, the master playback device obtains target audio data; the master playback device sends the target audio data to at least one slave playback device for playback; when the master playback device receives a target audio synchronization signal, the master playback device synchronizes its own local time with the local time of a reference clock device according to the target audio synchronization signal and obtains a reference playback timestamp in the target audio synchronization signal, wherein the target audio synchronization signal is a periodic signal emitted by a reference clock device, and the reference clock device is the master playback device or one of the preset number of slave playback devices; the master playback device starts playing from the target audio data frame corresponding to the reference playback timestamp.
[0006] A second aspect of the present invention provides an audio synchronous playback method, which is applied to an audio synchronous playback system, wherein the audio synchronous playback system includes a master playback device and a preset number of slave playback devices, and the audio synchronous playback method includes: when the slave playback device receives the target audio data sent by the master playback device, the slave playback device plays the target audio data; when the slave playback device receives a target audio synchronization signal, the slave playback device synchronizes its own local time with the local time of a reference clock device according to the target audio synchronization signal and obtains a reference playback timestamp in the target audio synchronization signal, wherein the target audio synchronization signal is a periodic signal emitted by a reference clock device, and the reference clock device is the master playback device or one of the preset number of slave playback devices; the slave playback device starts playing from the target audio data frame corresponding to the reference playback timestamp.
[0007] A third aspect of the present invention provides an audio synchronous playback method, which is applied to an audio synchronous playback system, wherein the audio synchronous playback system includes a master playback device and a preset number of slave playback devices, and the audio synchronous playback method includes: when a reference clock device detects target audio data, the reference clock device plays the target audio data, and the reference clock device is the master playback device or one of the preset number of slave playback devices; the reference clock device collects the current playback timestamp of the target audio data and the transmission time value of the signal in the reference clock device between the sound card and the speaker according to a preset sampling period, and obtains a reference playback timestamp and a delay calibration value of the reference clock device; the reference clock device determines the reference local time of the reference clock device according to the current local time and the delay calibration value of the reference clock device; the reference clock device generates a target audio synchronization signal according to the reference local time of the reference clock device and the reference playback timestamp; and the reference clock device broadcasts the target audio synchronization signal.
[0008] A fourth aspect of the present invention provides an audio synchronous playback system, comprising: a master playback device and a preset number of slave playback devices, wherein the audio synchronous playback system executes the above-mentioned audio synchronous playback method.
[0009] A fifth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned audio synchronization playback method.
[0010] In the technical solution provided by the present invention, when a synchronous playback instruction is received, the main playback device obtains target audio data, and the main playback device sends the target audio data to at least one slave playback device for playback. When the main playback device receives a target audio synchronization signal, the main playback device synchronizes its own local time with the local time of a reference clock device according to the target audio synchronization signal and obtains a reference playback timestamp in the target audio synchronization signal. The target audio synchronization signal is a periodic signal emitted by a reference clock device. The reference clock device is the main playback device or one of the preset number of slave playback devices. The main playback device starts playing from the target audio data frame corresponding to the reference playback timestamp. In an embodiment of the present invention, target audio data is sent to at least one slave playback device for synchronous playback through a master playback device, and a target audio synchronization signal is sent through a reference clock device. The target audio synchronization signal is a periodic signal. The master playback device and the slave playback device periodically perform clock synchronization with the reference clock device according to the target audio synchronization signal to achieve accurate synchronization of the local time of each playback device. After the local time is synchronized, the time base of each playback device for playing the target audio data is synchronized, and its own playback progress is adjusted based on the synchronized time base and the reference playback timestamp contained in the target audio synchronization signal, thereby improving the accuracy of synchronous playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] Figure 1 A schematic diagram of an embodiment of an audio synchronous playback system in an embodiment of the present invention;
[0012] Figure 2 A schematic diagram of an embodiment of a method for synchronously playing audio in an embodiment of the present invention;
[0013] Figure 3 A schematic diagram of another embodiment of the audio synchronous playback method in an embodiment of the present invention;
[0014] Figure 4 A schematic diagram of another embodiment of the audio synchronous playback method in an embodiment of the present invention;
[0015] Figure 5 A schematic diagram of another embodiment of the audio synchronous playback method in an embodiment of the present invention;
[0016] Figure 6 FIG. 2 is a schematic diagram of another embodiment of the method for synchronous audio playback in an embodiment of the present invention. DETAILED DESCRIPTION
[0017] The embodiments of the present invention provide an audio synchronous playback method, device and storage medium for improving the accuracy of synchronous playback.
[0018] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0019] To facilitate understanding, the audio synchronous playback system is first explained. The audio synchronous playback system includes multiple playback devices and a pre-built local area network that supports the TCP / IP communication protocol. There are two ways to build a local area network. The first is to connect multiple playback devices to the same router via wireless signals or to the router's switch via Ethernet cables. The second is to connect multiple playback devices to the created Wi-Fi hotspot and use Wi-Fi P2P technology to build a local area network that supports TCP / IP communication. Any two playback devices can communicate within the constructed local area network.
[0020] Audio synchronization playback systems are usually used in places with multiple partitions, such as buildings with multiple rooms, industrial parks with multiple areas, towns with multiple road sections, etc. Figure 1 As shown, one playback device in the audio synchronous playback system is a master playback device 110, and the other playback devices are slave playback devices 120. The master playback device 110 and the slave playback device 120 include a processor and a memory, the memory is used to store programs, and the processor is used to execute the programs in the memory.
[0021] The master playback device and the slave playback device are distributed according to actual needs. The master playback device and the slave playback device can be in different partitions or in the same partition. There can be one playback device or multiple playback devices in a partition, which is not limited here. Therefore, the audio synchronous playback system includes a master playback device and a preset number of slave playback devices.
[0022] The master playback device and the slave playback device are installed with the same or compatible playback application program. The master playback device is used to send the audio data to be played synchronously to the slave playback device. After receiving the audio data sent by the master playback device, the slave playback device plays the audio data on the slave playback device. After the master playback device sends the audio data, it automatically plays the audio data. In addition, a playback device is selected from the master playback device and a preset number of slave playback devices as a reference clock device. The reference clock device can be the master playback device or the slave playback device. The reference clock device periodically sends an audio synchronization signal. The audio synchronization signal includes the local clock information of the reference clock device and the reference playback timestamp of the audio data on the reference clock device. The master playback device or the slave playback device that receives the audio synchronization signal synchronizes its own local time with the local time of the reference clock device according to the local clock information of the reference clock device. After the local time is synchronized, the time base of each playback device playing the target audio data is consistent. The master playback device and the slave playback device determine the target audio data frame corresponding to the reference playback timestamp in the target audio data played by themselves based on the synchronized local time, and start playing from the target audio data frame, thereby eliminating the time deviation caused by hardware differences and improving the accuracy of synchronous playback.
[0023] Preferably, the device with the smallest clock error among the main playback device and a preset number of slave playback devices is determined as the reference clock device. The smaller the clock error of the reference clock device, the more stable the period of the provided audio synchronization signal, the smaller the accumulated time deviation between the main playback device and the slave playback device within one period, and the higher the synchronous playback accuracy of the main playback device and the slave playback device.
[0024] The specific process of the embodiment of the present invention is described below. Figure 2 , an embodiment of the audio synchronous playback method in the embodiment of the present invention includes:
[0025] 201. When receiving a synchronous playback instruction, the main playback device obtains target audio data.
[0026] It can be understood that the execution subject of the embodiment of the present invention may be an audio synchronous playback system or a main playback device. This embodiment is described by taking the main playback device as the execution subject.
[0027] The main playback device can be a designated playback device or a device that receives a synchronous playback instruction. When the main playback device receives the synchronous playback instruction, the main playback device obtains the target audio data to be synchronously played. The target audio data includes an initial timestamp sequence, and each audio frame of the target audio data corresponds to a timestamp.
[0028] For example, a building has 10 rooms, and a playback device is installed in each room, numbered as playback device 1, playback device 2, ... playback device 10. If playback device 1 is set as the main playback device in advance, when playback device 1 receives a synchronous playback instruction, playback device 1 obtains the target audio data; if the main playback device is not pre-specified and playback device 2 receives a synchronous playback instruction, playback device 2 is the main playback device, playback device 2 obtains the target audio data, and the synchronous playback instruction is a playback instruction generated after the user interacts with the playback device.
[0029] Specifically, when the main playback device receives the synchronous playback instruction, the main playback device obtains the original audio data indicated by the synchronous playback instruction, the original audio data is in PCM format, the main playback device obtains scene information, the scene information includes the audio type and network bandwidth information of the original audio data, the main playback device screens the preset encoding compression algorithm according to the audio type, the audio type includes the audio data format and the audio data encoding, selects the encoding compression algorithm that can show better sound quality according to the audio type, obtains the encoding compression algorithm set, and then the main playback device selects the algorithm that matches the network bandwidth information from the encoding compression algorithm set, wherein when the network bandwidth is greater than the threshold, the main playback device selects the encoding compression algorithm with the smallest compression ratio from the encoding compression algorithm set, when the network bandwidth is less than or equal to the threshold, the main playback device selects the encoding compression algorithm with the compression ratio matching the network bandwidth information from the encoding compression algorithm set, obtains the target encoding compression algorithm, the main playback device encodes and compresses the original audio data according to the target encoding compression algorithm, and the main playback device adds a timestamp to each compressed audio data frame to obtain the target audio data.
[0030] 202. The master playback device sends the target audio data to at least one slave playback device for playback.
[0031] The master playback device parses the synchronous playback instruction to obtain a synchronous device set, which includes at least one slave playback device to be used for audio synchronous playback. The number of slave playback devices in the synchronous device set is less than or equal to the number of slave playback devices in the audio synchronous playback system, that is, the slave playback devices for audio synchronous playback can be all slave playback devices in the audio synchronous playback system or some slave playback devices in the audio synchronous playback system. The master playback device sends the target audio data to the slave playback devices in the synchronous device set for playback, and the master playback device automatically plays the target audio data after sending the target audio data.
[0032] 203. When the master playback device receives the target audio synchronization signal, the master playback device synchronizes its own local time with the local time of the reference clock device according to the target audio synchronization signal and obtains a reference playback timestamp in the target audio synchronization signal. The target audio synchronization signal is a periodic signal emitted by the reference clock device. The reference clock device is the master playback device or one of a preset number of slave playback devices.
[0033] Since the reference clock device may be the main playback device or not, in this embodiment, description is made by taking the reference clock device not being the main playback device as an example.
[0034] The reference clock device periodically sends a target audio synchronization signal, which includes the reference local time of the reference clock device and the reference playback timestamp of the target audio data on the reference clock device. The main playback device synchronizes its own local time with the reference local time of the reference clock device according to the reference local time of the reference clock device.
[0035] Specifically, when the main playback device receives the target audio synchronization signal, the main playback device parses the target audio synchronization signal to obtain the reference local time and the reference playback timestamp of the reference clock device, the reference playback timestamp indicates the audio data frame position currently played by the reference clock device, and the main playback device performs time synchronization according to the reference local time of the reference clock device. The time synchronization method is: the main playback device determines the transmission time value of the signal between the sound card and the speaker to obtain the delay calibration value of the main playback device, and the main playback device determines the current local time of the main playback device according to the reference local time of the reference clock device and the delay calibration value of the main playback device. This time synchronization method can eliminate the hardware parameter differences between the playback devices, so that the time base of the audio output by the main playback device and the reference clock device is consistent. The main playback device and the reference clock device are in the same local area network, the signal transmission speed reaches microseconds or even higher, the time synchronization accuracy of the main playback device and the reference clock device is high, and the synchronous playback accuracy when playing audio will also be higher.
[0036] Optionally, before the main playback device synchronizes its own local time with the reference local time of the reference clock device according to the target audio synchronization signal and obtains the reference playback timestamp in the target audio synchronization signal, in order to avoid interference caused by simultaneous broadcasting of synchronization signals by devices other than the reference clock device, the main playback device first determines whether the received synchronization signal is the target audio synchronization signal emitted by the reference clock device. Specifically, the main playback device identifies the reference clock device in the audio synchronization playback system, the reference clock device is the playback device with the smallest clock error calibration value among the main playback device and at least one slave playback device, the clock error calibration value is a calibration value pre-written into the playback device, when the main playback device detects the synchronization signal, the main playback device determines whether the received synchronization signal is a signal emitted by the reference clock device, if so, the main playback device determines that the target audio synchronization signal is received, if not, the main playback device determines that the target audio synchronization signal is not detected.
[0037] 204. The main playback device starts playing the target audio data frame corresponding to the reference playback timestamp.
[0038] The main playback device determines the target audio data frame corresponding to the reference playback timestamp in the target audio data, jumps to the target audio data frame for decoding and playback. After the main playback device and the reference clock device perform local time synchronization, the time synchronization accuracy between the main playback device and the reference clock device is improved. The main playback device jumps to the position with the same playback progress as the reference clock device according to the reference playback timestamp to continue playback. There is no need to upgrade the hardware of the playback device to achieve microsecond-level audio synchronization playback effect.
[0039] Specifically, the main playback device counts the time deviation between the main playback device and the reference clock device in each period according to a first preset period to obtain a system time deviation of the main playback device, where the time deviation is the difference between the timestamp of the audio frame being played on the main playback device and the timestamp of the audio frame being played on the reference clock device. The main playback device determines the output sampling rate of the main playback device according to the system time deviation of the main playback device, the main playback device starts decoding from the target audio data frame corresponding to the reference playback timestamp, and the main playback device starts sampling and playing from the decoded target audio data frame based on the output sampling rate of the main playback device.
[0040] The main playback device determines the output sampling rate according to the system time deviation in the following way:
[0041] 1. Compare the absolute value of the system time deviation in the previous cycle with the deviation threshold;
[0042] 2. When the absolute value of the system time deviation is less than or equal to the deviation threshold, the main playback device does not adjust the output sampling rate;
[0043] 3. When the absolute value of the system time deviation is greater than the deviation threshold, the main playback device determines the sampling adjustment value according to the first preset formula. The first preset formula is as follows:
[0044]
[0045] Where D is the sampling adjustment value of the main playback device in the next cycle, is the system time deviation of the main playback device in the previous cycle, K is the preset scaling factor, and N is the number of audio frames of the target audio data in the buffer.
[0046] 4. The main playback device determines the output sampling rate in the next cycle according to the sampling adjustment value and the second preset formula. The second preset formula is as follows:
[0047]
[0048] Among them, S2 is the output sampling rate of the main playback device in the next cycle, S1 is the output sampling rate of the main playback device in the previous cycle, and D is the sampling adjustment value of the main playback device in the next cycle.
[0049] The output sampling rate is adjusted to offset the time error accumulated in the buffer of the main playback device when the target audio data is played, thereby further ensuring synchronization during the audio playback process.
[0050] In an embodiment of the present invention, a master playback device sends target audio data to at least one slave playback device for synchronous playback, a reference clock device periodically broadcasts a target audio synchronization signal, and the master playback device periodically performs clock synchronization with the reference clock device according to the target audio synchronization signal, thereby eliminating the hardware parameter difference between the master playback device and the reference clock device, and achieving accurate synchronization of the local time of the master playback device and the reference clock device. The master playback device adjusts its own playback progress based on the synchronized time reference and the reference playback timestamp included in the target audio synchronization signal, thereby achieving playback timestamp synchronization. Local time synchronization and playback timestamp synchronization jointly improve the accuracy of audio synchronous playback of the master playback device and the reference clock device.
[0051] Next, we will take the reference clock device as the main playback device as an example. Figure 3 , an embodiment of the audio synchronous playback method in the embodiment of the present invention includes:
[0052] 301. When receiving a synchronous playback instruction, the main playback device obtains target audio data.
[0053] It is understandable that the execution subject of the present invention may be an audio synchronous playback system or a main playback device, which is not limited here. The embodiment of the present invention is described by taking the main playback device as the execution subject as an example.
[0054] 302. The master playback device sends the target audio data to at least one slave playback device for playback.
[0055] In this embodiment, steps 301 - 302 are the same as steps 201 - 202 and are not described again.
[0056] 303. When the reference clock device (main playback device) detects the target audio data, the reference clock device (main playback device) plays the target audio data.
[0057] Since the target audio data already exists in the reference clock device (master playback device), after the reference clock device (master playback device) sends the target audio data to at least one slave playback device, the reference clock device (master playback device) plays the detected target audio data.
[0058] 304. The reference clock device (main playback device) collects the current playback timestamp of the target audio data and the transmission time value of the signal in the reference clock device (main playback device) between the sound card and the speaker according to a preset sampling period to obtain a reference playback timestamp and a delay calibration value of the reference clock device (main playback device).
[0059] The reference playback timestamp is the timestamp corresponding to the current playback progress of the target audio data in the reference clock device (main playback device). The signal transmission time value between the sound card and the speaker is the delay time value between the audio card outputting the audio data and the speaker outputting the sound. Differences in hardware parameters between playback devices will result in different delay time values.
[0060] 305. The reference clock device (main playback device) determines the reference local time of the reference clock device (main playback device) according to the current local time and the delay calibration value of the reference clock device (main playback device).
[0061] The reference clock device (master playback device) determines the sum of the current local time and the delay calibration value of the reference clock device (master playback device) as the reference local time of the reference clock device (master playback device). The slave playback device then subtracts the delay calibration value of the slave playback device from the reference local time to obtain the local time of the slave playback device. In this way, no matter how big the difference in hardware parameters between the reference clock device (master playback device) and the slave playback device is, the time base of the output audio can be kept consistent.
[0062] 306. The reference clock device (main playback device) generates a target audio synchronization signal according to the reference local time and the reference playback timestamp of the reference clock device (main playback device).
[0063] The reference clock device (master playback device) combines the reference local time of the reference clock device (master playback device) and the reference playback timestamp to generate a target audio synchronization signal.
[0064] 307. The reference clock device (main playback device) broadcasts the target audio synchronization signal.
[0065] The reference clock device (master playback device) broadcasts a target audio synchronization signal externally, so that the master playback device and at least one slave playback device receive the target audio synchronization signal.
[0066] 308. The main playback device continues to play the target audio data.
[0067] When the main playback device is used as a reference clock device, the main playback device compares its actual crystal oscillator frequency with the standard crystal oscillator frequency to obtain the crystal oscillator frequency deviation of the main playback device, and then obtains the time deviation of the main playback device. The main playback device adjusts its own output sampling rate according to the time deviation of the main playback device to achieve the accuracy of the main playback device in playing the target audio data and improve the synchronization accuracy.
[0068] That is to say, when the main playback device and the reference clock device are different playback devices, the output sampling rate is adjusted according to the time deviation of the main playback device and the reference clock device to eliminate the hardware parameter differences between different devices. When the main playback device and the reference clock device are the same playback device, the output sampling rate is adjusted according to the time deviation of the main playback device itself to eliminate the time deviation caused by its own crystal oscillator deviation, thereby further improving the synchronization accuracy.
[0069] Specifically, the main playback device counts the crystal oscillator frequency deviation of the main playback device in each period according to a second preset period, where the second preset period may be the same as or different from the first preset period, and the main playback device determines the system time deviation of the main playback device according to the crystal oscillator frequency deviation of the main playback device. The main playback device determines the output sampling rate of the main playback device according to the system time deviation of the main playback device, and the main playback device samples and plays the target audio data based on the output sampling rate of the main playback device.
[0070] The main playback device determines the output sampling rate according to the system time deviation as follows:
[0071] 1. Compare the absolute value of the system time deviation in the previous cycle with the deviation threshold;
[0072] 2. When the absolute value of the system time deviation is less than or equal to the deviation threshold, the main playback device does not adjust the output sampling rate;
[0073] 3. When the absolute value of the system time deviation is greater than the deviation threshold, the main playback device determines the sampling adjustment value according to the first preset formula. The first preset formula is as follows:
[0074]
[0075] Where D is the sampling adjustment value of the main playback device in the next cycle, is the system time deviation of the main playback device in the previous cycle, K is the preset scaling factor, and N is the number of audio frames of the target audio data in the buffer.
[0076] 4. The main playback device determines the output sampling rate in the next cycle according to the sampling adjustment value and the second preset formula. The second preset formula is as follows:
[0077]
[0078] Among them, S2 is the output sampling rate of the main playback device in the next cycle, S1 is the output sampling rate of the main playback device in the previous cycle, and D is the sampling adjustment value of the main playback device in the next cycle.
[0079] The output sampling rate is adjusted to offset the time error accumulated in the buffer of the main playback device when the target audio data is played, thereby ensuring synchronization during the audio playback process.
[0080] In an embodiment of the present invention, a master playback device sends target audio data to at least one slave playback device for synchronous playback. At the same time, the master playback device also serves as a reference clock device to periodically broadcast a target audio synchronization signal. Each playback device periodically performs clock synchronization with the reference clock device based on the target audio synchronization signal, thereby eliminating hardware parameter differences among the playback devices and achieving accurate synchronization of the local time of each playback device. After the local time is synchronized, the time base of each playback device for playing the target audio data is synchronized, thereby improving the accuracy of synchronous playback.
[0081] See also Figure 4 Another embodiment of the audio synchronous playback method in the embodiment of the present invention includes:
[0082] 401. When a slave playback device receives target audio data sent by a master playback device, the slave playback device plays the target audio data.
[0083] It is understandable that the execution subject of the embodiment of the present invention may be an audio synchronous playback system or a slave playback device. This embodiment is described by taking the slave playback device as the execution subject as an example.
[0084] When the slave playback device receives the target audio data sent by the master playback device, the slave playback device immediately plays the received target audio data.
[0085] Specifically, when the slave playback device receives the target audio data sent by the main playback device, the slave playback device determines whether there is audio data matching the target audio data in the preset database. If so, the audio data matching the target audio data is deleted from the playback device, and the target audio data is stored in the preset database, so that the latest version of the audio data is stored in the preset database to reduce redundancy. If not, the slave playback device determines whether the available storage space in the preset database is larger than the size of the target audio data. If so, the target audio data is stored in the preset database from the playback device. If not, the historical data in the preset database is deleted one by one from the playback device until the available storage space in the preset database is larger than the size of the target audio data. The target audio data is then stored in the preset database and played. The audio data in the preset database can be used as a local audio library for stand-alone playback when the playback device is offline. During the synchronous playback process, if a temporary network failure occurs, an audio synchronization effect within a certain duration can also be achieved.
[0086] 402. When a target audio synchronization signal is received from a playback device, the playback device synchronizes its own local time with the local time of a reference clock device according to the target audio synchronization signal and obtains a reference playback timestamp in the target audio synchronization signal. The target audio synchronization signal is a periodic signal emitted by a reference clock device. The reference clock device is a master playback device or one of a preset number of slave playback devices.
[0087] Since the reference clock device may be a slave playback device or may not be a slave playback device, in this embodiment, description is made by taking the reference clock device not being a slave playback device as an example.
[0088] The reference clock device periodically sends a target audio synchronization signal, which includes the reference local time of the reference clock device and the reference playback timestamp of the target audio data on the reference clock device. The slave playback device synchronizes its own local time with the reference local time of the reference clock device according to the reference local time of the reference clock device.
[0089] Specifically, when the slave playback device receives the target audio synchronization signal, the slave playback device parses the target audio synchronization signal to obtain the reference local time and reference playback timestamp of the reference clock device, the reference playback timestamp indicates the audio data frame position currently played by the reference clock device, and the slave playback device performs time synchronization according to the reference local time of the reference clock device. The time synchronization method is: the slave playback device determines the transmission time value of the signal between the sound card and the speaker, obtains the delay calibration value of the slave playback device, and the slave playback device determines the current local time of the slave playback device according to the reference local time of the reference clock device and the delay calibration value of the slave playback device. This time synchronization method can eliminate the hardware parameter differences between the playback devices, so that the time base of the output audio from the slave playback device and the reference clock device is consistent. The slave playback device and the reference clock device are in the same local area network, the signal transmission speed reaches microseconds or even higher, the time synchronization accuracy of the slave playback device and the reference clock device is high, and the synchronization playback accuracy when playing audio will also be higher.
[0090] 403. The playback device starts playing the target audio data frame corresponding to the reference playback timestamp.
[0091] The slave playback device determines the target audio data frame corresponding to the reference playback timestamp in the target audio data, jumps to the target audio data frame for decoding and playback, and after the slave playback device and the reference clock device perform local time synchronization, the time synchronization accuracy between the slave playback device and the reference clock device is improved. The slave playback device jumps to the position with the same playback progress as the reference clock device according to the reference playback timestamp to continue playback, and there is no need to upgrade the hardware of the playback device to achieve microsecond-level audio synchronization playback effect.
[0092] Specifically, the slave playback device counts the time deviation between the slave playback device and the reference clock device in each period according to a second preset period to obtain a system time deviation of the slave playback device, the slave playback device determines the output sampling rate of the slave playback device according to the system time deviation of the slave playback device, the slave playback device jumps to the target audio data frame corresponding to the reference playback timestamp for decoding, and the slave playback device starts sampling and playing from the decoded target audio data frame based on the output sampling rate of the slave playback device.
[0093] The way in which the slave playback device determines the output sampling rate according to the system time deviation is similar to the way in which the master playback device determines the output sampling rate according to the system time deviation in step 204, and will not be repeated here.
[0094] In an embodiment of the present invention, a slave playback device receives target audio data sent by a master playback device and plays the target audio data, a reference clock device periodically broadcasts a target audio synchronization signal, and the slave playback device periodically performs clock synchronization with the reference clock device according to the target audio synchronization signal, thereby eliminating the hardware parameter difference between the slave playback device and the reference clock device, and achieving accurate synchronization of the local time of the slave playback device and the reference clock device. After the local time is synchronized, the time base of each playback device in playing the target audio data is synchronized, and the slave playback device adjusts its own playback progress based on the synchronized time base and the reference playback timestamp contained in the target audio synchronization signal, thereby improving the accuracy of synchronized playback.
[0095] Next, we will take the reference clock device as the slave playback device as an example. Figure 5 Another embodiment of the audio synchronous playback method in the embodiment of the present invention includes:
[0096] 501. When a slave playback device receives target audio data sent by a master playback device, the slave playback device plays the target audio data.
[0097] In this embodiment, step 501 is the same as step 401 and will not be described in detail herein.
[0098] 502. The reference clock device (slave playback device) collects the current playback timestamp of the target audio data and the transmission time value of the signal in the reference clock device (slave playback device) between the sound card and the speaker according to a preset sampling period to obtain a reference playback timestamp and a delay calibration value of the reference clock device (slave playback device).
[0099] The reference playback timestamp is the timestamp corresponding to the current playback progress of the target audio data in the reference clock device (from the playback device). The signal transmission time value between the sound card and the speaker is the delay time value between the audio card outputting the audio data and the speaker outputting the sound. Differences in hardware parameters between playback devices will result in different delay time values.
[0100] 503. The reference clock device (slave playback device) determines the reference local time of the reference clock device (slave playback device) according to the current local time and the delay calibration value of the reference clock device (slave playback device).
[0101] The reference clock device (slave playback device) determines the sum of the current local time and the delay calibration value of the reference clock device (slave playback device) as the reference local time of the reference clock device (slave playback device). Subsequently, other slave playback devices or master playback devices will subtract the delay calibration value of the corresponding playback device from the reference local time to obtain the local time of each playback device. In this way, no matter how big the difference in hardware parameters between the reference clock device (slave playback device) and other playback devices is, the time base of the output audio can be kept consistent.
[0102] 504. The reference clock device (slave playback device) generates a target audio synchronization signal according to a reference local time and a reference playback timestamp of the reference clock device (slave playback device).
[0103] The reference clock device (slave playback device) combines the reference local time of the reference clock device (slave playback device) and the reference playback timestamp to generate a target audio synchronization signal.
[0104] 505. The reference clock device (from the playback device) broadcasts the target audio synchronization signal.
[0105] The reference clock device (slave playback device) broadcasts the target audio synchronization signal externally, so that the master playback device and at least one slave playback device receive the target audio synchronization signal.
[0106] 506. Continue playing the target audio data frame from the playback device.
[0107] The slave playback device counts the crystal oscillator frequency deviation of the slave playback device in each period according to a second preset period, the slave playback device determines the system time deviation of the slave playback device based on the crystal oscillator frequency deviation of the slave playback device, the slave playback device determines the output sampling rate of the slave playback device based on the system time deviation of the slave playback device, and the slave playback device samples and plays the target audio data based on the output sampling rate of the slave playback device.
[0108] The way in which the slave playback device determines the output sampling rate according to the system time deviation is similar to the way in which the master playback device determines the output sampling rate according to the system time deviation in step 204, and will not be repeated here.
[0109] That is to say, when the slave playback device and the reference clock device are different playback devices, the output sampling rate is adjusted according to the time deviation of the slave playback device and the reference clock device to eliminate the hardware parameter differences between different devices. When the slave playback device and the reference clock device are the same playback device, the output sampling rate is adjusted according to the time deviation of the slave playback device itself to eliminate the time deviation caused by its own crystal oscillator deviation, thereby further improving the synchronization accuracy.
[0110] In an embodiment of the present invention, a slave playback device receives target audio data sent by a master playback device and plays the target audio data. The slave playback device serves as a reference clock device and regularly broadcasts a target audio synchronization signal. Each playback device regularly performs clock synchronization with the reference clock device based on the target audio synchronization signal, thereby eliminating hardware parameter differences among the playback devices and achieving accurate synchronization of the local time of each playback device. After the local time is synchronized, the time base of each playback device for playing the target audio data is synchronized, thereby improving the accuracy of synchronous playback.
[0111] See also Figure 6Another embodiment of the audio synchronous playback method in the embodiment of the present invention includes:
[0112] 601. When a reference clock device receives target audio data, the reference clock device plays the target audio data. The reference clock device is a master playback device or one of a preset number of slave playback devices.
[0113] The reference clock device is a main broadcast room device or a playback device in at least one slave playback device. Optionally, the reference clock device is a playback device with the smallest clock error calibration value among the main playback device and at least one slave playback device.
[0114] The reference clock device counts the crystal oscillator frequency deviation of the reference clock device in each period according to a second preset period, the reference clock device determines the time deviation of the reference clock device according to the crystal oscillator frequency deviation of the reference clock device, the reference clock device determines the output sampling rate of the reference clock device according to the time deviation of the reference clock device, and the main playback device samples and plays the target audio data based on the output sampling rate of the reference clock device.
[0115] When the master playback device or the slave playback device and the reference clock device are different devices, the master playback device or the slave playback device can improve the accuracy of time synchronization based on the system time error between itself and the reference clock device. When the master playback device or the slave playback device serves as a reference clock device, it compares its actual crystal oscillator frequency with the standard crystal oscillator frequency to obtain the crystal oscillator frequency deviation of the reference clock device, and then obtains the time deviation of the reference clock device. The reference clock device adjusts its own output sampling rate according to the time deviation of the reference clock device, thereby achieving the accuracy of the reference clock device in playing the target audio data and improving the synchronization accuracy.
[0116] 602. The reference clock device collects the current play timestamp of the target audio data and the transmission time value of the signal in the reference clock device between the sound card and the speaker according to a preset sampling period to obtain a reference play timestamp and a delay calibration value of the reference clock device.
[0117] The reference playback timestamp is the timestamp corresponding to the current playback progress of the target audio data in the reference clock device. The transmission time value of the signal between the sound card and the speaker is the delay time value between the audio card outputting the audio data and the speaker outputting the sound. Differences in hardware parameters between playback devices will result in different delay time values.
[0118] 603. The reference clock device determines a reference local time of the reference clock device according to the current local time and a delay calibration value of the reference clock device.
[0119] The reference clock device determines the sum of the current local time and the delay calibration value of the reference clock device as the reference local time of the reference clock device. Subsequently, the slave playback device subtracts the delay calibration value of the slave playback device from the reference local time to obtain the local time of the slave playback device. In this way, no matter how large the difference in hardware parameters between the reference clock device and the slave playback device is, the time base of the output audio can be kept consistent.
[0120] 604. The reference clock device generates a target audio synchronization signal according to the reference local time and the reference playback timestamp of the reference clock device.
[0121] The reference clock device combines the reference local time of the reference clock device and the reference playback timestamp to generate a target audio synchronization signal.
[0122] 605. The reference clock device broadcasts the target audio synchronization signal.
[0123] The reference clock device broadcasts the target audio synchronization signal externally, so that the master playback device and at least one slave playback device receive the target audio synchronization signal.
[0124] In an embodiment of the present invention, a reference clock device periodically broadcasts a target audio synchronization signal, and each playback device periodically performs clock synchronization with the reference clock device according to the target audio synchronization signal, thereby eliminating differences in hardware parameters of each playback device and achieving accurate synchronization of the local time of each playback device. After the local time is synchronized, the time base of each playback device in playing the target audio data is synchronized, thereby improving the accuracy of synchronous playback.
[0125] In summary, Figure 2 and Figure 3 The embodiment of the present invention describes the audio synchronization playback process between the main playback device and the reference clock device. Figure 4 and Figure 5 The embodiment of the invention describes the process of synchronously playing audio from a playback device and a reference clock device. Figure 6 The working mode of the reference clock device is explained. In actual application, the main broadcast room device and the slave broadcast room device jointly realize audio synchronous playback based on the reference clock device. Those skilled in the art can obtain the audio synchronous playback method of each playback device in the audio synchronous playback system according to the above embodiment, which will not be repeated here.
[0126] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0127] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the whole or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0128] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for synchronous audio playback, characterized in that: Applied to an audio synchronous playback system, the audio synchronous playback system includes a master playback device and a preset number of slave playback devices, and the audio synchronous playback method includes: When receiving a synchronous playback instruction, the main playback device acquires target audio data; The master playback device sends the target audio data to at least one slave playback device for playback; The main playback device determines a reference clock device; When the master playback device receives the target audio synchronization signal, the master playback device synchronizes its own local time with the local time of the reference clock device according to the target audio synchronization signal and its own delay calibration value and obtains the reference playback timestamp in the target audio synchronization signal, wherein the target audio synchronization signal is a periodic signal emitted by the reference clock device, and the reference clock device is the playback device with the smallest clock error calibration value among the master playback device and the at least one slave playback device, and the delay calibration value is the transmission time value of the signal between the sound card and the speaker; The main playback device starts playing the target audio data frame corresponding to the reference playback timestamp; The main playback device starts playing the target audio data frame corresponding to the reference playback timestamp, including: The main playback device counts the time deviation between the main playback device and the reference clock device in each period according to a first preset period to obtain a system time deviation of the main playback device; The main playback device determines the output sampling rate of the main playback device according to the system time deviation of the main playback device; The main playback device jumps to the target audio data frame corresponding to the reference playback timestamp for decoding; The main playback device starts sampling and playing from the decoded target audio data frame based on the output sampling rate of the main playback device.
2. The audio synchronous playback method according to claim 1, characterized in that: When receiving the synchronous playback instruction, the main playback device obtains the target audio data, including: When receiving a synchronous playback instruction, the main playback device obtains the original audio data indicated by the synchronous playback instruction; The main playback device acquires scene information and determines a target encoding compression algorithm according to the scene information; The main playback device encodes and compresses the original audio data according to the target encoding and compression algorithm; The main playback device adds a timestamp to each compressed audio data frame to obtain target audio data.
3. The audio synchronous playback method according to claim 2, characterized in that: The main playback device acquires scene information and determines a target encoding compression algorithm according to the scene information, including: The main playback device acquires scene information, where the scene information includes the audio type and network bandwidth information of the original audio data; The main playback device selects preset encoding compression algorithms according to the audio type to obtain an encoding compression algorithm set; The main playback device selects an algorithm that matches the network bandwidth information from the encoding compression algorithm set to obtain a target encoding compression algorithm.
4. The audio synchronous playback method according to claim 1, characterized in that: When the main playback device receives the target audio synchronization signal, before the main playback device synchronizes its own local time with the reference local time of the reference clock device according to the target audio synchronization signal and obtains the reference playback timestamp in the target audio synchronization signal, it also includes: When the main playback device detects a synchronization signal, the main playback device determines whether the received synchronization signal is a periodic signal sent by the reference clock device; If yes, the main playback device determines that the target audio synchronization signal is received; If not, the master playback device determines that the target audio synchronization signal is not detected.
5. The audio synchronous playback method according to claim 1, characterized in that: When the main playback device receives the target audio synchronization signal, the main playback device synchronizes its own local time with the local time of the reference clock device according to the target audio synchronization signal and obtains the reference playback timestamp in the target audio synchronization signal, including: When the main playback device receives the target audio synchronization signal, the main playback device parses the target audio synchronization signal to obtain the reference local time and reference playback timestamp of the reference clock device, where the reference playback timestamp indicates the audio data frame position currently played by the reference clock device; The main playback device performs time synchronization according to the reference local time of the reference clock device.
6. The audio synchronous playback method according to claim 5, characterized in that: The main playback device performs time synchronization according to the reference local time of the reference clock device, including: The main playback device determines the current local time of the main playback device according to the reference local time of the reference clock device and the delay calibration value of the main playback device.
7. A method for synchronous audio playback, characterized in that: Applied to an audio synchronous playback system, the audio synchronous playback system includes a master playback device and a preset number of slave playback devices, and the audio synchronous playback method includes: When the slave playback device receives the target audio data sent by the master playback device, the slave playback device plays the target audio data; When the slave playback device receives the target audio synchronization signal, the slave playback device synchronizes its own local time with the local time of the reference clock device according to the target audio synchronization signal and its own delay calibration value and obtains the reference playback timestamp in the target audio synchronization signal, wherein the target audio synchronization signal is a periodic signal emitted by the reference clock device, and the reference clock device is a playback device with the smallest clock error calibration value among the master playback device and at least one slave playback device, and the delay calibration value is a transmission time value of the signal between the sound card and the speaker, and the reference clock device is determined by the master playback device; The slave playback device starts playing the target audio data frame corresponding to the reference playback timestamp; The slave playback device starts playing the target audio data frame corresponding to the reference playback timestamp, including: The slave playback device counts the time deviation between the slave playback device and the reference clock device in each period according to a second preset period to obtain a system time deviation of the slave playback device; The slave playback device determines the output sampling rate of the slave playback device according to the system time deviation of the slave playback device; The slave playback device jumps to the target audio data frame corresponding to the reference playback timestamp for decoding; The slave playback device starts sampling and playing from the decoded target audio data frame based on the output sampling rate of the slave playback device.
8. The audio synchronous playback method according to claim 7, characterized in that: When the slave playback device receives the target audio data sent by the master playback device, the slave playback device plays the target audio data, including: When the slave playback device receives the target audio data sent by the master playback device, the slave playback device determines whether there is audio data matching the target audio data in the preset database; If so, the slave playback device deletes the audio data matching the target audio data, and stores the target audio data in the preset database; If not, the slave playback device determines whether the available storage space in the preset database is greater than the size of the target audio data; If so, the slave playback device stores the target audio data in the preset database; If not, the slave playback device deletes the historical data in the preset database one by one until the available storage space in the preset database is larger than the size of the target audio data, and then stores the target audio data in the preset database and plays it.
9. The audio synchronous playback method according to claim 7, characterized in that: When the slave playback device receives the target audio synchronization signal, the slave playback device synchronizes its own local time with the local time of the reference clock device according to the target audio synchronization signal and obtains a reference playback timestamp in the target audio synchronization signal, including: When the slave playback device receives the target audio synchronization signal, the slave playback device parses the target audio synchronization signal to obtain a reference local time and a reference playback timestamp of the reference clock device, where the reference playback timestamp indicates a position of an audio data frame currently played by the reference clock device; The slave playback device performs time synchronization according to the reference local time of the reference clock device.
10. The audio synchronous playback method according to claim 9, characterized in that: The slave playback device performs time synchronization according to the reference local time of the reference clock device, including: The slave playback device determines the current local time of the slave playback device according to the reference local time of the reference clock device and the delay calibration value of the slave playback device.
11. A method for synchronous audio playback, characterized in that: Applied to an audio synchronous playback system, the audio synchronous playback system comprises a master playback device as claimed in claim 1 and a preset number of slave playback devices as claimed in claim 7, the audio synchronous playback method comprises: When the reference clock device detects the target audio data, the reference clock device plays the target audio data, and the reference clock device is the master playback device or one of the preset number of slave playback devices; The reference clock device collects the current play timestamp of the target audio data and the transmission time value of the signal in the reference clock device between the sound card and the speaker according to a preset sampling period, and obtains a reference play timestamp and a delay calibration value of the reference clock device; The reference clock device determines the reference local time of the reference clock device according to the current local time and the delay calibration value of the reference clock device; The reference clock device generates a target audio synchronization signal according to a reference local time of the reference clock device and a reference playback timestamp; The reference clock device broadcasts the target audio synchronization signal.
12. The audio synchronous playback method according to claim 11, characterized in that: Playing the target audio data on the reference clock device includes: The reference clock device counts the crystal oscillator frequency deviation of the reference clock device in each period according to a second preset period; The reference clock device determines a system time deviation of the reference clock device according to a crystal oscillator frequency deviation of the reference clock device; The reference clock device determines an output sampling rate of the reference clock device according to a time deviation of the reference clock device; The main playback device samples and plays the target audio data based on the output sampling rate of the reference clock device.
13. An audio synchronous playback system, characterized in that: The audio synchronous playback system includes a master playback device and a preset number of slave playback devices, and the audio synchronous playback system executes the audio synchronous playback method as described in any one of claims 1-12.
14. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instruction is executed by the processor, the audio synchronous playback method as described in any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Timing synchronization device and method
CN104735772A
Clock synchronization method and equipment for media play
CN105450382A
TPSN and TSync-based home appliance network time synchronization method
CN106912100A
Audio data communication equipment and system
CN109450490A
Time synchronization and frequency synchronization method under radio frequency transceiver cascade system
CN113055149A
