Method and apparatus for synchronously playing audio, electronic device and storage medium

By autonomously correcting clock errors and chip temperatures through audio playback devices and employing resampling rate compensation, the problems of resource waste and poor synchronization in existing technologies are solved, achieving efficient audio synchronous playback.

CN118535120BActive Publication Date: 2026-04-07LINKPLAY TECHNOLOGY INC NANJING
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-11
Publication Date
2026-04-07

Smart Images

  • Figure CN118535120B_ABST
    Figure CN118535120B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and device for synchronous playing of audio, electronic equipment and storage medium; wherein the method comprises: a master device and a slave device start playing a target audio object at a target starting moment; during the playing process, each first audio playing device calculates the deviation between the local clock and the master clock in real time to obtain the real-time clock drift of each first audio playing device; the first audio playing device calculates the first sampling rate corresponding to the first audio playing device in response to the real-time clock drift corresponding to the first audio playing device meeting a preset first resampling condition; the first audio playing device calculates the second sampling rate corresponding to the first audio playing device in response to the real-time chip temperature corresponding to the first audio playing device meeting a preset second resampling condition; and the first audio playing device performs real-time resampling playing on the target audio object according to the first sampling rate or the second sampling rate corresponding to the first audio playing device. The present disclosure is used for reducing resource waste and improving synchronization during synchronous playing of audio.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of audio processing, and in particular to a method and device for synchronously playing audio, an electronic device and a storage medium. BACKGROUND

[0002] In the field of audio technology, the technology for synchronously playing multiple audio devices, the higher the degree of synchronization of the system, the better the experience.

[0003] In the existing audio synchronous playing technology, the audio devices for synchronous playing need to continuously and frequently perform clock synchronization to ensure the synchronization of audio playing. This way needs to occupy a large amount of network bandwidth and device processing resources, and does not take into account the influencing factors of the actual playing speed of different audio playing devices, the consideration factor is too single, and the problem of asynchronization is easy to occur. It can be seen that, when the existing technology performs synchronous playing of audio, there are technical problems of resource waste and poor synchronization. SUMMARY

[0004] Therefore, the purpose of the present disclosure is to provide a method and device for synchronously playing audio, an electronic device and a storage medium, to reduce resource waste and improve synchronization when audio is synchronously played.

[0005] In a first aspect, an embodiment of the present disclosure provides a method for synchronously playing audio, applied to an audio playing system, the audio playing system at least comprising: at least two first audio playing devices, the at least two first audio playing devices comprising: a master device and at least one slave device, the method comprising: the master device sending an audio playing instruction to the at least one slave device, the at least one slave device responding to the audio playing instruction, the master device and the at least one slave device starting to play a target audio object at a target starting time; wherein the audio playing instruction is used to indicate the target audio object and the target starting time; during the playing process, each first audio playing device calculates a deviation between a local clock and a master clock in real time to obtain a real-time clock drift amount corresponding to each first audio playing device; a first audio playing device responds to a corresponding real-time clock drift amount satisfying a preset first resampling condition, calculates a first sampling rate corresponding to the first audio playing device based on a calibrated clock error corresponding to the first audio playing device and the real-time clock drift amount; the first audio playing device responds to a corresponding real-time chip temperature satisfying a preset second resampling condition, calculates a second sampling rate corresponding to the first audio playing device according to the first sampling rate and the real-time chip temperature corresponding to the first audio playing device; and the first audio playing device performs real-time resampling playing on the target audio object according to the corresponding first sampling rate or second sampling rate.

[0006] Optionally, the master device sends an audio playing instruction to the at least one slave device, and the at least one slave device plays the target audio object at the target starting time in response to the audio playing instruction, including: the master device determines the target starting time according to a current time in response to the synchronous playing instruction; the master device sends the audio playing instruction to the at least one slave device based on the target starting time; the at least one slave device plays the target audio object at the target starting time or at the current time in response to the audio playing instruction; and the master device plays the target audio object at the target starting time.

[0007] Optionally, the master device determines the target starting time according to a current time in response to the synchronous playing instruction, including: the master device acquires a current network transmission delay duration and an expected preparation duration of each slave device in response to the synchronous playing instruction; and the master device adds the current time to a maximum value of the current network transmission delay duration and all expected preparation durations to obtain the target starting time.

[0008] Optionally, the at least one slave device plays the target audio object at the target starting time or at the current time in response to the audio playing instruction, including: each slave device determines whether a pre-synchronized local clock is earlier than the target starting time in response to the audio playing instruction, wherein the pre-synchronized local clock is used to indicate a current time of the corresponding slave device; if the pre-synchronized local clock is earlier than the target starting time, the corresponding slave device plays the target audio object at the target starting time; and if the pre-synchronized local clock is not earlier than the target starting time, the corresponding slave device plays the target audio object at the current time.

[0009] Optionally, the audio playing instruction further indicates an audio transmission address of the target audio object, and the master device and the at least one slave device play the target audio object at the target starting time, including: the master device and the at least one slave device acquire the target audio object from the audio transmission address of the target audio object and store the target audio object in a local cache; and the master device and the at least one slave device read the target audio object from the local cache and play the target audio object in the local cache at the target starting time.

[0010] Optionally, the first audio playback device, in response to the corresponding real-time clock drift satisfying a preset first resampling condition, calculates the first sampling rate corresponding to the first audio playback device based on the corresponding calibrated clock error and the real-time clock drift of the first audio playback device, including: the first audio playback device, in response to the corresponding real-time clock drift being greater than a preset drift threshold, calculates a correction coefficient corresponding to the first audio playback device according to the corresponding calibrated clock error and the real-time clock drift of the first audio playback device; and calculates the first sampling rate corresponding to the first audio playback device according to the original sampling rate corresponding to the first audio playback device and the correction coefficient.

[0011] Optionally, the first audio playback device, in response to the corresponding real-time clock drift being greater than a preset drift threshold, calculates a correction coefficient corresponding to the first audio playback device according to the corresponding calibrated clock error and the real-time clock drift of the first audio playback device, including: the first audio playback device, in response to the corresponding real-time clock drift being greater than a preset drift threshold, superimposes the corresponding calibrated clock error and the real-time clock drift of the first audio playback device to obtain a first clock deviation corresponding to the first audio playback device; converts the clock deviation corresponding to the first audio playback device into a parts per million to obtain a second clock deviation corresponding to the first audio playback device; and adds a preset value to the second clock deviation corresponding to the first audio playback device to obtain the correction coefficient corresponding to the first audio playback device.

[0012] Optionally, the first audio playback device, in response to the corresponding real-time clock drift being greater than a preset drift threshold, calculates a correction coefficient corresponding to the first audio playback device according to the corresponding calibrated clock error and the real-time clock drift of the first audio playback device, including: the first audio playback device, in response to the corresponding real-time clock drift being greater than a preset drift threshold, superimposes the corresponding calibrated clock error and the real-time clock drift of the first audio playback device to obtain a first clock deviation corresponding to the first audio playback device; converts the clock deviation corresponding to the first audio playback device into a parts per million to obtain a second clock deviation corresponding to the first audio playback device; and adds a preset value to the second clock deviation corresponding to the first audio playback device to obtain the correction coefficient corresponding to the first audio playback device.

