Audio playing method and device
By predicting future signal conditions based on the quality of the wireless connection signal and switching the encoding format according to the terminal device, the problem of audio stuttering caused by unstable wireless connection is solved, and stable transmission of audio data is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-03-10
AI Technical Summary
When the wireless connection is unstable, stuttering issues can easily occur when transmitting lossless audio data over a wireless network.
The terminal device predicts the future signal quality based on the signal quality of the wireless connection, and switches to a lower bitrate encoding format for encoding and transmission when the predicted signal quality does not meet the conditions of the current encoding format, so as to ensure that the audio data can reach the audio output device in a timely manner.
By adaptively adjusting the encoding format, transmission latency is reduced, audio playback stuttering is avoided, and stable transmission of audio data is ensured.
Smart Images

Figure CN121644883A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of audio technology, in particular to a method and device for audio playing. BACKGROUND
[0002] At present, more and more users use wireless earphones to listen to songs, and the transmission of audio data between a mobile phone and a wireless earphone through Bluetooth cannot meet the high sound quality requirement of users for songs. In this background, a technical solution for transmitting lossless sound quality audio data between a mobile phone and a wireless earphone through a WiFi wireless network begins to appear.
[0003] However, in the process of implementing the present application, the inventors found that when the distance between the user's mobile phone and the router is too far, or other devices occupy the WiFi wireless network, the WiFi signal of the mobile phone will fluctuate. In this case, since the data volume of the lossless sound quality streaming media audio is large, the transmission delay of the lossless sound quality streaming media audio data will be high when the WiFi signal fluctuates, resulting in that the song heard by the user through the wireless earphone is stuttered. SUMMARY
[0004] Embodiments of the present application provide a method and device for audio playing, which can solve the problem that when audio data is transmitted between a terminal and an audio output device through a wireless connection, the audio output device plays audio stuttering as much as possible under the condition that the wireless connection is unstable. The technical solution is as follows: In a first aspect, a method for audio playing is provided, the method is applied to a streaming media audio playing system, the streaming media audio playing system includes a terminal device and an audio output device, a wireless connection is established between the terminal device and the audio output device, target audio data is streaming media audio data, and the method includes the following steps: The terminal device encodes the target audio data stream into first encoded data of a first encoding format, and sends the first encoded data to the audio output device through the wireless connection; The terminal device predicts a second signal quality of the wireless connection after a first time length according to a current first signal quality of the wireless connection; In a case where the second signal quality does not meet a signal quality condition corresponding to the first encoding format and meets a signal quality condition corresponding to a second encoding format, the terminal device encodes the target audio data stream into second encoded data of the second encoding format, and sends the second encoded data to the audio output device through the wireless connection, wherein the first encoding format and the second encoding format correspond to different encoding formats; The audio output device decodes the received encoded data, and plays the decoded audio data.
[0005] In one possible implementation, the first encoding format is a lossless encoding format and the second encoding format is a lossy encoding format; or, the first encoding format is a lossy encoding format and the second encoding format is a lossless encoding format.
[0006] In one possible implementation, the first signal quality includes a first signal strength and / or a first transmission speed, and the second signal quality includes a second signal strength and / or a second transmission speed.
[0007] In one possible implementation, when the bitrate corresponding to the first encoding format is greater than the bitrate corresponding to the second encoding format, the second signal quality does not meet the signal quality condition corresponding to the first encoding format, and meeting the signal quality condition corresponding to the second encoding format means that the second signal strength is less than the first threshold and / or the second transmission speed is less than the second threshold. When the bitrate corresponding to the first encoding format is less than the bitrate corresponding to the second encoding format, the second signal quality does not meet the signal quality condition corresponding to the first encoding format, and meeting the signal quality condition corresponding to the second encoding format means that the second signal strength is greater than the first threshold, and / or the second transmission speed is greater than the second threshold.
[0008] In one possible implementation, if the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format, the method further includes: The terminal device determines the target bit rate based on the second signal quality, the sampling rate, bit depth, and number of channels of the target audio data stream; The terminal device encodes the target audio data stream into second encoded data in a second encoding format, including: The terminal device encodes the target audio data stream into a second encoding format with a bitrate of the target bitrate.
[0009] In one possible implementation, the terminal device predicts a second signal quality of the wireless connection after a first duration based on the current first signal quality of the wireless connection, including: Using signal command information as system state variables, and employing a Kalman filter algorithm, the second signal quality of the wireless connection after the first duration is predicted based on the first signal quality and the historical signal quality of the wireless connection within the second duration prior to the current moment.
[0010] In one possible implementation, the terminal device predicts a second signal quality of the wireless connection after a first duration based on the current first signal quality of the wireless connection, including: The first signal quality and the historical signal quality of the wireless connection within the second time period before the current time are input into the signal quality prediction model to obtain the second signal quality of the wireless connection after the first time period, wherein the signal quality prediction model is an artificial intelligence model.
[0011] In one possible implementation, the audio output device decodes the received encoded data and plays the decoded audio data, including: The audio output device decodes the first encoded data to obtain the decoded first audio data, and plays the audio data in the first audio data except for the third duration of audio data at the end; The audio output device decodes the second encoded data to obtain the decoded second audio data stream, and performs crossfading processing on the audio data of the third duration at the beginning and the audio data of the third duration at the end of the second audio data, and plays the crossfaded audio data. The audio output device plays the audio data in the second audio data, excluding the audio data of the third duration at the beginning.
[0012] In a second aspect, an audio playback apparatus is provided, the apparatus comprising at least one module for performing operations as described in the first aspect and any possible method for implementing the audio playback described in the first aspect.
[0013] Thirdly, an electronic device is provided, the electronic device including a processor and a memory, the memory storing at least one instruction, the instruction being loaded and executed by the processor to perform the operations performed as described in the first aspect and any possible method of audio playback described in the first aspect. Fourthly, a computer-readable storage medium is provided, the storage medium storing at least one instruction that is loaded and executed by a processor to perform the operations performed by the first aspect and any possible method of audio playback described in the first aspect.
[0014] Fifthly, a computer program product is provided, the computer program product storing at least one instruction, the instruction being loaded and executed by a processor to perform the operations performed as described in the first aspect and any possible implementation of the audio playback method described in the first aspect.
[0015] The beneficial effects of the technical solution provided in this application are: In this scheme, the terminal device can predict the signal quality of the wireless network. If the signal quality is poor, a lower bit rate encoding format can be used for encoding and transmission. A lower bit rate results in a smaller amount of encoded data, and even with poor signal quality, transmission can be completed faster, meaning less transmission latency. In this way, even if the wireless connection signal quality is poor, the audio output device can receive the encoded audio data stream in a timely manner, and audio playback will not be interrupted due to poor wireless connection signal quality. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is an architecture diagram of an audio playback system provided in an embodiment of this application; Figure 2 This is a schematic diagram of an audio playback method provided in an embodiment of this application; Figure 3 This is a schematic diagram of a wireless connection provided in an embodiment of this application; Figure 4 This is a flowchart of an audio playback method provided in an embodiment of this application; Figure 5 This is a flowchart of an audio playback method provided in an embodiment of this application; Figure 6 This is a schematic diagram of an audio playback device provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0019] Currently, more and more users are listening to music with wireless headphones, and the Bluetooth transmission of audio data between mobile phones and wireless headphones can no longer meet users' demands for high-quality sound. Against this backdrop, a technical solution for transmitting lossless audio data between mobile phones and wireless headphones via WiFi (wireless fidelity) networks has begun to emerge.
[0020] However, when the user's phone is too far from the router, or when other devices occupy the WiFi network, the phone's WiFi signal will fluctuate. In this case, because the data volume of lossless audio data is very large, the transmission latency of lossless audio data will be very high when the WiFi signal fluctuates, causing the songs heard by the user through wireless headphones to stutter.
[0021] This application provides an audio playback method, which is applied to a streaming media audio playback system, such as... Figure 1 As shown, the streaming audio playback system includes terminal devices and audio output devices, with a wireless connection established between them, which can be a WiFi connection. The terminal devices can be smartphones, tablets, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 players (Moving Picture Experts Group Audio Layer IV), laptops, desktop computers, televisions, smart screens, etc., while the audio output devices can be headphones, speakers, etc.
[0022] In the technical solution provided in this application embodiment, the terminal device can first encode the target audio data stream into first encoded data in a first encoding format, and then send the first encoded data to the audio output device via a wireless connection. During this process, the terminal device predicts the second signal quality of the wireless connection after a specified time period based on the current first signal quality of the wireless connection. If the predicted second signal quality does not meet the signal quality conditions corresponding to the currently used first encoding format, but meets the signal quality conditions corresponding to the second encoding format, the terminal device stops using the first encoding format to encode the target audio data stream and instead uses second encoded data, which encodes the target audio data stream to be transmitted next, into a second encoding format. The terminal device then sends the second encoded data to the audio output device via a wireless connection. The first and second encoding formats have different bitrates. Correspondingly, the audio output device can decode the received encoded data and play the decoded audio data stream.
[0023] like Figure 2As shown, by using the above method, the terminal device can predict the signal quality of the wireless network. If the signal quality is poor, a lower bit rate encoding format can be used for encoding and transmission. A lower bit rate results in a smaller amount of encoded data, and even if the signal quality is poor, the transmission can be completed faster, i.e., the transmission delay is smaller. In this way, even if the wireless connection signal quality is poor, the audio output device can receive the encoded audio data stream in time, and the audio playback will not be stuttered due to the poor wireless connection signal quality.
[0024] The method for audio playback provided in the embodiments of this application will now be described with reference to the accompanying drawings. This method can be implemented using an audio playback system, which includes a terminal device and an audio output device. The terminal device and the audio output device are connected via a wireless network. The process of establishing a wireless connection between the terminal device and the audio output device will be described first: like Figure 3 As shown, firstly, the terminal device and the audio output device are connected to the same Wi-Fi network. Then, the terminal device acts as a UPnP Controller (Universal Plug and Play Controller), and the audio output device acts as a UPnP Renderer (Universal Plug and Play Media Renderer). The terminal device performs a UPnP Renderer discovery process to obtain the IP address (Internet Protocol) and port number of the audio output device, and then establishes a UPnP connection with the audio output device. Next, a TCP (Transmission Control Protocol) connection is established between the terminal device and the audio output device for subsequent audio data transmission. At this point, a wireless connection is established between the terminal device and the audio output device, and the terminal device can send audio data streams to the audio output device for playback via the Wi-Fi network.
[0025] Furthermore, during the establishment of a wireless connection between the terminal device and the audio output device, the terminal device can send first authentication information to the audio output device. After the wireless connection is established, the audio output device sends second authentication information to the terminal device. Upon receiving the second authentication information, the terminal device compares it with the first authentication information. If they match, the terminal device maintains the wireless connection, confirming that the audio output device has been authenticated. If they do not match, the terminal device disconnects the wireless connection with the audio output device.
[0026] After a wireless connection is established between the terminal device and the audio output device, the terminal device can use the method provided in the embodiments of this application to transmit audio data to the audio output device, and then the audio output device can play the audio data. Figure 4 As shown, the audio playback method provided in this application embodiment may include the following steps: Step 401: The terminal device encodes the target audio data stream into first encoded data in a first encoding format, and sends the first encoded data to the audio output device via a wireless connection.
[0027] The target audio data is streaming audio data.
[0028] In implementation, the terminal device can have a music application installed. Users can select a target song to play within the music application. On the playback interface of the target song, users can choose the audio quality. The terminal device then determines the corresponding first encoding format based on the user's selected audio quality. Different audio qualities require different encoding formats for compression before transmission. For example, lossless audio quality corresponds to lossless encoding, such as FLAC (Free Lossless Audio Codec), while lossy audio quality corresponds to lossy encoding, such as OGG Vorbis (an open-source lossy audio compression codec). Alternatively, the terminal device can automatically select the first encoding format based on the signal quality of the wireless connection with the audio output device. The specific selection logic will be explained in detail in subsequent embodiments.
[0029] After detecting a user-triggered playback operation on a target song, the terminal device first converts the audio of the target song from an analog signal to a digital signal, that is, it performs PCM (Pulse Code Modulation) on the audio of the target song to obtain the target audio data stream. The duration of the target audio data stream is the duration of the target song. This target data stream can also be called a PCM audio data stream, and the sampling rate of the PCM audio data stream can be 192kHz, and the bit depth can be 24bit.
[0030] Then, according to the playback sequence of the audio frames of the target audio data stream in the target song, the target audio data stream is encoded frame by frame using the first encoding format. Each audio frame, after encoding, yields a corresponding encoded data frame in the first encoding format. After obtaining a specified number of encoded data frames corresponding to a certain number of audio frames, these encoded data frames are combined into a single encoded data packet. Each time an encoded data packet is obtained, the terminal device transmits this encoded data packet to the audio output device via a wireless connection. The encoded data packet transmitted here is the aforementioned first encoded data.
[0031] Wherein, if the first encoding format is lossless, such as FLAC, the bitrate for encoding in the first encoding format can be equal to the sampling rate of the target audio data stream multiplied by the bit depth, then multiplied by the number of channels, and finally multiplied by the compression ratio. For ease of description, this bitrate is referred to as the first bitrate. If the first encoding format is lossy, the target bitrate to be used can be determined based on the current signal quality, and this target bitrate can be used for encoding in the first encoding format. The determination of the target bitrate based on signal quality will be described in detail in subsequent embodiments.
[0032] In addition, in order for the audio output device to be ready to decode the encoded data, the terminal device can send a first encoding format indication message to the audio output device before sending the first encoded data frame of the first encoding format to the audio output device, so as to indicate that the encoding format of the encoded data frame sent next is the first encoding format.
[0033] Step 402: The terminal device predicts the second signal quality of the wireless connection after a first duration based on the current first signal quality of the wireless connection.
[0034] In practice, after the terminal device connects to the WiFi network, it can periodically detect the signal quality of the WiFi signal. The signal quality of the WiFi signal can be used as the signal quality of the wireless connection between the terminal device and the audio output.
[0035] The terminal device can predict the signal quality of the wireless connection after a preset prediction period, based on the current first signal quality. For example, if the prediction period is 10 seconds and the first duration is 5 seconds, the terminal device will predict the second signal quality of the wireless connection after 5 seconds, based on the current first signal quality, every 10 seconds.
[0036] In one possible implementation, signal quality may include one or more of signal strength and transmission speed. For example, signal quality includes signal strength and transmission speed; correspondingly, first signal quality includes first signal strength and first transmission speed, and second signal quality includes second signal strength and second transmission speed. Here, signal strength can refer to RSSI (Received Signal Strength Indication). There are various methods for predicting the second signal quality; two are illustrated below: Method 1: Using signal quality as the system state variable, the Kalman filter algorithm predicts the second signal quality of the wireless connection after the first time interval, based on the first signal quality and the historical signal quality of the wireless connection detected within the second time interval before the current moment. The second time interval can be configured according to actual needs; for example, it can be 5 seconds.
[0037] For signal quality, including signal strength and transmission speed, the signal strength and transmission speed after the first duration can be predicted separately.
[0038] The process of predicting the signal strength after the first duration can be as follows: using the signal strength as the system state variable, and using the Kalman filter algorithm, based on the first signal strength and the historical signal strength of the wireless connection within the second duration before the current moment, predict the second signal strength of the wireless connection after the first duration.
[0039] The process of predicting the transmission speed after the first duration can be as follows: using the transmission speed as a system state variable, and using the Kalman filter algorithm, based on the first transmission speed and the historical transmission speed of the wireless connection within the second duration before the current moment, predict the second transmission speed of the wireless connection after the first duration.
[0040] Method 2: The signal quality prediction model is obtained by inputting the first signal quality and the historical signal quality of the wireless connection detected within the second time period before the current moment into the signal quality prediction model, thus obtaining the predicted second signal quality of the wireless connection after the first time period. The signal quality prediction model is a pre-trained artificial intelligence model.
[0041] For signal quality, including signal strength and transmission speed, the signal strength and transmission speed after the first duration can be predicted separately.
[0042] The process of predicting the signal strength after the first duration can be as follows: input the first signal strength and the historical signal strength of the wireless connection detected in the second duration before the current time into the first signal quality prediction model to obtain the predicted second signal strength of the wireless connection after the first duration.
[0043] The process of predicting the transmission speed after the first duration can be as follows: input the first transmission speed and the historical transmission speed of the wireless connection detected within the second duration before the current moment into the second signal quality prediction model to obtain the predicted second transmission speed of the wireless connection after the first duration. The first signal quality prediction model and the second signal quality prediction model can be the same artificial intelligence model or different artificial intelligence models.
[0044] Step 403: If the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format, the terminal device encodes the target audio data stream into second encoded data in the second encoding format and sends the second encoded data to the audio output device via wireless connection.
[0045] The first and second encoding formats have different bitrates. One of the first and second encoding formats is a lossy encoding, and the other is a lossless encoding. Alternatively, both the first and second encoding formats are lossy encodings, but their bitrates differ. This application does not limit this specific case.
[0046] In practice, whenever the quality of the second signal after the first duration is predicted, it can be further determined whether the encoding format needs to be switched based on the quality of the second signal.
[0047] If the second signal quality indicator signal is of good quality and the currently used first encoding format is a high-bit-rate lossless encoding, then there is no need to switch the encoding format. If the second signal quality indicator signal is of good quality and the currently used first encoding format is a low-bit-rate lossy encoding, then the encoding format can be switched to a high-bit-rate lossless encoding. If the second signal quality indicator signal is of poor quality and the currently used first encoding format is a high-bit-rate lossless encoding, then the encoding format can be switched to a low-bit-rate lossy encoding. If the second signal quality indicator signal is of poor quality and the currently used first encoding format is a low-bit-rate lossy encoding, then there is no need to switch the encoding format.
[0048] The following example illustrates the specific processing of step 403, using signal quality (including signal strength and transmission speed) as an example, where one of the first encoding format and the other is lossy encoding and the other is lossless encoding: The signal quality conditions corresponding to lossy encoding can be: a second signal strength less than a first threshold, or a second transmission speed less than a second threshold. Thus, if either the signal strength or the transmission speed is lower, the encoding format can be switched from lossless to lossy encoding, which can better provide stability for audio data transmission.
[0049] The signal quality conditions for lossless encoding can be: a second signal strength greater than a first threshold, and a second transmission speed greater than a second threshold. Only when both signal strength and transmission speed are high enough will the encoding format be switched from lossy to lossless, thus providing better stability for audio data transmission.
[0050] When the first encoding format is lossless and the second encoding format is lossy, if the second signal strength is less than the first threshold or the second transmission speed is less than the second threshold, it can be determined that the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format. Conversely, if the first encoding format is lossy and the second encoding format is lossless, and the second signal strength is greater than the first threshold and the second transmission speed is greater than the second threshold, it can be determined that the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format.
[0051] Then, the encoding format is switched from the first encoding format to the second encoding format. Encoding of the audio frames of the target audio data stream using the first encoding format is stopped, and encoding using the second encoding format begins from the next audio frame. Each audio frame, after encoding, yields a corresponding encoded data frame in the second encoding format. Every specified number of encoded data frames corresponding to a certain number of audio frames are combined into a single encoded data packet. Upon receiving each encoded data packet, the terminal device transmits it to the audio output device via a wireless connection. The encoded data packet transmitted here is the aforementioned second encoded data.
[0052] In addition, in order for the audio output device to be ready to decode the encoded data, after the terminal device switches the encoding format to the audio output device, before sending the first encoded data frame of the second encoding format, it can first send a second encoding format indication information to the audio output device to indicate that the encoding format of the next encoded data frame sent is the second encoding format.
[0053] In one possible implementation, the overall signal quality value can be calculated first based on the second signal strength and the second transmission speed. Then, when the first encoding format is lossless and the second encoding format is lossy, if the overall signal quality value is less than a third threshold, it can be determined that the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format. Conversely, when the first encoding format is lossy and the second encoding format is lossless, if the overall signal quality value is greater than the third threshold, it can be determined that the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format. The third threshold can be configured by those skilled in the art according to actual needs; this embodiment does not limit its configuration.
[0054] The process for calculating the comprehensive value of the first signal quality based on the second signal strength and the second transmission speed can be as follows: The second signal strength is multiplied by the first weight to obtain the first product, and the second transmission speed is multiplied by the second weight to obtain the second product. The first product and the second product are added together to obtain the first signal quality comprehensive value. The sum of the first weight and the second weight is 1, and both the first weight and the second weight are values greater than 0 and less than 1. Specific values can be configured by relevant personnel according to actual needs.
[0055] In one possible implementation, after determining that the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but does meet the signal quality conditions corresponding to the second encoding format, the target bitrate can be determined based on the second signal quality. Furthermore, after switching to the second encoding format, the bitrate used when encoding the audio data frame in the second encoding format is the target bitrate. If the first encoding format is lossy and the second encoding format is lossless, then the target bitrate to be used here can be the aforementioned first bitrate. If the second encoding format is lossless, then the method for determining the target bitrate can be as follows: When signal quality is defined as signal strength, a pre-stored correspondence between signal strength ranges and bit rates can be established. After determining the second signal strength, the target signal strength range to which the second signal strength belongs is determined from this correspondence. Furthermore, the target bit rate corresponding to the target signal strength range is determined from this correspondence. In the correspondence between signal strength ranges and bit rates, the bit rate corresponding to each signal strength range is such that if the corresponding bit rate is used for encoding within that signal strength range, the encoded data can be transmitted stably. This bit rate can be calculated based on the first bit rate mentioned above. For example, if the signal strength range is divided into three levels, with the first level having the strongest signal strength, the second level weaker than the first level, and the third level weaker than the second level, then the bit rate corresponding to the first level of signal strength range can be 80% of the first bit rate, the bit rate corresponding to the second level of signal strength range can be 60% of the first bit rate, and the bit rate corresponding to the third level of signal strength range can be 40% of the first bit rate.
[0056] Given a signal quality and transmission speed, a pre-stored correspondence between transmission speed ranges and bit rates can be established. After determining a second transmission speed, the target transmission speed range to which the second speed belongs is determined from this correspondence. Furthermore, the target bit rate corresponding to the target transmission speed range is determined from this correspondence. In the correspondence between transmission speed ranges and bit rates, the bit rate corresponding to each signal strength range is such that if the corresponding bit rate is used for encoding within that transmission speed range, the encoded data can be transmitted stably. This bit rate can be calculated based on the first bit rate mentioned above. For example, if the transmission speed range is divided into three levels, with the first level having the highest transmission speed, the second level having a lower transmission speed than the first level, and the third level having a lower transmission speed than the second level, then the bit rate corresponding to the first level of transmission speed range can be 80% of the first bit rate, the bit rate corresponding to the second level of transmission speed range can be 60% of the first bit rate, and the bit rate corresponding to the third level of transmission speed range can be 40% of the first bit rate.
[0057] When signal quality is defined as signal strength and transmission speed, a pre-stored correspondence between the range of comprehensive signal quality values and the bit rate can be established. After determining the first comprehensive signal quality value based on the second signal strength and the second transmission speed, the target comprehensive signal quality value range to which the first comprehensive signal quality value belongs can be determined from the correspondence between the range of comprehensive signal quality values and the bit rate. Furthermore, the target bit rate corresponding to the target comprehensive signal quality value range can be determined from the aforementioned correspondence. In the correspondence between the signal quality composite value range and the bit rate, the bit rate corresponding to each signal quality composite value range is the bit rate at which the encoded data can be stably transmitted if the corresponding bit rate is used for encoding within that signal quality composite value range. This bit rate can be calculated based on the first bit rate mentioned above. For example, if the signal quality composite value range is divided into 3 levels, with the first level having the largest signal quality composite value, the second level having a lower signal quality composite value than the first level, and the third level having a lower signal quality composite value than the second level, then the bit rate corresponding to the first level of signal quality composite value range can be 80% of the first bit rate, the second level of signal quality composite value range can be 60% of the first bit rate, and the third level of signal quality composite value range can be 40% of the first bit rate.
[0058] The bit rate corresponding to the signal strength range / transmission speed range / signal quality comprehensive value range can be calculated and stored in advance based on the first bit rate, or it can be calculated in real time when used. This application embodiment does not limit this in advance.
[0059] Furthermore, it is worth noting that the above embodiments only illustrate one encoding format switch. In subsequent transmission processes, the above method will continue to be executed to switch the encoding format. The specific processing is the same as or similar to the processing in the above embodiments, and this application embodiment will not repeat it.
[0060] The process of "determining the target code rate to be used based on signal quality" mentioned in step 401 above is the same as the method for determining the target code rate described in this possible implementation.
[0061] Step 404: The audio output device decodes the received encoded data and plays the decoded audio data.
[0062] In practice, whenever an audio output device receives an encoded data packet, it can decode the encoded data frame according to the encoding format corresponding to each encoded data frame in the encoded data packet, and then play the decoded audio data frame.
[0063] For ease of explanation, the encoded data frame using the first encoding format will be referred to as the first encoded data frame, and the encoded data frame using the second encoding format will be referred to as the second encoded data frame. When switching encoding formats, the first audio data frame obtained by decoding the last first encoded data frame and the second audio data frame obtained by decoding the first second encoded data frame are not sequentially connected, resulting in popping sounds. To avoid this, the transition point can be crossfaded before playback. Specifically, the processing can be as follows: The audio output device decodes the first encoded data according to the decoding library corresponding to the first encoding format to obtain the decoded first audio data stream, and plays the audio data in the first audio data excluding the third duration audio data at the end. The audio output device decodes the second encoded data according to the decoding library corresponding to the second encoding format to obtain the decoded second audio data, and performs crossfading processing on the third duration audio data at the beginning of the second audio data and the third duration audio data at the end of the first audio data, and plays the crossfaded audio data. The audio output device plays the audio data in the second audio data excluding the third duration audio data at the beginning. The third duration audio data can be 1024 frames of audio data. The crossfading process is explained below: Copy the last 1024 frames of audio data from the first audio data set to obtain a 1024-frame copy of the first audio data frame. Then copy the first 1024 frames of audio data from the second audio data set to obtain a 1024-frame copy of the second audio data frame. Cross-fade the first and second audio data frame copies by gradually fading them out (volume gradually decreasing from 1 to 0) and gradually fading them in (volume gradually decreasing from 0 to 1). This results in 1024 smooth audio data frames. Then, replace the last 512 frames of the first audio data set with the first 512 frames of this smooth audio data set, and replace the first 512 frames of the second audio data set with the last 512 frames of this smooth audio data set.
[0064] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0065] In the embodiments of this application, such as Figure 5 As shown, the music application in the terminal device performs PCM encoding on the audio of the target song to be played, obtaining the target audio data stream, also known as the PCM audio data stream. The sampling rate of the PCM audio data stream can be 192kHz, and the bit depth can be 24bit. Then, adaptive bitrate encoding is applied to the PCM audio data stream. That is, steps 401-403 above are executed to predict the signal quality of the WiFi signal. If the WiFi signal quality is predicted to meet the lossless encoding requirements after a certain period of time, the PCM audio data stream is losslessly encoded, such as FLAC. If the WiFi signal quality is predicted to not meet the lossless encoding requirements after a certain period of time, the PCM audio data stream is lossily encoded, such as OGG Vorbis. The target bitrate for lossy encoding is determined based on the predicted signal quality, and then the encoded data is transmitted to the hardware (audio output device). After receiving the encoded data, the audio output device performs an adaptive bitrate decoding process, as described in step 404 above. During this process, if there is a switch in the encoding format, the audio output device can perform smoothing during decoding. The adaptive bitrate decoding technology can be provided by the music application manufacturer. After decoding, a PCM audio data stream is obtained, and the PCM data is converted into an analog signal, i.e., through a DAC (Digital-to-Analog Converter) for digital-to-analog conversion, before playback. The technology related to this function can be implemented by the audio output device manufacturer.
[0066] Based on the same technical concept, embodiments of this application also provide an audio playback device, which can be applied to terminal devices, such as... Figure 6 As shown, the device includes an encoding module 510, a prediction module 520, and a switching module 530, wherein: Encoding module 510 is used to encode the target audio data stream into first encoded data in a first encoding format, and to send the first encoded data to the audio output device via the wireless connection. Prediction module 520 is used to predict the second signal quality of the wireless connection after a first duration based on the current first signal quality of the wireless connection. The switching module 530 is used to encode the target audio data stream into second encoded data in the second encoding format when the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format, and then send the second encoded data to the audio output device through the wireless connection, wherein the bitrates corresponding to the first encoding format and the second encoding format are different.
[0067] In one possible implementation, the first encoding format is a lossless encoding format and the second encoding format is a lossy encoding format; or, the first encoding format is a lossy encoding format and the second encoding format is a lossless encoding format.
[0068] In one possible implementation, the first signal quality includes a first signal strength and / or a first transmission speed, and the second signal quality includes a second signal strength and / or a second transmission speed.
[0069] In one possible implementation, when the bitrate corresponding to the first encoding format is greater than the bitrate corresponding to the second encoding format, the second signal quality does not meet the signal quality condition corresponding to the first encoding format, and meeting the signal quality condition corresponding to the second encoding format means that the second signal strength is less than the first threshold and / or the second transmission speed is less than the second threshold. When the bitrate corresponding to the first encoding format is less than the bitrate corresponding to the second encoding format, the second signal quality does not meet the signal quality condition corresponding to the first encoding format, and meeting the signal quality condition corresponding to the second encoding format means that the second signal strength is greater than the first threshold, and / or the second transmission speed is greater than the second threshold.
[0070] In one possible implementation, if the second signal quality does not meet the signal quality conditions corresponding to the first encoding format, but meets the signal quality conditions corresponding to the second encoding format, the encoding module 510 is further configured to: The terminal device determines the target bit rate based on the second signal quality, the sampling rate, bit depth, and number of channels of the target audio data stream; The terminal device encodes the target audio data stream into a second encoding format with a bitrate of the target bitrate.
[0071] In one possible implementation, the prediction module 520 is configured to: Using signal command information as system state variables, and employing a Kalman filter algorithm, the second signal quality of the wireless connection after the first duration is predicted based on the first signal quality and the historical signal quality of the wireless connection within the second duration prior to the current moment.
[0072] In one possible implementation, the prediction module 520 is configured to: The first signal quality and the historical signal quality of the wireless connection within the second time period before the current time are input into the signal quality prediction model to obtain the second signal quality of the wireless connection after the first time period, wherein the signal quality prediction model is an artificial intelligence model.
[0073] In the solution provided in this application embodiment, the terminal device can predict the signal quality of the wireless network. If the signal quality is poor, a lower bit rate encoding format can be used for encoding and transmission. A lower bit rate results in a smaller amount of encoded data, and even if the signal quality is poor, the transmission can be completed faster, i.e., the transmission delay is smaller. In this way, even if the wireless connection signal quality is poor, the audio output device can receive the encoded audio data stream in time, and the audio playback will not be stuttered due to the poor wireless connection signal quality.
[0074] It should be noted that the audio playback device provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the terminal device can be divided into different functional modules to complete all or part of the functions described above. In addition, the audio playback device and the audio playback method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0075] Figure 7This illustration shows a structural block diagram of an electronic device 800 provided in an exemplary embodiment of this application. The electronic device 800 can be a terminal device, such as a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The electronic device 800 may also be an audio output device, such as headphones or speakers.
[0076] Typically, electronic device 800 includes a processor 801 and a memory 802.
[0077] Processor 801 may include one or more processing cores, such as a quad-core processor or an octa-core processor. Processor 801 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 801 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 801 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 801 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0078] The memory 802 may include one or more computer-readable storage media, which may be non-transitory. The memory 802 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 802 are used to store at least one instruction, which is executed by the processor 801 to implement the audio playback method provided in the method embodiments of this application.
[0079] In some embodiments, the electronic device 800 may optionally include a peripheral device interface 803 and at least one peripheral device. The processor 801, memory 802, and peripheral device interface 803 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 803 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807, a positioning assembly 808, and a power supply 809.
[0080] Peripheral device interface 803 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 801 and memory 802. In some embodiments, processor 801, memory 802 and peripheral device interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 801, memory 802 and peripheral device interface 803 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0081] The radio frequency (RF) circuit 804 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 804 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 804 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 804 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0082] Display screen 805 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 805 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 801 for processing. In this case, display screen 805 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 805, disposed on the front panel of electronic device 800; in other embodiments, there may be at least two display screens, disposed on different surfaces of electronic device 800 or in a folded design; in still other embodiments, display screen 805 may be a flexible display screen, disposed on a curved or folded surface of electronic device 800. Furthermore, display screen 805 may be configured as a non-rectangular irregular shape, i.e., a non-rectangular screen. Display screen 805 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0083] The camera assembly 806 is used to acquire images or videos. Optionally, the camera assembly 806 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 806 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0084] The audio circuit 807 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 801 for processing, or input to the radio frequency circuit 804 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located in a different part of the electronic device 800. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert the electrical signals from the processor 801 or the radio frequency circuit 804 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 807 may also include a headphone jack.
[0085] The positioning component 808 is used to locate the current geographical location of the electronic device 800 in order to enable navigation or LBS (Location Based Service). The positioning component 808 can be a positioning component based on GPS (Global Positioning System), BeiDou system or Galileo system.
[0086] Power supply 809 is used to supply power to various components in electronic device 800. Power supply 809 can be alternating current, direct current, a disposable battery, or a rechargeable battery. When power supply 809 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. A wired rechargeable battery is a battery that is charged via a wired line, while a wireless rechargeable battery is a battery that is charged via a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0087] In some embodiments, the electronic device 800 further includes one or more sensors 810. The one or more sensors 810 include, but are not limited to: an accelerometer 811, a gyroscope 812, a pressure sensor 813, a fingerprint sensor 814, an optical sensor 815, and a proximity sensor 816.
[0088] Accelerometer 811 can detect the magnitude of acceleration on the three coordinate axes of a coordinate system established by electronic device 800. For example, accelerometer 811 can be used to detect the components of gravitational acceleration on the three coordinate axes. Processor 801 can control display screen 805 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 811. Accelerometer 811 can also be used for games or for acquiring user motion data.
[0089] The gyroscope sensor 812 can detect the orientation and rotation angle of the electronic device 800. The gyroscope sensor 812, in conjunction with the accelerometer sensor 811, can collect 3D motion data from the user on the electronic device 800. Based on the data collected by the gyroscope sensor 812, the processor 801 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0090] The pressure sensor 813 can be disposed on the side bezel of the electronic device 800 and / or on the lower layer of the display screen 805. When the pressure sensor 813 is disposed on the side bezel of the electronic device 800, it can detect the user's grip signal on the electronic device 800, and the processor 801 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 813. When the pressure sensor 813 is disposed on the lower layer of the display screen 805, the processor 801 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 805. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0091] The fingerprint sensor 814 is used to collect a user's fingerprint. The processor 801 identifies the user based on the fingerprint collected by the fingerprint sensor 814, or vice versa. When the user's identity is verified as trusted, the processor 801 authorizes the user to perform relevant sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, making payments, and changing settings. The fingerprint sensor 814 can be located on the front, back, or side of the electronic device 800. When the electronic device 800 has a physical button or manufacturer logo, the fingerprint sensor 814 can be integrated with the physical button or manufacturer logo.
[0092] An optical sensor 815 is used to collect ambient light intensity. In one embodiment, the processor 801 can control the display brightness of the display screen 805 based on the ambient light intensity collected by the optical sensor 815. Specifically, when the ambient light intensity is high, the display brightness of the display screen 805 is increased; when the ambient light intensity is low, the display brightness of the display screen 805 is decreased. In another embodiment, the processor 801 can also dynamically adjust the shooting parameters of the camera assembly 806 based on the ambient light intensity collected by the optical sensor 815.
[0093] A proximity sensor 816, also known as a distance sensor, is typically located on the front panel of an electronic device 800. The proximity sensor 816 is used to detect the distance between the user and the front of the electronic device 800. In one embodiment, when the proximity sensor 816 detects that the distance between the user and the front of the electronic device 800 is gradually decreasing, the processor 801 controls the display screen 805 to switch from a screen-on state to a screen-off state; when the proximity sensor 816 detects that the distance between the user and the front of the electronic device 800 is gradually increasing, the processor 801 controls the display screen 805 to switch from a screen-off state to a screen-on state.
[0094] Those skilled in the art will understand that Figure 7 The structure shown does not constitute a limitation on the electronic device 800, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0095] In an exemplary embodiment, a computer-readable storage medium is also provided, such as a memory including instructions that can be executed by a processor in a terminal to perform the audio playback method described above. This computer-readable storage medium may be non-transitory. For example, the computer-readable storage medium may be ROM (Read-Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, and optical data storage devices, etc.
[0096] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals (including but not limited to signals transmitted between user terminals and other devices) involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, all audio, text, and song information involved in this application were obtained with full authorization.
[0097] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0098] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.
[0099] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method of audio playback, characterized by, The method is applied to a streaming audio playing system, the audio playing system comprising a terminal device and an audio output device, a wireless connection being established between the terminal device and the audio output device, target audio data being streaming audio data, the method comprising: The terminal device encodes the target audio data stream into first encoded data of a first encoding format, and sends the first encoded data to the audio output device through the wireless connection; The terminal device predicts a second signal quality of the wireless connection after a first time length according to a current first signal quality of the wireless connection; In a case where the second signal quality does not satisfy a signal quality condition corresponding to the first encoding format and satisfies a signal quality condition corresponding to a second encoding format, the terminal device encodes the target audio data stream into second encoded data of the second encoding format, and sends the second encoded data to the audio output device through the wireless connection, wherein the first encoding format and the second encoding format correspond to different encoding formats; The audio output device decodes the received encoded data, and plays the decoded audio data.
2. The method of claim 1, wherein, The first encoding format is a lossless encoding format, and the second encoding format is a lossy encoding format; or, the first encoding format is a lossy encoding format, and the second encoding format is a lossless encoding format.
3. The method of claim 1, wherein, The first signal quality comprises a first signal strength and / or a first transmission speed, and the second signal quality comprises a second signal strength and / or a second transmission speed.
4. The method of claim 1, wherein, In a case where the second signal quality does not satisfy a signal quality condition corresponding to the first encoding format and satisfies a signal quality condition corresponding to a second encoding format, the method further comprises: The terminal device determines a target code rate according to the second signal quality, a sampling rate, a bit depth and a number of channels of the target audio data stream; The terminal device encodes the target audio data stream into second encoded data of the second encoding format, comprising: The terminal device encodes the target audio data stream into second encoded data of the second encoding format and with a code rate of the target code rate.
5. The method of claim 3, wherein, In a case where a code rate corresponding to the first encoding format is greater than a code rate corresponding to the second encoding format, the second signal quality does not satisfy the signal quality condition corresponding to the first encoding format, and satisfies the signal quality condition corresponding to the second encoding format means that the second signal strength is less than a first threshold value, and / or the second transmission speed is less than a second threshold value; In a case where the code rate corresponding to the first encoding format is less than the code rate corresponding to the second encoding format, the second signal quality does not satisfy the signal quality condition corresponding to the first encoding format, and satisfies the signal quality condition corresponding to the second encoding format means that the second signal strength is greater than the first threshold value, and / or the second transmission speed is greater than the second threshold value.
6. The method of claim 1, wherein, The terminal device predicts a second signal quality of the wireless connection after a first time length according to a current first signal quality of the wireless connection, comprising: The signal instruction information is taken as a system state variable, and the Kalman filtering algorithm is used to predict the second signal quality of the wireless connection after the first time length based on the first signal quality and the historical signal quality of the wireless connection within the second time length before the current time.
7. The method of claim 1, wherein, The terminal device predicts the second signal quality of the wireless connection after the first time length according to the current first signal quality of the wireless connection, and the method comprises the following steps of: The first signal quality and the historical signal quality of the wireless connection within the second time length before the current time are input into a signal quality prediction model to obtain the second signal quality of the wireless connection after the first time length, wherein the signal quality prediction model is an artificial intelligence model.
8. The method according to any one of claims 1-7, characterized in that, The audio output device decodes the received encoded data and plays the decoded audio data, and the method comprises the following steps of: The audio output device decodes the first encoded data to obtain decoded first audio data, and plays the audio data except the fixed-bit audio data at the end of the first audio data; The audio output device decodes the second encoded data to obtain a decoded second audio data stream, performs cross-fading processing on the fixed-bit audio data at the beginning of the second audio data and the fixed-bit audio data at the end of the first audio data, and plays the cross-fading processed audio data; The audio output device plays the audio data except the fixed-bit audio data at the beginning of the second audio data.
9. A terminal device, comprising: The terminal device comprises a processor and a memory, and the memory stores at least one instruction, which is loaded and executed by the processor to realize the operation of the terminal device in the audio playing method of any one of claims 1-8.
10. An audio output device, characterized by The audio output device comprises a processor and a memory, and the memory stores at least one instruction, which is loaded and executed by the processor to realize the operation of the audio output device in the audio playing method of any one of claims 1-8.
11. A computer readable storage medium, characterized in that, The storage medium stores at least one instruction, which is loaded and executed by the processor to realize the operation of the audio playing method of any one of claims 1-8.
12. A computer program product, characterised in that, The computer program product stores at least one instruction, which is loaded and executed by the processor to realize the operation of the audio playing method of any one of claims 1-8.