Audio data transmission method and device, electronic equipment and storage medium
By obtaining the time delay information during the audio data transmission process and determining the corresponding data format based on the information, the problem of inaccurate audio data transmission caused by clock and data delay is solved, and the consistency and transmission accuracy of data between the sending and receiving ends are achieved.
Patent Information
- Application Number
- CN202510122311.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-05-09
AI Technical Summary
During the audio data transmission process, the increase in the serial clock frequency and the delay of the clock and data transmission path lead to a change in the phase relationship between the data and the clock, which makes it impossible for both the sending and receiving devices to receive accurate audio data in the same data format, affecting the accuracy of data transmission.
By obtaining the first time stamp of the audio data sent by the sending end device and the second time stamp of the audio data received by the receiving end device, the time delay information is determined, and the corresponding second data format is determined based on the time delay information and the first data format of the sending end device. The audio data sent by the transmitting end device is then received according to the second data format, and the data format of the receiving end device is matched by moving the bytes or serial clock signals of the audio data forward or backward.
The audio data consistency received by the transmitting device and the receiving device is realized, the accuracy of audio data transmission is improved, and the data format mismatch caused by clock and data delay is solved.
Smart Images

Figure CN119966595A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data transmission, and in particular to a method, device, electronic device and storage medium for transmitting audio data. Background Art
[0002] In the process of transmitting audio data, in order to ensure the correct transmission of audio data, the sending device and the receiving device should use the same data format to transmit audio data. However, in the actual transmission process, when the serial clock frequency becomes higher, coupled with the delay in the clock and data transmission path of the sending and receiving parties, the phase relationship between the data and the clock will change. If the sending and receiving devices still use the same data format, accurate audio data cannot be received. Therefore, how to improve the accuracy of audio data transmission is an urgent problem to be solved. Summary of the invention
[0003] The purpose of some embodiments of the present application is to provide a method, device, electronic device and storage medium for transmitting audio data. Through the technical solution of the embodiments of the present application, by obtaining the first timestamp of the audio data sent by the transmitting device, and obtaining the second timestamp of the received audio data; determining the time delay information according to the first timestamp and the second timestamp; determining the second data format corresponding to the time delay information according to the time delay information and the first data format of the audio data sent by the transmitting device; receiving the audio data sent by the transmitting device according to the second data format; wherein the second data format is determined by moving the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, and n and m are natural numbers greater than 0. The embodiments of the present application obtain the time delay information in the audio data transmission process, and determine the corresponding data format according to the time delay time, and can move any number of bytes or any number of serial clock signals forward or backward, so that the audio data received by the transmitting device and the receiving device are consistent, and the accuracy of data transmission is improved.
[0004] In a first aspect, some embodiments of the present application provide a method for transmitting audio data, including:
[0005] Obtaining a first timestamp of the audio data being sent by the transmitting device, and obtaining a second timestamp of the audio data being received;
[0006] Determining time delay information according to the first timestamp and the second timestamp;
[0007] Determine a second data format corresponding to the time delay information according to the time delay information and a first data format of the audio data sent by the transmitting end device;
[0008] receiving, according to the second data format, audio data sent by the transmitting end device;
[0009] The second data format is determined by shifting the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, where n and m are natural numbers greater than 0.
[0010] Some embodiments of the present application obtain time delay information during audio data transmission and determine the corresponding data format based on the time delay time, and can move any number of bytes or any number of serial clock signals forward or backward. In this way, the audio data received by the sending device and the receiving device are consistent, thereby improving the accuracy of data transmission.
[0011] Optionally, determining a second data format corresponding to the time delay information according to the time delay information and a first data format of the audio data sent by the transmitting end device includes:
[0012] When the frame clock signal changes, obtaining the first moment when the serial clock signal changes;
[0013] Determine a moving direction and moving parameters corresponding to the first moment according to the first moment and the time delay information, wherein the moving direction at least includes forward or backward, and the moving parameters at least include target moving bit number or target moving clock information;
[0014] A second data format corresponding to the time delay information is determined according to the moving direction, the moving parameters and the first data format corresponding to the first moment.
[0015] Optionally, determining a second data format corresponding to the time delay information according to the moving direction, the moving parameter and the first data format corresponding to the first moment includes:
[0016] In the case where the mth serial clock signal of the transmitting device sends the target audio data, the moving time is determined forward or backward according to the first time and the target moving bit number or the target moving clock information, and the target audio data is received according to the moving time.
[0017] Some embodiments of the present application use LRCLK edge changes to delay multiple SCLKs, advance multiple SCLK cycles, and start sending or receiving data to provide a more flexible handshake method for both the receiving and sending parties. This allows the slave device to have enough time to store the currently received data and prepare to receive the next set of data.
[0018] Optionally, the change in the frame clock signal at least includes changing from a high level to a low level, or from a low level to a high level.
[0019] In some embodiments of the present application, the data format of the audio data is defined by the number of SCLK cycles delayed relative to the LRCLK, and the transmission of the first channel data is flexibly configured to be started at the rising edge or the falling edge of the LRCLK, and the frame clock format is arbitrary.
[0020] Optionally, the data format includes at least one or more of the following formats:
[0021] The highest bit data of the audio data is placed in the data format of the m serial clock signals before the frame clock signal changes, or the highest bit data of the audio data is placed in the data format of the m serial clock signals after the frame clock signal changes;
[0022] The highest bit of the audio data is placed in the data format of n bytes before the frame clock signal changes, or the highest bit of the audio data is placed in the data format of n bytes after the frame clock signal changes;
[0023] When the data transmission of the preset position of the audio data is completed, the data format in which the level of the frame clock signal is flipped in the current cycle or k cycles; k is a natural number greater than 1.
[0024] Some embodiments of the present application redefine the data format based on the number of SCLK cycles that the data is delayed relative to the LRCLK to support the uncertainty of data and clock delays and the impact of high-speed audio communications.
[0025] Optionally, the audio data is transmitted between the transmitting device and the receiving device via two channels or multiple channels.
[0026] In a second aspect, some embodiments of the present application provide a device for transmitting audio data, including:
[0027] An acquisition module, used to acquire a first timestamp when the transmitting end device sends the audio data, and to acquire a second timestamp when the audio data is received;
[0028] A determination module, configured to determine time delay information according to the first timestamp and the second timestamp;
[0029] A calculation module, configured to determine a second data format corresponding to the time delay information according to the time delay information and a first data format of the audio data sent by the transmitting end device;
[0030] A receiving module, configured to receive the audio data sent by the transmitting end device according to the second data format;
[0031] The second data format is determined by shifting the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, where n and m are natural numbers greater than 0.
[0032] Some embodiments of the present application obtain time delay information during audio data transmission and determine the corresponding data format based on the time delay time, and can move any number of bytes or any number of serial clock signals forward or backward. In this way, the audio data received by the sending device and the receiving device are consistent, thereby improving the accuracy of data transmission.
[0033] Optionally, the computing module is used to:
[0034] When the frame clock signal changes, obtaining the first moment when the serial clock signal changes;
[0035] Determine a moving direction and moving parameters corresponding to the first moment according to the first moment and the time delay information, wherein the moving direction at least includes forward or backward, and the moving parameters at least include target moving bit number or target moving clock information;
[0036] A second data format corresponding to the time delay information is determined according to the moving direction, the moving parameters and the first data format corresponding to the first moment.
[0037] Optionally, the computing module is used to:
[0038] In the case where the mth serial clock signal of the transmitting device sends the target audio data, the moving time is determined forward or backward according to the first time and the target moving bit number or the target moving clock information, and the target audio data is received according to the moving time.
[0039] Some embodiments of the present application use LRCLK edge changes to delay multiple SCLKs, advance multiple SCLK cycles, and start sending or receiving data to provide a more flexible handshake method for both the receiving and sending parties. This allows the slave device to have enough time to store the currently received data and prepare to receive the next set of data.
[0040] Optionally, the change in the frame clock signal at least includes changing from a high level to a low level, or from a low level to a high level.
[0041] In some embodiments of the present application, the data format of the audio data is defined by the number of SCLK cycles delayed relative to the LRCLK, and the transmission of the first channel data is flexibly configured to be started at the rising edge or the falling edge of the LRCLK, and the frame clock format is arbitrary.
[0042] Optionally, the data format includes at least one or more of the following formats:
[0043] The highest bit data of the audio data is placed in the data format of the m serial clock signals before the frame clock signal changes, or the highest bit data of the audio data is placed in the data format of the m serial clock signals after the frame clock signal changes;
[0044] The highest bit of the audio data is placed in the data format of n bytes before the frame clock signal changes, or the highest bit of the audio data is placed in the data format of n bytes after the frame clock signal changes;
[0045] When the data transmission of the preset position of the audio data is completed, the data format in which the level of the frame clock signal is flipped in the current cycle or k cycles; k is a natural number greater than 1.
[0046] Some embodiments of the present application redefine the data format based on the number of SCLK cycles that the data is delayed relative to the LRCLK to support the uncertainty of data and clock delays and the impact of high-speed audio communications.
[0047] Optionally, the audio data is transmitted between the transmitting device and the receiving device via two channels or multiple channels.
[0048] In a third aspect, some embodiments of the present application provide an electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, the audio data transmission method as described in any embodiment of the first aspect can be implemented.
[0049] In a fourth aspect, some embodiments of the present application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the audio data transmission method as described in any embodiment of the first aspect.
[0050] In a fifth aspect, some embodiments of the present application provide a computer program product, comprising a computer program, wherein the computer program, when executed by a processor, can implement the audio data transmission method as described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of some embodiments of the present application, the drawings required for use in some embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0052] Figure 1 A flowchart of an audio data transmission method provided in an embodiment of the present application;
[0053] Figure 2 A schematic diagram of the existing data format;
[0054] Figure 3 A schematic diagram of the structure of the master and slave device transceiver system provided in an embodiment of the present application;
[0055] Figure 4 A schematic diagram of the structure of a master device receiving and slave device sending system provided in an embodiment of the present application;
[0056] Figure 5 The data format difference caused by the delay when the master device receives and the slave device sends according to the embodiment of the present application;
[0057] Figure 6 A schematic diagram of the structure of a master device sending and slave device receiving system provided in an embodiment of the present application;
[0058] Figure 7 The data format difference caused by the delay when the master device sends and the slave device receives according to the embodiment of the present application;
[0059] Figure 8 A schematic diagram of a redefined data format provided in an embodiment of the present application;
[0060] Fig. 9 A schematic diagram of another redefined data format provided in an embodiment of the present application;
[0061] Fig.10 A schematic diagram of four-channel data transmission of short pulses provided in an embodiment of the present application;
[0062] Fig.11 A schematic diagram of four-channel data transmission of long pulses provided in an embodiment of the present application;
[0063] Fig.12 A schematic diagram of the structure of an audio data transmission device provided in an embodiment of the present application;
[0064] Fig.13 A schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] The technical solutions in some embodiments of the present application will be described below in conjunction with the drawings in some embodiments of the present application.
[0066] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0067] In the process of transmitting audio data, in order to ensure the correct transmission of audio data, the transmitting device and the receiving device should use the same data format to transmit audio data. However, in the actual transmission process, when the serial clock frequency becomes higher, coupled with the delay in the clock and data transmission path of the transmitting and receiving parties, the phase relationship between the data and the clock will change. If the transmitting and receiving devices still use the same data format, accurate audio data cannot be received. Therefore, how to improve the accuracy of audio data transmission is a problem that needs to be solved urgently. In view of this, some embodiments of the present application provide a method for transmitting audio data, the method comprising obtaining a first timestamp of the audio data sent by the transmitting device, and obtaining a second timestamp of the received audio data; determining time delay information according to the first timestamp and the second timestamp; determining a second data format corresponding to the time delay information according to the time delay information and the first data format of the audio data sent by the transmitting device; receiving the audio data sent by the transmitting device according to the second data format; wherein the second data format is determined by moving the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, and n and m are natural numbers greater than 0. The embodiment of the present application obtains the time delay information during the audio data transmission process and determines the corresponding data format according to the time delay time. It can move any number of bytes or any number of serial clock signals forward or backward. In this way, the audio data received by the sending device and the receiving device are consistent, thereby improving the accuracy of data transmission.
[0068] like Figure 1 As shown, an embodiment of the present application provides a method for transmitting audio data, the method comprising:
[0069] S101, obtaining a first timestamp of audio data sent by a transmitting device, and obtaining a second timestamp of audio data received;
[0070] Specifically, an embodiment of the present application is applied to an audio data transmission system, which includes at least a transmitting device and a receiving device, wherein the transmitting device and the receiving device transmit data through an audio communication interface. There are many types of audio communication interfaces, including but not limited to I2S, TDM, PDM, etc. Their similar working interfaces all have a serial clock, a frame clock, one input and one output signal, which are divided into multiple channels within a frame clock cycle, and each channel transmits audio data in a certain data format.
[0071] The receiving device and the transmitting device may have the function of transmitting audio data, or may be an audio chip. The receiving device may be a master device or a slave device, and the transmitting device may be a master device or a slave device.
[0072] When the transmitting device sends audio data to the receiving device, the receiving device obtains a first timestamp carried in the audio data packet sent by the transmitting device, and at the same time, obtains a second timestamp of the received audio data.
[0073] S102, determining time delay information according to the first timestamp and the second timestamp;
[0074] The receiving end device calculates the difference between the first timestamp and the second timestamp according to the first timestamp and the second timestamp to obtain the time delay information.
[0075] S103, determining a second data format corresponding to the time delay information according to the time delay information and the first data format of the audio data sent by the transmitting end device;
[0076] The second data format is determined by shifting the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, where n and m are natural numbers greater than 0.
[0077] Specifically, the receiving device calculates the number of serial clocks that need to be moved, that is, the value of m, based on the calculated time delay information and serial clock information. Based on the obtained value of m, the audio data packet can be moved forward or backward by m serial clock signals.
[0078] Alternatively, after calculating the time delay information, the receiving device determines the number of bytes corresponding to the time delay, that is, n bytes, and can move the audio data packet forward or backward by n bytes according to the value of n.
[0079] The receiving device moves the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, and redefines the second data format in combination with the first data format of the transmitting device.
[0080] S104: Receive audio data sent by the transmitting device according to the second data format.
[0081] Specifically, after obtaining the re-determined second data format, the receiving device receives the audio data, i.e., the audio data packet, sent by the sending device according to the second data format. The embodiment of the present application can solve the data errors caused by clock data delay by flexibly configuring the data format. According to the actual application scenario, by configuring the receiving and sending parties with different data formats, the communication between the sending and receiving parties can be better matched.
[0082] Some embodiments of the present application obtain the time delay information during the audio data transmission process and determine the corresponding data format according to the time delay time. They can move any number of bytes or any number of serial clock signals forward or backward to regenerate the data format. In this way, the audio data received by the sending device and the receiving device are consistent, thereby improving the accuracy of data transmission.
[0083] Another embodiment of the present application further supplements the audio data transmission method provided in the above embodiment.
[0084] The embodiment of the present application takes two-channel I2S communication as an example to discuss the technical solution of the present application.
[0085] I2S is a standard for audio communication interface, including serial clock SCLK (serial clock signal), frame clock LRCLK (frame clock signal), input data, and output data SDATA. The high and low levels of LRCLK represent the left and right channels or the right and left channels respectively, and the left and right channels transmit one channel of data respectively. According to the different positions of SDATA data relative to LRCK and SCLK, it is divided into left-aligned format, I2S standard format, and right-aligned format; different data formats have different definitions of left and right channels.
[0086] Figure 2 The relationship between the three data formats of I2S SDATA data and LRCK and SCLK. The left and right channels transmit one channel of data respectively, Msb represents the highest bit of the data, and Lsb represents the lowest bit of the data. In addition, Figure 2 An example of a TDM transmission data format is also given. The LRCLK pulse width is one sclk width. The first channel data transmission starts with a rising edge. There are four channels in one frame clock.
[0087] Left-aligned format: Data transmission starts with the first SCLK clock pulse after the LRCLK level changes. LRCLK high level represents the left channel, and LRCLK low level represents the right channel.
[0088] Right-aligned format: When the lowest bit Lsb of the audio data is transmitted, the LRCLK level is flipped. LRCLK high level represents the left channel, and LRCLK low level represents the right channel.
[0089] I2S standard format: The first SCLK clock pulse after LRCLK changes does not transmit data, and the second SCLK clock pulse starts to transmit data. LRCLK low level represents the left channel, and LRCLK high level represents the right channel.
[0090] like Figure 3 As shown, in a transceiver system of a master I2S device and a slave I2S device, the master I2S device generates SCLK and LRCLK, and sends the SCLK and LRCLK to the slave I2S device, so that the slave I2S device works according to the SCLK and LRCLK, and the data signals of the master I2S device and the slave I2S device both work with the SCLK and LRCLK generated by the master I2S device, SDI represents input serial audio data, and SDO represents output serial audio data.
[0091] In order to ensure the correct transmission of digital audio signals, the sending and receiving devices should use the same data format. When the serial clock frequency becomes higher, coupled with the delay in the clock and data transmission path of both the sender and the receiver, the phase relationship between the data and the clock will change. If the sender and the receiver still use the same data, the data cannot be sent and received correctly.
[0092] Optionally, determining a second data format corresponding to the time delay information according to the time delay information and a first data format of the audio data sent by the transmitting end device includes:
[0093] When the frame clock signal changes, obtaining the first moment when the serial clock signal changes;
[0094] Determine a moving direction and moving parameters corresponding to the first moment according to the first moment and the time delay information, wherein the moving direction at least includes forward or backward, and the moving parameters at least include target moving bit number or target moving clock information;
[0095] A second data format corresponding to the time delay information is determined according to the moving direction, the moving parameters and the first data format corresponding to the first moment.
[0096] For example, for the three data formats of I2S, due to the difference in clock and data delay, the receiver cannot use the same data format as the sender, and the overhead of processing data is increased; in addition, some data formats are completely unsupported. In view of this situation, the data format of I2S is redefined based on the number of SCLKs that the audio data leads or lags behind LRCLK.
[0097] like Figure 5 As shown, when the frame clock signal LRCLK of the master device flips from a low level to a high level, the master device uses the I2S standard format to transmit audio data. When receiving audio data from the slave device, the second data format is regenerated according to the I2S standard format and the calculated time delay information.
[0098] Optionally, determining a second data format corresponding to the time delay information according to the moving direction, the moving parameter and the first data format corresponding to the first moment includes:
[0099] In the case where the mth serial clock signal of the transmitting end device sends the target audio data, the moving time is determined forward or backward according to the first time, and the target moving bit number or the target moving clock information, and the target audio data is received according to the moving time.
[0100] Some embodiments of the present application use LRCLK edge changes to delay multiple SCLKs, advance multiple SCLK cycles, and start sending or receiving data to provide a more flexible handshake method for both the receiving and sending parties. This allows the slave device to have enough time to store the currently received data and prepare to receive the next set of data.
[0101] Optionally, the change in the frame clock signal at least includes changing from a high level to a low level, or from a low level to a high level.
[0102] In the embodiment of the present application, when the frame clock signal of the transmitting device is flipped, that is, the rising edge or the falling edge, the first channel transmission is started. In the embodiment of the present application, two-channel transmission or multi-channel transmission can be performed, which is not specifically limited here.
[0103] In some embodiments of the present application, the data format of the audio data is defined by the number of SCLK cycles delayed relative to the LRCLK, and the transmission of the first channel data is flexibly configured to be started at the rising edge or the falling edge of the LRCLK, and the frame clock format is arbitrary.
[0104] Optionally, the data format includes at least one or more of the following formats:
[0105] The highest bit data of the audio data is placed in the data format of the m serial clock signals before the frame clock signal changes, or the highest bit data of the audio data is placed in the data format of the m serial clock signals after the frame clock signal changes;
[0106] The highest bit of the audio data is placed in the data format of n bytes before the frame clock signal changes, or the highest bit of the audio data is placed in the data format of n bytes after the frame clock signal changes;
[0107] When the data transmission of the preset position of the audio data is completed, the data format in which the level of the frame clock signal is flipped in the current cycle or k cycles; k is a natural number greater than 1.
[0108] For example, Figure 8 As shown, the high level of the frame clock LRCLK is the left channel, and the low level is the right channel, and 7 data formats SDATA_0-SDATA_6 are defined.
[0109] SDATA_0 represents data format 0 for data transmission with one SCLK clock before LRCLK changes;
[0110] SDATA_1 represents the data format 1 (i.e. left-aligned format) in which data transmission starts with the first SCLK clock pulse after the LRCK changes.
[0111] SDATA_2 represents data format 2 where data transmission starts with the second SCLK clock pulse after LRCK changes;
[0112] SDATA_3 represents data format 3 where data transmission starts at the third SCLK clock pulse after LRCK changes;
[0113] SDATA_4 represents data format 4 (i.e. right-aligned format) in which LRCK performs level flipping when the transmission of the lowest bit Lsb of the audio data is completed;
[0114] SDATA_5 represents data format 5 in which LRCK performs level inversion when the transmission of the second lowest bit of audio data is completed;
[0115] SDATA_6 represents data format 6 in which the LRCK level is flipped after the transmission of the lowest bit Lsb of the audio data completes one SCLK cycle.
[0116] like Fig. 9 As shown, with the low level of the frame clock LRCLK as the left channel and the high level as the right channel, 7 data formats SDATA_7-SDATA_13 are defined.
[0117] Specifically, SDATA_7 represents data format 7 for data transmission one SCLK clock before LRCLK changes;
[0118] SDATA_8 represents data format 8 where the first SCLK clock pulse after the LRCK changes starts data transmission.
[0119] SDATA_9 represents data format 9 (I2S standard format) that starts data transmission at the second SCLK clock pulse after LRCK changes;
[0120] SDATA_10 represents data format 10 where data transmission starts at the third SCLK clock pulse after LRCK changes;
[0121] SDATA_11 represents the data format 11 when the transmission of the lowest bit Lsb of the audio data is completed and the LRCK level is flipped;
[0122] SDATA_12 represents the data format 12 in which LRCK performs level flipping when the transmission of the second lowest bit of the audio data is completed;
[0123] SDATA_13 represents data format 13 in which the LRCK level is flipped after the transmission of the lowest bit Lsb of the audio data completes one SCLK cycle.
[0124] The embodiment of the present application adopts a redefined data format, which does not require subsequent data processing and is compatible with three data formats, thereby solving the problem of data format mismatch between the receiving and sending parties caused by different data clock delays. The new data format definition includes but is not limited to three traditional data formats (left-aligned, right-aligned, and I2S standard).
[0125] The second data format in the embodiment of the present application, including but not limited to the 14 data formats mentioned above, can also be further defined to delay multiple SCLKs with the change of LRCLK edge, and start sending or receiving data multiple SCLK cycles in advance, so as to provide a more flexible handshake method for both the receiving and sending parties. In this way, the slave device can have enough time to store the currently received data and be ready to receive the next set of data, with more time margin. When the nth SCLK of the master / slave audio interface sends data Msb, the slave / master audio interface can select the n+ / -mth SCLK clock to start receiving Msb according to the on-site delay.
[0126] Some embodiments of the present application redefine the data format based on the number of SCLK cycles that the data is delayed relative to the LRCLK to support the uncertainty of data and clock delays and the impact of high-speed audio communications.
[0127] Optionally, audio data is transmitted between the transmitting device and the receiving device via two channels or multiple channels.
[0128] The embodiment of the present application not only supports a two-channel data transmission mode, but also supports a multi-channel data transmission mode. The above is a two-channel data transmission format. Fig.10 and Fig.11 It is a four-channel data transmission method, in which: Fig.10 The format of the frame clock signal LRCLK in is a short pulse, with the rising edge as the start of the first channel transmission; Fig.11The format of the frame clock signal LRCLK is a long pulse (occupying the width of one channel), and the falling edge is used as the start of transmission of the first channel. Regardless of the method, after the frame clock signal is flipped, it is determined that the transmission of the first channel has started, that is, the above-mentioned redefined data format can be used for data transmission to avoid data errors caused by signal delays in audio data.
[0129] For example:
[0130] For compatibility with abnormal audio data formats, when the chip sends audio data, the three data formats of I2S are not used. For example, when the sending chip sends data in data format 8 (neither left-aligned, nor right-aligned, nor I2S standard format), the receiving chip can choose data format 7 or data format 9 to receive data according to the delay situation.
[0131] like Figure 4 As shown in the figure, when the clock and data directions of the master I2S device and the slave I2S device are opposite (master I2S receives, slave I2S sends), due to the delay of the chip's internal clock and data, the chip pad delay, and the superposition of the PCB board-level wiring delay, it will cause the following Figure 5 The SCLK and LRCLK sent by the master I2S are sent to the slave I2S after a delay of tcd1, and the data SDO sent by the slave I2S is sent to the SDI port of the master I2S after a delay of tdd1. When tcd1+tdd1 equals one SCLK cycle (not necessarily exactly equal, but when the slave I2S sends the data Msb relative to the i-th SCLK of the slave I2S's LRCLK, the master I2S starts receiving the Msb relative to the i+1-th SCLK of the master I2S's LRCLK to get the correct data). If the sender and receiver use the same data format, data errors will occur.
[0132] In order to offset the deviation of data relative to the clock caused by delay, different data formats can be used for receiving and sending.
[0133] That is to say, when the clock and data directions of the master and slave I2S are opposite, Figure 5It can be seen that the slave I2S sends data Msb at the i-th SCLK relative to the LRCLK of the slave I2S, and the master I2S starts to receive Msb at the i+1-th SCLK clock relative to the LRCLK of the master I2S. In this case, when the slave I2S uses the left-aligned format to send data, the master I2S can receive data in the I2S standard format, but because the left and right channel definitions of the left-aligned format are different from those of the I2S standard format, for the left-aligned format, the correct data is the left channel of the first frame and the right channel of the first frame merged into one frame; for the I2S standard format, the right channel of the first frame and the left channel of the second frame will be merged into one frame, so that an incorrect sound will be heard, so the data must be further exchanged and processed. When the slave I2S uses the I2S standard format or the right-aligned format, the master I2S cannot receive the correct data regardless of the data format used and how the data is processed later.
[0134] When the clock and data directions of the master and slave I2S are opposite, Figure 4 It can be seen that the slave I2S sends data Msb at the i-th SCLK relative to the LRCLK of the slave I2S, and the master I2S starts to receive Msb at the i+1-th SCLK clock relative to the LRCLK of the master I2S. In this case, the method of redefining the data format provided in the embodiment of the present application is adopted. When the slave I2S sends data in the left-aligned format, the master I2S receives data in data format 2; when the slave I2S sends data in the I2S standard format, the master I2S receives data in data format 10; when the slave I2S sends data in the right-aligned format, the master I2S receives data in data format 5.
[0135] like Figure 6 As shown in the figure, when the clock and data directions of the master and slave I2S are the same (the master I2S sends, the slave I2S receives), the clock and data are delayed respectively, and the phase between the two is offset, which will appear Figure 7 There are two possibilities.
[0136] Figure 7 On the left is the case where the clock delay is less than the data delay. The SCLK and LRCLK sent by the master I2S are sent to the slave I2S after a delay of tcd2. The data SDO sent by the master I2S is sent to the SDI port of the slave I2S after a delay of tdd2. When tdd2-tcd2 is equal to 1 SCLK cycle (not necessarily exactly equal, but when the master I2S sends data Msb relative to the jth SCLK of the master I2S's LRCLK, the slave I2S receives the Msb from the j+1th SCLK clock relative to the LRCLK of the slave I2S to get the correct data), if the sender and receiver use the same data format, data errors will occur.
[0137] When the clock and data directions of the master and slave I2S are the same, Figure 7As can be seen from the left, when the master I2S sends data Msb at the jth SCLK relative to the LRCLK of the master I2S, the slave I2S starts to receive Msb at the j+1th SCLK clock relative to the LRCLK of the slave I2S. In this case, when the master I2S uses the left-aligned format to send data, the slave I2S can receive data in the I2S standard format, but because the left and right channels of the left-aligned format are different from the left and right channels of the I2S standard format, for the left-aligned format, the correct data is the left channel of the first frame and the right channel of the first frame merged into one frame; for the I2S standard format, the right channel of the first frame and the left channel of the second frame will be merged into one frame, so you will hear the wrong sound, so you must further exchange and process the data. When the master I2S uses the I2S standard format or the right-aligned format, the slave I2S cannot receive the correct data regardless of the data format used and how the data is processed later.
[0138] When the clock and data directions of the master and slave I2S are the same, Figure 7 As can be seen from the left, when the master I2S sends data Msb at the jth SCLK relative to the LRCLK of the master I2S, the slave I2S starts receiving Msb at the j+1th SCLK clock relative to the LRCLK of the slave I2S. In this case, when the master I2S sends data in the left-aligned format, the slave I2S receives data in data format 2; when the master I2S sends data in the I2S standard format, the slave I2S receives data in data format 10; when the master I2S sends data in the right-aligned format, the slave I2S receives data in data format 5.
[0139] Figure 7 The right is the case where the clock delay is greater than the data delay. The SCLK and LRCLK sent by the master I2S are sent to the slave I2S after a delay of tcd3. The data SDO sent by the master I2S is sent to the SDI port of the slave I2S after a delay of tdd3. When tcd3-tdd3 is equal to 1 SCLK cycle (not necessarily exactly equal, but when the master I2S sends the data Msb relative to the kth SCLK of the master I2S's LRCLK, the slave I2S starts receiving the Msb relative to the k-1 SCLK clocks of the slave I2S's LRCLK to get the correct data), if the sender and receiver use the same data format, data errors will occur.
[0140] When the clock and data directions of the master and slave I2S are the same, Figure 7As can be seen from the right, when the master I2S sends data Msb at the kth SCLK relative to the LRCLK of the master I2S, the slave I2S starts to receive Msb at the k-1th SCLK relative to the LRCLK of the slave I2S. In this case, when the master I2S uses the I2S standard format to send data, the slave I2S can receive data in the left-aligned format, but because the left and right channels of the I2S standard format are different from the left and right channels of the left-aligned format, for the I2S standard format, the correct data is the left channel of the first frame and the right channel of the first frame merged into one frame; for the left-aligned format, the right channel of the first frame and the left channel of the second frame will be merged into one frame, so that the wrong sound will be heard, so the data must be further exchanged and processed. When the master I2S uses the left-aligned format or the right-aligned format, the slave I2S cannot receive the correct data regardless of the data format used and how the data is processed subsequently.
[0141] When the clock and data directions of the master and slave I2S are the same, Figure 7 As can be seen from the right, when the master I2S sends data Msb at the kth SCLK relative to the LRCLK of the master I2S, the slave I2S starts to receive Msb at the k-1th SCLK relative to the LRCLK of the slave I2S. In this case, the method of redefining the data format in the embodiment of the present application is adopted. When the master I2S uses the left-aligned format to send data, the slave I2S uses data format 0 to receive data; when the master I2S uses the I2S standard format to send data, the slave I2S uses data format 8 to receive data; when the master I2S uses the right-aligned format to send data, the slave I2S uses data format 6 to receive data.
[0142] The embodiments of the present application are based on the position of the data of the transmitting and receiving parties relative to the LRCLK. For example, when the clocks of the master device and the slave device are in opposite directions to the data, the SCLK frequency of the master I2S is too high, and the delay between the data and the clock is too large, it may cause the slave I2S to send data Msb at the i-th SCLK relative to the LRCLK of the slave I2S, and the master I2S can receive the correct Msb at the i+2-th SCLK clock relative to the LRCLK of the master I2S. For example, when the slave I2S uses left-aligned (data format 1) to send data, the master I2S uses data format 3 to receive data.
[0143] It should be noted that each implementable method in this embodiment may be implemented separately, or may be implemented in combination in any manner without conflict, and this application is not limited thereto.
[0144] Another embodiment of the present application provides an audio data transmission device, which is used to execute the audio data transmission method provided in the above embodiment.
[0145] like Fig.12, which is a schematic diagram of the structure of the audio data transmission device provided in an embodiment of the present application. The audio data transmission device includes an acquisition module 1201, a determination module 1202, a calculation module 1203 and a receiving module 1204, wherein:
[0146] The acquisition module 1201 is used to acquire a first timestamp of the audio data sent by the transmitting end device, and acquire a second timestamp of the audio data received;
[0147] The determination module 1202 is used to determine the time delay information according to the first timestamp and the second timestamp;
[0148] The calculation module 1203 is used to determine a second data format corresponding to the time delay information according to the time delay information and the first data format of the audio data sent by the transmitting end device;
[0149] The receiving module 1204 is used to receive the audio data sent by the transmitting end device according to the second data format;
[0150] The second data format is determined by shifting the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, where n and m are natural numbers greater than 0.
[0151] Regarding the device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0152] Some embodiments of the present application obtain time delay information during audio data transmission and determine the corresponding data format based on the time delay time, and can move any number of bytes or any number of serial clock signals forward or backward. In this way, the audio data received by the sending device and the receiving device are consistent, thereby improving the accuracy of data transmission.
[0153] Another embodiment of the present application further supplements the audio data transmission device provided in the above embodiment.
[0154] Optionally, the computing module is used to:
[0155] When the frame clock signal changes, obtaining the first moment when the serial clock signal changes;
[0156] Determine a moving direction and moving parameters corresponding to the first moment according to the first moment and the time delay information, wherein the moving direction at least includes forward or backward, and the moving parameters at least include target moving bit number or target moving clock information;
[0157] A second data format corresponding to the time delay information is determined according to the moving direction, the moving parameters and the first data format corresponding to the first moment.
[0158] Optionally, the computing module is used to:
[0159] In the case where the mth serial clock signal of the transmitting end device sends the target audio data, the moving time is determined forward or backward according to the first time, and the target moving bit number or the target moving clock information, and the target audio data is received according to the moving time.
[0160] Some embodiments of the present application use LRCLK edge changes to delay multiple SCLKs, advance multiple SCLK cycles, and start sending or receiving data to provide a more flexible handshake method for both the receiving and sending parties. This allows the slave device to have enough time to store the currently received data and prepare to receive the next set of data.
[0161] Optionally, the change in the frame clock signal at least includes changing from a high level to a low level, or from a low level to a high level.
[0162] In some embodiments of the present application, the data format of the audio data is defined by the number of SCLK cycles delayed relative to the LRCLK, and the transmission of the first channel data is flexibly configured to be started at the rising edge or the falling edge of the LRCLK, and the frame clock format is arbitrary.
[0163] Optionally, the data format includes at least one or more of the following formats:
[0164] The highest bit data of the audio data is placed in the data format of the m serial clock signals before the frame clock signal changes, or the highest bit data of the audio data is placed in the data format of the m serial clock signals after the frame clock signal changes;
[0165] The highest bit of the audio data is placed in the data format of n bytes before the frame clock signal changes, or the highest bit of the audio data is placed in the data format of n bytes after the frame clock signal changes;
[0166] When the data transmission of the preset position of the audio data is completed, the data format in which the level of the frame clock signal is flipped in the current cycle or k cycles; k is a natural number greater than 1.
[0167] Some embodiments of the present application redefine the data format based on the number of SCLK cycles that the data is delayed relative to the LRCLK to support the uncertainty of data and clock delays and the impact of high-speed audio communications.
[0168] Optionally, audio data is transmitted between the transmitting device and the receiving device via two channels or multiple channels.
[0169] Regarding the device in this embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0170] It should be noted that each implementable method in this embodiment may be implemented separately, or may be implemented in combination in any manner without conflict, and this application is not limited thereto.
[0171] The embodiments of the present application also provide a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the operation of the method corresponding to any embodiment of the audio data transmission method provided in the above embodiments can be implemented.
[0172] An embodiment of the present application further provides a computer program product, wherein the computer program product includes a computer program, wherein when the computer program is executed by a processor, it can implement the operations of the method corresponding to any embodiment of the audio data transmission method provided in the above embodiments.
[0173] like Fig.13 As shown, some embodiments of the present application provide an electronic device 1300, which includes: a memory 1310, a processor 1320, and a computer program stored in the memory 1310 and executable on the processor 1320, wherein the processor 1320 can implement any embodiment of the method for transmitting audio data as described above when reading the program from the memory 1310 through a bus 1330 and executing the program.
[0174] Processor 1320 can process digital signals and can include various computing structures, such as complex instruction set computer structure, reduced instruction set computer structure, or a structure that implements a combination of multiple instruction sets. In some examples, processor 1320 can be a microprocessor.
[0175] The memory 1310 may be used to store instructions executed by the processor 1320 or data related to the execution of instructions. These instructions and / or data may include codes for implementing some or all functions of one or more modules described in the embodiments of the present application. The processor 1320 of the disclosed embodiment may be used to execute instructions in the memory 1310 to implement the method shown above. The memory 1310 includes a dynamic random access memory, a static random access memory, a flash memory, an optical memory, or other memory known to those skilled in the art.
[0176] The above are only embodiments of the present application and are not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0177] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0178] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for transmitting audio data, characterized in that: Applied to a receiving device, the method comprises: Obtaining a first timestamp of the audio data being sent by the transmitting device, and obtaining a second timestamp of the audio data being received; Determining time delay information according to the first timestamp and the second timestamp; Determine a second data format corresponding to the time delay information according to the time delay information and a first data format of the audio data sent by the transmitting end device; receiving, according to the second data format, audio data sent by the transmitting end device; The second data format is determined by shifting the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, where n and m are natural numbers greater than 0.
2. The method for transmitting audio data according to claim 1, characterized in that: The determining, according to the time delay information and the first data format of the audio data sent by the transmitting end device, a second data format corresponding to the time delay information comprises: When the frame clock signal changes, obtaining the first moment when the serial clock signal changes; Determine a moving direction and moving parameters corresponding to the first moment according to the first moment and the time delay information, wherein the moving direction at least includes forward or backward, and the moving parameters at least include target moving bit number or target moving clock information; A second data format corresponding to the time delay information is determined according to the moving direction, the moving parameters and the first data format corresponding to the first moment.
3. The method for transmitting audio data according to claim 2, characterized in that: The determining, according to the moving direction, the moving parameter and the first data format corresponding to the first moment, a second data format corresponding to the time delay information comprises: In the case where the mth serial clock signal of the transmitting device sends the target audio data, the moving time is determined forward or backward according to the first time and the target moving bit number or the target moving clock information, and the target audio data is received according to the moving time.
4. The method for transmitting audio data according to claim 2, characterized in that: The frame clock signal changes at least from a high level to a low level, or from a low level to a high level.
5. The method for transmitting audio data according to claim 4, characterized in that: The data format includes at least one or more of the following formats: The highest bit data of the audio data is placed in the data format of the m serial clock signals before the frame clock signal changes, or the highest bit data of the audio data is placed in the data format of the m serial clock signals after the frame clock signal changes; The highest bit of the audio data is placed in the data format of n bytes before the frame clock signal changes, or the highest bit of the audio data is placed in the data format of n bytes after the frame clock signal changes; When the data transmission of the preset position of the audio data is completed, the data format in which the level of the frame clock signal is flipped in the current cycle or k cycles; k is a natural number greater than 1.
6. The method for transmitting audio data according to claim 1, characterized in that: The audio data is transmitted between the transmitting end device and the receiving end device via two channels or multiple channels.
7. An audio data transmission device, characterized in that: The device comprises: An acquisition module, used to acquire a first timestamp when the transmitting end device sends the audio data, and to acquire a second timestamp when the audio data is received; A determination module, configured to determine time delay information according to the first timestamp and the second timestamp; A calculation module, configured to determine a second data format corresponding to the time delay information according to the time delay information and a first data format of the audio data sent by the transmitting end device; A receiving module, configured to receive the audio data sent by the transmitting end device according to the second data format; The second data format is determined by shifting the audio data forward or backward by n bytes or m serial clock signals according to the serial clock signal of the audio data sent by the transmitting device, where n and m are natural numbers greater than 0.
8. The audio data transmission device according to claim 7, characterized in that: The computing module is used for: When the frame clock signal changes, obtaining the first moment when the serial clock signal changes; Determine a moving direction and moving parameters corresponding to the first moment according to the first moment and the time delay information, wherein the moving direction at least includes forward or backward, and the moving parameters at least include target moving bit number or target moving clock information; A second data format corresponding to the time delay information is determined according to the moving direction, the moving parameters and the first data format corresponding to the first moment.
9. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor can implement the audio data transmission method described in any one of claims 1 to 6 when executing the program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the program, when executed by a processor, can implement the audio data transmission method described in any one of claims 1 to 6.