[0013] Optionally, the first audio playback device, in response to the corresponding real-time clock drift satisfying a preset first resampling condition, calculates the first sampling rate corresponding to the first audio playback device based on the corresponding calibrated clock error and the real-time clock drift of the first audio playback device, including: the first audio playback device, in response to the corresponding real-time clock drift being greater than a preset drift threshold, calculates a correction coefficient corresponding to the first audio playback device according to the corresponding calibrated clock error and the real-time clock drift of the first audio playback device; and calculates the first sampling rate corresponding to the first audio playback device according to the original sampling rate corresponding to the first audio playback device and the correction coefficient.

[0014] Optionally, the first audio playback device determines a clock error parameter offset according to the real-time chip temperature in response to a change value of the corresponding real-time chip temperature within a preset time length exceeding a preset change threshold, including: the first audio playback device looks up a clock error parameter offset corresponding to the real-time chip temperature from a preset temperature offset mapping table in response to a change value of the corresponding real-time chip temperature within a preset time length exceeding a preset change threshold.

[0015] Optionally, the first audio playback device performs real-time resampling playback on the target audio object according to the corresponding first sampling rate or second sampling rate, including: if the real-time chip temperature meets a preset second resampling condition, performing real-time resampling on the target audio object by the second sampling rate, and playing the resampled sampling points; if the real-time chip temperature does not meet the preset second resampling condition, performing real-time resampling on the target audio object by the first sampling rate, and playing the resampled sampling points.

[0016] Optionally, before the master device sends the audio playback instruction to the at least one slave device, the method further includes: recording a playback time length required by each first audio playback device to play a preset audio object, and obtaining a standard time length corresponding to the preset audio object; calculating a difference value between the standard time length and the playback time length to obtain a calibrated clock error corresponding to each first audio playback device.

[0017] In a second aspect, the embodiments of the present disclosure provide a device for synchronized playing of audio. The device comprises: an application to an audio playing system, the audio playing system comprising at least two first audio playing devices, the at least two first audio playing devices comprising a master device and at least one slave device, the device comprising: a starting playing module configured to send, by the master device, an audio playing instruction to the at least one slave device, the at least one slave device responding to the audio playing instruction, and the master device and the at least one slave device starting to play a target audio object at a target starting time; wherein the audio playing instruction is configured to indicate the target audio object and the target starting time; a deviation calculating module configured to calculate, by each first audio playing device, a deviation between a local clock and a master clock in a playing process to obtain a real-time clock drift of each first audio playing device; a first judging module configured to calculate, by a first audio playing device, a first sampling rate corresponding to the first audio playing device based on a calibrated clock error corresponding to the first audio playing device and the real-time clock drift of the first audio playing device in response to the real-time clock drift corresponding to the first audio playing device satisfying a preset first resampling condition; a second judging module configured to calculate, by a first audio playing device, a second sampling rate corresponding to the first audio playing device based on the first sampling rate and a real-time chip temperature corresponding to the first audio playing device in response to the real-time chip temperature corresponding to the first audio playing device satisfying a preset second resampling condition; and a resampling playing module configured to perform, by the first audio playing device, real-time resampling playing on the target audio object based on the first sampling rate or the second sampling rate corresponding to the first audio playing device.

[0018] In a third aspect, the embodiments of the present disclosure provide an electronic device comprising a processor and a memory, the memory storing machine executable instructions capable of being executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned method for synchronized playing of audio.

[0019] In a fourth aspect, the embodiments of the present disclosure provide a computer readable storage medium storing computer executable instructions, and the computer executable instructions, when invoked and executed by a processor, cause the processor to implement the above-mentioned method for synchronized playing of audio.

[0020] The embodiments of the present disclosure bring the following beneficial effects:

[0021] The above-mentioned method, device, electronic device and storage medium for synchronized playing of audio can compensate clock error in a synchronized playing process by resampling rate according to clock error, clock drift and chip temperature of each slave device after the master device controls the slave device to start synchronized playing, which can reduce resources required for synchronization, and realize real-time correction of playing speed without introducing distortion, and the combination of clock error, clock drift and chip temperature can also improve the synchronization of audio playing.

[0022] Other features and advantages of the present disclosure will be set forth in the descriptions that follow and in part will be apparent from the description or can be learned by practice of the present disclosure. The purposes and other advantages of the present disclosure will be realized and attained by the structures particularly pointed out in the description, the claims and the drawings.

[0023] In order to make the above-mentioned purposes, features and advantages of the present disclosure more obvious and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are described as follows. BRIEF DESCRIPTION OF DRAWINGS

[0024] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the specific embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0025] Figure 1 An embodiment flow chart of the method for synchronously playing audio in the embodiment of the present disclosure;

[0026] Figure 2 Another embodiment flow chart of the method for synchronously playing audio in the embodiment of the present disclosure;

[0027] Figure 3 A schematic diagram of an audio synchronous playing device provided by the embodiment of the present disclosure;

[0028] Figure 4 A schematic diagram of an electronic device provided by the embodiment of the present disclosure. DETAILED DESCRIPTION

[0029] In order to make the purposes, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the present disclosure will be described clearly and completely in combination with the drawings. Obviously, the described embodiments are some of the embodiments of the present disclosure, but not all the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative labor fall within the protection scope of the present disclosure.

[0030] The terms "first", "second", "third", "fourth", and the like in the description and claims of this disclosure and the aforementioned drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of the terms so construed herein can interchange, under appropriate circumstances, with one another, such that the embodiments described herein can be carried out in other sequences than the one illustrated or described herein. Moreover, the terms "comprising" or "having", and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, product, or apparatus that comprises a list of steps or units not only comprises those steps or units but can include other steps or units not expressly listed or inherent to such process, method, product, or apparatus.

[0031] It should be noted that one embodiment of the method for synchronously playing audio in the embodiments of the present disclosure is applied to an audio playing system, and the audio playing system at least includes: at least two first audio playing devices, the at least two first audio playing devices include: a master device and at least one slave device; wherein any one of the first audio playing devices can be used as the master device, and the first audio playing devices other than the master device in all the first audio playing devices are the slave devices, the master device can be a pre-designated first audio playing device which does not change any more, or can be dynamically determined before each execution of the method for synchronously playing audio in the embodiments of the present disclosure, for example, the master device is dynamically selected by a negotiation algorithm, such as selecting the first audio playing device with the smallest or largest IP address as the master device, and the specific implementation is not limited here.

[0032] In the embodiments of the present disclosure, the audio playing system can further include audio playing devices other than the first audio playing devices and other devices other than the audio playing devices, such as control devices, display devices, and the like, and the specific implementation is not limited here. The at least two first audio playing devices in the audio playing system refer to the audio devices that need to be synchronously played, and any audio playing device in the audio playing system can be specified as the first audio playing device by a synchronous playing instruction.

[0033] For the convenience of understanding, the specific flow of the embodiments of the present disclosure is described below, please refer to Figure 1 The present embodiment includes:

[0034] In step S10, the master device sends an audio playing instruction to the at least one slave device, the at least one slave device responds to the audio playing instruction, and the master device and the at least one slave device start playing a target audio object at a target starting time; wherein the audio playing instruction is used to indicate the target audio object and the target starting time;

[0035] In this embodiment, the master device is responsible for sending the audio playing instruction to the slave device, the slave device receives and executes the instruction sent by the master device, and the master device and the slave device start playing the target audio object from the target start time. It can be understood that the target start time can be represented by a timestamp, or represented by any other time representation format, which is not limited here. In order to improve the synchronization of audio playing, all time parameters in the embodiment of the disclosure are accurate to microseconds, including but not limited to the target start time, the local clock and the master clock, etc., so that the accuracy of audio synchronous playing reaches the level of microsecond synchronization. In an embodiment, the master device and the slave device each determine whether the target start time has been reached according to the local clock stored by itself, and if the local clock reaches the target start time, the target audio object is started to be played.

