CN116347319A - Audio data transmission method, device, earphone, earphone set and medium - Google Patents

Audio data transmission method, device, earphone, earphone set and medium Download PDF

Info

Publication number
CN116347319A
CN116347319A CN202111583097.XA CN202111583097A CN116347319A CN 116347319 A CN116347319 A CN 116347319A CN 202111583097 A CN202111583097 A CN 202111583097A CN 116347319 A CN116347319 A CN 116347319A
Authority
CN
China
Prior art keywords
earphone
recording data
data
recording
audio data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111583097.XA
Other languages
Chinese (zh)
Other versions
CN116347319B (en
Inventor
包建全
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202111583097.XA priority Critical patent/CN116347319B/en
Publication of CN116347319A publication Critical patent/CN116347319A/en
Application granted granted Critical
Publication of CN116347319B publication Critical patent/CN116347319B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04SSTEREOPHONIC SYSTEMS 
    • H04S7/00Indicating arrangements; Control arrangements, e.g. balance control
    • H04S7/30Control circuits for electronic adaptation of the sound field
    • H04S7/308Electronic adaptation dependent on speaker or headphone connection
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04RLOUDSPEAKERS, MICROPHONES, GRAMOPHONE PICK-UPS OR LIKE ACOUSTIC ELECTROMECHANICAL TRANSDUCERS; ELECTRIC HEARING AIDS; PUBLIC ADDRESS SYSTEMS
    • H04R1/00Details of transducers, loudspeakers or microphones
    • H04R1/10Earpieces; Attachments therefor ; Earphones; Monophonic headphones
    • H04R1/1041Mechanical or electronic switches, or control elements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W56/00Synchronisation arrangements
    • H04W56/001Synchronization between nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Physics & Mathematics (AREA)
  • Acoustics & Sound (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

本申请提供了一种音频数据传输方法、装置、耳机、耳机组及介质。该音频数据传输方法包括:在第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据;若第一录音数据与第一耳机缓存的第二录音数据不同步,则根据第一录音数据获取第三录音数据,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据;根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。本申请能够避免发生数据丢失,保证录音效果。

Figure 202111583097

The present application provides an audio data transmission method, device, earphone, earphone set and medium. The audio data transmission method includes: when the first earphone is switched from the slave earphone to the master earphone, receiving the first recording data sent by the second earphone; if the first recording data is not synchronized with the second recording data buffered by the first earphone , the third recording data is obtained according to the first recording data, and the third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data; according to the first recording data, the second recording data and the first recording data 3. The recorded data generates synthesized recorded data. This application can avoid data loss and ensure the recording effect.

Figure 202111583097

Description

音频数据传输方法、装置、耳机、耳机组及介质Audio data transmission method, device, earphone, earphone set and medium

技术领域technical field

本申请涉及音频设备技术领域,特别是涉及一种音频数据传输方法、装置、耳机、耳机组及介质。The present application relates to the technical field of audio equipment, in particular to an audio data transmission method, device, earphone, earphone set and medium.

背景技术Background technique

随着科技的快速发展,耳机已经得到越来越广泛的应用。一些带有麦克风的耳机除了实现音频的播放,还用于实现音频的录制。为了实现立体声录音,可以使用两个耳机的麦克风分别进行收音录制。With the rapid development of science and technology, earphones have been used more and more widely. Some earphones with microphones are also used to record audio in addition to audio playback. In order to achieve stereo recording, the microphones of the two earphones can be used for radio recording respectively.

发明内容Contents of the invention

本申请实施例提供了一种音频数据传输方法、装置、第一耳机、第二耳机、耳机组及介质,可以避免发生数据丢失,保证录音效果。The embodiment of the present application provides an audio data transmission method, device, first earphone, second earphone, earphone set and medium, which can avoid data loss and ensure recording effect.

一种音频数据传输方法,应用于耳机组的第一耳机,耳机组还包括第二耳机,方法包括:在第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据;若第一录音数据与第一耳机缓存的第二录音数据不同步,则根据第一录音数据获取第三录音数据,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据;根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。An audio data transmission method, which is applied to a first earphone of an earphone set, and the earphone set also includes a second earphone. The method includes: when the first earphone is switched from the slave earphone to the master earphone, receiving the first recording data; if the first recording data is not synchronized with the second recording data buffered by the first headphone, the third recording data is obtained according to the first recording data, and the third recording data is the difference between the first recording data and the second recording data synchronizing the audio data corresponding to the part; generating synthesized recording data according to the first recording data, the second recording data and the third recording data.

一种音频数据传输方法,应用于耳机组的第二耳机,耳机组还包括第一耳机,方法包括:在第二耳机由主耳机切换为从耳机的情况下,发送第一录音数据及从耳录音数据至第一耳机;其中,第一录音数据为第二耳机录制的音频数据,从耳录音数据为第一耳机作为从耳机时录制并发送至第二耳机的音频数据;第一耳机用于在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,并根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据;第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据。An audio data transmission method, applied to the second earphone of the earphone set, the earphone set also includes the first earphone, the method includes: when the second earphone is switched from the master earphone to the slave earphone, sending the first recording data and the slave earphone Recording data to the first earphone; wherein, the first recording data is the audio data recorded by the second earphone, and the ear recording data is the audio data recorded and sent to the second earphone when the first earphone is used as the slave earphone; the first earphone is used for When the first recording data is not synchronized with the second recording data buffered by the first earphone, the third recording data is obtained according to the first recording data, and the synthesized recording data is generated according to the first recording data, the second recording data and the third recording data ; The third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data.

一种音频数据传输方法,应用于耳机组,耳机组包括第一耳机和第二耳机,方法包括:在第一耳机由从耳机切换为主耳机的情况下,第二耳机将第一录音数据发送至第一耳机;第一录音数据为第二耳机录制的音频数据;第一耳机在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,并根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据;第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据。An audio data transmission method, applied to an earphone set, the earphone set includes a first earphone and a second earphone, the method includes: when the first earphone is switched from the slave earphone to the master earphone, the second earphone sends the first recording data To the first earphone; the first recording data is the audio data recorded by the second earphone; when the first recording data is not synchronized with the second recording data buffered by the first earphone, the first earphone obtains the third recording data according to the first recording data , and generate synthesized recording data according to the first recording data, the second recording data and the third recording data; the third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data.

一种音频数据传输装置,应用于耳机组的第一耳机,耳机组还包括第二耳机,装置包括:第一接收模块,用于在第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据;数据获取模块,用于在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据;数据合成模块,用于根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。An audio data transmission device, applied to a first earphone of an earphone set, the earphone set also includes a second earphone, and the device includes: a first receiving module, used to receive The first recording data sent by the second earphone; the data acquisition module is used to obtain the third recording data according to the first recording data when the first recording data is not synchronized with the second recording data buffered by the first earphone, and the third recording data It is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data; the data synthesis module is used to generate synthesized recording data according to the first recording data, the second recording data and the third recording data.

一种第一耳机,包括存储器及处理器,存储器中储存有计算机程序,计算机程序被处理器执行时,使得处理器执行以下步骤:在第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据;若第一录音数据与第一耳机缓存的第二录音数据不同步,则根据第一录音数据获取第三录音数据,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据;根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。A first earphone, comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor performs the following steps: when the first earphone is switched from the slave earphone to the master earphone, receiving The first recording data sent by the second earphone; if the first recording data is not synchronized with the second recording data buffered by the first earphone, the third recording data is obtained according to the first recording data, and the third recording data is relative to the first recording data Audio data corresponding to the asynchronous part of the second recording data; generating synthesized recording data according to the first recording data, the second recording data and the third recording data.

一种第二耳机,包括存储器及处理器,存储器中储存有计算机程序,计算机程序被处理器执行时,使得处理器执行以下步骤:在第二耳机由主耳机切换为从耳机的情况下,发送第一录音数据及从耳录音数据至第一耳机;其中,第一录音数据为第二耳机录制的音频数据,从耳录音数据为第一耳机作为从耳机时录制并发送至第二耳机的音频数据;第一耳机用于在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,并根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据;第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据。A second earphone includes a memory and a processor, and a computer program is stored in the memory, and when the computer program is executed by the processor, the processor performs the following steps: when the second earphone is switched from the master earphone to the slave earphone, sending The first recording data and the recording data from the ear to the first earphone; wherein, the first recording data is the audio data recorded by the second earphone, and the recording data from the ear is the audio recorded and sent to the second earphone when the first earphone is used as the earphone data; the first earphone is used to obtain the third recording data according to the first recording data when the first recording data is not synchronized with the second recording data buffered by the first earphone, and obtain the third recording data according to the first recording data, the second recording data and the first recording data Synthetic recording data is generated from the third recording data; the third recording data is audio data corresponding to the asynchronous part of the first recording data relative to the second recording data.

一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现如上述的方法的步骤。A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned method are realized.

一种耳机组,包括应用如上述的音频数据传输方法的第一耳机和第二耳机。An earphone set includes a first earphone and a second earphone to which the above-mentioned audio data transmission method is applied.

上述音频数据传输方法、装置、耳机、耳机组及介质,在第一耳机与第二耳机发生主从切换的情况下,切换为主耳机的第一耳机接收第二耳机发送的第一录音数据,若第一录音数据与第一耳机缓存的第二录音数据不同步,则根据第一录音数据获取第三录音数据,第三录音数据即为第一录音数据相对于第二录音数据的不同步部分对应的音频数据,根据第一录音数据、第二录音数据及第三录音数据生成合成录音数据,合成录音数据即为需要发送至终端设备的双耳录音数据,使得耳机能够支持双耳立体声录音,并且能够保证耳机在发生主从切换的情况下不会发生数据丢失,保证录制效果。In the above audio data transmission method, device, earphone, earphone set and medium, in the case of a master-slave switch between the first earphone and the second earphone, the first earphone switched to be the master earphone receives the first recording data sent by the second earphone, If the first recording data is not synchronized with the second recording data buffered by the first earphone, the third recording data is obtained according to the first recording data, and the third recording data is the asynchronous part of the first recording data relative to the second recording data For the corresponding audio data, synthesized recording data is generated according to the first recording data, the second recording data and the third recording data, and the synthesized recording data is the binaural recording data that needs to be sent to the terminal device, so that the earphone can support binaural stereo recording, And it can ensure that the headset will not lose data when the master-slave switch occurs, and the recording effect is guaranteed.

附图说明Description of drawings

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present application. Those skilled in the art can also obtain other drawings based on these drawings without creative work.

图1为一个实施例中音频数据传输方法的应用环境图;Fig. 1 is an application environment diagram of an audio data transmission method in an embodiment;

图2为一个实施例中音频数据传输方法的流程图;Fig. 2 is the flowchart of audio data transmission method in an embodiment;

图3为一个实施例中步骤根据第一录音数据获取第三录音数据的流程图;Fig. 3 is a flow chart of steps obtaining the third recording data according to the first recording data in one embodiment;

图4为一个实施例中发生主从切换前耳机组的录音数据传输示意图;Fig. 4 is a schematic diagram of recording data transmission of the earphone set before master-slave switching occurs in one embodiment;

图5为一个实施例中发生主从切换后耳机组的录音数据传输示意图;Fig. 5 is a schematic diagram of recording data transmission of the earphone set after the master-slave switch occurs in one embodiment;

图6为另一个实施例中步骤根据第一录音数据获取第三录音数据的流程图;FIG. 6 is a flow chart of steps obtaining third recording data according to the first recording data in another embodiment;

图7为另一个实施例中发生主从切换前耳机组的录音数据传输示意图;Fig. 7 is a schematic diagram of recording data transmission of the earphone set before master-slave switching occurs in another embodiment;

图8为另一个实施例中发生主从切换后耳机组的录音数据传输示意图;FIG. 8 is a schematic diagram of recording data transmission of the earphone set after master-slave switching occurs in another embodiment;

图9为一个实施例中音频数据传输装置的结构框图;Fig. 9 is a structural block diagram of an audio data transmission device in an embodiment;

图10为一个实施例中第一耳机或第二耳机的内部结构示意图;Fig. 10 is a schematic diagram of the internal structure of the first earphone or the second earphone in an embodiment;

图11为一个实施例中耳机组的结构示意图。Fig. 11 is a schematic structural diagram of an earphone set in an embodiment.

具体实施方式Detailed ways

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the purpose, technical solution and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present application, and are not intended to limit the present application.

可以理解,本申请所使用的术语“第一”、“第二”等可在本文中用于描述各种技术特征,但这些技术特征不受这些术语限制。这些术语仅用于将第一个技术特征与另一个技术特征区分。举例来说,在不脱离本申请的范围的情况下,可以将第一耳机称为第二耳机,且类似地,可将第二耳机称为第一耳机。第一耳机和第二耳机两者都是耳机组中的其中一只(或一组)耳机,但其不是同一耳机。It can be understood that the terms "first" and "second" used in this application may be used to describe various technical features herein, but these technical features are not limited by these terms. These terms are only used to distinguish the first technical feature from another technical feature. For example, a first headset could be termed a second headset, and, similarly, a second headset could be termed a first headset, without departing from the scope of the present application. Both the first earphone and the second earphone are one (or a group) of earphones in the earphone set, but they are not the same earphone.

图1为一个实施例中音频数据传输方法的应用环境示意图。如图1所示,该应用环境包括终端设备101和耳机组102,耳机组102包括第一耳机1021和第二耳机1022。其中,终端设备101通过与耳机组102中的主耳机进行通信,主耳机与从耳机进行通信,即主耳机与终端设备101建立通信连接,从耳机与主耳机建立通信连接,从耳机监听主耳机与终端设备101之间的通信连接。在终端设备101需要发送数据至耳机组102时,终端设备101发送至主耳机,主耳机再将需要发送至从耳机的数据发送至从耳机。同理,从耳机需要向终端设备发送数据时,需要将数据发送至主耳机,主耳机再发送至终端设备101。第一耳机1021和第二耳机1022其中一个作为主耳机,另一个则为从耳机,在满足主从切换条件时,还会相互切换。具体的,若第二耳机1022为主耳机,则第一耳机1021为从耳机,在满足主从切换条件时,第一耳机1021切换为主耳机,此时第二耳机1022则切换为从耳机。Fig. 1 is a schematic diagram of an application environment of an audio data transmission method in an embodiment. As shown in FIG. 1 , the application environment includes a terminal device 101 and an earphone set 102 , and the earphone set 102 includes a first earphone 1021 and a second earphone 1022 . Wherein, the terminal device 101 communicates with the master earphone in the earphone set 102, the master earphone communicates with the slave earphone, that is, the master earphone establishes a communication connection with the terminal device 101, the slave earphone establishes a communication connection with the master earphone, and the slave earphone monitors the master earphone Communication connection with the terminal device 101. When the terminal device 101 needs to send data to the earphone set 102, the terminal device 101 sends the data to the master earphone, and the master earphone then sends the data to be sent to the slave earphone to the slave earphone. Similarly, when the slave earphone needs to send data to the terminal device, it needs to send the data to the master earphone, and the master earphone then sends the data to the terminal device 101 . One of the first earphone 1021 and the second earphone 1022 serves as the master earphone, and the other serves as the slave earphone, and they will switch between each other when the master-slave switching condition is met. Specifically, if the second earphone 1022 is the master earphone, the first earphone 1021 is the slave earphone. When the master-slave switching condition is met, the first earphone 1021 is switched to the master earphone, and the second earphone 1022 is then switched to the slave earphone.

其中,终端设备101可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑、物联网设备和便携式可穿戴设备,物联网设备可为智能电视、智能车载设备等。便携式可穿戴设备可为智能手表、智能手环、头戴设备等。耳机组为真无线立体声耳机(TWS耳机)或其他类型的蓝牙耳机。Wherein, the terminal device 101 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices, and the Internet of Things devices may be smart TVs, smart vehicle-mounted devices, and the like. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, and the like. The earphone set is a true wireless stereo earphone (TWS earphone) or other types of Bluetooth earphones.

在耳机组进行立体声录音时,耳机组102与终端设备101成功建立通信连接后,响应于终端设备101发送的开始录音指令而执行录音动作。耳机组102有第一耳机和第二耳机,分别为主耳机和从耳机,比如第一耳机为主耳机时,则第二耳机为从耳机。主耳机与从耳机分别通过各自的麦克风进行音频数据的采集,并分别对采集的音频数据进行编码,从耳机将编码后生成的从录音数据包存至缓存区中,通过与主耳机建立的通信连接将从录音数据包发送至主耳机;主耳机对其麦克风采集的音频数据进行编码生成主录音数据包,并将主录音数据包存至本地缓存区中。主耳机接收从耳机发送的从录音数据包,将从录音数据包存至从缓存区。其中,从耳机可以根据预设周期向主耳机发送从录音数据包;也可以在接收到主耳机发送的指示时向主耳机发送从录音数据包;在一些实施例中,从耳机可以每生成一个从录音数据包后发送一次数据至主耳机;在另一个实施例中,从耳机可以在缓存区内的从录音数据包数量达到预设值时向主耳机发送从录音数据包。在启动上行发送时,主耳机在本地缓存区中获取主录音数据包,并在从缓存区中依次获取从录音数据包与主录音数据包进行同步比对,比对为同步的主录音数据包与从录音数据包则合并为双耳数据包,通过与终端设备之间的通信连接将双耳数据包发送至终端设备。When the earphone set performs stereo recording, after the earphone set 102 successfully establishes a communication connection with the terminal device 101 , it performs a recording action in response to a recording start instruction sent by the terminal device 101 . The earphone set 102 has a first earphone and a second earphone, which are master earphones and slave earphones respectively. For example, when the first earphone is the master earphone, the second earphone is the slave earphone. The master earphone and the slave earphone collect audio data through their respective microphones, and encode the collected audio data respectively. The slave earphone stores the encoded slave recording data packets in the buffer area, and communicates with the master earphone The connection will send the slave recording data packet to the main earphone; the master earphone encodes the audio data collected by its microphone to generate the main recording data packet, and stores the main recording data packet in the local buffer. The master earphone receives the slave recording data packet sent from the slave earphone, and stores the slave recording data packet into the slave buffer. Wherein, the slave earphone can send the slave recording data packet to the master earphone according to the preset cycle; it can also send the slave recording data packet to the master earphone when receiving the instruction sent by the master earphone; in some embodiments, the slave earphone can generate a Send data to the master earphone once after the slave recording data packet; in another embodiment, the slave earphone can send the slave recording data packet to the master earphone when the number of slave recording data packets in the buffer reaches a preset value. When the uplink transmission is started, the master earphone obtains the main recording data packet in the local buffer area, and sequentially obtains the slave recording data packet and the main recording data packet in the slave buffer area for synchronous comparison, and the comparison is a synchronous main recording data packet The binaural data packet is combined with the slave recording data packet, and the binaural data packet is sent to the terminal device through the communication connection with the terminal device.

使用耳机组的两个耳机中分别设置的麦克风进行音频录制时,可以达到双耳录音的效果,但是在录制的过程中,由于耳机的主耳机既负责与手机进行数据传输,同时还负责将接收到的从耳录制的音频数据发送给手机,故主耳机会更耗电一些,当主从耳电量差异较大时就需要进行主从切换,即当主耳机电量较低时可能会发生主从切换,即将主耳机切换为从耳机,从耳机切换为主耳机。在一些情况下,用户摘下主耳机,也会触发主从切换。在其中一个实施例中,若主耳机与终端设备之间的通信信号较差,也可能会触发主从切换。而在发生主从切换时,在进行双耳录音的耳机组可能会发生数据丢失。When using the microphones set in the two earphones of the earphone group for audio recording, the effect of binaural recording can be achieved, but during the recording process, since the main earphone of the earphone is not only responsible for data transmission with the mobile phone, The audio data recorded from the slave earphone is sent to the mobile phone, so the main earphone will consume more power. When the power difference between the master earphone and the slave earphone is large, the master-slave switch needs to be performed, that is, the master-slave switch may occur when the power of the master earphone is low. That is to switch the master earphone to the slave earphone, and switch the slave earphone to the master earphone. In some cases, the user takes off the master earphone, which will also trigger the master-slave switch. In one of the embodiments, if the communication signal between the master earphone and the terminal device is poor, the master-slave switch may also be triggered. When master-slave switching occurs, data loss may occur in the headphone set for binaural recording.

为防止数据丢失,本申请提供一种音频数据传输方法。图2为一个实施例中音频数据传输方法的流程图。本实施例中的音频数据传输方法,以运行于图1中的第一耳机1021上为例进行描述。如图2所示,音频数据传输方法包括步骤201至步骤203。To prevent data loss, the present application provides an audio data transmission method. Fig. 2 is a flowchart of an audio data transmission method in an embodiment. The audio data transmission method in this embodiment is described by taking the operation on the first earphone 1021 in FIG. 1 as an example. As shown in FIG. 2 , the audio data transmission method includes step 201 to step 203 .

步骤201,在第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据。Step 201, when the first earphone is switched from the slave earphone to the master earphone, receive the first recording data sent by the second earphone.

其中,第一录音数据为第二耳机录制的音频数据,包括第二耳机在切换为从耳机之前录制的且未发送至终端设备的音频数据,和/或,第二耳机在切换为从耳机后录制的音频数据。Wherein, the first recording data is the audio data recorded by the second earphone, including audio data recorded by the second earphone before switching to the slave earphone and not sent to the terminal device, and/or, after the second earphone is switched to the slave earphone Recorded audio data.

步骤202,若第一录音数据与第一耳机缓存的第二录音数据不同步,则根据第一录音数据获取第三录音数据。Step 202, if the first recording data is not synchronized with the second recording data buffered by the first earphone, then obtain third recording data according to the first recording data.

其中,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据。第二录音数据为第一耳机录制的还未发送至终端设备的音频数据,可选的是,第二录音数据还可以包括第一耳机在切换为主耳机后录制的并且还未发送至终端设备的音频数据;在一些实施例中,第二录音数据还可以包括第一耳机在切换为主耳机之前录制的但未发送给原主耳机(即第二耳机)的音频数据。在发生主从切换之前,第一耳机作为从耳机录制音频数据并发送至作为主耳机的第二耳机,这部分音频数据中还未发送至终端设备的即为第三录音数据。Wherein, the third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data. The second recording data is the audio data recorded by the first earphone and has not been sent to the terminal device. Optionally, the second recording data may also include the audio data recorded by the first earphone after switching to the main earphone and not yet sent to the terminal device In some embodiments, the second recording data may also include audio data recorded by the first earphone before switching to the master earphone but not sent to the original master earphone (ie, the second earphone). Before the master-slave switch occurs, the first earphone records audio data as the slave earphone and sends it to the second earphone as the master earphone, and the part of the audio data that has not been sent to the terminal device is the third recording data.

若第一录音数据包括了第二耳机在切换为从耳机之前录制的音频数据,可能发生第一录音数据与第二录音数据不同步的情况。原因在于,第一耳机在切换为主耳机之前录制的音频数据已经发送给作为主耳机的第二耳机,并在第一耳机的本地缓存区中将此数据删除;当耳机出现主从切换时,原来的第二耳机变成从耳机,导致原来的第一耳机(原从耳机)转发给第二耳机的音频数据可能未来得及发送给终端设备(比如终端设备与第二耳机信号较差时或者干扰信号太强时,一个数据包需要经过多次重传才能发送成功);而发生主从切换后,第二耳机将其录制的音频数据发送给第一耳机(现主耳机),此数据是比较完整的,而对于第一耳机在切换为主耳机之前录制的音频数据,第一耳机的本地缓存已经没有相关数据,那么主从切换前的音频数据就不同步,存在数据丢失。此时则需要找回缺失的第三录音数据,第三录音数据与第二耳机在切换为从耳机之前录制的且未发送至终端设备的音频数据同步,根据第一录音数据找回第三录音数据。If the first recording data includes the audio data recorded by the second earphone before switching to the slave earphone, it may happen that the first recording data is out of sync with the second recording data. The reason is that the audio data recorded by the first earphone before switching to the master earphone has been sent to the second earphone as the master earphone, and this data is deleted in the local buffer area of the first earphone; when the master-slave switch occurs in the earphone, The original second earphone becomes the slave earphone, so the audio data forwarded from the original first earphone (original slave earphone) to the second earphone may not be sent to the terminal device in time (for example, when the signal between the terminal device and the second earphone is poor or there is interference When the signal is too strong, a data packet needs to be retransmitted multiple times before it can be successfully sent); after the master-slave switch occurs, the second earphone sends its recorded audio data to the first earphone (now the master earphone), this data is compared Complete, but for the audio data recorded by the first earphone before switching to the master earphone, the local cache of the first earphone has no relevant data, then the audio data before the master-slave switch is not synchronized, and there is data loss. At this time, it is necessary to retrieve the missing third recording data. The third recording data is synchronized with the audio data recorded by the second earphone before switching to the slave earphone and not sent to the terminal device, and the third recording is retrieved based on the first recording data. data.

可选的,判断第一录音数据与第二录音数据是否同步,可以将第一录音数据的第一同步信息与第二录音数据的第二同步信息进行比对进行确定。可以理解的是,第一同步信息为第二耳机对录制的音频数据添加的标识信息,第二同步信息为第一耳机对录制的音频数据添加的标识信息。Optionally, to determine whether the first recording data is synchronized with the second recording data, it may be determined by comparing the first synchronization information of the first recording data with the second synchronization information of the second recording data. It can be understood that the first synchronization information is identification information added to the recorded audio data by the second earphone, and the second synchronization information is identification information added to the recorded audio data by the first earphone.

示例性的,第一同步信息与第二同步信息可以是用于标识时间帧的时间戳信息,也可以是用于标识录制顺序的序列号信息或者其他数据标识信息。Exemplarily, the first synchronization information and the second synchronization information may be time stamp information used to identify a time frame, or may be sequence number information or other data identification information used to identify a recording sequence.

若第一同步信息与第二同步信息不匹配,则判定第一录音数据与第二录音数据不同步。若第一同步信息与第二同步信息匹配,则判定第一录音数据与第二录音数据同步。通过采用同步信息比对的方式来判断第一录音数据与第二录音数据是否匹配,判断过程简单,易于执行。If the first synchronization information does not match the second synchronization information, it is determined that the first recording data is not synchronized with the second recording data. If the first synchronization information matches the second synchronization information, it is determined that the first recording data is synchronized with the second recording data. Judging whether the first recording data matches the second recording data by using the synchronous information comparison method, the judgment process is simple and easy to execute.

在其中一个实施例中,第一同步信息和第二同步信息是在对音频数据编码前加入的。在本实施例中,第一耳机需要先将接收的第一录音数据解码后获取到第一同步信息与第二同步信息进行比对,再对同步的第一录音数据和第二录音数据和/或第三录音数据进行编码后生成双耳数据包。In one of the embodiments, the first synchronization information and the second synchronization information are added before encoding the audio data. In this embodiment, the first earphone needs to first decode the received first recording data and compare the obtained first synchronization information with the second synchronization information, and then compare the synchronized first recording data with the second recording data and/or Or the third recording data is encoded to generate a binaural data packet.

在其中一个实施例中,第一同步信息和第二同步信息是在对音频数据编码后加入的。在本实施例中,第一耳机可以直接对接收到的编码后的第一录音数据和第二录音数据或第三录音数据进行同步信息的比对,比对为同步则生成为合成录音数据进行发送,减少第一耳机的数据处理过程,提高数据传输效率。在其中一个实施例中,同步比对可以通过录制时间进行比对,比较音频数据的录制时间,相同录制时间的数据(数据包)为同步的数据(或数据包);或者第一耳机和第二耳机采用相同的数据录制机制,在同一时间段录制的音频被标识有相同的序列号,通过序列号进行同步对比。步骤203,根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。In one of the embodiments, the first synchronization information and the second synchronization information are added after encoding the audio data. In this embodiment, the first earphone can directly compare the received encoded first recording data with the second recording data or the third recording data for synchronization information, and if the comparison is synchronous, it will be generated as synthetic recording data for further processing. Send, reduce the data processing process of the first earphone, and improve the data transmission efficiency. In one of the embodiments, the synchronous comparison can be compared by recording time, comparing the recording time of audio data, the data (data packet) of the same recording time is synchronous data (or data packet); or the first earphone and the second earphone The two earphones use the same data recording mechanism, and the audio recorded at the same time period is marked with the same serial number, and the serial number is used for synchronous comparison. Step 203, generating synthesized recording data according to the first recording data, the second recording data and the third recording data.

其中,合成录音数据包括有第一耳机录制的以及第二耳机录制的一段时间内的音频数据;合成录音数据可用于发送至终端设备。Wherein, the synthesized recording data includes the audio data recorded by the first earphone and the audio data recorded by the second earphone within a period of time; the synthesized recording data can be used to send to the terminal device.

可以理解的是,可将双耳录制的经比对为同步的音频数据进行合成,以发送给终端设备。在本申请实施例中,可根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。可选的,第一耳机先合成第一耳机数据,第一耳机数据包括第一耳机在主从切换前录制的第三录音数据,以及在主从切换后录制的第二录音数据,并且第三录音数据与第二录音数据在时间上有连续性,根据时间顺序可以对第二录音数据与第三录音数据进行拼接,合成为第一耳机数据。在此基础上,再将第一耳机数据与第一录音数据合成为双耳录音数据。第一录音数据即为第二耳机录制的音频数据,从而可以实现双耳机录制数据的同步。当同步成功后,将主耳机的数据和从耳机的数据合并打包成一包数据后,通过无线通信(例如蓝牙通信、ZigBee通信等方式)发送至终端设备。It can be understood that the binaurally recorded and compared audio data can be synthesized to be sent to the terminal device. In the embodiment of the present application, synthesized recording data may be generated according to the first recording data, the second recording data and the third recording data. Optionally, the first earphone first synthesizes the first earphone data, the first earphone data includes the third recording data recorded by the first earphone before the master-slave switching, and the second recording data recorded after the master-slave switching, and the third The recording data and the second recording data are continuous in time, and the second recording data and the third recording data can be spliced according to the time sequence to synthesize the first earphone data. On this basis, the first headphone data and the first recording data are synthesized into binaural recording data. The first recording data is the audio data recorded by the second earphone, so that the synchronization of the recording data of the two earphones can be realized. After the synchronization is successful, the data of the master earphone and the data of the slave earphone are combined and packaged into a packet of data, and then sent to the terminal device through wireless communication (such as Bluetooth communication, ZigBee communication, etc.).

在其中一个实施例中,可将双耳录制的同步音频数据进行合成,以发送给终端设备。在启动上行发送时,读取第一录音数据中的录制顺序最早的音频数据,并读取第二录音数据中的录制顺序最早的音频数据,比较两个数据的同步信息是否匹配,若匹配则合成为合成录音数据发送至终端设备。若不匹配,则获取与第一录音数据同步的第三录音数据,将两个数据合成为合成录音数据,并发送至终端设备。In one of the embodiments, the synchronous audio data recorded by both ears can be synthesized and sent to the terminal device. When starting uplink transmission, read the audio data with the earliest recording order in the first recording data, and read the audio data with the earliest recording order in the second recording data, compare whether the synchronization information of the two data matches, if they match, then Synthesized into synthesized recording data and sent to the terminal equipment. If they do not match, the third recording data synchronized with the first recording data is obtained, the two data are synthesized into synthesized recording data, and sent to the terminal device.

由于此时第一耳机为主耳机,因此第一耳机与终端设备建立有通信连接,将合成录音数据发送至终端。Since the first earphone is the main earphone at this time, a communication connection is established between the first earphone and the terminal device, and the synthesized recording data is sent to the terminal.

在其中一个实施例中,成功发送至终端设备的音频数据将从缓存中释放。In one of the embodiments, the audio data successfully sent to the terminal device will be released from the buffer.

本实施例中的音频数据传输方法,在第一耳机和第二耳机发生主从切换后,切换为主耳机的第一耳机接收第二耳机发送的第一录音数据,若第一录音数据与第一耳机缓存的第二录音数据不同步,则根据第一录音数据获取第三录音数据,第三录音数据即为第一录音数据相对于第二录音数据的不同步部分对应的音频数据,根据第一录音数据、第二录音数据及第三录音数据生成合成录音数据,避免丢失第一耳机作为从耳机时录制的音频数据发生丢失,保证了录音数据的完整性,避免由于主从切换导致录音数据丢失而影响录制效果。并且,相比采用单耳录制的平衡立体声录音的耳机直接将单耳录音数据叠加作为双耳数据而言,本实施例中采用的是分别由两只(或两组)耳机单独录制实现的真立体声,能够表现真实的空间声场,提高音质。In the audio data transmission method in this embodiment, after the master-slave switch occurs between the first earphone and the second earphone, the first earphone switched to be the master earphone receives the first recording data sent by the second earphone. If the second recording data buffered by an earphone is not synchronized, the third recording data is obtained according to the first recording data. The third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data. According to the first recording data The first recording data, the second recording data and the third recording data generate synthetic recording data, avoiding the loss of the audio data recorded when the first earphone is used as the slave earphone, ensuring the integrity of the recording data, and avoiding the recording data due to master-slave switching Lost and affect the recording effect. In addition, compared with the balanced stereo recording earphones that use single ear recording to directly superimpose the single ear recording data as binaural data, what is used in this embodiment is the real recording achieved by two (or two groups) earphones respectively. Stereo, which can express the real spatial sound field and improve the sound quality.

为使得录制的音频数据完整,第一录音数据与第二录音数据不同步时,则需要找回缺失的录音数据。如图3所示,在其中一个实施例中,根据第一录音数据获取第三录音数据,包括:In order to make the recorded audio data complete, when the first recording data and the second recording data are out of sync, it is necessary to retrieve the missing recording data. As shown in Figure 3, in one of the embodiments, the third recording data is obtained according to the first recording data, including:

步骤301,将第一录音数据与第一耳机的备份区的音频数据进行同步比对。Step 301, synchronously comparing the first recording data with the audio data in the backup area of the first earphone.

其中,备份区用于备份第一耳机作为从耳机时录制并发送至第二耳机的音频数据。Wherein, the backup area is used for backing up the audio data recorded by the first earphone as the slave earphone and sent to the second earphone.

在其中一个实施例中,第一耳机作为从耳机时,每发送一次数据给第二耳机,就将这部分数据备份至备份区,并从主缓存区内清除。发送数据给第二耳机可以是录制完成一组数据就进行一次发送以及备份;也可以是根据预设的发送周期定期发送第一耳机主缓存区内还未发送至第二耳机的全部数据,并进行备份;在一些实施例中,还可以累计数据达到预设数量时发送一次至第二耳机,并进行备份。In one of the embodiments, when the first earphone serves as the slave earphone, every time data is sent to the second earphone, this part of the data is backed up to the backup area and cleared from the main buffer area. Sending data to the second earphone can be sending and backing up a set of data after recording a set of data; it can also be sending all the data in the main buffer area of the first earphone that has not been sent to the second earphone regularly according to the preset sending cycle, and Back up; in some embodiments, when the accumulated data reaches a preset amount, it can also be sent to the second earphone once and backed up.

步骤302,提取备份区内与第一录音数据同步的第三录音数据。Step 302, extract the third recording data synchronized with the first recording data in the backup area.

基于第一同步信息和第二同步信息同样/类似的比对原理和方法,可以根据第一录音数据的第一同步信息找到具有相匹配的第三同步信息的第三录音数据,通过将第一同步信息与需要比对的数据的同步标识信息进行比对,若匹配则确定为第三录音数据,第三同步信息为第一耳机作为从耳机时对录制的音频数据加入的标识信息。通过同步比对找到与第一录音数据同步的第三录音数据,从备份区将第三录音数据恢复缓存。Based on the same/similar comparison principle and method between the first synchronization information and the second synchronization information, the third recording data with matching third synchronization information can be found according to the first synchronization information of the first recording data, by combining the first The synchronization information is compared with the synchronization identification information of the data to be compared, and if they match, it is determined to be the third recording data, and the third synchronization information is the identification information added to the recorded audio data when the first earphone is used as the slave earphone. The third recording data synchronized with the first recording data is found through synchronous comparison, and the third recording data is restored to the cache from the backup area.

在其中一个实施例中,第一同步信息、第二同步信息和第三同步信息可以为时间戳或序列号。In one of the embodiments, the first synchronization information, the second synchronization information and the third synchronization information may be timestamps or serial numbers.

以序列号为例进行说明,第一耳机为录制的录音数据按照录制顺序依次加入序列号B1、B2、B3…,缓存至第一耳机的主缓存区;第二耳机为录制的录音数据按照录制顺序依次加入序列号A1、A2、A3…,缓存至第二耳机的主缓存区。Taking the serial number as an example, the recording data recorded by the first earphone is sequentially added with serial numbers B1, B2, B3... in order of recording, and cached in the main buffer area of the first earphone; the recording data recorded by the second earphone is recorded in accordance with the recording order. Add serial numbers A1, A2, A3... in sequence, and cache them in the main buffer of the second earphone.

参考图4所示,在第一耳机作为从耳机时,若启动发送,则按照录制顺序依次发送数据至第二耳机(此时为主耳机),第二耳机将接收到的数据(例如序列号为B2的数据)存入从缓存区。同时,第一耳机将发送成功的数据备份至备份区,并将该数据在主缓存区内清除。Referring to Fig. 4, when the first earphone is used as a slave earphone, if the transmission is started, the data will be sent to the second earphone in sequence according to the recording order (at this time, the master earphone), and the second earphone will receive the data (such as the serial number) The data of B2) is stored in the slave buffer. At the same time, the first earphone backs up the successfully sent data to the backup area, and clears the data in the main buffer area.

参考图5所示,在第一耳机切换为主耳机时,此时第二耳机切换为从耳机,第二耳机按照录制顺序依次将其主缓存区中的第一录音数据发送至第一耳机,第一耳机将接收到的该第一录音数据存入从缓存区内。在启动上行发送时,第一耳机读取主缓存区内的第二录音数据,并读取从缓存区内的第一录音数据,与读取的第二录音数据的序列号进行比对,若匹配(例如A1与B1为匹配的序列号),则确定为同步数据,将同步的数据合并为合成录音数据发送至终端设备。如果第二录音数据的序列号与第一录音数据的序列号均不匹配,即至少存在部分第一录音数据与第一耳机主缓存区内的数据无法同步,此时则认为发生了数据丢失,需要找回缺失的数据。第一耳机从备份区中读取录音数据(例如B2)与第一录音数据(A2)进行序列号比对,若匹配,则将匹配的录音数据与第一录音数据合并为合成录音数据。As shown in FIG. 5, when the first earphone is switched to be the master earphone, the second earphone is switched to be the slave earphone at this time, and the second earphone sends the first recording data in its main buffer area to the first earphone sequentially according to the recording order, The first earphone stores the received first recording data into the slave buffer. When starting uplink transmission, the first earphone reads the second recording data in the main buffer area, and reads the first recording data in the slave buffer area, and compares it with the serial number of the read second recording data, if If they match (for example, A1 and B1 are matching serial numbers), it is determined as synchronous data, and the synchronous data is combined into synthesized recording data and sent to the terminal device. If the serial number of the second recording data does not match the serial number of the first recording data, that is, at least part of the first recording data cannot be synchronized with the data in the main buffer area of the first earphone, then it is considered that data loss has occurred. Need to retrieve missing data. The first earphone reads the recorded data (for example B2) from the backup area and compares the serial numbers with the first recorded data (A2). If they match, the matched recorded data and the first recorded data are combined into synthesized recorded data.

可以理解的是,第一耳机的存储空间具有主缓存区和从缓存区,第一耳机的主缓存区用于缓存第二录音数据,第一耳机的从缓存区用于缓存第二耳机发送的音频数据(例如在第一耳机切换为主耳机时接收第二耳机发送的第一录音数据)。第二耳机的存储空间具有主缓存区和从缓区,第二耳机的主缓存区用于缓存第一录音数据,第二耳机的从缓存区用于缓存第一耳机发送的从录音数据。It can be understood that the storage space of the first earphone has a main buffer area and a slave buffer area, the main buffer area of the first earphone is used for buffering the second recording data, and the slave buffer area of the first earphone is used for buffering Audio data (for example, receiving the first recording data sent by the second earphone when the first earphone is switched to be the main earphone). The storage space of the second earphone has a main buffer area and a slave buffer area, the main buffer area of the second earphone is used for buffering the first recording data, and the slave buffer area of the second earphone is used for buffering the slave recording data sent by the first earphone.

本申请实施例中所提到的第一耳机的从缓存区可以是发生主从切换后新增的,也可以是自始存在的。第二耳机在切换为从耳机时可以新增备份区,也可以自始存在有备份区。第一耳机和第二耳机中的主缓存区、从缓存区、备份区可以是软件实现的虚拟分区,也可以是硬件实现的实体存储器。The slave buffer area of the first earphone mentioned in the embodiment of the present application may be newly added after the master-slave switch occurs, or may exist from the beginning. When the second earphone is switched to the slave earphone, a backup area can be added, or there can be a backup area from the beginning. The primary buffer area, the secondary buffer area, and the backup area in the first earphone and the second earphone may be virtual partitions implemented by software, or physical memories implemented by hardware.

由于无线耳机内存较小,若备份数据一直不进行释放将会影响其正常使用,本申请的一实施例中,在第一耳机作为从耳机时,根据预设规则释放备份区内的数据,可以设定释放的预设规则,达到释放条件时就释放备份数据。Since the memory of the wireless earphone is small, if the backup data is not released all the time, it will affect its normal use. In one embodiment of the application, when the first earphone is used as a slave earphone, the data in the backup area can be released according to preset rules, which can Set the default rules for release, and release the backup data when the release conditions are met.

在其中一个实施例中,预设规则可以是设定内存的阈值,在第一耳机的内存低于阈值时,释放备份区的音频数据。在其中一个实施例中,可以按照数据存入的顺序先后依次进行释放,优先释放先存入的数据。示例性的,在t时刻存入数据a1,t+1时刻存入数据a2,在内存低于阈值时,先释放数据a1,释放数据a1之后,如果内存还低于阈值,则再释放数据a2In one of the embodiments, the preset rule may be to set a memory threshold, and when the memory of the first earphone is lower than the threshold, release the audio data in the backup area. In one of the embodiments, the data may be released sequentially according to the order in which the data is stored, and the data stored first is released first. Exemplarily, store data a 1 at time t, store data a 2 at time t+1, release data a 1 first when the memory is lower than the threshold, after releasing data a 1 , if the memory is still lower than the threshold, then Data a 2 is released again.

在其中一个实施例中,预设规则还可以为根据预设周期按照数据的存入顺序依次释放。即,预设周期为T,每间隔T时间则按照数据的存入顺序释放一部分数据。示例性的,在t时刻存入数据a1,t+1时刻存入数据a2,间隔T时间,释放数据a1,再间隔T时间释放数据a2In one of the embodiments, the preset rule can also be that the data is released sequentially according to the order in which the data is stored according to the preset period. That is, the preset period is T, and at intervals of T, a part of data is released according to the order in which the data is stored. Exemplarily, data a 1 is stored at time t, data a 2 is stored at time t+1, data a 1 is released at an interval of T time, and data a 2 is released at an interval of T time.

在其中一个实施例中,可以结合预设周期及内存的阈值共同作为预设规则,可选的,根据预设周期进行释放,释放数据时根据内存剩余量确定需要释放的数据量,例如,在t时刻存入数据a1,t+1时刻存入数据a2,间隔T时间,释放数据a1,若释放数据a1后,内存高于阈值,则停止释放,直到下一个T时间再释放数据a2;若释放数据a1后,内存仍低于阈值,则继续释放数据,直至内存不低于阈值。In one of the embodiments, the preset period and the memory threshold can be combined as the preset rule. Optionally, the release is performed according to the preset period. When releasing data, the amount of data to be released is determined according to the remaining amount of memory. For example, in Store data a 1 at time t, store data a 2 at time t+1, and release data a 1 at an interval of T time. If the memory is higher than the threshold after releasing data a 1 , stop releasing until the next T time Data a 2 ; if the memory is still lower than the threshold after data a 1 is released, continue to release data until the memory is not lower than the threshold.

可选的是,还可以基于第二耳机的数据发送记录来释放备份区内的数据。可以理解的是,数据发送记录记录有第二耳机在作为主耳机时已完成发送的数据记录。第二耳机可以在每完成一组数据的发送时反馈一次数据发送记录至第一耳机,也可以定期反馈数据发送记录至第一耳机。第一耳机根据数据发送记录即可确定备份区内备份音频数据对应的数据已经经由第二耳机发送至终端设备,将这部分数据从备份区中进行释放。Optionally, the data in the backup area may also be released based on the data sending record of the second earphone. It can be understood that the data sending record records the data record that the second earphone has completed sending when it serves as the master earphone. The second earphone may feed back the data sending record to the first earphone once every time a set of data is sent, or may periodically feed back the data sending record to the first earphone. According to the data transmission record, the first earphone can determine that the data corresponding to the backup audio data in the backup area has been sent to the terminal device via the second earphone, and release this part of data from the backup area.

本实施例中第一耳机通过获取数据发送记录,根据数据发送记录对备份区内已完成发送的数据进行释放,减少备份数据对内存的占用,并且能够保证未发送的数据仍然存有备份,在发生主从切换时,能够恢复还未发送的数据,保证音频数据的完整性。In this embodiment, the first earphone releases the data that has been sent in the backup area according to the data sending record by acquiring the data sending record, so as to reduce the memory occupation of the backup data and ensure that the unsent data still has a backup. When a master-slave switch occurs, the data that has not been sent can be recovered to ensure the integrity of the audio data.

如图6所示,在其中一个实施例中,根据第一录音数据获取第三录音数据,包括:As shown in Figure 6, in one of the embodiments, the third recording data is obtained according to the first recording data, including:

步骤601,第一耳机获取第二耳机发送的从录音数据。Step 601, the first earphone acquires the slave recording data sent by the second earphone.

其中,从录音数据可以为第二耳机作为主耳机时接收的第一耳机录制的音频数据,并且为第二耳机还未发送至终端设备的数据。Wherein, the slave recording data may be audio data recorded by the first earphone received when the second earphone serves as the master earphone, and may be data not yet sent to the terminal device by the second earphone.

步骤602,将第一录音数据与从录音数据进行同步比对,从从录音数据中获取与第一录音数据同步的第三录音数据。Step 602: Synchronously compare the first recording data with the slave recording data, and obtain third recording data synchronized with the first recording data from the slave recording data.

示例性的,以利用序列号进行同步比对为例进行说明,第一耳机为录制的录音数据按照录制顺序依次加入序列号B1、B2、B3…,缓存至第一耳机的主缓存区;第二耳机为录制的录音数据按照录制顺序依次加入序列号A1、A2、A3…,缓存至第二耳机的主缓存区。Exemplarily, taking the use of serial numbers for synchronous comparison as an example, the first earphone adds serial numbers B1, B2, B3... to the recording data recorded in sequence according to the recording order, and caches them in the main buffer area of the first earphone; The recording data recorded by the second earphone is sequentially added with serial numbers A1, A2, A3... in order of recording, and cached in the main buffer area of the second earphone.

参考图7所示,在第一耳机作为从耳机时,若启动发送,则按照录制顺序依次发送数据至第二耳机(此时为主耳机),第二耳机将接收到的从录音数据(例如序列号为B1、B2的数据)存入从缓存区。同时,第一耳机将发送成功的数据从第一耳机的主缓存区内清除。Referring to Fig. 7, when the first earphone is used as the slave earphone, if the transmission is started, the data will be sent to the second earphone in sequence according to the recording order (the master earphone at this time), and the second earphone will receive the slave recording data (for example The data whose sequence numbers are B1 and B2) are stored in the slave cache. At the same time, the first earphone clears the successfully sent data from the main buffer area of the first earphone.

参考图8所示,在第一耳机切换为主耳机时,此时第二耳机切换为从耳机,第二耳机将主缓存区中的第一录音数据以及从缓存区内的从录音数据发送至第一耳机,第一耳机将接收到的第一录音数据和从录音数据存入从缓存区内(可以分别设置两个从缓存区,一个用于缓存第一录音数据,一个用于缓存从录音数据)。可以理解的是,从录音数据可以是在第一耳机判断第一录音数据与第二录音数据存在不同步部分时,再从第二耳机获取的;也可以是第二耳机与第一录音数据一起发送的。在启动上行发送时,第一耳机读取主缓存区内的第二录音数据,并读取从缓存区内的第一录音数据,与读取的第二录音数据的序列号进行比对,若匹配(例如A1与B1为匹配的序列号),则确定为同步数据,将同步的数据合并为合成录音数据发送至终端设备。如果第二录音数据的序列号与第一录音数据的序列号均不匹配,即至少存在部分第一录音数据与第一耳机主缓存区内的数据无法同步,此时则认为发生了数据丢失,需要找回缺失的数据。第一耳机读取从录音数据(例如B1)与第一录音数据(A1)进行序列号比对,若匹配,则将该录音数据确定为确实的第三录音数据,将第三录音数据与第一录音数据合并为合成录音数据。在本实施例中,在发生主从切换时,作为原主耳机的第二耳机将未发送至终端设备的从录音数据以及第一录音数据均发送至第一耳机,第一耳机将第一录音数据与从录音数据进行同步比对,在从录音数据中获取与第一录音数据同步的第三录音数据。本实施例能够节省从耳机的内存,并且保证在发生主从切换时不会发生数据丢失。As shown in Figure 8, when the first earphone is switched to be the master earphone, the second earphone is now switched to be the slave earphone, and the second earphone will send the first recording data in the master buffer area and the slave recording data in the slave buffer area to The first earphone, the first earphone stores the received first recording data and slave recording data into the slave buffer area (two slave buffer areas can be set respectively, one for buffering the first recording data and one for buffering the slave recording data). It can be understood that the recorded data can be obtained from the second earphone when the first earphone judges that there is an asynchronous part between the first recorded data and the second recorded data; sent. When starting uplink transmission, the first earphone reads the second recording data in the main buffer area, and reads the first recording data in the slave buffer area, and compares it with the serial number of the read second recording data, if If they match (for example, A1 and B1 are matching serial numbers), it is determined as synchronous data, and the synchronous data is combined into synthesized recording data and sent to the terminal device. If the serial number of the second recording data does not match the serial number of the first recording data, that is, at least part of the first recording data cannot be synchronized with the data in the main buffer area of the first earphone, then it is considered that data loss has occurred. Need to retrieve missing data. The first earphone reads and compares the sequence number from the recording data (such as B1) with the first recording data (A1), if it matches, then the recording data is determined to be the sure third recording data, and the third recording data is compared with the first recording data. One recorded data is merged into synthesized recorded data. In this embodiment, when master-slave switching occurs, the second earphone as the original master earphone sends both the slave recording data and the first recording data not sent to the terminal device to the first earphone, and the first earphone sends the first recording data Synchronously comparing with the slave recording data, the third recording data synchronized with the first recording data is obtained from the slave recording data. This embodiment can save the memory of the slave earphone, and ensure that no data loss occurs when the master-slave switch occurs.

本申请实施例中还提供了一种音频数据传输方法,以应用于耳机组为例进行说明,耳机组包括第一耳机和第二耳机,方法包括:The embodiment of the present application also provides an audio data transmission method, which is applied to an earphone set as an example for illustration. The earphone set includes a first earphone and a second earphone. The method includes:

在第二耳机由主耳机切换为从耳机的情况下,发送第一录音数据及从录音数据至第一耳机;When the second earphone is switched from the master earphone to the slave earphone, send the first recording data and the slave recording data to the first earphone;

其中,第一录音数据为第二耳机录制的音频数据,从耳录音数据为第一耳机作为从耳机时录制并发送至第二耳机的音频数据;Wherein, the first recording data is the audio data recorded by the second earphone, and the ear recording data is the audio data recorded and sent to the second earphone when the first earphone is used as the slave earphone;

第一耳机用于在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,并根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据;第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据。The first earphone is used to obtain the third recording data according to the first recording data when the first recording data is not synchronized with the second recording data buffered by the first earphone, and obtain the third recording data according to the first recording data, the second recording data and the third recording data Synthetic recording data is generated from the data; the third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data.

在本实施例中,第二耳机由主耳机切换为从耳机,可能存在还未发送至终端的音频数据,此时第二耳机将其自身录制的还未发送至终端的第一录音数据发送至第一耳机,并且将第一耳机在作为从耳机时发送至第二耳机的从录音数据发送回第一耳机,以使第一耳机能够在第一录音数据与第二录音数据不同步时,根据第一录音数据在从录音数据中获取第三录音数据,并根据第一录音数据、第二录音数据及第三录音数据生成合成录音数据发送至终端设备,避免由于第一耳机与第二耳机发生主从切换导致数据丢失。In this embodiment, the second earphone is switched from the master earphone to the slave earphone. There may be audio data that has not been sent to the terminal. At this time, the second earphone sends the first recording data recorded by itself and has not been sent to the terminal. the first earphone, and send back the slave recording data that the first earphone sends to the second earphone when it is the slave earphone, so that the first earphone can, when the first recording data is not synchronized with the second recording data, The first recording data obtains the third recording data from the recording data, and generates synthetic recording data according to the first recording data, the second recording data and the third recording data and sends it to the terminal device, so as to avoid the occurrence of the first earphone and the second earphone Master-slave switching results in data loss.

本申请实施例中还提供了一种音频数据传输方法,应用于第一耳机和第二耳机构成的耳机组,包括:An embodiment of the present application also provides an audio data transmission method, which is applied to an earphone set composed of a first earphone and a second earphone, including:

在第一耳机由从耳机切换为主耳机的情况下,第二耳机将第一录音数据发送至第一耳机。When the first earphone is switched from the slave earphone to the master earphone, the second earphone sends the first recording data to the first earphone.

第一耳机在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,When the first recording data is not synchronized with the second recording data buffered by the first earphone, the first earphone obtains the third recording data according to the first recording data,

第一耳机根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。The first earphone generates synthesized recording data according to the first recording data, the second recording data and the third recording data.

其中,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据。第二录音数据为第一耳机录制的还未发送至终端设备的音频数据。具体的,第二录音数据可以包括第一耳机在切换为主耳机后录制的并且还未发送至终端设备的音频数据;在一些实施例中,第二录音数据还可以包括第一耳机在切换为主耳机之前录制的但未发送给原主耳机(即第二耳机)的音频数据。合成录音数据包括有第一耳机录制的以及第二耳机录制的一段时间内的音频数据;合成录音数据用于发送至终端设备。Wherein, the third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data. The second recording data is audio data recorded by the first earphone and not sent to the terminal device. Specifically, the second recording data may include audio data recorded by the first earphone after switching to the main earphone and not yet sent to the terminal device; in some embodiments, the second recording data may also include The audio data recorded by the main earphone but not sent to the original main earphone (that is, the second earphone). The synthesized recording data includes the audio data recorded by the first earphone and the audio data recorded by the second earphone within a period of time; the synthesized recording data is used to send to the terminal device.

在发生主从切换之前,第一耳机作为从耳机录制音频数据并发送至作为主耳机的第二耳机,这部分音频数据中还未发送至终端设备的即为第三录音数据。若第一录音数据包括有第二耳机在切换为从耳机之前录制的音频数据,则第一录音数据与第二录音数据不同步,此时则需要找回缺失的第三录音数据,第三录音数据与第二耳机在切换为从耳机之前录制的且未发送至终端设备的音频数据同步,根据第一录音数据找回第三录音数据。由于此时第一耳机为主耳机,因此第一耳机与终端设备建立有通信连接,通过第一耳机将合成录音数据发送至终端设备。在其中一个实施例中,成功发送至终端设备的数据将从缓存中释放。Before the master-slave switch occurs, the first earphone records audio data as the slave earphone and sends it to the second earphone as the master earphone, and the part of the audio data that has not been sent to the terminal device is the third recording data. If the first recording data includes the audio data recorded by the second earphone before switching to the slave earphone, then the first recording data and the second recording data are not synchronized. At this time, it is necessary to retrieve the missing third recording data. The data is synchronized with the audio data recorded by the second earphone before switching to the slave earphone and not sent to the terminal device, and the third recording data is retrieved according to the first recording data. Since the first earphone is the main earphone at this time, a communication connection is established between the first earphone and the terminal device, and the synthesized recording data is sent to the terminal device through the first earphone. In one of the embodiments, data successfully sent to the end device will be released from the cache.

应该理解的是,上述实施例对应的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,各流程图的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that, the steps in the flow chart corresponding to the above embodiments are displayed sequentially as indicated by the arrows, but these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in each flow chart may include multiple sub-steps or multiple stages, these sub-steps or stages are not necessarily executed at the same time, but may be executed at different times, the execution of these sub-steps or stages The order is not necessarily performed sequentially, but may be performed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.

如图9所示,本申请还提供了一种音频数据传输装置900,应用于耳机组中的第一耳机,耳机组还包括第二耳机,装置包括:As shown in Figure 9, the present application also provides an audio data transmission device 900, which is applied to the first earphone in the earphone set, and the earphone set also includes a second earphone, and the device includes:

第一接收模块901,用于在第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据;The first receiving module 901 is configured to receive the first recording data sent by the second earphone when the first earphone is switched from the slave earphone to the master earphone;

数据获取模块902,用于在第一录音数据与第一耳机缓存的第二录音数据不同步时,根据第一录音数据获取第三录音数据,第三录音数据为第一录音数据相对于第二录音数据的不同步部分所对应的音频数据;The data acquisition module 902 is configured to acquire third recording data according to the first recording data when the first recording data is not synchronized with the second recording data buffered by the first earphone, and the third recording data is the first recording data relative to the second recording data. Audio data corresponding to the asynchronous part of the recording data;

数据合成模块903,用于根据第一录音数据、第二录音数据和第三录音数据生成合成录音数据。A data synthesis module 903, configured to generate synthesized recording data according to the first recording data, the second recording data and the third recording data.

在其中一个实施例中,数据获取模块包括:In one of the embodiments, the data acquisition module includes:

同步单元,用于将第一录音数据与第一耳机的备份区的音频数据进行同步比对;备份区用于备份存储第一耳机作为从耳机时录制并发送至第二耳机的音频数据;The synchronization unit is used for synchronously comparing the first recording data with the audio data in the backup area of the first earphone; the backup area is used for backing up and storing the first earphone as the audio data recorded from the earphone and sent to the second earphone;

备份恢复单元,用于提取备份区内与第一录音数据同步的第三录音数据。The backup restoration unit is used to extract the third recording data synchronized with the first recording data in the backup area.

在其中一个实施例中,数据获取模块包括:In one of the embodiments, the data acquisition module includes:

从录音数据获取单元,用于获取第二耳机发送的从录音数据;从录音数据为第二耳机作为主耳机时接收的第一耳机录制的音频数据;The slave recording data acquisition unit is used to obtain the slave recording data sent by the second earphone; the slave recording data is the audio data recorded by the first earphone received when the second earphone is used as the master earphone;

数据提取单元,用于将第一录音数据与从录音数据进行同步比对,从从录音数据中获取与第一录音数据同步的第三录音数据。The data extraction unit is used for synchronously comparing the first recording data with the secondary recording data, and obtaining third recording data synchronized with the first recording data from the secondary recording data.

在其中一个实施例中,音频数据传输装置还包括:In one of the embodiments, the audio data transmission device further includes:

同步模块,用于将第一录音数据的第一同步信息与第二录音数据的第二同步信息进行比对;第一同步信息为第二耳机对录制的音频数据添加的标识信息;第二同步信息为第一耳机对录制的音频数据添加的标识信息;The synchronization module is used to compare the first synchronization information of the first recording data with the second synchronization information of the second recording data; the first synchronization information is the identification information added by the second earphone to the recorded audio data; the second synchronization The information is the identification information added by the first earphone to the recorded audio data;

判定模块,用于在第一同步信息与第二同步信息不匹配时,判定第一录音数据与第二录音数据不同步。A judging module, configured to judge that the first recording data and the second recording data are out of sync when the first synchronizing information does not match the second synchronizing information.

在其中一个实施例中,音频数据传输装置还包括:In one of the embodiments, the audio data transmission device further includes:

发送模块,用于合成录音数据发送至终端设备。The sending module is used to send the synthesized recording data to the terminal equipment.

上述音频数据传输装置中各个模块的划分仅仅用于举例说明,在其他实施例中,可将音频数据传输装置按照需要划分为不同的模块,以完成上述音频数据传输装置的全部或部分功能。The division of each module in the above-mentioned audio data transmission device is only for illustration. In other embodiments, the audio data transmission device can be divided into different modules according to needs, so as to complete all or part of the functions of the above-mentioned audio data transmission device.

关于音频数据传输装置的具体限定可以参见上文中对于音频数据传输方法的限定,在此不再赘述。上述音频数据传输装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For specific limitations on the audio data transmission device, refer to the above-mentioned limitations on the audio data transmission method, which will not be repeated here. Each module in the above-mentioned audio data transmission device can be fully or partially realized by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.

图10为一个实施例中耳机的内部结构示意图。该耳机可以是第一耳机或第二耳机。该耳机包括通过系统总线连接的处理器和存储器。其中,该处理器可以包括一个或多个处理单元。处理器可为CPU(Central Processing Unit,中央处理单元)或DSP(DigitalSignal Processing,数字信号处理器)等。存储器可包括非易失性存储介质及内存储器。非易失性存储介质存储有操作系统和计算机程序。该计算机程序可被处理器所执行,以用于实现以下各个实施例所提供的一种音频数据传输方法。内存储器为非易失性存储介质中的操作系统计算机程序提供高速缓存的运行环境。Fig. 10 is a schematic diagram of the internal structure of the earphone in one embodiment. The earphone can be the first earphone or the second earphone. The headset includes a processor and memory connected by a system bus. Wherein, the processor may include one or more processing units. The processor may be a CPU (Central Processing Unit, central processing unit) or a DSP (Digital Signal Processing, digital signal processor), etc. The memory may include non-volatile storage media and internal memory. Nonvolatile storage media store operating systems and computer programs. The computer program can be executed by a processor, so as to implement an audio data transmission method provided in the following embodiments. The internal memory provides a high-speed running environment for the operating system computer program in the non-volatile storage medium.

本申请实施例中提供的音频数据传输装置中的各个模块的实现可为计算机程序的形式。该计算机程序可在耳机上运行。该计算机程序构成的程序模块可存储在电子设备的存储器上。该计算机程序被处理器执行时,实现本申请实施例中所描述方法的步骤。The implementation of each module in the audio data transmission device provided in the embodiment of the present application may be in the form of a computer program. The computer program can run on the headset. The program modules constituted by the computer program can be stored in the memory of the electronic device. When the computer program is executed by the processor, the steps of the methods described in the embodiments of the present application are realized.

本申请实施例还提供了一种计算机可读存储介质。一个或多个包含计算机可执行指令的非易失性计算机可读存储介质,当所述计算机可执行指令被一个或多个处理器执行时,使得所述处理器执行上述音频数据传输方法的步骤。The embodiment of the present application also provides a computer-readable storage medium. One or more non-transitory computer-readable storage media containing computer-executable instructions, when the computer-executable instructions are executed by one or more processors, causing the processors to perform the steps of the above audio data transmission method .

本申请实施例还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述音频数据传输方法。The embodiment of the present application also provides a computer program product including instructions, which, when running on a computer, causes the computer to execute the above audio data transmission method.

本申请所使用的对存储器、存储、数据库或其它介质的任何引用可包括非易失性和/或易失性存储器。非易失性存储器可包括ROM(Read-Only Memory,只读存储器)、PROM(Programmable Read-only Memory,可编程只读存储器)、EPROM(Erasable ProgrammableRead-Only Memory,可擦除可编程只读存储器)、EEPROM(Electrically ErasableProgrammable Read-only Memory,电可擦除可编程只读存储器)或闪存。易失性存储器可包括RAM(Random Access Memory,随机存取存储器),它用作外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如SRAM(Static Random Access Memory,静态随机存取存储器)、DRAM(Dynamic Random Access Memory,动态随机存取存储器)、SDRAM(Synchronous Dynamic Random Access Memory,同步动态随机存取存储器)、双数据率DDRSDRAM(Double Data Rate Synchronous Dynamic Random Access memory,双数据率同步动态随机存取存储器)、ESDRAM(Enhanced Synchronous Dynamic Random Access memory,增强型同步动态随机存取存储器)、SLDRAM(Sync Link Dynamic Random Access Memory,同步链路动态随机存取存储器)、RDRAM(Rambus Dynamic Random Access Memory,总线式动态随机存储器)、DRDRAM(Direct Rambus Dynamic Random Access Memory,接口动态随机存储器)。Any reference to memory, storage, database, or other medium as used herein may include non-volatile and/or volatile memory. Non-volatile memory can include ROM (Read-Only Memory, read-only memory), PROM (Programmable Read-only Memory, programmable read-only memory), EPROM (Erasable Programmable Read-Only Memory, erasable programmable read-only memory ), EEPROM (Electrically Erasable Programmable Read-only Memory, Electrically Erasable Programmable Read-Only Memory) or flash memory. The volatile memory may include RAM (Random Access Memory), which is used as an external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as SRAM (Static Random Access Memory, Static Random Access Memory), DRAM (Dynamic Random Access Memory, Dynamic Random Access Memory), SDRAM (Synchronous Dynamic Random Access Memory , synchronous dynamic random access memory), double data rate DDRSDRAM (Double Data Rate Synchronous Dynamic Random Access memory, double data rate synchronous dynamic random access memory), ESDRAM (Enhanced Synchronous Dynamic Random Access memory, enhanced synchronous dynamic random access memory), SLDRAM (Sync Link Dynamic Random Access Memory, synchronous link dynamic random access memory), RDRAM (Rambus Dynamic Random Access Memory, bus dynamic random access memory), DRDRAM (Direct Rambus Dynamic Random Access Memory, interface dynamic random access memory ).

如图11所示,本申请实施例还提供了一种耳机组,包括如上述实施例中的第一耳机和第二耳机。As shown in FIG. 11 , an embodiment of the present application further provides an earphone set, including the first earphone and the second earphone in the foregoing embodiment.

耳机组能够通过其中一只(或一组)耳机作为主耳机与终端设备进行交互,另一只(或一组)耳机作为从耳机,经过主耳机与终端设备进行交互,进而实现音频数据的传输。本申请实施例中的耳机组通过两只(或两组)耳机分别进行音频的录制,从耳机将录制的音频数据发送至主耳机,主耳机进行同步比对后,将同步的数据打包后发送至终端,实现真立体声录音。另外,耳机组发生耳机的主从切换后,主耳机获取从耳机在作为原主耳机时还未发送至终端的音频数据,对音频数据进行处理后发送至终端,避免由于主从切换导致数据丢失,保证数据的完整性。The earphone set can interact with the terminal device through one (or a group) of earphones as the master earphone, and the other (or a group of) earphones as the slave earphone, interact with the terminal device through the master earphone, and then realize the transmission of audio data . The earphone set in the embodiment of the present application records audio through two (or two) earphones respectively, and sends the recorded audio data from the earphones to the main earphone, and after the main earphone performs synchronization comparison, the synchronized data is packed and sent to the terminal to achieve true stereo recording. In addition, after the master-slave switch of the earphones occurs in the earphone set, the master earphone obtains the audio data that has not been sent to the terminal when the slave earphone is used as the original master earphone, processes the audio data and sends it to the terminal to avoid data loss due to the master-slave switch. Guarantee data integrity.

以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present application, and the description thereof is relatively specific and detailed, but should not be construed as limiting the patent scope of the present application. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the scope of protection of the patent application should be based on the appended claims.

Claims (18)

1.一种音频数据传输方法,其特征在于,应用于耳机组中的第一耳机,所述耳机组还包括第二耳机,所述方法包括:1. A method for transmitting audio data, characterized in that it is applied to the first earphone in the earphone set, and the earphone set also includes the second earphone, and the method comprises: 在所述第一耳机由从耳机切换为主耳机的情况下,接收所述第二耳机发送的第一录音数据;When the first earphone is switched from the slave earphone to the master earphone, receiving the first recording data sent by the second earphone; 若所述第一录音数据与所述第一耳机缓存的第二录音数据不同步,则根据所述第一录音数据获取第三录音数据,所述第三录音数据为所述第一录音数据相对于所述第二录音数据的不同步部分所对应的音频数据;If the first recording data is not synchronized with the second recording data buffered by the first earphone, then obtain third recording data according to the first recording data, and the third recording data is relative to the first recording data. audio data corresponding to the asynchronous part of the second recording data; 根据所述第一录音数据、所述第二录音数据和所述第三录音数据生成合成录音数据。Synthetic recording data is generated according to the first recording data, the second recording data and the third recording data. 2.根据权利要求1所述的音频数据传输方法,其特征在于,所述第一耳机具有备份区,所述备份区用于备份所述第一耳机作为从耳机时录制并发送至所述第二耳机的音频数据;所述根据所述第一录音数据获取第三录音数据,包括:2. The audio data transmission method according to claim 1, wherein the first earphone has a backup area, and the backup area is used to back up the first earphone as a slave earphone to record and send to the second earphone. The audio data of the two earphones; the acquisition of the third recording data according to the first recording data includes: 将所述第一录音数据与所述备份区的音频数据进行同步比对;synchronously comparing the first recording data with the audio data in the backup area; 提取所述备份区内与所述第一录音数据同步的所述第三录音数据。Extracting the third recording data synchronized with the first recording data in the backup area. 3.根据权利要求2所述的音频数据传输方法,其特征在于,所述方法还包括:3. audio data transmission method according to claim 2, is characterized in that, described method also comprises: 所述第一耳机在作为从耳机的状态下,在每次完成发送音频数据至所述第二耳机时,将完成发送的所述音频数据备份至所述备份区。In the state of being a slave earphone, the first earphone backs up the audio data that has been sent to the backup area each time the audio data is sent to the second earphone. 4.根据权利要求2所述的音频数据传输方法,其特征在于,所述方法还包括:4. audio data transmission method according to claim 2, is characterized in that, described method also comprises: 在所述第一耳机的内存低于阈值时释放所述备份区的音频数据;或releasing the audio data in the backup area when the internal memory of the first earphone is lower than a threshold; or 根据预设周期按照所述备份区存入音频数据的顺序依次进行释放;或Release sequentially according to the order in which the audio data is stored in the backup area according to a preset period; or 获取所述第二耳机的数据发送记录;Obtain the data sending record of the second earphone; 根据所述数据发送记录确定所述备份区内已被发送至终端设备的音频数据并进行数据释放。Determine the audio data in the backup area that has been sent to the terminal device according to the data sending record and release the data. 5.根据权利要求1所述的音频数据传输方法,其特征在于,所述根据所述第一录音数据获取第三录音数据,包括:5. The audio data transmission method according to claim 1, wherein said obtaining the third recording data according to the first recording data comprises: 获取所述第二耳机发送的从录音数据;所述从录音数据为所述第二耳机作为主耳机时接收的所述第一耳机录制的音频数据;Acquiring the slave recording data sent by the second earphone; the slave recording data is the audio data recorded by the first earphone received when the second earphone is used as the master earphone; 将所述第一录音数据与所述从录音数据进行同步比对,从所述从录音数据中获取与所述第一录音数据同步的所述第三录音数据。Synchronously comparing the first recording data with the secondary recording data, and obtaining the third recording data synchronized with the first recording data from the secondary recording data. 6.根据权利要求1所述的音频数据传输方法,其特征在于,所述方法还包括:6. audio data transmission method according to claim 1, is characterized in that, described method also comprises: 将所述第一录音数据的第一同步信息与所述第二录音数据的第二同步信息进行比对;所述第一同步信息为所述第二耳机对录制的音频数据添加的标识信息;所述第二同步信息为所述第一耳机对录制的音频数据添加的标识信息;Comparing the first synchronization information of the first recording data with the second synchronization information of the second recording data; the first synchronization information is the identification information added by the second earphone to the recorded audio data; The second synchronization information is the identification information added by the first earphone to the recorded audio data; 若所述第一同步信息与所述第二同步信息不匹配,则判定所述第一录音数据与所述第二录音数据不同步。If the first synchronization information does not match the second synchronization information, it is determined that the first recording data is not synchronized with the second recording data. 7.根据权利要求2所述的音频数据传输方法,其特征在于,所述将所述第一录音数据与所述备份区的音频数据进行同步比对,提取所述备份区内与所述第一录音数据同步的所述第三录音数据,包括:7. The audio data transmission method according to claim 2, characterized in that, synchronously comparing the first recording data with the audio data in the backup area, extracting the audio data in the backup area and the second audio data in the backup area. The third recording data synchronized with the first recording data includes: 将所述第一录音数据的第一同步信息与所述备份区的各音频数据的第三同步信息进行比对;所述第一同步信息为所述第二耳机对录制的音频数据添加的标识信息;所述第三同步信息为所述第一耳机对录制的音频数据添加的标识信息;Comparing the first synchronization information of the first recording data with the third synchronization information of each audio data in the backup area; the first synchronization information is the identification added by the second earphone to the recorded audio data information; the third synchronization information is the identification information added by the first earphone to the recorded audio data; 若所述第一同步信息与所述第三同步信息匹配,则在所述备份区中提取具有与第一同步信息同步的第三同步信息的音频数据作为第三录音数据。If the first synchronization information matches the third synchronization information, extract audio data having third synchronization information synchronized with the first synchronization information as third recording data in the backup area. 8.根据权利要求6或7所述的音频数据传输方法,其特征在于,8. The audio data transmission method according to claim 6 or 7, characterized in that, 所述第一同步信息、所述第二同步信息和所述第三同步信息为时间戳或序列号。The first synchronization information, the second synchronization information and the third synchronization information are time stamps or serial numbers. 9.根据权利要求1所述的音频数据传输方法,其特征在于,所述在所述第一耳机由从耳机切换为主耳机的情况下,接收第二耳机发送的第一录音数据,包括:9. The audio data transmission method according to claim 1, wherein, when the first earphone is switched from the slave earphone to the master earphone, receiving the first recording data sent by the second earphone comprises: 所述第一耳机处于主耳机状态下时,所述第一耳机的存储空间具有主缓存区和从缓存区,将录制的所述第二录音数据存入所述第一耳机的主缓存区,将接收的所述第一录音数据存入所述第一耳机的从缓存区。When the first earphone is in the master earphone state, the storage space of the first earphone has a master buffer area and a slave buffer area, and the recorded second recording data is stored in the master buffer area of the first earphone, storing the received first recording data into the slave buffer area of the first earphone. 10.根据权利要求9所述的音频数据传输方法,其特征在于,10. audio data transmission method according to claim 9, is characterized in that, 所述第二耳机的存储空间具有主缓存区,所述第二耳机的主缓存区用于缓存所述第一录音数据。The storage space of the second earphone has a main buffer area, and the main buffer area of the second earphone is used for buffering the first recording data. 11.根据权利要求5所述的音频数据传输方法,其特征在于,11. audio data transmission method according to claim 5, is characterized in that, 所述第二耳机的存储空间具有主缓存区和从缓存区,所述第二耳机的主缓存区用于缓存所述第一录音数据,所述第二耳机的从缓存区用于缓存所述从录音数据。The storage space of the second earphone has a master buffer area and a slave buffer area, the master buffer area of the second earphone is used for buffering the first recording data, and the slave buffer area of the second earphone is used for buffering the from recording data. 12.根据权利要求1至7或9至11任一项所述的音频数据传输方法,其特征在于,还包括:12. The audio data transmission method according to any one of claims 1 to 7 or 9 to 11, further comprising: 将所述合成录音数据发送至终端设备。Send the synthesized recording data to the terminal device. 13.一种音频数据传输方法,其特征在于,应用于耳机组中的第二耳机,所述耳机组还包括第一耳机,所述方法包括:13. An audio data transmission method, characterized in that it is applied to a second earphone in an earphone set, the earphone set also includes a first earphone, and the method comprises: 在所述第二耳机由主耳机切换为从耳机的情况下,In the case that the second earphone is switched from the master earphone to the slave earphone, 发送第一录音数据及从录音数据至所述第一耳机;sending the first recording data and the slave recording data to the first earphone; 其中,所述第一录音数据为所述第二耳机录制的音频数据,所述从耳录音数据为所述第一耳机作为从耳机时录制并发送至所述第二耳机的音频数据;Wherein, the first recording data is the audio data recorded by the second earphone, and the slave ear recording data is the audio data recorded and sent to the second earphone when the first earphone is used as the slave earphone; 所述第一耳机用于在所述第一录音数据与所述第一耳机缓存的第二录音数据不同步时,根据所述第一录音数据获取第三录音数据,并根据所述第一录音数据、所述第二录音数据和所述第三录音数据生成合成录音数据;所述第三录音数据为所述第一录音数据相对于所述第二录音数据的不同步部分所对应的音频数据。The first earphone is used to obtain third recording data according to the first recording data when the first recording data is not synchronized with the second recording data buffered by the first earphone, and obtain third recording data according to the first recording data. data, the second recording data and the third recording data to generate synthetic recording data; the third recording data is the audio data corresponding to the asynchronous part of the first recording data relative to the second recording data . 14.一种音频数据传输方法,其特征在于,应用于耳机组,所述耳机组包括第一耳机和第二耳机,所述方法包括:14. An audio data transmission method, characterized in that it is applied to an earphone set, the earphone set includes a first earphone and a second earphone, and the method comprises: 在所述第一耳机由从耳机切换为主耳机的情况下,In the case where the first earphone is switched from the slave earphone to the master earphone, 所述第二耳机将第一录音数据发送至所述第一耳机;所述第一录音数据为所述第二耳机录制的音频数据;The second earphone sends the first recording data to the first earphone; the first recording data is the audio data recorded by the second earphone; 所述第一耳机在所述第一录音数据与所述第一耳机缓存的第二录音数据不同步时,根据所述第一录音数据获取第三录音数据,并根据所述第一录音数据、所述第二录音数据和所述第三录音数据生成合成录音数据;所述第三录音数据为所述第一录音数据相对于所述第二录音数据的不同步部分所对应的音频数据。When the first recording data is not synchronized with the second recording data buffered by the first earphone, the first earphone acquires third recording data according to the first recording data, and obtains third recording data according to the first recording data, The second recording data and the third recording data generate synthesized recording data; the third recording data is audio data corresponding to an asynchronous part of the first recording data relative to the second recording data. 15.一种音频数据传输装置,其特征在于,应用于耳机组中的第一耳机,所述耳机组还包括第二耳机,所述装置包括:15. An audio data transmission device, characterized in that it is applied to a first earphone in an earphone set, the earphone set also includes a second earphone, and the device includes: 第一接收模块,用于在所述第一耳机由从耳机切换为主耳机的情况下,接收所述第二耳机发送的第一录音数据;The first receiving module is configured to receive the first recording data sent by the second earphone when the first earphone is switched from the slave earphone to the master earphone; 数据获取模块,用于在所述第一录音数据与所述第一耳机缓存的第二录音数据不同步时,根据所述第一录音数据获取第三录音数据,所述第三录音数据为所述第一录音数据相对于所述第二录音数据的不同步部分所对应的音频数据;A data acquisition module, configured to acquire third recording data according to the first recording data when the first recording data is not synchronized with the second recording data buffered by the first earphone, and the third recording data is the The audio data corresponding to the asynchronous part of the first recording data relative to the second recording data; 数据合成模块,用于根据所述第一录音数据、所述第二录音数据和所述第三录音数据生成合成录音数据。A data synthesis module, configured to generate synthesized recording data according to the first recording data, the second recording data and the third recording data. 16.一种耳机,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1至13中任一项所述的音频数据传输方法的步骤。16. An earphone, comprising a memory and a processor, wherein a computer program is stored in the memory, wherein when the computer program is executed by the processor, the processor executes the The steps of the audio data transmission method described in any one. 17.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至13中任一项所述的方法的步骤。17. A computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented. 18.一种耳机组,其特征在于,包括应用如权利要求1至12任一项所述的音频数据传输方法的第一耳机,以及应用如权利要求13所述的音频数据传输方法的第二耳机。18. An earphone set, characterized in that it comprises a first earphone to which the audio data transmission method according to any one of claims 1 to 12 is applied, and a second earphone to which the audio data transmission method according to claim 13 is applied. earphone.
CN202111583097.XA 2021-12-22 2021-12-22 Audio data transmission method, device, earphone set and medium Active CN116347319B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111583097.XA CN116347319B (en) 2021-12-22 2021-12-22 Audio data transmission method, device, earphone set and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111583097.XA CN116347319B (en) 2021-12-22 2021-12-22 Audio data transmission method, device, earphone set and medium

Publications (2)

Publication Number Publication Date
CN116347319A true CN116347319A (en) 2023-06-27
CN116347319B CN116347319B (en) 2026-01-13

Family

ID=86879257

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111583097.XA Active CN116347319B (en) 2021-12-22 2021-12-22 Audio data transmission method, device, earphone set and medium

Country Status (1)

Country Link
CN (1) CN116347319B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200053612A1 (en) * 2017-11-15 2020-02-13 Amazon Technologies, Inc. Wireless device connection handover
CN113542479A (en) * 2021-07-26 2021-10-22 Oppo广东移动通信有限公司 Recording method, device, wireless earphone and storage medium
CN113573202A (en) * 2021-09-23 2021-10-29 深圳市外星人创新电子有限公司 Data transmission control method and system of Bluetooth headset
CN113613223A (en) * 2021-06-29 2021-11-05 成都市安比科技有限公司 Master-slave switching method of TWS (time-and-time-shift switching) system, first equipment and second equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200053612A1 (en) * 2017-11-15 2020-02-13 Amazon Technologies, Inc. Wireless device connection handover
CN113613223A (en) * 2021-06-29 2021-11-05 成都市安比科技有限公司 Master-slave switching method of TWS (time-and-time-shift switching) system, first equipment and second equipment
CN113542479A (en) * 2021-07-26 2021-10-22 Oppo广东移动通信有限公司 Recording method, device, wireless earphone and storage medium
CN113573202A (en) * 2021-09-23 2021-10-29 深圳市外星人创新电子有限公司 Data transmission control method and system of Bluetooth headset

Also Published As

Publication number Publication date
CN116347319B (en) 2026-01-13

Similar Documents

Publication Publication Date Title
CN116601973B (en) Share audio from the source device
CN111200769B (en) Communication method for Bluetooth headset device and Bluetooth headset device
CN113542479B (en) Recording method, recording device, wireless earphone and storage medium
EP3713243A1 (en) Mp4 file processing method and related device therefor
TW201731252A (en) Key synchronization, package transfer method and device for quantum key distribution process
WO2020248364A1 (en) Data synchronization method and related device
WO2017028651A1 (en) Method, apparatus and system for performing configuration setting between devices
CN111352959B (en) Data synchronous remedying and storing method and cluster device
CN109194720A (en) Standby machine method of data synchronization, device and computer equipment
US20180034749A1 (en) System and method for distributing and replaying trigger packets via a variable latency bus interconnect
CN116347319A (en) Audio data transmission method, device, earphone, earphone set and medium
CN101583027A (en) Method for caching image data in real time and movable terminal
CN113613221B (en) TWS master device, TWS slave device, audio device and system
CN102739860A (en) Method and device for synchronizing contact information, and terminal
CN113571032B (en) Audio data transmission method, device, computer equipment and storage medium
CN110602524B (en) Method, device and system for synchronizing multi-channel digital streams and storage medium
CN113612962A (en) Video conference processing method, system and device
CN113613124B (en) TWS master and slave equipment and audio equipment and system
CN104753969B (en) The synchronous method and device of Contents of clipboard information
CN115022537B (en) Video shooting method, device, electronic equipment and storage medium
CN114296758B (en) Firmware sending method, firmware receiving method and firmware upgrading system
CN115776628A (en) Method for accurate synchronization of double-ear recording of TWS (two way communication system) Bluetooth headset
CN116709281A (en) Audio transmission method, device, equipment, system and storage medium based on bluetooth
CN116744162A (en) Time synchronization method, electronic device, chip and readable storage medium
CN116743693B (en) Message synchronization method, electronic device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant