Audio synchronous playing method and device, electronic equipment and storage medium
By calculating the real-time clock drift and chip temperature between the master device and the slave device in the audio playback system and calculating the sampling rate for resampling playback, the problems of resource waste and poor synchronization in the existing technology are solved, and efficient audio synchronization playback is achieved. and playback speed correction.
Patent Information
- Application Number
- CN202410580489.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-11
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-05-11
AI Technical Summary
Existing audio synchronization playback technology has the problems of resource waste and poor synchronization. Especially in the process of clock synchronization between multiple audio devices, the actual playback speed factors of different devices are not effectively considered, and desynchronization problems are prone to occur.
By introducing a master device and a slave device into the audio playback system, the master device sends audio playback instructions to the slave device, calculates the sampling rate based on the real-time clock drift and chip temperature, and performs real-time resampling playback to compensate for clock errors and temperature effects. Achieve synchronous playback.
It reduces the resources required for synchronization, improves the synchronization of audio playback, and realizes real-time correction of playback speed without introducing distortion, improving the overall synchronization and sound quality of audio playback.
Smart Images

Figure CN118535120A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of audio processing, and in particular to a method, device, electronic device and storage medium for synchronously playing audio. Background Art
[0002] In the field of audio technology, it involves the synchronous playback technology of multiple audio devices. The higher the degree of synchronization of the system, the better the experience.
[0003] In the existing audio synchronization playback technology, the audio devices that play synchronously need to synchronize their clocks continuously and frequently to ensure the synchronization of audio playback. This method requires a large amount of network bandwidth and device processing resources, and does not consider the factors affecting the actual playback speed of different audio playback devices. The consideration factors are too single and it is easy to cause the problem of asynchrony. It can be seen that the existing technology has technical problems of resource waste and poor synchronization when playing audio synchronously. Summary of the invention
[0004] In view of this, an object of the present disclosure is to provide a method, device, electronic device and storage medium for synchronous audio playback, which are used to reduce resource waste and improve synchronization during synchronous audio playback.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for synchronous audio playback, which is applied to an audio playback system, wherein the audio playback system includes at least: at least two first audio playback devices, and the at least two first audio playback devices include: a master device and at least one slave device, and the method includes: the master device sends an audio playback instruction to the at least one slave device, and the at least one slave device responds to the audio playback instruction, and the master device and the at least one slave device start playing a target audio object at a target start time; wherein the audio playback instruction is used to indicate a target audio object and a target start time; during the playback process, each first audio playback device calculates in real time the deviation between a local clock and a master clock , obtaining the real-time clock drift corresponding to each first audio playback device; in response to the corresponding real-time clock drift satisfying a preset first resampling condition, the first audio playback device calculates a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift corresponding to the first audio playback device; in response to the corresponding real-time chip temperature satisfying a 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; the first audio playback device resamples and plays the target audio object in real time according to the corresponding first sampling rate or the second sampling rate.
[0006] Optionally, the master device sends an audio playback instruction to the at least one slave device, the at least one slave device responds to the audio playback instruction, and the master device and the at least one slave device start playing the target audio object at a target start time, including: the master device responds to the synchronous playback instruction, and determines the target start time according to the current time; the master device sends the audio playback instruction to the at least one slave device based on the target start time; the at least one slave device responds to the audio playback instruction, and starts playing the target audio object at the target start time, or starts playing the target audio object at the current time; the master device starts playing the target audio object at the target start time.
[0007] Optionally, the master device responds to the synchronous playback instruction and determines the target start time based on the current time, including: the master device responds to the synchronous playback instruction to obtain the current network transmission delay time and the expected preparation time of each slave device; the current time is superimposed with the maximum value of the current network transmission delay time and all expected preparation times to obtain the target start time.
[0008] Optionally, at least one slave device responds to the audio playback instruction, starts playing the target audio object at the target start time, or starts playing the target audio object at the current time, including: each slave device responds to the audio playback instruction, and determines whether the 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 starts 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 starts playing the target audio object at the current time.
[0009] Optionally, 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 start 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.
[0010] Optionally, in response to the corresponding real-time clock drift amount satisfying a preset first resampling condition, the first audio playback device calculates a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift amount corresponding to the first audio playback device, including: in response to the corresponding real-time clock drift amount being greater than a preset drift threshold, the first audio playback device calculates a correction coefficient corresponding to the first audio playback device according to the calibrated clock error and the real-time clock drift amount corresponding to 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, in response to the corresponding real-time clock drift being greater than a preset drift threshold, the first audio playback device calculates a correction coefficient corresponding to the first audio playback device according to a calibrated clock error and the real-time clock drift corresponding to the first audio playback device, including: in response to the corresponding real-time clock drift being greater than a preset drift threshold, the first audio playback device superimposes the calibrated clock error and the real-time clock drift corresponding to 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 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, calculating 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 includes: calculating the product between the 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.
[0013] Optionally, in response to the corresponding real-time chip temperature satisfying a preset second resampling condition, 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, including: in response to the corresponding real-time chip temperature of the first audio playback device, a change value within a preset time period exceeds a preset change threshold, then, according to the real-time chip temperature, determining a clock error parameter offset; converting the clock error parameter offset 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 calibrated clock error and the real-time clock drift; and superimposing the first adoption rate with the third clock deviation to obtain the second sampling rate corresponding to the first audio playback device.
[0014] Optionally, in response to the corresponding real-time chip temperature changing by more than a preset change threshold within a preset time period, the first audio playback device determines a clock error parameter offset based on the real-time chip temperature, including: in response to the corresponding real-time chip temperature changing by more than a preset change threshold within a preset time period, the first audio playback device searches a preset temperature offset mapping table for the clock error parameter offset corresponding to the real-time chip temperature.
[0015] Optionally, the first audio playback device resamples and plays the target audio object in real time according to the corresponding first sampling rate or second sampling rate, including: if the real-time chip temperature meets the preset second resampling condition, resampling the target audio object in real time at the second sampling rate, and playing the sampling points obtained by resampling; if the real-time chip temperature does not meet the preset second resampling condition, resampling the target audio object in real time at the first sampling rate, and playing the sampling points obtained by resampling.
[0016] Optionally, before the master device sends an audio playback instruction to the at least one slave device, the method further includes: recording the playback time required for each first audio playback device to play a preset audio object, and obtaining a standard time corresponding to the preset audio object; calculating the difference between the standard time and the playback time, and obtaining a calibrated clock error corresponding to each first audio playback device.
[0017] In a second aspect, an embodiment of the present disclosure provides an apparatus for synchronously playing audio, the apparatus comprising: an apparatus for being applied to an audio playing system, the audio playing system comprising at least: 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 apparatus comprising: a start playing module, for the master device to send 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 a target audio object and a target starting time; a deviation calculation module, for during the playing process, each first audio playing device calculates in real time the deviation between a local clock and a master clock, to obtain to the real-time clock drift amount corresponding to each first audio playback device; a first judgment module, used for the first audio playback device to respond to the corresponding real-time clock drift amount satisfying the preset first resampling condition, and calculate the first sampling rate corresponding to the first audio playback device based on the calibrated clock error and the real-time clock drift amount corresponding to the first audio playback device; a second judgment module, used for the first audio playback device to respond to the corresponding real-time chip temperature satisfying the preset second resampling condition, and calculate 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; a resampling and playing module, used for the first audio playback device to perform real-time resampling and playing of the target audio object according to the corresponding first sampling rate or second sampling rate.
[0018] In a third aspect, an embodiment of the present disclosure provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned method of synchronous playback of audio.
[0019] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned method for synchronous playback of audio.
[0020] The embodiments of the present disclosure bring the following beneficial effects:
[0021] The above-mentioned audio synchronous playback method, device, electronic device and storage medium, after the master device controls the slave device to start synchronous playback, each slave device compensates for the clock error in the synchronous playback process by resampling the rate according to its own clock error, clock drift and chip temperature, which can reduce the resources required for synchronization and realize 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.
[0022] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0023] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 A flowchart of an embodiment of a method for synchronously playing audio in an embodiment of the present disclosure;
[0026] Figure 2 It is a flow chart of another embodiment of the method for synchronously playing audio in the embodiment of the present disclosure;
[0027] Figure 3 A schematic diagram of a synchronous audio playback device provided by an embodiment of the present disclosure;
[0028] Figure 4 A schematic diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0030] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] It should be noted that an embodiment of the method for synchronous audio playback in the embodiments of the present disclosure is applied to an audio playback system, and the audio playback system includes at least: at least two first audio playback devices, and the at least two first audio playback devices include: a master device and at least one slave device; wherein any first audio playback device can be used as a master device, and all first audio playback devices except the master device are slave devices. The master device can be a pre-designated first audio playback device that no longer changes, or it can be dynamically determined before each execution of the method for synchronous audio playback in the embodiments of the present disclosure, for example, the master device is dynamically selected through a negotiation algorithm, such as selecting the first audio playback device with the smallest or largest IP address as the master device, which is not specifically limited here.
[0032] In the disclosed embodiment, the audio playback system may also include an audio playback device other than the first audio playback device and other devices other than the audio playback device, such as a control device, a display device, etc., which are not specifically limited here. The at least two first audio playback devices in the audio playback system refer to audio devices that need to be played synchronously, and specifically, any audio playback device in the audio playback system can be designated as the first audio playback device through a synchronous playback instruction.
[0033] For ease of understanding, the specific process of the embodiment of the present disclosure is described below. Figure 1 , this embodiment includes:
[0034] Step S10: The master device sends an audio play instruction to at least one slave device, and at least one slave device responds to the audio play instruction. The master device and at least one slave device start playing the target audio object at the target start time; wherein the audio play instruction is used to indicate the target audio object and the target start time;
[0035] In this embodiment, the master device is responsible for sending audio playback instructions to the slave device, the slave device receives and executes the instructions sent by the master device, and the master device and the slave device simultaneously 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 any other time representation format, which is not specifically limited here. In order to improve the synchronization of audio playback, all time parameters in the disclosed embodiment are accurate to microseconds, including but not limited to the target start time, local clock and master clock, etc., so that the accuracy of audio synchronization playback reaches the synchronization level of microseconds. In one embodiment, the master device and the slave device each determine whether the target start time has been reached based on the local clock stored in themselves. If the local clock reaches the target start time, the target audio object starts to be played.
[0036] In one embodiment, this step can be triggered by a synchronous playback instruction. A synchronous playback instruction can be generated for any device or equipment in the audio playback system, which is used to trigger the master device to send an audio playback instruction to at least one slave device. For example, if any audio playback device or control device in the audio playback system receives a voice message "Play music A throughout the house", then the audio playback device or control device can generate a synchronous playback instruction and send the generated synchronous playback instruction to the master device, which then sends the audio playback instruction to the slave device. Alternatively, the audio playback device that receives the voice can act as the master device and immediately send an audio playback instruction to the slave device.
[0037] In one implementation, 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 present disclosure can synchronously play a specified audio file or a specified list of audio files, and the flexibility of synchronous playback is high.
[0038] In one embodiment, the audio playback instruction is also used to indicate the format parameters of the target audio object, such as the number of channels, bit depth, original sampling rate, duration, etc., and is used to indicate how the first audio playback device plays the target audio object, which is not specifically limited here. In one embodiment, the audio playback instruction is also used to indicate: the audio transmission address of the target audio object; the transmission of the playback control instruction and the audio data is decoupled from each other, which can effectively reduce the network load.
[0039] In one embodiment, the master device and at least one slave device start playing the target audio object at the target start time, including: the master device and 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 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. In this embodiment, when playing the target audio object, the first audio playback device first obtains the target audio object from the audio transmission address through the local area network, stores it in the local cache, and directly reads the target audio object in the local cache during playback, and starts playing the target audio object in the local cache at the target start time, so that the synchronization of the audio synchronous playback is improved.
[0040] In one embodiment, before step S10, it also includes: recording the playback time required for each first audio playback device to play the preset audio object, obtaining the standard time corresponding to the preset audio object; calculating the difference between the standard time and the playback time, and obtaining the calibrated clock error corresponding to each first audio playback device. In this embodiment, each first audio playback device is allowed to play a reference audio (i.e., a preset audio object) with a known duration of L0, such as a 500Hz sine wave, and the actual duration L1 of each first audio playback device playing the reference audio is recorded, and the calibrated clock error bias of each first audio playback device is calculated. The calculated bias can be stored in the non-volatile memory of the device, and the bias calculation formula is:
[0041] bias=(L1-L0) / L0*1000000
[0042] Step S20: During the playback process, each first audio playback device calculates the deviation between the local clock and the master clock in real time to obtain the real-time clock drift corresponding to each first audio playback device;
[0043] It should be noted that step S20 to step S50 are steps that are continuously executed in a loop during the playback process. In this step, each first audio playback device calculates the deviation between the local clock and the master clock according to a preset calculation frequency, thereby obtaining the real-time clock drift corresponding to each first audio playback device, wherein the master clock is the local clock of the master clock device, and the master clock device can be any first audio playback device among at least two first audio playback devices, which can be the same as the master device or one of the slave devices. The master clock device can also be a device / equipment other than the first audio playback device in the audio playback system, which is not specifically limited here. For the first audio playback device that is the master clock device, since its local clock is the master clock, the real-time clock drift corresponding to the first audio playback device that is the master clock device is 0.
[0044] In one implementation, the master clock may 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, thereby obtaining the real-time clock drift corresponding to each first audio playback device. For example, the first audio playback device may request the master clock from the master clock device every second, and the master clock device responds to the request and sends the local clock to the first audio playback device. The first audio playback device calculates the deviation between the received local clock of the master clock device and its own local clock, thereby obtaining the real-time clock drift corresponding to the first audio playback device.
[0045] In one implementation, the master clock may also be actively sent by the master clock device. Specifically, this step includes: during the playback process, each first audio playback device obtains 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, thereby obtaining the real-time clock drift corresponding to each first audio playback device. In this implementation, the PTP protocol can control the clock deviation between devices to the sub-microsecond level through hardware timestamps and multiple message exchanges, laying the foundation for the synchronous playback of unified audio.
[0046] It is understandable that clock drift refers to several related phenomena in which a clock does not run at exactly the same rate as a reference clock, that is, after a period of time, a clock will "deviate" or gradually become out of sync with another clock, and all clocks will drift, and unless resynchronized, will eventually lead to divergence. In this embodiment, the master clock is the reference clock, and the real-time clock drift amount 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 in real time. 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. The absence of the need to maintain the absolute accuracy of the master clock can save computing resources for audio synchronous playback to a certain extent, thereby reducing resource waste during audio synchronous playback.
[0047] Step S30: In response to the corresponding real-time clock drift satisfying the preset first resampling condition, the first audio playback device calculates a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift corresponding to the first audio playback device.
[0048] In this embodiment, during the playback process, each first audio playback device detects whether the real-time clock drift meets the preset first resampling condition according to a preset detection frequency. When the real-time clock drift corresponding to the first audio playback device meets the preset first resampling condition, the first audio playback device calculates the first sampling rate corresponding to the first audio playback device based on the calibrated clock error and the real-time clock drift corresponding to the first audio playback device. Among them, the calibrated clock error is a pre-calibrated attribute of the corresponding first audio playback device, which is used to represent the clock deviation generated by each preset clock cycle. The specific calibration method is not limited here. In one embodiment, the unit of the calibrated clock error is PPM (part per million), then each 1PPM represents: 1 clock deviation is generated for every 1 million clocks. The unit of the calibrated clock error can also be other units, such as seconds, milliseconds, microseconds, etc. PPM can more accurately record the clock deviation of the audio playback device.
[0049] In one implementation, the preset first resampling condition may be that the real-time clock drift corresponding to the first audio playback device exceeds a preset normal clock drift range. Then, when the first audio playback device detects that the corresponding real-time clock drift exceeds the preset normal clock drift range, the first sampling rate corresponding to the first audio playback device is calculated based on the calibrated clock error and the real-time clock drift corresponding to the first audio playback device. It should be noted that the preset first resampling condition may be any condition for determining whether the first audio playback device needs to be resampled based on the real-time clock drift, and is not specifically limited here.
[0050] In one embodiment, the first sampling rate can be calculated by superimposing the calibration clock error and the real-time clock drift corresponding to the first audio playback device to obtain the total clock deviation, then calculating the ratio between the total clock deviation and the preset unit deviation to obtain the sampling point deviation, and finally, superimposing the sampling point deviation with the original sampling rate to obtain the first sampling rate. For example, assuming that the calibration clock error and the real-time clock drift corresponding to the first audio playback device are 15PPM and 5PPM respectively, then the total clock deviation is 15+5=20, assuming that the preset unit deviation is 20, then the sampling point deviation is 20 / 20=1, assuming that the original sampling rate is 48000 sampling points, then the first sampling point is 48000+1=48001, and the specific details are not limited here. In this embodiment, the preset unit deviation can be used to easily calculate that the total clock deviation increases / decreases by a certain amount, and the corresponding sampling point also increases / decreases by a corresponding amount. The calculation method is simple and efficient, and the efficiency of audio synchronous playback can be improved.
[0051] Step S40: In response to the corresponding real-time chip temperature satisfying 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;
[0052] It should be noted that the real-time chip temperature refers to the real-time temperature of the chip required for audio playback in the audio playback device, such as a digital signal processing (DSP) chip, an audio codec chip, a clock and timing chip, a power amplifier chip, etc., which are not specifically limited here. In this embodiment, during the playback process, each first audio playback device detects the corresponding real-time chip temperature according to a preset detection frequency to meet the preset second resampling condition. When the real-time chip temperature corresponding to the first audio playback device meets the preset second resampling condition, the second sampling rate corresponding to the first audio playback device is calculated according to the first sampling rate and the real-time chip temperature corresponding to the first audio playback device.
[0053] It is understandable that the temperature of the chip has a certain influence on the audio playback speed. In one 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 can be obtained by querying a preset mapping table, which is not limited here.
[0054] In one implementation, the correlation model between chip temperature and resampling rate can be pre-established to obtain the correlation resampling rate corresponding to the real-time chip temperature, and then the correlation resampling rate is superimposed on the first sampling rate to obtain the second sampling rate corresponding to the first audio playback device. This implementation introduces a temperature compensation mechanism to further improve synchronization accuracy and stability.
[0055] Step S50: The first audio playback device resamples and plays the target audio object in real time according to the corresponding first sampling rate or second sampling rate.
[0056] It is understandable that, during the playback process, the first audio playback device can perform real-time resampling of the target audio object according to the corresponding first sampling rate or second sampling rate, and play the sampling points obtained by the resampling. 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 the duration of a preset detection frequency, the first audio playback device performs real-time resampling and playback of the target audio object according to the corresponding first sampling rate, otherwise, the first audio playback device performs real-time resampling and playback of 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 have a corresponding second sampling rate, it means that the corresponding real-time chip temperature of the first audio playback device during the synchronous playback of this audio does not meet the preset second resampling condition. If the storage time of the second sampling rate corresponding to the first audio playback device exceeds the time of a preset detection frequency, it means that the latest second sampling rate saved by the first audio playback device is expired data, has been used for resampling playback, and cannot be used as data for this resampling playback. By comprehensively considering the impact of factors such as calibration clock error, clock drift, and chip temperature on audio synchronous playback, higher long-term synchronization accuracy and sound quality can be obtained.
[0058] The audio synchronous playback method provided in the above-mentioned implementation mode is that after the master device controls the slave devices to start synchronous playback, each slave device compensates for the clock error in the synchronous playback process by resampling the rate according to its own clock error, clock drift and chip temperature, thereby reducing the resources required for synchronization and 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] See also Figure 2 Another embodiment of the method for synchronously playing audio in the embodiment of the present disclosure includes:
[0060] Step S201: The master device responds to the synchronous play instruction and determines the target start time according to the current time;
[0061] In this embodiment, after the master device receives the synchronous play instruction of the audio playback system, it responds to the synchronous play instruction and determines a unified play start time, i.e., the target start time, according to the current time, wherein the target start time is at least greater than the maximum value of the expected playable time corresponding to all slave devices, and the expected playable time represents the current time superimposed on the time required for the corresponding slave device to prepare for play, and the time required for play preparation includes the time required for receiving the audio play instruction and the time required for play preparation. For example, assuming that the current time is 1713516795000, the audio playback system includes 2 slave devices, the expected playable time corresponding to one slave device is 1713516805000, and the expected playable time corresponding to the other slave device is 1713516803000. Since 1713516805000 is the maximum value of the expected playable time corresponding to all slave devices, the target start time can be determined to be 1713516805000, and the specific time is not limited here. In one implementation, the time required for the slave device to prepare for playback may be a preset value, and the corresponding playback preparation time may be pre-set as a preset value according to hardware parameters of different slave devices, thereby improving the efficiency of synchronous playback.
[0062] In one embodiment, in order to more accurately predict the expected playable time of the slave device, step S201 includes: the master device responds to the synchronous play instruction, obtains the current network transmission delay time and the expected preparation time of each slave device; superimposes the current time with the maximum value of the current network transmission delay time and all expected preparation times to obtain the target start time. In this embodiment, after the master device responds to the synchronous play instruction, it predicts the current network transmission delay time according to the current network state, which is used to indicate the time required for the slave device to receive the audio play instruction, and then determines the maximum value of the expected preparation time of all slave devices, and superimposes the current network transmission delay time and the maximum value at the current time to obtain the target start time. It can be understood that the play preparation includes: applying for a play buffer and filling the received audio data into the play buffer, setting the play clock and waiting for the arrival of the target start time, configuring audio decoding and output channels, etc. The expected preparation time refers to the time required for the play preparation to be completed, which can be a preset value or determined according to the buffer size of the slave device and the current network state, which is not specifically limited here.
[0063] Step S202: The master device sends an audio play instruction to at least one slave device based on the target start time;
[0064] In this implementation, the master device encapsulates the target start time in the audio playback instruction and distributes it to each slave device through a reliable transmission protocol (such as TCP). Further, the audio playback instruction may also include the identifier of the target audio object, format parameters, and audio transmission address, etc., which are not specifically 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 playback time, then the target start time in the instruction is 1676234010000000, and the audio playback instruction sent at this time may include: target start time 1676234010000000, 2 audio channels, 16-bit depth, 48kHz sampling rate, 30 minutes of PCM data stream, data audio transmission address is http: / / 192.168.1.100 / audio / sample.pcm, which are not specifically limited here.
[0065] Step S203: at least one slave device responds to the audio play instruction and starts playing the target audio object at the target start 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 from the target start time or to play the target audio object immediately from the current time based on the pre-synchronized local clock. In one embodiment, the slave device corresponding to the maximum expected preparation time plays the target audio object immediately from the current time, and other slave devices play the target audio object from the target start time.
[0067] In one embodiment, step S203 includes: each slave device responds to the audio play instruction and determines whether the 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 starts 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 starts playing the target audio object at 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 it has not arrived, wait for the arrival of the target start time, and start playing the target audio object when the target start time arrives. If the target start time has arrived, start playing the target audio object immediately, that is, start playing the target audio object at the current time.
[0068] Step S204: The master device starts playing the target audio object at the target start time;
[0069] It is understandable that the master device only needs to wait for the target start time to arrive, and start playing the target audio object when the target start time arrives. In one embodiment, the master device can also perform playback preparation while waiting for the target start time to arrive, 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, thereby improving audio playback efficiency.
[0070] Step S205: During the playback process, each first audio playback device calculates the deviation between the local clock and the master clock in real time to obtain the real-time clock drift corresponding to each first audio playback device;
[0071] In this implementation, after playback starts, the master device and the slave device calculate the deviation between the local clock and the master clock according to a preset calculation frequency to obtain the real-time clock drift corresponding to each first audio playback 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 playback device.
[0072] Step S206: In response to the corresponding real-time clock drift satisfying the preset first resampling condition, the first audio playback device calculates a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift corresponding to the first audio playback device.
[0073] In one embodiment, step S206 includes: in response to the corresponding real-time clock drift being greater than a preset drift threshold, the first audio playback device calculates a correction coefficient corresponding to the first audio playback device according to a calibrated clock error and the real-time clock drift corresponding to the first audio playback device; and calculates a first sampling rate corresponding to the first audio playback device according to the original sampling rate and the correction coefficient corresponding to the target audio object.
[0074] In this implementation, the preset first resampling condition is that the real-time clock drift is greater than the preset drift threshold. During the playback process, each first audio playback device detects whether the corresponding real-time chip temperature is greater than the preset drift threshold according to a preset detection frequency. When it is detected that the corresponding real-time chip temperature is greater than the preset drift threshold, the correction coefficient corresponding to the first audio playback device is calculated according to the calibrated clock error and the real-time clock drift corresponding to the target audio object, and then the first sampling rate corresponding to the first audio playback device is calculated according to the original sampling rate and the correction coefficient corresponding to the target audio object, so that the original sampling rate is corrected by the correction coefficient to achieve the purpose of clock deviation compensation.
[0075] Further, in one embodiment, when calculating the correction coefficient corresponding to the first audio playback device according to the calibrated clock error and the real-time clock drift corresponding to the first audio playback device in response to the corresponding real-time clock drift being greater than the preset drift threshold, the first audio playback device superimposes the calibrated clock error and the real-time clock drift corresponding to the first audio playback device in response to the corresponding real-time clock drift being greater than the preset drift threshold 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 parts per million to obtain a second clock deviation corresponding to the first audio playback device; and adds the 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.
[0076] In this implementation, when the units of the calibration clock error and the real-time clock drift are both PPM, this implementation 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 calibrated 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 one implementation, when calculating the first sampling rate corresponding to the first audio playback device according to the original sampling rate and the correction coefficient corresponding to the first audio playback device, 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 implementation is expressed by the following formula:
[0080] SR1=SR0×R
[0081] SR1 represents a first sampling rate corresponding to the first audio playback device, SR0 represents an original sampling rate corresponding to the first audio playback device, and R represents a correction coefficient corresponding to the first audio playback device.
[0082] Step S207: In response to the corresponding real-time chip temperature satisfying 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.
[0083] In one embodiment, step S207 includes: in response to the corresponding real-time chip temperature of the first audio playback device changing by more than a preset change threshold within a preset time period, 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 calibrated clock error and the real-time clock drift; and the first sampling rate is superimposed on the third clock deviation to obtain a 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. During the playback process, each first audio playback device detects the change value of the corresponding real-time chip temperature within a preset time length according to a preset detection frequency and exceeds the preset change threshold. When it is detected that the change value of the corresponding real-time chip temperature within the preset time length exceeds the 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 calibrated clock error and the real-time clock drift, wherein the target measurement unit is PPM, to obtain the third clock deviation, and finally the first adoption rate is superimposed with the third clock deviation to obtain the second sampling rate corresponding to the first audio playback device.
[0085] In one embodiment, the first audio playback device determines the clock error parameter offset according to the real-time chip temperature in response to the corresponding real-time chip temperature changing value exceeding the preset change threshold within the preset time length, including: the first audio playback device searches for the clock error parameter offset corresponding to the real-time chip temperature from a preset temperature offset mapping table in response to the corresponding real-time chip temperature changing value exceeding the preset change threshold within the preset time length. In this embodiment, the preset temperature offset mapping table records the clock error parameter offset TPPM corresponding to different chip temperatures. For example, when the chip temperature rises by 10°C above the base temperature, the corresponding TPPM is -8PPM. Then, if the real-time chip temperature corresponding to the first audio playback device rises by more than 10°C within the preset time length, the TPPM corresponding to the real-time chip temperature at this time is -8PPM. The specific details are not limited here.
[0086] In one embodiment, when calculating the second sampling rate, the influence of the chip operating frequency on the clock deviation can also be introduced. Specifically, this step includes: the first audio playback device responds to the corresponding real-time chip temperature and / or real-time chip operating frequency satisfying a preset second resampling condition, and calculates the second sampling rate corresponding to the first audio playback device according to the first sampling rate and the real-time chip temperature and real-time chip operating frequency corresponding to the first audio playback device.
[0087] Further, when the first audio playback device responds to the corresponding real-time chip temperature and / or real-time chip operating frequency satisfying the preset second resampling condition, the first audio playback device performs sampling rate calculation on the first sampling rate and the real-time chip temperature and real-time chip operating frequency corresponding to the first audio playback device through a preset sampling rate calculation formula to obtain the second sampling rate corresponding to the first audio playback device. The preset sampling rate calculation formula is:
[0088] SR2=SR1×[1+α×(T-T0) 2 +β×(f-f0) γ +δ×TPPM / 1000000]
[0089] Among them, 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 operating frequency, f0 represents the preset chip operating frequency used as a reference, TPPM represents the clock error parameter offset, and α, β, γ, and δ are preset correction coefficients obtained by fitting 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 operating frequency on clock deviation. At the same time, 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 power function (f-f0) γ It can more accurately describe the nonlinear relationship between chip temperature and chip frequency and clock deviation, and the preset correction coefficient can flexibly adjust the formula according to the different working environments of different types of chips and audio devices to achieve the best compensation effect, making the audio synchronous playback more synchronized.
[0091] For ease of understanding, the meaning of each physical parameter in the preset sampling rate calculation formula is explained below. In this implementation, T0 represents the nominal operating temperature of the chip, which is generally provided by the chip manufacturer. The T0 of the audio processing chip is usually taken as 25°C; f0 represents the nominal operating frequency of the chip, which is determined by the chip clock system, such as the common 48kHz, 96kHz, etc.; α reflects the magnitude of the impact of the chip temperature change on the quadratic term of the clock deviation, β reflects the magnitude of the impact of the chip frequency change on the power function of the clock deviation, γ reflects the nonlinear degree of the impact of the chip frequency change on the clock deviation, and δ reflects the influence weight of the clock error parameter offset TPPM.
[0092] It should be noted that the above preset correction coefficients are obtained by fitting experimental data. Specifically, for α, different ambient temperatures are controlled in a constant temperature box, and the actual clock deviation of the chip at different temperatures is tested under the condition of the nominal operating frequency f0, and the value of α is determined by data fitting; for β and γ, different chip operating frequencies f are controlled under the condition of the nominal temperature T0, and the actual clock deviation of the chip at different frequencies is tested, and the values of β and γ are determined by data fitting; for δ, the clock error parameter offset TPPM data of different chips is integrated, and the value of δ is determined by data fitting. Through the above experimental design and data fitting process, it can be ensured that the algorithm formula can achieve the best clock compensation effect in practical applications, thereby effectively improving the accuracy and stability of audio synchronization playback.
[0093] Step S208: The first audio playback device resamples and plays the target audio object in real time according to the corresponding first sampling rate or second sampling rate.
[0094] In one embodiment, step S208 includes: if the real-time chip temperature meets the preset second resampling condition, the target audio object is resampled in real time at the second sampling rate, and the sampling points obtained by the resampling 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 at the first sampling rate, and the sampling points obtained by the resampling are played. In this embodiment, if the real-time chip temperature corresponding to the first audio playback device triggers the second resampling condition, the target audio object is resampled in real time according to the second sampling rate, and the sampling points obtained by the resampling are played; conversely, if the real-time chip temperature corresponding to the first audio playback device does not trigger the second resampling condition, the target audio object is resampled in real time according to the first sampling rate, and the sampling points obtained by the resampling are played.
[0095] The above-mentioned implementation method provides a method for synchronous audio playback. After the master device sets a unified playback start time, it controls the slave devices to start synchronous playback. Each slave device compensates for the clock error in the synchronous playback process by resampling the rate according to its own clock error, clock drift and chip temperature, thereby reducing the resources required for synchronization and achieving 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.
[0096] Corresponding to the above method embodiment, see Figure 3A schematic diagram of a synchronous audio playback device shown in the figure, the device includes: applied to an audio playback system, the audio playback system includes at least: at least two first audio playback devices, the at least two first audio playback devices include: a master device and at least one slave device, the device includes: a start playback module 31, used for the master device to send an audio playback instruction to the at least one slave device, the at least one slave device responds to the audio playback instruction, the master device and the at least one slave device start playing the target audio object at the target start time; wherein the audio playback instruction is used to indicate the target audio object and the target start time; a deviation calculation module 32, used for, during the playback process, each first audio playback device to calculate in real time the deviation between the local clock and the master clock, and obtain each first A real-time clock drift corresponding to an audio playback device; a first judgment module 33, used for the first audio playback device to respond to the corresponding real-time clock drift satisfying a preset first resampling condition, and calculate the first sampling rate corresponding to the first audio playback device based on the calibrated clock error and the real-time clock drift corresponding to the first audio playback device; a second judgment module 34, used for the first audio playback device to respond to the corresponding real-time chip temperature satisfying a preset second resampling condition, and calculate 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; a resampling playback module 35, used for the first audio playback device to perform real-time resampling and playback of the target audio object according to the corresponding first sampling rate or second sampling rate.
[0097] The above-mentioned audio synchronous playback device, after the master device controls the slave devices to start synchronous playback, each slave device compensates for the clock error in the synchronous playback process by resampling the rate according to its own clock error, clock drift and chip temperature, which can reduce the resources required for synchronization and realize 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.
[0098] Optionally, the above-mentioned start playback module 31 includes: a time determination unit, used for the master device to respond to the synchronous playback instruction and determine the target start time according to the current time; an instruction sending unit, used for the master device to send an audio playback instruction to the at least one slave device based on the target start time; a first playback unit, used for the at least one slave device to respond to the audio playback instruction and start playing the target audio object at the target start time, or start playing the target audio object at the current time; a second playback unit, used for the master device to start playing the target audio object at the target start time.
[0099] Optionally, the above-mentioned time determination unit is specifically used for: the master device responds to the synchronous playback instruction, obtains the current network transmission delay time and the expected preparation time of each slave device; superimposes the current time with the maximum value of the current network transmission delay time and all expected preparation times to obtain the target start time.
[0100] Optionally, the above-mentioned first playback unit is specifically used for: each slave device responds to the audio playback instruction to determine whether the 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 starts 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 starts playing the target audio object at the current time.
[0101] Optionally, the audio playback instruction is also used to indicate: the audio transmission address of the target audio object; the above-mentioned start playback module 31 is also used for: 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.
[0102] Optionally, the first judgment module 33 includes: a coefficient calculation unit, used for the first audio playback device to calculate a correction coefficient corresponding to the first audio playback device in response to the corresponding real-time clock drift being greater than a preset drift threshold, according to a calibrated clock error and real-time clock drift corresponding to the first audio playback device; and a sampling rate calculation unit, used for calculating a first sampling rate corresponding to the first audio playback device according to an original sampling rate corresponding to the first audio playback device and the correction coefficient.
[0103] Optionally, the coefficient calculation unit is specifically used for: in response to the corresponding real-time clock drift of the first audio playback device being greater than a preset drift threshold, superimposing the calibrated clock error and the real-time clock drift corresponding to the first audio playback device to obtain a first clock deviation corresponding to the first audio playback device; converting the clock deviation corresponding to the first audio playback device into parts per million to obtain a second clock deviation corresponding to the first audio playback device; adding a preset value to the second clock deviation corresponding to the first audio playback device to obtain a correction coefficient corresponding to the first audio playback device.
[0104] Optionally, the sampling rate calculation unit is specifically used to: calculate the product of an original sampling rate corresponding to the first audio playback device and the correction coefficient to obtain a first sampling rate corresponding to the first audio playback device.
[0105] Optionally, the second judgment module 34 includes: a determination unit, used for determining a clock error parameter offset in response to the first audio playback device, when a change value of the corresponding real-time chip temperature within a preset time period exceeds a preset change threshold, according to the real-time chip temperature; a conversion unit, used for converting the clock error parameter offset 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 calibrated clock error and the real-time clock drift; and a superposition unit, used for superimposing the first sampling rate with the third clock deviation to obtain a second sampling rate corresponding to the first audio playback device.
[0106] Optionally, the above-mentioned determination unit is specifically used for: in response to the corresponding real-time chip temperature changing by more than a preset change threshold within a preset time period, the first audio playback device searches for a clock error parameter offset corresponding to the real-time chip temperature from a preset temperature offset mapping table.
[0107] Optionally, the above-mentioned resampling and playback module 35 is specifically used for: if the real-time chip temperature meets the preset second resampling condition, then the target audio object is resampled in real time at the second sampling rate, and the sampling points obtained by the resampling are played; if the real-time chip temperature does not meet the preset second resampling condition, then the target audio object is resampled in real time at the first sampling rate, and the sampling points obtained by the resampling are played.
[0108] Optionally, the above-mentioned device also includes: a recording module, used to record the playback time required for each first audio playback device to play a preset audio object, and obtain the standard time corresponding to the preset audio object; a calibration module, used to calculate the difference between the standard time and the playback time, and obtain the calibration clock error corresponding to each first audio playback device.
[0109] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned audio synchronous playback method. The electronic device can be a server or a terminal device.
[0110] See also Figure 4 As shown, the electronic device includes a processor 400 and a memory 401, wherein the memory 401 stores machine executable instructions that can be executed by the processor 400, and the processor 400 executes the machine executable instructions to implement the above-mentioned audio synchronous playback method.
[0111] Further, Figure 4 The electronic device shown further includes a bus 402 and a communication interface 403 , and the processor 400 , the communication interface 403 and the memory 401 are connected via the bus 402 .
[0112] The memory 401 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 403 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 402 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may 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 diagram, but this does not mean that there is only one bus or only one type of bus.
[0113] The processor 400 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 400. The above processor 400 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. The disclosed methods, steps and logic block diagrams 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, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 401, and the processor 400 reads the information in the memory 401 and completes the steps of the method of the above embodiment in combination with its hardware.
[0114] This embodiment also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned audio synchronous playback method.
[0115] The computer program product of the method, device, electronic device and storage medium for synchronous audio playback provided in the embodiments of the present disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated 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 aforementioned method embodiment, and will not be repeated here.
[0117] In addition, in the description of the embodiments of the present disclosure, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present disclosure can be understood according to specific circumstances.
[0118] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0119] In the description of the present disclosure, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are 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, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present disclosure. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0120] Finally, it should be noted that the above embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above embodiments, those skilled in the art should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for synchronously playing audio, characterized in that: Applied to an audio playback system, the audio playback system at least comprises: at least two first audio playback devices, the at least two first audio playback devices comprise: a master device and at least one slave device, the method comprises: The master device sends an audio play instruction to the at least one slave device, the at least one slave device responds to the audio play instruction, and the master device and the at least one slave device start playing the target audio object at a target start time; wherein the audio play instruction is used to indicate the target audio object and the target start time; During the playback process, each first audio playback device calculates the deviation between the local clock and the master clock in real time to obtain the real-time clock drift corresponding to each first audio playback device; In response to the corresponding real-time clock drift amount satisfying a preset first resampling condition, the first audio playback device calculates a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift amount corresponding to the first audio playback device; In response to the corresponding real-time chip temperature satisfying 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; The first audio playback device resamples and plays the target audio object in real time according to the corresponding first sampling rate or second sampling rate.
2. The method according to claim 1, characterized in that The master device sends an audio play instruction to the at least one slave device, the at least one slave device responds to the audio play instruction, and the master device and the at least one slave device start playing a target audio object at a target start time, including: The master device responds to the synchronous play instruction and determines the target start time according to the current time; The master device sends an audio play instruction to the at least one slave device based on the target start time; The at least one slave device responds to the audio play instruction and starts playing the target audio object at the target start time or starts playing the target audio object at the current time; The master device starts 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 play instruction and determines the target start time according to the current time, including: The master device responds to the synchronous play instruction to obtain the current network transmission delay duration and the expected preparation duration of each slave device; The current time is superimposed with the maximum value of the current network transmission delay duration and all expected preparation durations to obtain the target start time.
4. The method according to claim 2, characterized in that: The at least one slave device responds to the audio play instruction and starts playing the target audio object at the target start time, or starts playing the target audio object at the current time, including: Each slave device responds to the audio play instruction and determines whether the 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 starts 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 starts 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 start playing the target audio object at a 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 a local cache, and start playing the target audio object in the local cache at a target start time.
6. The method according to claim 1, characterized in that In response to the corresponding real-time clock drift amount satisfying the preset first resampling condition, the first audio playback device calculates a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift amount corresponding to the first audio playback device, including: In response to the corresponding real-time clock drift being greater than a preset drift threshold, the first audio playback device calculates a correction coefficient corresponding to the first audio playback device according to a calibrated clock error and the real-time clock drift corresponding to the first audio playback device; A first sampling rate corresponding to the first audio playback device is calculated according to an original sampling rate corresponding to the first audio playback device and the correction coefficient.
7. The method according to claim 6, characterized in that In response to a corresponding real-time clock drift being greater than a preset drift threshold, the first audio playback device calculates a correction coefficient corresponding to the first audio playback device according to a calibrated clock error and the real-time clock drift corresponding to the first audio playback device, including: In response to the corresponding real-time clock drift being greater than a preset drift threshold, the first audio playback device superimposes a calibrated clock error corresponding to the first audio playback device and the real-time clock drift to obtain a first clock deviation corresponding to the first audio playback device; Converting the clock deviation corresponding to the first audio playback device into parts per million to obtain a second clock deviation 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 a correction coefficient corresponding to the first audio playback device.
8. The method according to claim 6, characterized in that Calculating a first sampling rate corresponding to the first audio playback device according to an original sampling rate corresponding to the first audio playback device and the correction coefficient includes: The product of the original sampling rate corresponding to the first audio playback device and the correction coefficient is calculated to obtain a first sampling rate corresponding to the first audio playback device.
9. The method according to claim 1, characterized in that: In response to the corresponding real-time chip temperature satisfying 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, including: 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 exceeding a preset change threshold within a preset time period; Convert the clock error parameter offset 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 calibrated clock error and the real-time clock drift; The first sampling rate is superimposed on the third clock deviation to obtain a second sampling rate corresponding to the first audio playback device.
10. The method according to claim 9, characterized in that In response to a change value of the corresponding real-time chip temperature exceeding a preset change threshold within a preset time period, the first audio playback device determines a clock error parameter offset according to the real-time chip temperature, including: In response to a change value of the corresponding real-time chip temperature exceeding a preset change threshold within a preset time period, the first audio playback device searches a preset temperature offset mapping table for a clock error parameter offset corresponding to the real-time chip temperature.
11. The method according to claim 1, characterized in that: The first audio playback device resamples and plays the target audio object in real time according to the 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 at a 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.
12. The method according to claim 1, characterized in that Before the master device sends the audio play instruction to the at least one slave device, the method further includes: Recording the playback time required for each first audio playback device to play the preset audio object, and obtaining the standard time corresponding to the preset audio object; The difference between the standard duration and the playback duration is calculated to obtain a calibrated clock error corresponding to each first audio playback device.
13. An audio synchronous playback device, characterized in that: Applied to an audio playback system, the audio playback system at least comprises: at least two first audio playback devices, the at least two first audio playback devices comprise: a master device and at least one slave device, the apparatus comprises: a start playing module, configured for the master device to send an audio playing instruction to the at least one slave device, the at least one slave device to respond to the audio playing instruction, and the master device and the at least one slave device to start playing the 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; The deviation calculation module is used to calculate the deviation between the local clock and the master clock of each first audio playback device in real time during the playback process to obtain the real-time clock drift corresponding to each first audio playback device; A first judgment module is configured to calculate, in response to a corresponding real-time clock drift amount of the first audio playback device satisfying a preset first resampling condition, a first sampling rate corresponding to the first audio playback device based on a calibrated clock error and the real-time clock drift amount corresponding to the first audio playback device; A second judgment module is configured to calculate 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 corresponding real-time chip temperature of the first audio playback device satisfying a preset second resampling condition; The resampling and playing module is used for the first audio playing device to resample and play the target audio object in real time according to the corresponding first sampling rate or second sampling rate.
14. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for synchronously playing audio according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by the processor, the computer-executable instructions prompt the processor to implement the method for synchronously playing audio according to any one of claims 1 to 12.
Citation Information
Patent Citations
Voice data processing method, device and system and controlled device
CN105611222A
Method for synchronously playing audios of wireless equipment
CN110636349A
Multi-device adaptive audio synchronous playing method and processing terminal
CN113300797A
Audio synchronous playing method and system, audio equipment and storage medium
CN116828585A
Audio synchronization method, audio playing system and storage medium
CN117768993A
Cited By
Star flash wireless audio transmission system and networking control method thereof
CN120857250A