[0036] In an embodiment, this step can be triggered by a synchronous playing instruction. The synchronous playing instruction can be generated for any device or apparatus in the audio playing system, and is used to trigger the master device to send the audio playing instruction to at least one slave device. For example, any audio playing device or control apparatus in the audio playing system receives the voice "playing music A in the whole house", and then the audio playing device or the control apparatus can generate the synchronous playing instruction, and send the generated synchronous playing instruction to the master device, and then the master device sends the audio playing instruction to the slave device. Alternatively, the audio playing device receiving the voice can serve as the master device, and immediately sends the audio playing instruction to the slave device.

[0037] In an embodiment, the target audio object refers to an audio object that needs to be played synchronously, which can be indicated by an identifier of the audio object, or by a data audio transmission address of the audio object, which is not limited here. It should be noted that the target audio object can be an audio file or a list of audio files. The embodiment of the disclosure can play a specified audio file synchronously, or play a specified list of audio files synchronously, and has high flexibility of synchronous playing.

[0038] In an embodiment, the audio playing instruction is also used to indicate the format parameters of the target audio object, such as the number of channels, the bit depth, the original sampling rate, the time length, etc., which are used to indicate the playing mode of the target audio object by the first audio playing device, which is not limited here. In an embodiment, the audio playing instruction is also used to indicate the audio transmission address of the target audio object, and the transmission of the playing control instruction and the audio data is decoupled, which can effectively reduce the network load.

[0039] In an embodiment, the master device and the at least one slave device start playing the target audio object at the target start time, comprising: the master device and the at least one slave device obtaining the target audio object from the audio transmission address of the target audio object and storing in the local cache; the master device and the at least one slave device reading the target audio object from the local cache and starting playing the target audio object in the local cache at the target start time. In this embodiment, when playing the target audio object, the first audio playing device first obtains the target audio object from the audio transmission address through the local area network and stores in the local cache, and then reads the target audio object in the local cache directly and starts playing the target audio object in the local cache at the target start time, so that the synchronization of audio synchronous playing is improved.

[0040] In an embodiment, before step S10, further comprising: recording a playing time length required for each first audio playing device to play the preset audio object, and obtaining a standard time length corresponding to the preset audio object; calculating a difference between the standard time length and the playing time length to obtain a calibration clock error corresponding to each first audio playing device. In this embodiment, a reference audio (i.e. the preset audio object) with a known time length L0, such as a 500Hz sine wave, is played by each first audio playing device, the actual playing time length L1 of the reference audio played by each first audio playing device is recorded, and the calibration clock error bias of each first audio playing device is calculated. The calculated bias can be stored in the non-volatile memory of the device, and the calculation formula of the bias is:

[0041] bias = (L1-L0) / L0*1000000

[0042] Step S20, during the playing process, each first audio playing device calculates the deviation between the local clock and the master clock in real time to obtain a real-time clock drift corresponding to each first audio playing device;

[0043] It should be noted that steps S20-S50 are steps that are continuously executed during the playing process. In this step, each first audio playing device calculates the deviation between the local clock and the master clock according to a preset calculation frequency, thereby obtaining a real-time clock drift corresponding to each first audio playing device. The master clock is the local clock of the master clock device, which can be any one of the at least two first audio playing devices, can be the same as the master device, or can be one of the slave devices. The master clock device can also be a device / device other than the first audio playing device in the audio playing system, which is not limited here. For the first audio playing device as the master clock device, since its local clock is the master clock, the real-time clock drift corresponding to the first audio playing device as the master clock device is 0.

[0044] In an embodiment, the master clock can be actively acquired by the first audio playback device, specifically, each first audio playback device acquires the master clock from the master clock device at a preset first time interval, and then calculates the deviation between the acquired master clock and the local clock, so as to obtain the real-time clock drift corresponding to each first audio playback device. For example, the first audio playback device can request the master clock from the master clock device every 1 second, the master clock device responds to the request and sends the local clock to the first audio playback device, and the first audio playback device calculates the deviation between the received local clock of the master clock device and the local clock of itself, so as to obtain the real-time clock drift corresponding to the first audio playback device.

[0045] In an embodiment, the master clock can also be actively sent by the master clock device, specifically, the step includes: during the playback process, each first audio playback device acquires the master clock periodically sent by the master clock device through the Precision Time Protocol (PTP), and then calculates the deviation between the latest received master clock and the local clock, so as to obtain the real-time clock drift corresponding to each first audio playback device. In the embodiment, the PTP protocol can control the clock deviation between devices to the sub-microsecond level through hardware timestamp and multiple message exchanges, thereby laying a foundation for the synchronized playback of unified audio.

[0046] It can be understood that the clock drift refers to several related phenomena that the clock does not run at the same rate as the reference clock, that is, after a period of time, the clock will "deviate" or gradually become unsynchronized with another clock, all clocks will drift, and unless resynchronized, will eventually lead to divergence. In the embodiment, the master clock is the reference clock, and the real-time clock drift corresponding to each first audio playback device can be obtained by calculating the deviation between the local clock of each first audio playback device and the master clock. Since the embodiment of the present disclosure focuses on the time synchronization between the first audio playback devices to maintain the synchronization of audio playback, the master clock does not need to be an absolutely accurate clock, but a reference clock, and it is not necessary to maintain the absolute accuracy of the master clock. To some extent, this can save the calculation resources of audio synchronized playback and reduce the resource waste during audio synchronized playback.

[0047] In step S30, the first audio playback device calculates the first sampling rate corresponding to the first audio playback device based on the calibrated clock error corresponding to the first audio playback device and the real-time clock drift corresponding to the first audio playback device, in response to the real-time clock drift corresponding to the first audio playback device satisfying a preset first resampling condition.

[0048] In this embodiment, during the playing process, each first audio playing device detects whether the real-time clock drift amount satisfies the preset first resampling condition according to the preset detection frequency. When the real-time clock drift amount corresponding to the first audio playing device satisfies the preset first resampling condition, the first audio playing device calculates the first sampling rate corresponding to the first audio playing device based on the calibration clock error corresponding to the first audio playing device and the real-time clock drift amount. The calibration clock error is a property previously calibrated for the first audio playing device and is used to represent the clock deviation amount generated by each preset clock period. The specific calibration manner is not limited here. In an embodiment, the unit of the calibration clock error is PPM (part per million), so that each 1 PPM represents that 1 clock deviation amount is generated for each 1 million clocks. The unit of the calibration clock error can also be other units, such as seconds, milliseconds, microseconds, etc. PPM can more accurately record the clock deviation of the audio playing device.

[0049] In an embodiment, the preset first resampling condition can be that the real-time clock drift amount corresponding to the first audio playing device exceeds the preset normal clock drift range. Then, when the first audio playing device detects that the corresponding real-time clock drift amount exceeds the preset normal clock drift range, the first sampling rate corresponding to the first audio playing device is calculated based on the calibration clock error corresponding to the first audio playing device and the real-time clock drift amount. It should be noted that the preset first resampling condition can be any condition for judging whether the first audio playing device needs to be resampled based on the real-time clock drift amount, and the specific condition is not limited here.

