Disclosure of Invention
The invention provides a method for bidirectionally transmitting voice data by Bluetooth, which can simply distinguish the transmitted data or the received data.
The technical scheme of the invention is realized as follows:
a method for Bluetooth bidirectional transmission of voice data specifically comprises the following steps:
(1) a Bluetooth device at a sending end collects a voice signal, performs A/D conversion on the voice signal, and converts an analog voice signal into a digital voice signal;
(2) setting the address code of the receiving end Bluetooth device at the front end of the digital voice signal, and setting the address code of the sending end Bluetooth device at the tail end of the digital voice signal;
(3) the Bluetooth equipment at the sending end sends the configured voice signal;
(4) the receiving end Bluetooth device receives and screens the voice signals.
Preferably, in step (3), the sending-end bluetooth device buffers the configured voice signal in the sending data buffer, and then sends the configured voice signal.
Preferably, in step (4), after buffering the received voice signal in the received data buffer, the receiving-end bluetooth device analyzes whether the address code of the front end of the voice signal is the same as the address code of the device, and if so, converts the voice signal into an analog signal and plays the analog signal.
Preferably, the method further comprises the following steps:
(5) the receiving end Bluetooth device extracts the address code at the tail end of the voice signal and sets the extracted address code at the front end of the returned voice signal.
Preferably, steps (1) and (2) specifically include the following:
(1) the method comprises the steps that a sending end Bluetooth device collects multiple groups of voice signals, A/D conversion is carried out on all the voice signals, analog voice signals are converted into digital voice signals, and the multiple groups of voice signals correspond to multiple receiving end Bluetooth devices;
(2) the address code of the corresponding receiving end Bluetooth device is arranged at the front end of each group of digital voice signals, and the address code of the sending end Bluetooth device is arranged at the tail end of the digital voice signals.
Preferably, steps (1), (2) and (3) specifically include the following:
(1) the method comprises the steps that a sending end Bluetooth device collects multiple groups of voice signals, A/D conversion is carried out on all the voice signals, analog voice signals are converted into digital voice signals, and the multiple groups of voice signals correspond to the same receiving end Bluetooth device;
(2) the address code of the corresponding receiving end Bluetooth device and the timestamp for collecting each group of voice signals are arranged at the front end of each group of digital voice signals, and the address code of the transmitting end Bluetooth device is arranged at the tail end of the digital voice signals;
(3) the Bluetooth device at the sending end takes the timestamp as the priority level for judging the sending of each group of voice signals, and sends the configured voice signals according to the priority level.
Preferably, step (3) is preceded by the following steps:
the transmitting end Bluetooth device packs the address code of the receiving end Bluetooth device and the address code of the transmitting end Bluetooth device and sends the packed address code and the packed address code to the receiving end Bluetooth device, and the receiving end Bluetooth device packs the address code of the transmitting end Bluetooth device and the address code of the receiving end Bluetooth device and responses the packed address code to the transmitting end Bluetooth device.
Preferably, step (2) is preceded by the following steps:
the sending end Bluetooth device acquires the address code of the receiving end Bluetooth device.
The invention has the beneficial effects that: the transmitted data or the received data can be distinguished more simply.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, the present invention provides a method for bluetooth bidirectional voice data transmission, which specifically includes the following steps:
(1) a Bluetooth device at a sending end collects a voice signal, performs A/D conversion on the voice signal, and converts an analog voice signal into a digital voice signal;
(2) setting the address code of the receiving end Bluetooth device at the front end of the digital voice signal, and setting the address code of the sending end Bluetooth device at the tail end of the digital voice signal;
(3) the Bluetooth equipment at the sending end sends the configured voice signal;
(4) the receiving end Bluetooth device receives and screens the voice signals.
Preferably, in step (3), the sending-end bluetooth device buffers the configured voice signal in the sending data buffer, and then sends the configured voice signal.
Preferably, in step (4), after buffering the received voice signal in the received data buffer, the receiving-end bluetooth device analyzes whether the address code of the front end of the voice signal is the same as the address code of the device, and if so, converts the voice signal into an analog signal and plays the analog signal.
Preferably, the method further comprises the following steps:
(5) the receiving end Bluetooth device extracts the address code at the tail end of the voice signal and sets the extracted address code at the front end of the returned voice signal.
Preferably, steps (1) and (2) specifically include the following:
(1) the method comprises the steps that a sending end Bluetooth device collects multiple groups of voice signals, A/D conversion is carried out on all the voice signals, analog voice signals are converted into digital voice signals, and the multiple groups of voice signals correspond to multiple receiving end Bluetooth devices;
(2) the address code of the corresponding receiving end Bluetooth device is arranged at the front end of each group of digital voice signals, and the address code of the sending end Bluetooth device is arranged at the tail end of the digital voice signals.
Preferably, steps (1), (2) and (3) specifically include the following:
(1) the method comprises the steps that a sending end Bluetooth device collects multiple groups of voice signals, A/D conversion is carried out on all the voice signals, analog voice signals are converted into digital voice signals, and the multiple groups of voice signals correspond to the same receiving end Bluetooth device;
(2) the address code of the corresponding receiving end Bluetooth device and the timestamp for collecting each group of voice signals are arranged at the front end of each group of digital voice signals, and the address code of the transmitting end Bluetooth device is arranged at the tail end of the digital voice signals;
(3) the Bluetooth device at the sending end takes the timestamp as the priority level for judging the sending of each group of voice signals, and sends the configured voice signals according to the priority level.
Preferably, step (3) is preceded by the following steps:
the transmitting end Bluetooth device packs the address code of the receiving end Bluetooth device and the address code of the transmitting end Bluetooth device and sends the packed address code and the packed address code to the receiving end Bluetooth device, and the receiving end Bluetooth device packs the address code of the transmitting end Bluetooth device and the address code of the receiving end Bluetooth device and responses the packed address code to the transmitting end Bluetooth device.
Preferably, step (2) is preceded by the following steps:
the sending end Bluetooth device acquires the address code of the receiving end Bluetooth device.
In other embodiments, the sending end bluetooth device judges whether data subpackaging is needed or not after the step (1), and if so, performs the next step; dividing the digital voice signal into a plurality of voice data packets, and sequentially setting an address code, a packet encoding number and a timestamp of the Bluetooth equipment at a receiving end at the starting end of each voice data packet; setting an address code of the Bluetooth equipment of the sending end at the end of the voice data packet; in the step (3), a Bluetooth transmission link is established, and the configured voice data packets are sequentially sent according to the packet coding number or the timestamp. Correspondingly, the receiving end Bluetooth device receives the voice data packet; each group of voice data packets consists of first address code information, a timestamp, voice data and second address code information; extracting first address code information from the front end of the voice data packet, comparing the first address code information with the address code of the equipment, judging whether the first address code information is consistent with the address code of the equipment, if so, entering the next step, and if not, discarding the voice data packet; extracting a time stamp from the front end included in the voice data, taking the time stamp as a priority judgment standard of processing, extracting second address code information from the tail end of the voice data packet, and grouping the received voice data packet according to the second address code information; and recombining the grouped voice data packets according to the time stamp, converting the voice data packets into analog voice signals, and playing the analog voice signals. The voice data packet may be comprised of first address code information, a timestamp, voice data, background noise data, and second address code information. And setting fixed byte number for the first address code information, the timestamp, the background noise data and the second address code information, wherein after receiving the voice data packet, the receiving end Bluetooth equipment can selectively discard the background noise data, and can also optimize the voice data by using the background noise data.
The encoding method of the voice data packet comprises the following steps:
acquiring an original audio, removing non-voice data in the original audio, acquiring voice segment data and background voice data, and quantizing, encoding and transmitting the voice segment data and the background voice data respectively;
extracting characteristic parameters of input voice segment data and background voice data, wherein the extracted characteristic parameters comprise a line spectrum pair, a pitch period and a gain mean value, and performing parameter transformation on the parameters to convert the parameters into a format required by parameter quantization;
and quantizing and encoding various voice parameters, and generating a voice data packet according to the formats of the first address code information, the timestamp, the voice data, the background noise data and the second address code information.
The invention can simply distinguish the sent data or the received data, and the Bluetooth equipment also sends the data packet in a broadcasting mode so as to prevent the problems that the pairing of the Bluetooth equipment is interrupted, the data transmission fails and the experience of a user is poor.
The technical scheme discloses the improvement point of the invention, and technical contents which are not disclosed in detail can be realized by the prior art by a person skilled in the art.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.