A multi-audio superposition method based on an embedded device and a related device
By monitoring and adjusting the data volume of the ring buffer in the embedded device, multi-audio superposition is achieved on devices with limited performance, which solves the problem that the embedded device cannot decode multiple white noises at the same time and realizes the flexibility and continuity of audio superposition.
Patent Information
- Application Number
- CN202410976488.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-20
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-07-20
AI Technical Summary
Due to performance limitations, existing embedded devices cannot use multiple decoders to decode different white noises simultaneously, resulting in the inability to flexibly superimpose white noises.
By adopting a multi-audio superposition method in embedded devices, the data volume of the player buffer and the ring buffer is monitored in real time, the ring buffer that needs to be read is determined according to the volume adjustment parameters, and data reading, adjustment and superposition operations are performed, avoiding the use of multiple file decoders and reducing system resource usage.
It enables audio superposition on embedded devices with insufficient processor performance, ensures the continuity and personalized adjustment of audio output, and reduces the requirements for device performance.
Smart Images

Figure CN118981297B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio processing technology, and in particular to a multi-audio superposition method based on an embedded device and related equipment. Background Art
[0002] The current urban life is fast-paced and people are under great pressure. White noise can relieve anxiety, improve work efficiency, and improve concentration. Therefore, more and more people choose to play white noise in their free time. Gradually, people have also put forward more personalized requirements for the white noise played by the device, requiring multiple different white noises to be played in superposition and the volume of different white noises in the superimposed audio to be freely adjusted.
[0003] Currently, a number of mobile phone apps have appeared on the market. Relying on the powerful performance of mobile phones, they can use multiple decoders to decode different white noises at the same time, allowing multiple white noise audios to be played superimposed and controlling the volume of each white noise in the superimposed audio. However, in embedded devices with limited performance, it is impossible to use multiple decoders to decode multiple white noises at the same time, resulting in the inability of embedded devices to flexibly superimpose white noises. Summary of the Invention
[0004] In order to solve the problem that existing embedded devices are unable to use multiple decoders to decode different white noises simultaneously due to performance limitations, resulting in limitations on the embedded devices in superimposing and playing white noise, the present application provides a multi-audio superposition method based on an embedded device and related devices.
[0005] The first aspect of the present application provides a multi-audio superposition output method based on an embedded device, comprising:
[0006] If the user's volume adjustment parameter is received, it is determined whether the data volume in the player buffer is lower than a preset threshold;
[0007] If the data volume of the player buffer is lower than the preset threshold, determining M ring buffers according to the volume adjustment parameter, where M is an integer greater than or equal to 2;
[0008] Determining whether there is a target circular buffer area with a data volume lower than a second preset threshold among the M circular buffer areas, each of the M circular buffer areas storing target data, and the target data stored in each circular buffer area corresponding to one PCM file;
[0009] If the target circular buffer area does not exist in the M circular buffer areas, reading the target data in each of the circular buffer areas according to the volume adjustment parameter to obtain M target sub-data;
[0010] adjusting each of the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data;
[0011] superimposing the M adjusted sub-data to obtain target superimposed data, and writing the target superimposed data into a player buffer area.
[0012] By using the above technical solution, after receiving the volume adjustment parameter of the user, it is judged whether the player buffer area can receive superimposed data. If the player buffer area can receive superimposed data, the ring buffer area that needs to be read is determined according to the volume adjustment parameter, and it is judged whether each determined ring buffer area has sufficient data amount for reading. If each determined ring buffer area has sufficient data amount, the data in each determined ring buffer area is read, the read data is adjusted according to the volume adjustment parameter, and finally the adjusted data is superimposed and stored into the player buffer area. Therefore, when performing audio superimposition operation, multiple file decoders do not need to be opened, and excessive system resource occupation is avoided, so that audio superimposition is realized on an embedded device with insufficient processor performance.
[0013] Optionally, the method further comprises:
[0014] If the data amount of the player buffer area is not less than the preset threshold, the data amount of the player buffer area is monitored in real time.
[0015] If the data amount of the player buffer area is less than the preset threshold, the step of determining M ring buffer areas according to the volume adjustment parameter is performed.
[0016] By using the above technical solution, the data amount of the player buffer area is detected in real time, and the data amount of the player buffer area is supplemented in time when the data amount of the player buffer area is insufficient, so that interruption during output of audio is avoided.
[0017] Optionally, the method further comprises:
[0018] If there is a target ring buffer area in the M ring buffer areas, the data amount of which is less than the second preset threshold, the data amount of the target ring buffer area is supplemented until the data amount of the target ring buffer area reaches the second preset threshold.
[0019] adjusting the data in the target ring buffer area and the data in other ring buffer areas according to the volume adjustment parameter to obtain adjusted multiple sub-data, the other ring buffer areas being buffer areas other than the target ring buffer area in the M ring buffer areas;
[0020] A superposition operation is performed on the plurality of sub-data to obtain first superposition data, and the first superposition data is written into a buffer area of the player.
[0021] By adopting the above technical solution, when performing data superposition, it is determined whether the amount of data in the circular buffer area where data superposition is required is sufficient. If the amount of data in the circular buffer area is insufficient, the amount of data in the corresponding circular buffer area is supplemented, and then the data reading, adjustment and superposition operations are performed to ensure that when data superposition is performed, the corresponding circular buffer area can have enough data to be read.
[0022] Optionally, determining the M ring buffer areas according to the volume adjustment parameter includes the following steps:
[0023] Determine whether there is a first circular buffer area with a volume adjustment parameter of 0 among the N circular buffer areas, where N is an integer greater than or equal to 2;
[0024] If there is a first circular buffer area whose volume adjustment parameter is 0, then remove the first circular buffer area from the N circular buffer areas to obtain the M circular buffer areas, wherein M is less than or equal to N;
[0025] If there is no first circular buffer area with a volume adjustment parameter of 0, the N circular buffer areas are determined as the M circular buffer areas.
[0026] By adopting the above technical solution, the circular buffer area with a volume adjustment parameter of 0 is removed from the list of circular buffer areas to be read, thereby reducing the resource overhead of the embedded system.
[0027] Optionally, the step of reading the target data in each ring buffer according to the volume adjustment parameter to obtain M target sub-data includes the following steps:
[0028] Determine a target reading volume for each of the M annular buffer areas according to a preset reading volume corresponding to the player buffer area;
[0029] Each of the ring buffer areas is read according to the target reading amount to obtain the M target sub-data.
[0030] By adopting the above technical solution, a preset data reading amount is set according to the number of player cache areas and the circular cache areas that need to be read, and the same amount of data from each circular cache area is read according to the preset data reading amount to facilitate subsequent data superposition operations.
[0031] Optionally, adjusting each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data includes the following steps:
[0032] Converting the volume adjustment parameter into a corresponding volume scale coefficient;
[0033] The M target sub-data are adjusted according to the volume proportional coefficient to obtain the M adjusted sub-data.
[0034] By adopting the above technical solution, the volume adjustment parameter is converted into a corresponding volume scale coefficient, and the read data is adjusted according to the volume scale coefficient, so as to facilitate the audio superposition operation of different volumes.
[0035] Optionally, a multi-audio superposition output method based on an embedded device also includes
[0036] If there is no second circular buffer area with a data volume lower than the second preset threshold value among the N circular buffer areas, monitoring the data volume of the N circular buffer areas in real time;
[0037] If there is a second annular buffer area among the N annular buffer areas whose data volume is lower than the second preset threshold, the data volume of the second annular buffer area is replenished until the data volume of the second annular buffer area reaches the second preset threshold.
[0038] By adopting the above technical solution, the data volume of the circular buffer area can be detected in real time, and the data volume of the circular buffer area can be supplemented in time when the data volume of the circular buffer area is insufficient, ensuring that the circular buffer area can provide sufficient data when data superposition is required.
[0039] The second aspect of the present application provides an embedded device, which adopts the following technical solution:
[0040] An embedded device, comprising:
[0041] A receiving module, configured to receive a volume adjustment parameter from a user;
[0042] a determining module, configured to determine M ring buffers according to the volume adjustment parameter, wherein M is an integer greater than or equal to 2;
[0043] A determination module, configured to determine whether there is a target circular buffer having a data volume lower than a second preset threshold value among the M circular buffers and to determine whether the data volume of the player buffer is lower than a preset threshold value;
[0044] a reading module, configured to read the target data in each of the ring buffer areas according to the volume adjustment parameter to obtain M target sub-data;
[0045] an adjustment module, configured to adjust each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data;
[0046] The superposition module is used to perform a superposition operation on the M adjusted sub-data to obtain target superposition data, and write the target superposition data into a player buffer area.
[0047] A third aspect of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the multi-audio superposition method based on an embedded device described in the first aspect are implemented.
[0048] In a fourth aspect, the present application provides a computer storage medium comprising instructions, which, when executed on a computer, enables the computer to execute the steps of a multi-audio superposition method based on an embedded device as described in any one of the above aspects.
[0049] In summary, it can be seen that in the embodiments provided by this application, the data volume in the player buffer and each annular buffer is monitored in real time. If the data volume in each annular buffer is insufficient, data is read from the corresponding PCM file to ensure that the data volume in the annular buffer is sufficient. If the data volume in the player buffer is insufficient, the data in each annular buffer is read and adjusted according to the obtained volume adjustment parameters, and a data superposition operation is performed, and the superimposed data is written to the annular buffer. This eliminates the need to use multiple decoders to decode different audio files before performing audio superposition, reduces the requirements for device performance when performing audio superposition operations, and can achieve personalized superimposed audio on embedded devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 This is a flowchart of a multi-audio superposition method based on an embedded device provided in an embodiment of the present application;
[0051] Figure 2 This is a virtual structural diagram of a multi-audio superposition device based on an embedded device provided in an embodiment of the present application;
[0052] Figure 3 This is a schematic diagram of the hardware structure of a computer device provided in an embodiment of the present application; DETAILED DESCRIPTION
[0053] The following will combine the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0054] For ease of understanding, some terms provided in the embodiments of this application are explained below, specifically as follows:
[0055] A PCM file is an audio file format that stores sound information by converting analog audio signals into digital signals.
[0056] Sampling rate refers to the number of times the original sound signal is sampled per second during the audio digitization process. The unit of sampling rate is Hertz, which represents the number of samples per second.
[0057] The number of bits refers to the bit depth of the audio file, which indicates the quantization accuracy of each sampling point, that is, how many bits of binary number are used to represent each sampling value.
[0058] The following describes a multi-audio superposition method based on an embedded device from the perspective of an embedded device. The embedded device may be a server or a service unit in a server, and the specific details are not limited thereto.
[0059] See also Figure 1 , Figure 1 The embodiment of the present application provides a multi-audio superposition method based on an embedded device, comprising:
[0060] 101. If the volume adjustment parameter of the user is received, determine whether the data volume in the player buffer is lower than a preset threshold. If so, execute step 102.
[0061] In this embodiment, the embedded device can obtain the user's volume adjustment parameters, which include but are not limited to various audio volume increase and decrease parameters and audio signal parameters, the embedded device's system volume control parameters, and the application volume control parameters. The method of obtaining the volume adjustment parameters can be that the user obtains the volume adjustment parameters by adjusting a knob on the embedded device, or the user enters the volume adjustment parameters through a dialog box provided by the embedded device or by sliding a slider in the dialog box. Of course, the volume adjustment parameters can also be obtained through other methods, such as the user storing multiple volume adjustment parameters in the embedded device in advance and automatically obtaining the corresponding volume adjustment parameters when needed. The specific method is not limited;
[0062] Afterwards, the embedded device will determine whether the data volume in the player cache is lower than the preset threshold. The preset threshold is the limit value at which the data volume in the player cache is at a lower level. The data volume in the player cache is maintained above this limit value to ensure that the player cache has enough data volume to continuously output audio data.
[0063] In one embodiment, after the embedded device determines whether the amount of data in the player buffer is lower than a preset threshold, the embedded device includes the following steps:
[0064] If the data volume in the player buffer is not less than a preset threshold, the data volume in the player buffer is monitored in real time;
[0065] If the data volume in the player buffer is lower than a preset threshold, the step of determining M circular buffers according to the volume adjustment parameter is executed.
[0066] In this embodiment, the embedded device will continuously monitor the data volume of the player cache area. If the data volume of the current player cache area is lower than the preset threshold, the embedded device will promptly start the data superposition operation according to the currently obtained volume adjustment parameter to supplement the data volume of the player cache area, that is, execute step 102 to determine the M circular buffer areas according to the volume adjustment parameter. If the data volume of the current player cache area is not lower than the preset threshold, the embedded device will continue to monitor the data volume of the player cache area.
[0067] In one embodiment, the embedded device determines whether the amount of data in the player buffer is lower than a preset threshold before the embedded device determines whether the amount of data in the player buffer is lower than a preset threshold, including the following steps:
[0068] If there is no second circular buffer area with a data volume lower than the second preset threshold value among the N circular buffer areas, the data volume of the N circular buffer areas is monitored in real time;
[0069] If there is a second circular buffer area with a data volume lower than the second preset threshold value among the N circular buffer areas, the data volume of the second circular buffer area is replenished until the data volume of the second circular buffer area reaches the second preset threshold value.
[0070] In this embodiment, the embedded device will continuously monitor the data volume of N circular buffer areas. If the data volume appearing in the N circular buffer areas is lower than the circular buffer area at the second preset threshold, the embedded device will promptly read the PCM file data and write it to the circular buffer area. The PCM file can be stored in the embedded device in advance according to the corresponding audio parameters, or the embedded device can filter out the corresponding audio parameters in the audio database according to the corresponding audio parameters. There is no specific limitation. The audio parameters are determined based on the processor performance of the embedded device, including but not limited to the audio sampling rate, the number of audio bits, etc. If the data volume that does not exist in the current N circular buffer areas is not lower than the circular buffer area at the second preset threshold, the embedded device will continue to monitor the data volume of the N circular buffer areas.
[0071] 102. Determine M ring buffer areas according to the volume adjustment parameter;
[0072] In this embodiment, when the amount of data in the player buffer area is lower than a preset threshold, the embedded device will determine M circular buffer areas based on the user's volume adjustment parameter, where M is an integer greater than or equal to 2. The M circular buffer areas are the circular buffer areas that need to be read and superimposed for data subsequently.
[0073] In one embodiment, determining the M ring buffer areas according to the volume adjustment parameter includes:
[0074] Determine whether there is a first circular buffer area with a volume adjustment parameter of 0 among the N circular buffer areas, where N is an integer greater than or equal to 2;
[0075] If there is a first circular buffer area with a volume adjustment parameter of 0, the first circular buffer area is removed from the N circular buffer areas to obtain M circular buffer areas, where M is less than or equal to N;
[0076] If there is no first circular buffer area with a volume adjustment parameter of 0, the N circular buffer areas are determined to be M circular buffer areas.
[0077] In this embodiment, the embedded device determines whether the volume adjustment parameter of the circular buffer area is 0, and eliminates the circular buffer area with the volume adjustment parameter being 0, thereby determining M circular buffer areas from the N circular buffer areas. The embedded device may also add an identifier of the circular buffer area to the received volume adjustment parameter. The embedded device parses the volume adjustment parameter to obtain the identifier of the circular buffer area, and determines M circular buffer areas from the N circular buffer areas according to the identifier.
[0078] 103 . Determine whether there is a target circular buffer with a data volume lower than a second preset threshold among the M circular buffers. If not, execute step 104 .
[0079] In this embodiment, the embedded device determines whether the data volume of the M ring buffer areas reaches a second preset threshold value. The second preset threshold value is the limit value at which the data volume of the ring buffer areas is at a lower level. The data volume of the ring buffer areas is maintained above this limit value to ensure that the ring buffer areas have sufficient data volume to be read in subsequent overlay operations.
[0080] In one embodiment, after determining whether there is a target ring buffer area with a data volume lower than a second preset threshold among the M ring buffer areas, the following steps are further included:
[0081] If there is a target circular buffer area with a data volume lower than the second preset threshold value among the M circular buffer areas, the data volume of the target circular buffer area is replenished until the data volume of the target circular buffer area reaches the second preset threshold value;
[0082] Adjusting the data in the target annular buffer and the data in other annular buffers according to the volume adjustment parameter to obtain a plurality of adjusted sub-data, where the other annular buffers are buffers other than the target annular buffer among the M annular buffers;
[0083] A superposition operation is performed on the plurality of sub-data to obtain first superposition data, and the first superposition data is written into a buffer area of the player.
[0084] In this embodiment, if a circular buffer area with a data volume lower than the second preset threshold appears in the M circular buffer areas of the embedded device, the corresponding PCM file data will be read and written into the circular buffer area until the data of the M circular buffer areas reaches the second preset threshold value. The data of the M circular buffer areas are adjusted according to the volume adjustment parameter, and the adjusted multiple sub-data are superimposed, and the superimposed data are written into the player buffer area, that is, the operations of steps 104 to 106 are executed.
[0085] 104. Read the target data in each ring buffer according to the volume adjustment parameter to obtain M target sub-data;
[0086] In this embodiment, if there is no circular buffer area with a volume lower than the second threshold value among the M circular buffer areas of the embedded device, the data of the circular buffer area is read according to the volume adjustment parameter obtained in step 101, and the reading position of the circular buffer area is the position at the end of the last reading of the circular buffer area.
[0087] In one embodiment, reading the target data in each ring buffer according to the volume adjustment parameter to obtain M target sub-data further includes the following steps:
[0088] Determine the target reading volume of each of the M circular buffer areas according to the preset reading volume corresponding to the player buffer area;
[0089] Each ring buffer is read according to the target reading amount to obtain M target sub-data.
[0090] In this embodiment, the embedded device determines a preset read amount according to the size of the player buffer area, calculates a target read amount according to the preset read amount and M ring buffers, and reads data of the M target read amount from the M ring buffers to obtain M target sub-data;
[0091] The following uses a specific example to illustrate how an embedded device calculates the target read volume based on the preset read volume and M ring buffers. Assuming that the preset read volume of the embedded device is 64KB and there are 4 ring buffers that need to be read, the target read volume is 16KB. 16KB of data will be read from each ring buffer to obtain 4 16KB target sub-data.
[0092] 105. Adjust each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data;
[0093] In this embodiment, the embedded device adjusts each target sub-data according to the volume adjustment parameter. Adjusting the target sub-data includes but is not limited to adjusting the volume, adjusting the equalizer, bass enhancement, treble enhancement, adjusting the channel, etc.
[0094] In one embodiment, adjusting each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data further includes the following steps:
[0095] Convert the volume adjustment parameter into the corresponding volume scale coefficient;
[0096] The M target sub-data are adjusted according to the volume scale coefficient to obtain M adjusted sub-data.
[0097] In this embodiment, the embedded device converts the volume adjustment parameter into a corresponding volume scale coefficient, and multiplies the volume scale coefficient by the target sub-data to obtain adjusted sub-data.
[0098] The following describes how to convert volume adjustment parameters into corresponding volume scaling coefficients using a specific example. The volume adjustment parameters received in step 101 are 60, 40, and 100, which correspond to the volume adjustment parameters of three target sub-data, respectively. The volume adjustment parameters are converted into corresponding volume scaling coefficients of 0.6, 0.4, and 1. The volume scaling coefficients are multiplied by the corresponding target sub-data to obtain the corresponding adjusted sub-data.
[0099] 106. Perform a superposition operation on the M adjusted sub-data to obtain target superposition data, and write the target superposition data into a player buffer area.
[0100] In this embodiment, the embedded device performs a superposition operation on the M adjusted sub-data, aligns the multiple target sub-data in time, and adds the values at each sampling point to form superimposed data. After the audio superposition is completed, in order to avoid value overflow and audio distortion, the embedded device can avoid value overflow by calculating the average value of the superimposed data, using a limiter to limit the overflow of the superimposed data, or continuously monitoring the superimposed data and making timely adjustments when the superimposed data is about to overflow. The specific details are not limited.
[0101] The overlay data is then written to the player buffer.
[0102] In summary, it can be seen that in the embodiment provided by the present application, N PCM files with the same sampling rate and number of bits are selected and stored in the embedded device according to the performance parameters of the embedded device.
[0103] The embedded device simultaneously monitors the data volume of N ring buffers and the data volume of the player buffer. When the data volume of the N ring buffers is too low, the corresponding PCM files can be read in time to supplement them. When the data volume of the player buffer is too low, the audio superposition operation can be started in time to supplement them, and the superimposed data can be processed to prevent overflow, so as to realize personalized and continuous audio superposition operations on embedded devices with insufficient performance.
[0104] See also Figure 2 , Figure 2 This is a virtual structural diagram of a multi-audio superposition device based on an embedded device in this application. The image transmission test system 200 includes:
[0105] Receiving module 201, used to receive the volume adjustment parameter of the user;
[0106] A determination module 202 is configured to determine M ring buffers according to the volume adjustment parameter, where M is an integer greater than or equal to 2;
[0107] A determination module 203 is configured to determine whether there is a target circular buffer with a data volume lower than a second preset threshold value among the M circular buffers and to determine whether the data volume of the player buffer is lower than a preset threshold value;
[0108] a reading module 204 configured to read the target data in each of the ring buffers according to the volume adjustment parameter to obtain M target sub-data;
[0109] an adjustment module 205 for adjusting each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data;
[0110] The superposition module 206 is configured to perform a superposition operation on the M adjusted sub-data to obtain target superposition data, and write the target superposition data into a player buffer area.
[0111] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device 300 includes:
[0112] At least one processor 301, at least one communication bus 302, at least one memory 306, a power supply 307, and a user interface 308. The user interface 308 of the computer device 300 includes a display, a knob, or a click device. The memory 306 may include a high-speed RAM memory or a non-volatile memory, such as at least one disk storage. The memory 306 stores one or more computer programs 303 or data 305. When the terminal device 300 is running, the processor 301 communicates with the memory 306, and the processor 301 calls the instructions stored in the memory 306 to execute the above-mentioned instructions. Figure 1 The operating system 304 includes various programs for implementing various basic services and processing tasks based on hardware.
[0113] In one embodiment, the present application provides a computer device, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a multi-audio superposition method based on an embedded device is implemented.
[0114] Those skilled in the art will understand that Figure 3 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0115] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0116] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The above-described computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the above-described method embodiments. Any reference to memory, storage, database, or other media used in the embodiments provided herein may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0117] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.
Claims
1. A multi-audio superposition method based on embedded devices, characterized in that: The method comprises: If the user's volume adjustment parameter is received, it is determined whether the data volume in the player buffer is lower than a preset threshold; If the data volume of the player buffer is lower than the preset threshold, determining M ring buffers according to the volume adjustment parameter, where M is an integer greater than or equal to 2; Determining whether there is a target circular buffer area with a data volume lower than a second preset threshold among the M circular buffer areas, each of the M circular buffer areas storing target data, and the target data stored in each circular buffer area corresponding to one PCM file; If the target circular buffer area does not exist in the M circular buffer areas, reading the target data in each of the circular buffer areas according to the volume adjustment parameter to obtain M target sub-data; Adjusting each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data; Performing a superposition operation on the M adjusted sub-data to obtain target superposition data, and writing the target superposition data into a player buffer area; If there is a target circular buffer area among the M circular buffer areas whose data volume is lower than the second preset threshold, the data volume of the target circular buffer area is supplemented until the data volume of the target circular buffer area reaches the second preset threshold, wherein the data volume of the target circular buffer area is supplemented by an embedded device reading PCM file data and writing it into the target circular buffer area, wherein the PCM file is stored in the embedded device according to corresponding audio parameters, or the embedded device selects the audio file according to corresponding audio parameters in an audio database, wherein the audio parameters are determined according to the processor performance of the embedded device, and the audio parameters include audio sampling rate and audio bit number; adjusting the data in the target annular buffer and the data in other annular buffers according to the volume adjustment parameter to obtain a plurality of adjusted sub-data, wherein the other annular buffers are buffers in the M annular buffers other than the target annular buffer; A superposition operation is performed on the plurality of sub-data to obtain first superposition data, and the first superposition data is written into a buffer area of the player.
2. The method according to claim 1, characterized in that The method further comprises: If the data volume in the player buffer area is not less than the preset threshold, the data volume in the player buffer area is monitored in real time; If the data volume of the player buffer is lower than the preset threshold, the step of determining M ring buffers according to the volume adjustment parameter is performed.
3. The method according to claim 1, characterized in that Determining the M ring buffer areas according to the volume adjustment parameter includes: Determine whether there is a first circular buffer area with a volume adjustment parameter of 0 among the N circular buffer areas, where N is an integer greater than or equal to 2; If there is a first circular buffer area with a volume adjustment parameter of 0, then removing the first circular buffer area from the N circular buffer areas to obtain the M circular buffer areas, wherein M is less than N; If there is no first circular buffer area with a volume adjustment parameter of 0, the N circular buffer areas are determined as the M circular buffer areas.
4. The method according to claim 1, characterized in that The step of reading the target data in each ring buffer according to the volume adjustment parameter to obtain M target sub-data includes: Determine a target reading volume for each of the M annular buffer areas according to a preset reading volume corresponding to the player buffer area; Each of the ring buffer areas is read according to the target reading amount to obtain the M target sub-data.
5. The method according to claim 1, characterized in that: The step of adjusting each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data includes: Converting the volume adjustment parameter into a corresponding volume scale coefficient; The M target sub-data are adjusted according to the volume proportional coefficient to obtain the M adjusted sub-data.
6. The method according to claim 3, characterized in that: The method further comprises: If there is no second circular buffer area with a data volume lower than the second preset threshold value among the N circular buffer areas, monitoring the data volume of the N circular buffer areas in real time; If there is a second annular buffer area among the N annular buffer areas whose data volume is lower than the second preset threshold, the data volume of the second annular buffer area is replenished until the data volume of the second annular buffer area reaches the second preset threshold.
7. A multi-audio superposition device based on an embedded device, characterized in that: include: A receiving module, configured to receive a volume adjustment parameter from a user; a determining module, configured to determine M ring buffers according to the volume adjustment parameter, wherein M is an integer greater than or equal to 2; a determination module, configured to determine whether there is a target circular buffer with a data volume lower than a second preset threshold value among the M circular buffers and to determine whether the data volume of the player buffer is lower than a preset threshold value, wherein each of the M circular buffers stores target data, and the target data stored in each circular buffer corresponds to one PCM file; a reading module, configured to read the target data in each of the ring buffer areas according to the volume adjustment parameter to obtain M target sub-data; an adjustment module, configured to adjust each target sub-data in the M target sub-data according to the volume adjustment parameter to obtain M adjusted sub-data; a superposition module, configured to perform a superposition operation on the M adjusted sub-data to obtain target superposition data, and write the target superposition data into a player buffer; The adjustment module is also used for: If there is a target circular buffer area among the M circular buffer areas whose data volume is lower than the second preset threshold, the data volume of the target circular buffer area is supplemented until the data volume of the target circular buffer area reaches the second preset threshold, wherein the data volume of the target circular buffer area is supplemented by an embedded device reading PCM file data and writing it into the target circular buffer area, wherein the PCM file is stored in the embedded device according to corresponding audio parameters, or the embedded device selects the audio file according to corresponding audio parameters in an audio database, wherein the audio parameters are determined according to the processor performance of the embedded device, and the audio parameters include audio sampling rate and audio bit number; adjusting the data in the target annular buffer and the data in other annular buffers according to the volume adjustment parameter to obtain a plurality of adjusted sub-data, wherein the other annular buffers are buffers in the M annular buffers other than the target annular buffer; A superposition operation is performed on the plurality of sub-data to obtain first superposition data, and the first superposition data is written into a buffer area of the player.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the multi-audio superposition method based on an embedded device are implemented as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the multi-audio superposition method based on an embedded device are implemented.
Citation Information
Patent Citations
Audio and video processing method and device, terminal and storage medium
CN109819314A
Audio mixing processing method and device, chip, Bluetooth equipment and audio mixing system
CN117012215A