[0050] In an embodiment, the calculation manner of the first sampling rate can be that the calibration clock error corresponding to the first audio playing device and the real-time clock drift amount are superimposed to obtain a total clock deviation amount, the ratio between the total clock deviation amount and a preset unit deviation amount is calculated to obtain a sampling point deviation amount, and finally, the sampling point deviation amount and the original sampling rate are superimposed to obtain the first sampling rate. For example, assuming that the calibration clock error and the real-time clock drift amount corresponding to the first audio playing device are 15 PPM and 5 PPM respectively, the total clock deviation amount is 15+5=20, assuming that the preset unit deviation amount is 20, the sampling point deviation amount is 20 / 20=1, and assuming that the original sampling rate is 48000 sampling points, the first sampling point is 48000+1=48001, and the specific manner is not limited here. In this embodiment, through the preset unit deviation amount, when the total clock deviation amount increases / decreases by a certain amount, the corresponding sampling point also increases / decreases by a corresponding amount. The calculation manner is simple and efficient, and can improve the efficiency of audio synchronous playing.

[0051] In step S40, the first audio playback device calculates a second sampling rate corresponding to the first audio playback device according to the first sampling rate and the real-time chip temperature corresponding to the first audio playback device, in response to the real-time chip temperature corresponding to the first audio playback device satisfying the preset second resampling condition.

[0052] It should be noted that the real-time chip temperature refers to the real-time temperature of a chip used in the audio playback device during audio playback, such as a digital signal processing (DSP) chip, an audio codec chip, a clock and timing chip, a power amplifier chip, etc., which is not limited here. In this embodiment, during playback, each first audio playback device detects whether the real-time chip temperature corresponding to the first audio playback device satisfies the preset second resampling condition according to a preset detection frequency. When the real-time chip temperature corresponding to the first audio playback device satisfies the preset second resampling condition, the first audio playback device calculates a second sampling rate corresponding to the first audio playback device according to the first sampling rate and the real-time chip temperature corresponding to the first audio playback device.

[0053] It can be understood that the temperature of the chip has a certain influence on the playback speed of the audio. In an embodiment, the playback delay duration corresponding to the real-time chip temperature is obtained, and then the second sampling rate corresponding to the first audio playback device is calculated according to the playback delay duration corresponding to the first audio playback device and the first sampling frequency. Specifically, the playback delay duration corresponding to the real-time chip temperature can be calculated by a preset mapping function or obtained by querying a preset mapping table, which is not limited here.

[0054] In an embodiment, the associated resampling rate corresponding to the real-time chip temperature can also be obtained through a pre-established association model between the chip temperature and the resampling rate, and then the associated resampling rate and the first sampling rate are superimposed to obtain the second sampling rate corresponding to the first audio playback device. This embodiment introduces a temperature compensation mechanism, which further improves the synchronization accuracy and stability.

[0055] In step S50, the first audio playback device performs real-time resampling playback on the target audio object according to the corresponding first sampling rate or the second sampling rate.

[0056] It can be understood that during playback, the first audio playback device can perform real-time resampling on the target audio object according to the corresponding first sampling rate or the second sampling rate, and play the resampled sampling points. Specifically, if the first audio playback device does not have a corresponding second sampling rate, or the storage duration of the second sampling rate exceeds a preset detection frequency duration, the first audio playback device performs real-time resampling playback on the target audio object according to the corresponding first sampling rate, otherwise, the first audio playback device performs real-time resampling playback on the target audio object according to the corresponding second sampling rate.

[0057] It should be noted that if the first audio playback device does not exist corresponding second sampling rate, it means that the corresponding real-time chip temperature of the first audio playback device does not meet the preset second resampling condition in the synchronous playback process of this time audio, if the saving time length of the corresponding second sampling rate of the first audio playback device exceeds a preset detection frequency time length, it means that the latest second sampling rate saved by the first audio playback device is expired data, which has been used for resampling playback and cannot be used as data for this time resampling playback. By comprehensively considering the influence of factors such as clock error, clock drift and chip temperature on audio synchronous playback, higher long-term synchronization accuracy and sound quality can be obtained.

[0058] The above-mentioned embodiment provides a synchronous playback method of audio, which can reduce the resources required for synchronization by each slave device compensating the clock error in the synchronous playback process through the resampling rate according to its own clock error, clock drift and chip temperature after the master device controls the slave device to start synchronous playback, while realizing real-time correction of the playback speed without introducing distortion. The combination of multiple factors such as clock error, clock drift and chip temperature can also improve the synchronization of audio playback.

[0059] Referring to Figure 2 Another embodiment of the synchronous playback method of audio in the embodiment of the present disclosure includes:

[0060] Step S201, the master device determines a target starting time according to the current time in response to the synchronous playback instruction;

[0061] In this embodiment, after the master device receives the synchronous playback instruction of the audio playback system, it responds to the synchronous playback instruction and determines a unified playback starting time, i.e. the target starting time, according to the current time. The target starting time is at least greater than the maximum value of the expected playable time of all slave devices, and the expected playable time represents the current time plus the time required for playback preparation of the corresponding slave device. The time required for playback preparation includes the time required for receiving the audio playback instruction and the time required for playback preparation. For example, assuming that the current time is 1713516795000, the audio playback system includes two slave devices, one of which has an expected playable time of 1713516805000, and the other has an expected playable time of 1713516803000. Since 1713516805000 is the maximum value of the expected playable time of all slave devices, the target starting time can be determined as 1713516805000, which is not limited in detail. In an embodiment, the time required for playback preparation of the slave device can be a preset value, and the corresponding playback preparation time is set as a preset value according to the hardware parameters of different slave devices, so as to improve the efficiency of synchronous playback.

[0062] In an embodiment, in order to more accurately predict the expected playable time of the slave device, step S201 comprises: the master device, in response to the synchronous playing instruction, obtaining a current network transmission delay duration and an expected preparation duration of each slave device; and adding the current time to the maximum of the current network transmission delay duration and all expected preparation durations to obtain a target starting time. In this embodiment, after the master device responds to the synchronous playing instruction, the current network transmission delay duration is predicted according to the current network state, which is used to indicate the duration required for the slave device to receive the audio playing instruction, and the maximum of the expected preparation durations of all slave devices is determined, and the current time is added to the current network transmission delay duration and the maximum to obtain the target starting time. It can be understood that the playing preparation includes: applying a playing buffer and filling the received audio data into the playing buffer, setting a playing clock and waiting for the arrival of the target starting time, configuring an audio decoding and output channel, etc. The expected preparation duration refers to the duration required for the playing preparation to be completed, which can be a preset value or can be determined according to the buffer size of the slave device and the current network state, and is not limited here.

[0063] Step S202: the master device sends an audio playing instruction to at least one slave device based on the target starting time;

[0064] In this embodiment, the master device encapsulates the target starting time in the audio playing instruction and distributes it to each slave device through a reliable transmission protocol (such as TCP), and further, the audio playing instruction can also contain the identification of the target audio object, format parameters and an audio transmission address, etc., and is not limited here. For example, assuming that the local clock of the master device is 1676234000000000 microseconds, and the master device selects 10 seconds later as the unified playing time, then the target starting time in the instruction is 1676234010000000, and the audio playing instruction sent at this time can include: the target starting time 1676234010000000, 2 audio channels, 16-bit depth, 48 kHz sampling rate, a PCM data stream with a duration of 30 minutes, and a data audio transmission address of http: / / 192.168.1.100 / audio / sample.pcm, and is not limited here.

[0065] Step S203: at least one slave device, in response to the audio playing instruction, starts playing the target audio object at the target starting time or starts playing the target audio object at the current time;

[0066] It can be understood that the slave device can determine whether to play the target audio object starting from the target start time according to the pre-synchronized local clock or to play the target audio object immediately starting from the current time. In an embodiment, the maximum expected preparation time corresponds to the slave device playing the target audio object immediately starting from the current time, and other slave devices playing the target audio object starting from the target start time.

[0067] In an embodiment, the step S203 comprises: each slave device determining whether the pre-synchronized local clock is earlier than the target start time in response to the audio playing instruction, wherein the pre-synchronized local clock is used to indicate the current time of the corresponding slave device; if the pre-synchronized local clock is earlier than the target start time, the corresponding slave device plays the target audio object starting from the target start time; if the pre-synchronized local clock is not earlier than the target start time, the corresponding slave device plays the target audio object starting from the current time. In this embodiment, according to the local clock of each slave device, it is determined whether the target start time in the slave device has arrived, if not, the arrival of the target start time is waited for, and the target audio object is played when the target start time arrives; if the target start time has already arrived, the target audio object is played immediately, that is, the target audio object is played starting from the current time.

[0068] The step S204 comprises: the master device playing the target audio object starting from the target start time.

[0069] It can be understood that the master device only needs to wait for the arrival of the target start time, and play the target audio object when the target start time arrives. In an embodiment, the master device can also perform playing preparation during the waiting period for the arrival of the target start time, and can also download the target audio object to the data audio transmission address in the local area network, so that the slave device can quickly receive the target audio object through the local area network, and the audio playing efficiency is improved.

[0070] The step S205 comprises: each first audio playing device calculating the deviation between the local clock and the master clock in real time during the playing process, to obtain the real-time clock drift of each first audio playing device.

[0071] In this embodiment, after the playing starts, the master device and the slave device calculate the deviation between the local clock and the master clock according to the preset calculation frequency, to obtain the real-time clock drift of each first audio playing device. The real-time clock drift is the latest clock drift, and is used to measure the size of the clock deviation of the first audio playing device.

[0072] In step S206, the first audio playback device calculates the first sampling rate corresponding to the first audio playback device based on the real-time clock drift and the calibration clock error corresponding to the first audio playback device, in response to the real-time clock drift corresponding to the first audio playback device satisfying a preset first resampling condition.

[0073] In an embodiment, step S206 includes: the first audio playback device calculates a correction coefficient corresponding to the first audio playback device according to the real-time clock drift and the calibration clock error corresponding to the first audio playback device, in response to the real-time clock drift corresponding to the first audio playback device being greater than a preset drift threshold; and calculates the first sampling rate corresponding to the first audio playback device according to the original sampling rate corresponding to the target audio object and the correction coefficient.

[0074] In the embodiment, the preset first resampling condition is that the real-time clock drift is greater than the preset drift threshold. In the playback process, each first audio playback device detects whether the real-time chip temperature corresponding to the first audio playback device is greater than the preset drift threshold at a preset detection frequency. When it is detected that the real-time chip temperature corresponding to the first audio playback device is greater than the preset drift threshold, a correction coefficient corresponding to the first audio playback device is calculated according to the real-time clock drift and the calibration clock error corresponding to the first audio playback device, and then the first sampling rate corresponding to the first audio playback device is calculated according to the original sampling rate corresponding to the target audio object and the correction coefficient. Thus, the original sampling rate is corrected by the correction coefficient, so as to achieve the purpose of clock bias compensation.

[0075] Further, in an embodiment, when the first audio playback device calculates the correction coefficient corresponding to the first audio playback device according to the real-time clock drift and the calibration clock error corresponding to the first audio playback device, in response to the real-time clock drift corresponding to the first audio playback device being greater than the preset drift threshold, the first audio playback device superimposes the real-time clock drift and the calibration clock error corresponding to the first audio playback device to obtain a first clock bias corresponding to the first audio playback device; converts the clock bias corresponding to the first audio playback device into parts per million (PPM) to obtain a second clock bias corresponding to the first audio playback device; and adds a preset value to the second clock bias corresponding to the first audio playback device to obtain the correction coefficient corresponding to the first audio playback device.

[0076] In the embodiment, when the calibration clock error and the real-time clock drift are both in PPM, the embodiment is expressed by the following formula:

[0077] R = 1 + (bias + drift) / 1000000

[0078] Wherein, R represents the correction coefficient corresponding to the first audio playback device, 1 is a preset value, bias represents the calibration clock error corresponding to the first audio playback device, and drift represents the real-time clock drift corresponding to the first audio playback device.

[0079] In an embodiment, when the first sampling rate corresponding to the first audio playback device is calculated according to the original sampling rate corresponding to the first audio playback device and the correction coefficient, the product between the original sampling rate corresponding to the first audio playback device and the correction coefficient is calculated to obtain the first sampling rate corresponding to the first audio playback device. This embodiment is expressed by the following formula:

[0080] SR1=SR0×R

[0081] Wherein, SR1 represents the first sampling rate corresponding to the first audio playback device, SR0 represents the original sampling rate corresponding to the first audio playback device, and R represents the correction coefficient corresponding to the first audio playback device.

[0082] In step S207, the first audio playback device calculates the second sampling rate corresponding to the first audio playback device according to the first sampling rate and the real-time chip temperature corresponding to the first audio playback device in response to the fact that the real-time chip temperature corresponding to the first audio playback device satisfies a preset second resampling condition.

[0083] In an embodiment, step S207 includes: in response to the fact that the change value of the real-time chip temperature corresponding to the first audio playback device within a preset time length exceeds a preset change threshold, the clock error parameter offset is determined according to the real-time chip temperature; the clock error parameter offset is converted into a target measurement unit to obtain a third clock deviation; wherein the target measurement unit is the same as the measurement unit of the calibration clock error and the real-time clock drift; and the first sampling rate is superimposed with the third clock deviation to obtain the second sampling rate corresponding to the first audio playback device.

[0084] In this embodiment, the preset second resampling condition is whether the change value of the real-time chip temperature within a preset time length exceeds a preset change threshold. In the playback process, each first audio playback device detects whether the change value of the real-time chip temperature within a preset time length exceeds a preset change threshold according to a preset detection frequency. When it is detected that the change value of the real-time chip temperature within a preset time length exceeds a preset change threshold, the clock error parameter offset is determined according to the real-time chip temperature, and then the clock error parameter offset is converted into the same unit as the calibration clock error and the real-time clock drift, wherein the target measurement unit is PPM to obtain a third clock deviation. Finally, the first sampling rate is superimposed with the third clock deviation to obtain the second sampling rate corresponding to the first audio playback device.

[0085] In an embodiment, the first audio playback device, in response to the variation of the corresponding real-time chip temperature within the preset time length exceeding the preset variation threshold, determines the clock error parameter offset according to the real-time chip temperature, including: the first audio playback device, in response to the variation of the corresponding real-time chip temperature within the preset time length exceeding the preset variation threshold, looks up the preset temperature offset mapping table to find the clock error parameter offset corresponding to the real-time chip temperature. In this embodiment, the preset temperature offset mapping table records the clock error parameter offsets corresponding to different chip temperatures, for example, when the chip temperature rises by 10℃ from the base temperature, the corresponding TPM is -8PPM, then if the corresponding real-time chip temperature of the first audio playback device rises by more than 10℃ within the preset time length, the TPM corresponding to the real-time chip temperature at this time is -8PPM, which is not limited here.

[0086] In an embodiment, when calculating the second sampling rate, the influence of the chip working frequency on the clock deviation can also be introduced, specifically, the step includes: the first audio playback device, in response to the corresponding real-time chip temperature and / or real-time chip working frequency satisfying the preset second resampling condition, calculates the second sampling rate corresponding to the first audio playback device according to the first sampling rate and the corresponding real-time chip temperature and real-time chip working frequency of the first audio playback device.

[0087] Further, the first audio playback device, in response to the corresponding real-time chip temperature and / or real-time chip working frequency satisfying the preset second resampling condition, calculates the second sampling rate corresponding to the first audio playback device by calculating the sampling rate of the first sampling rate and the corresponding real-time chip temperature and real-time chip working frequency of the first audio playback device through the preset sampling rate calculation formula. Wherein, the preset sampling rate calculation formula is:

[0088] SR2=SR1×[1+α×(T-T0) 2 +β×(f-f0) γ +δ×TPPM / 1000000]

[0089] Wherein, SR2 represents the second sampling rate corresponding to the first audio playback device, SR1 represents the first sampling rate corresponding to the first audio playback device, T represents the real-time chip temperature, T0 represents the preset reference temperature, f represents the real-time chip working frequency, f0 represents the preset chip working frequency as a reference, TPM represents the clock error parameter offset, and α, β, γ, δ are preset correction coefficients fitted according to experimental data.

[0090] In this embodiment, the preset sampling rate calculation formula not only combines the influence of temperature on clock deviation, but also combines the influence of chip working frequency on clock deviation. Meanwhile, by introducing the preset reference temperature T0 and the preset reference frequency f0, compensation can be performed when the actual working environment deviates from the nominal value. In addition, the quadratic term (T-T0) 2 and the power function (f-f0) γ can more accurately describe the nonlinear relationship between chip temperature and chip frequency and clock deviation, and the preset correction coefficient can be flexibly adjusted according to different working environments of different types of chips and audio devices to achieve optimal compensation effect, so that the synchronization of audio synchronous playback is higher.

[0091] To facilitate understanding, the meanings of various physical parameters in the preset sampling rate calculation formula are described below. In this embodiment, T0 represents the nominal working temperature of the chip, which is generally provided by the chip manufacturer, and the T0 of the audio processing chip is usually 25℃. f0 represents the nominal working frequency of the chip, which is determined by the clock system of the chip, such as common 48kHz, 96kHz, etc. Alpha reflects the size of the quadratic term influence of chip temperature change on clock deviation. Beta reflects the size of the power function influence of chip frequency change on clock deviation. Gamma reflects the nonlinear degree of the influence of chip frequency change on clock deviation. Delta reflects the influence weight of the clock error parameter offset TPPM.

[0092] It should be noted that the above-mentioned preset correction coefficient is obtained by fitting experimental data. Specifically, for alpha, different environmental temperatures are controlled in a thermostat, and the actual clock deviation of the chip under different temperatures is tested under the condition of the nominal working frequency f0. The value of alpha is determined by data fitting. For beta and gamma, different chip working frequencies f are controlled under the condition of the nominal temperature T0, and the actual clock deviation of the chip under different frequencies is tested. The values of beta and gamma are determined by data fitting. For delta, the clock error parameter offset TPPM data of different chips is integrated, and the value of delta is determined by data fitting. Through the above experimental design and data fitting process, the algorithm formula can achieve the best clock compensation effect in actual application, thereby effectively improving the accuracy and stability of audio synchronous playback.

[0093] Step S208, the first audio playback device performs real-time resampling playback on the target audio object according to the corresponding first sampling rate or second sampling rate.

[0094] In an embodiment, the step S208 comprises: if the real-time chip temperature satisfies a preset second resampling condition, resampling the target audio object in real time by a second resampling rate, and playing the resampled sampling points; if the real-time chip temperature does not satisfy the preset second resampling condition, resampling the target audio object in real time by a first resampling rate, and playing the resampled sampling points. In the embodiment, if the real-time chip temperature corresponding to the first audio playing device triggers the second resampling condition, the target audio object is resampled in real time according to the second resampling rate, and the resampled sampling points are played; otherwise, if the real-time chip temperature corresponding to the first audio playing device does not trigger the second resampling condition, the target audio object is resampled in real time according to the first resampling rate, and the resampled sampling points are played.

[0095] The method for synchronously playing audio provided by the above embodiments can control the slave devices to start synchronous playing after the master device sets a uniform playing start time, each slave device respectively compensates the clock error in the synchronous playing process by a resampling rate according to its own clock error, clock drift and chip temperature, can reduce the resources required for synchronization, and realizes real-time correction of the playing speed without introducing distortion. The combination of the clock error, the clock drift and the chip temperature can also improve the synchronization of audio playing.

[0096] Corresponding to the method embodiments, refer to Figure 3As shown in a schematic diagram of a synchronous playing device of an audio, the device comprises: being applied to an audio playing system, the audio playing system at least comprising: at least two first audio playing devices, the at least two first audio playing devices comprising: a master device and at least one slave device, the device comprising: a starting playing module 31, configured to send, by the master device, an audio playing instruction to the at least one slave device, the at least one slave device responding to the audio playing instruction, the master device and the at least one slave device starting to play a target audio object at a target starting time; wherein the audio playing instruction is used to indicate the target audio object and the target starting time; a deviation calculation module 32, configured to calculate, by each first audio playing device, a deviation between a local clock and a master clock in a playing process, to obtain a real-time clock drift amount corresponding to each first audio playing device; a first judgment module 33, configured to, in response to the corresponding real-time clock drift amount satisfying a preset first resampling condition, calculate, by the first audio playing device, a first sampling rate corresponding to the first audio playing device based on a calibrated clock error corresponding to the first audio playing device and the real-time clock drift amount; a second judgment module 34, configured to, in response to a corresponding real-time chip temperature satisfying a preset second resampling condition, calculate, by the first audio playing device, a second sampling rate corresponding to the first audio playing device according to the first sampling rate and the real-time chip temperature corresponding to the first audio playing device; and a resampling playing module 35, configured to perform, by the first audio playing device, real-time resampling playing on the target audio object according to the corresponding first sampling rate or the second sampling rate.

[0097] The synchronous playing device of the audio can reduce resources required for synchronization, and can realize real-time correction of playing speed without introducing distortion, by compensating clock error in a synchronous playing process through a resampling rate according to clock error, clock drift amount and chip temperature of each slave device after the master device controls the slave device to start synchronous playing.

[0098] Optionally, the starting playing module 31 comprises: a time determination unit, configured to determine, by the master device, the target starting time according to a current time in response to a synchronous playing instruction; an instruction sending unit, configured to send, by the master device, the audio playing instruction to the at least one slave device based on the target starting time; a first playing unit, configured to play, by the at least one slave device, the target audio object at the target starting time or at the current time in response to the audio playing instruction; and a second playing unit, configured to play, by the master device, the target audio object at the target starting time.

[0099] Optionally, the time point determination unit is specifically configured to: in response to the synchronization playing instruction, the master device acquires a current network transmission delay duration and an expected preparation duration of each slave device; and the current time point is superimposed with a maximum value among the current network transmission delay duration and all expected preparation durations to obtain the target starting time point.

[0100] Optionally, the first playing unit is specifically configured to: in response to the audio playing instruction, each slave device judges whether the pre-synchronized local clock is earlier than the target starting time point; the pre-synchronized local clock is used to indicate a current time point of the corresponding slave device; if the pre-synchronized local clock is earlier than the target starting time point, the corresponding slave device starts playing the target audio object at the target starting time point; and if the pre-synchronized local clock is not earlier than the target starting time point, the corresponding slave device starts playing the target audio object at the current time point.

[0101] Optionally, the audio playing instruction is further used to indicate: an audio transmission address of the target audio object; and the starting playing module 31 is further configured to: the master device and the at least one slave device acquire the target audio object from the audio transmission address of the target audio object and store the target audio object in a local cache; and the master device and the at least one slave device read the target audio object from the local cache and start playing the target audio object in the local cache at the target starting time point.

[0102] Optionally, the first judging module 33 includes: a coefficient calculation unit, configured to, in response to the corresponding real-time clock drift being greater than a preset drift threshold, calculate a correction coefficient corresponding to the first audio playing device according to the calibration clock error corresponding to the first audio playing device and the real-time clock drift; and a sampling rate calculation unit, configured to calculate a first sampling rate corresponding to the first audio playing device according to the original sampling rate corresponding to the first audio playing device and the correction coefficient.

[0103] Optionally, the coefficient calculation unit is specifically configured to: in response to the corresponding real-time clock drift being greater than a preset drift threshold, superimpose the calibration clock error corresponding to the first audio playing device and the real-time clock drift to obtain a first clock deviation amount corresponding to the first audio playing device; convert the clock deviation amount corresponding to the first audio playing device into a parts per million (ppm) value to obtain a second clock deviation amount corresponding to the first audio playing device; and add a preset value to the second clock deviation amount corresponding to the first audio playing device to obtain the correction coefficient corresponding to the first audio playing device.

[0104] Optionally, the sampling rate calculation unit is specifically configured to: calculate a product between an original sampling rate corresponding to the first audio playback device and the correction coefficient, to obtain the first sampling rate corresponding to the first audio playback device.

[0105] Optionally, the second determination module 34 includes: a determination unit, configured to: in response to a change value of the real-time chip temperature corresponding to the first audio playback device exceeding a preset change threshold within a preset time length, determine a clock error parameter offset amount according to the real-time chip temperature; a conversion unit, configured to: convert the clock error parameter offset amount into a target measurement unit to obtain a third clock deviation amount; wherein the target measurement unit is the same as a measurement unit of the calibration clock error and the real-time clock drift amount; and a superposition unit, configured to: superimpose the first sampling rate and the third clock deviation amount to obtain a second sampling rate corresponding to the first audio playback device.

[0106] Optionally, the determination unit is specifically configured to: in response to a change value of the real-time chip temperature corresponding to the first audio playback device exceeding a preset change threshold within a preset time length, search for a clock error parameter offset amount corresponding to the real-time chip temperature from a preset temperature offset amount mapping table.

[0107] Optionally, the resampling playback module 35 is specifically configured to: if the real-time chip temperature satisfies a preset second resampling condition, perform real-time resampling on the target audio object by using a second sampling rate, and play the resampled sampling points; and if the real-time chip temperature does not satisfy the preset second resampling condition, perform real-time resampling on the target audio object by using a first sampling rate, and play the resampled sampling points.

[0108] Optionally, the apparatus further includes: a recording module, configured to record a playback time length required by each first audio playback device to play a preset audio object, and obtain a standard time length corresponding to the preset audio object; and a calibration module, configured to calculate a difference between the standard time length and the playback time length to obtain a calibration clock error corresponding to each first audio playback device.

[0109] The embodiment also provides an electronic device including a processor and a memory. The memory stores machine executable instructions capable of being executed by the processor. The processor executes the machine executable instructions to implement the above-described audio synchronous playback method. The electronic device can be a server or a terminal device.

[0110] Referring to Figure 4 As shown in the figure, the electronic device includes a processor 400 and a memory 401. The memory 401 stores machine executable instructions capable of being executed by the processor 400. The processor 400 executes the machine executable instructions to implement the above-described audio synchronous playback method.

[0111] Further, Figure 4 The electronic device shown also includes a bus 402 and a communication interface 403, the processor 400, the communication interface 403, and the memory 401 being connected through the bus 402.

[0112] The memory 401 can include a high-speed random access memory (RAM) and can also include a non-volatile memory such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through the at least one communication interface 403 (which can be wired or wireless) and can use the Internet, a wide area network, a local area network, a metropolitan area network, etc. The bus 402 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the figure to represent the bus, but this does not mean that there is only one bus or only one type of bus.

[0113] The processor 400 can be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the above method can be completed by integrated logic circuits of hardware in the processor 400 or instructions in the form of software. The processor 400 described above can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. Each method, step and logic block disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present disclosure can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, or other mature storage media in the art. The storage medium is located in the memory 401, and the processor 400 reads the information in the memory 401 and combines the hardware to complete the steps of the method of the above embodiments.

[0114] The embodiment also provides a computer readable storage medium, which stores computer executable instructions. When the computer executable instructions are invoked and executed by a processor, the computer executable instructions cause the processor to implement the method for synchronously playing audio.

[0115] The method, the device, the electronic device and the computer program product of the storage medium provided by the embodiment of the present disclosure include a computer readable storage medium storing program codes. The instructions included in the program codes can be used to execute the method described in the foregoing method embodiments. For specific implementation, refer to the method embodiments, which will not be described here.

[0116] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the foregoing method embodiments, which will not be described here.

[0117] In addition, in the description of the embodiment of the present disclosure, unless explicitly defined and limited, the terms "mounting", "connection" and "connection" should be understood in a broad sense, for example, it can be fixed connection, or detachable connection, or integral connection; it can be mechanical connection, or electrical connection; it can be directly connected, or indirectly connected through an intermediate medium, or the communication between two elements. For those skilled in the art, the specific meaning of the above terms in the present disclosure can be understood according to the specific circumstances.

[0118] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present disclosure or the part of the present disclosure that essentially contributes to the prior art or the part of the technical solutions can be embodied in the form of software products. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in various embodiments of the present disclosure. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and various program code storage media.

[0119] In the description of the present disclosure, it should be explained that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer" and the like indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the devices or elements referred to must have a particular orientation, be constructed and operated in a particular orientation, and therefore cannot be understood as a limitation on the present disclosure. In addition, the terms "first", "second", "third" are only for the purpose of description, and cannot be understood as indicating or implying relative importance.

[0120] Finally, it should be noted that the above embodiments are only specific embodiments of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, and are not limiting, and the protection scope of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can make modifications or easily think of changes to the technical solutions described in the foregoing embodiments within the technical range disclosed by the present disclosure, or make equivalent replacements to some of the technical features; and these modifications, changes or replacements do not cause the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.

Claims

1. A method for synchronized audio playback, characterized in that, The method is applied to an audio playback system, the audio playback system comprising at least two first audio playback devices, the at least two first audio playback devices comprising a master device and at least one slave device, the method comprising: The master device sends an audio playback command to the at least one slave device, and the at least one slave device responds to the audio playback command. The master device and the at least one slave device start playing the target audio object at the target start time. The audio playback command is used to indicate the target audio object and the target start time. During playback, each first audio playback device calculates the deviation between its local clock and the master clock in real time to obtain the real-time clock drift amount corresponding to each first audio playback device; The first audio playback device responds to the corresponding real-time clock drift amount satisfying the preset first resampling condition, and calculates the first sampling rate corresponding to the first audio playback device based on the calibration clock error and real-time clock drift amount corresponding to the first audio playback device. The first audio playback device responds to the corresponding real-time chip temperature meeting the preset second sampling condition, and calculates the second sampling rate corresponding to the first audio playback device based on the first sampling rate and the real-time chip temperature corresponding to the first audio playback device. The first audio playback device performs real-time resampling playback on the target audio object according to the corresponding first sampling rate or second sampling rate; The first audio playback device, in response to the corresponding real-time chip temperature satisfying a preset second resampling condition, calculates the second sampling rate corresponding to the first audio playback device based on the first sampling rate and the real-time chip temperature corresponding to the first audio playback device, including: If the first audio playback device responds to the change value of the corresponding real-time chip temperature within a preset time period exceeding a preset change threshold, it determines the clock error parameter offset based on the real-time chip temperature. The clock error parameter offset is converted into a target unit of measurement to obtain a third clock deviation; wherein the target unit of measurement is the same as the unit of measurement for the calibrated clock error and the real-time clock drift. The first sampling rate is superimposed with the third clock offset to obtain the second sampling rate corresponding to the first audio playback device.

2. The method according to claim 1, characterized in that, The master device sends an audio playback command to the at least one slave device, and the at least one slave device responds to the audio playback command. The master device and the at least one slave device begin playing the target audio object at the target start time, including: The master device responds to the synchronous playback command and determines the target start time based on the current time; The master device sends an audio playback command to the at least one slave device based on the target start time; The at least one slave device responds to the audio playback command by starting to play the target audio object at the target start time or starting to play the target audio object at the current time; The main device begins playing the target audio object at the target start time.

3. The method according to claim 2, characterized in that, The master device responds to the synchronous playback command and determines the target start time based on the current time, including: The master device responds to the synchronous playback command and obtains the current network transmission delay and the expected preparation time of each slave device; The target start time is obtained by superimposing the current time with the maximum value among the current network transmission delay and all expected preparation times.

4. The method according to claim 2, characterized in that, The at least one slave device responds to the audio playback command by starting to play the target audio object at the target start time or starting to play the target audio object at the current time, including: Each slave device responds to the audio playback command by determining whether its pre-synchronized local clock is earlier than the target start time; wherein, the pre-synchronized local clock is used to indicate the current time of the corresponding slave device; If the pre-synchronized local clock is earlier than the target start time, the corresponding slave device will start playing the target audio object at the target start time; If the pre-synchronized local clock is not earlier than the target start time, the corresponding slave device will start playing the target audio object at the current time.

5. The method according to claim 1, characterized in that, The audio playback instruction is also used to indicate: the audio transmission address of the target audio object; The master device and the at least one slave device begin playing the target audio object at the target start time, including: The master device and the at least one slave device obtain the target audio object from the audio transmission address of the target audio object and store it in a local cache; The master device and the at least one slave device read the target audio object from the local cache and start playing the target audio object in the local cache at the target start time.

6. The method according to claim 1, characterized in that, The first audio playback device, in response to a preset first resampling condition satisfying a corresponding real-time clock drift, calculates a first sampling rate corresponding to the first audio playback device based on the calibration clock error and real-time clock drift, including: When the real-time clock drift exceeds a preset drift threshold, the first audio playback device calculates a correction coefficient corresponding to the first audio playback device based on the calibration clock error and the real-time clock drift. The first sampling rate corresponding to the first audio playback device is calculated based on the original sampling rate and the correction coefficient.

7. The method according to claim 6, characterized in that, When the real-time clock drift exceeds a preset drift threshold, the first audio playback device calculates a correction coefficient based on its calibration clock error and the real-time clock drift, including: In response to the real-time clock drift being greater than a preset drift threshold, the first audio playback device adds the calibration clock error and the real-time clock drift corresponding to the first audio playback device to obtain the first clock deviation corresponding to the first audio playback device. Convert the clock offset corresponding to the first audio playback device into parts per million to obtain the second clock offset corresponding to the first audio playback device. The preset value is added to the second clock deviation corresponding to the first audio playback device to obtain the correction coefficient corresponding to the first audio playback device.

8. The method according to claim 6, characterized in that, Calculating the first sampling rate corresponding to the first audio playback device based on the original sampling rate and the correction coefficient includes: The first sampling rate corresponding to the first audio playback device is obtained by multiplying the original sampling rate corresponding to the first audio playback device with the correction coefficient.

9. The method according to claim 1, characterized in that, If the first audio playback device responds to a change in the corresponding real-time chip temperature exceeding a preset change threshold within a preset time period, it determines a clock error parameter offset based on the real-time chip temperature, including: The first audio playback device responds to the fact that the change value of the corresponding real-time chip temperature within a preset time period exceeds a preset change threshold, and looks up the clock error parameter offset corresponding to the real-time chip temperature from a preset temperature offset mapping table.

10. The method according to claim 1, characterized in that, The first audio playback device performs real-time resampling playback of the target audio object according to a corresponding first sampling rate or second sampling rate, including: If the real-time chip temperature meets the preset second resampling condition, the target audio object is resampled in real time using the second sampling rate, and the resampled sampling points are played. If the real-time chip temperature does not meet the preset second resampling condition, the target audio object is resampled in real time using the first sampling rate, and the resampled sampling points are played.

11. The method according to claim 1, characterized in that, Before the master device sends an audio playback command to the at least one slave device, the method further includes: Record the playback duration required for each first audio playback device to play a preset audio object, and obtain the standard duration corresponding to the preset audio object; The difference between the standard duration and the playback duration is calculated to obtain the calibration clock error corresponding to each first audio playback device.

12. An audio synchronization playback device, characterized in that, Applied to an audio playback system, the audio playback system includes at least two first audio playback devices, each of the at least two first audio playback devices including a master device and at least one slave device, the device comprising: A playback start module is used for the master device to send an audio playback command to the at least one slave device, the at least one slave device to respond to the audio playback command, and the master device and the at least one slave device to start playing the target audio object at a target start time; wherein, the audio playback command is used to indicate the target audio object and the target start time; The deviation calculation module is used to calculate the deviation between the local clock and the master clock in real time for each first audio playback device during playback, so as to obtain the real-time clock drift amount corresponding to each first audio playback device. The first judgment module is used to calculate the first sampling rate corresponding to the first audio playback device based on the calibration clock error and real-time clock drift of the first audio playback device in response to the first audio playback device meeting the preset first resampling condition. The second judgment module is used to calculate the second sampling rate corresponding to the first audio playback device based on the first sampling rate and the real-time chip temperature corresponding to the first audio playback device in response to the first audio playback device meeting the preset second resampling condition. The resampling playback module is used by the first audio playback device to perform real-time resampling playback of the target audio object according to the corresponding first sampling rate or second sampling rate. The second judgment module includes: The determining unit is configured to determine the clock error parameter offset based on the real-time chip temperature when the first audio playback device responds to the change value of the corresponding real-time chip temperature within a preset time period exceeding a preset change threshold. A conversion unit is used to convert the clock error parameter offset into a target unit of measurement to obtain a third clock deviation; wherein the target unit of measurement is the same as the unit of measurement for the calibrated clock error and the real-time clock drift. The superposition unit is used to superimpose the first sampling rate and the third clock deviation to obtain the second sampling rate corresponding to the first audio playback device.

13. An electronic device, characterized in that, The device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, the processor executing the machine-executable instructions to implement the audio synchronous playback method according to any one of claims 1-11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the audio synchronization playback method according to any one of claims 1-11.

Citation Information

Patent Citations

  • Method for synchronously playing audios of wireless equipment

    CN110636349A

  • Audio output delay measurement method, device, system and equipment and storage medium

    CN117915255A