Mode switching optimization method, system and equipment of audio input player and storage medium
A persistent audio capture session and dynamic processing pipeline with gradual switching and cross-fade technology address mode switching issues in audio input players, providing seamless transitions and improved user experience.
Patent Information
- Application Number
- CN202411176407.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-27
AI Technical Summary
Existing audio input player technologies face delays, hardware instability, and audio interruptions during mode switching, particularly in scenarios requiring frequent mode changes.
Implement a persistent audio capture session and dynamic audio processing pipeline with gradual switching and cross-fade technology, using system-level APIs, variable circular buffers, and intelligent resource management to ensure seamless mode transitions.
This approach reduces delays, stabilizes the system, and enhances the user experience by ensuring audio continuity and smooth transitions while optimizing resource usage and error handling.
Smart Images

Figure CN119201030A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of audio playback technology, and in particular to a mode switching optimization method, system, device and storage medium for an audio input player. Background Art
[0002] In existing audio input player technologies, mode switching usually involves reconfiguring and initializing the audio capture device. Although this method is simple and direct, it has many problems. First, it takes a certain amount of time to reopen the capture device, resulting in a significant delay when switching modes. Second, frequently opening and closing the capture device may cause hardware or driver instability, increasing the risk of system crashes. In addition, during the switching process, short audio interruptions or noise may occur, affecting the user experience. These problems are particularly prominent in scenarios where frequent mode switching is required, such as in multi-function audio processing systems or professional audio production environments. Summary of the invention
[0003] The present invention provides a mode switching optimization method, system, device and storage medium for an audio input player. Through a persistent audio capture session and a dynamic audio processing pipeline, the problem of reopening the capture when the audio input player switches modes is effectively solved. Combined with gradual switching and cross-fade technology, audio continuity and smooth transition are ensured, greatly improving the user experience.
[0004] A first aspect of the present invention provides a mode switching optimization method for an audio input player, comprising the following steps:
[0005] Creating a persistent audio capture session, and calling a background service process to maintain the persistent audio capture session;
[0006] Continuously capture audio data and store it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used to monitor and cache audio data of a corresponding audio input interface;
[0007] Controlled by a preset switching instruction, adjusting a processing pipeline configuration based on corresponding audio data in the preset buffer;
[0008] The playing module switches to the target mode of the switching instruction based on the preset smooth switching module to play the audio.
[0009] Preferably, creating a persistent audio capture session, calling a background service process to maintain the persistent audio capture session further comprises:
[0010] Use system-level APIs to create a persistent audio capture session. The background service process runs automatically at system startup and remains active after the application exits.
[0011] Preferably, the IAudioClient interface of WASAPI is used on Windows, and the AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag is specified when the Initialize method is called to run in an event-driven manner.
[0012] Preferably, continuously capturing audio data and storing it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used to monitor and cache audio data of a corresponding audio input interface, further comprising:
[0013] Monitor and capture audio data of each audio input interface based on configured basic parameters, wherein the basic parameters include at least: sampling rate, bit depth, and number of channels;
[0014] The audio capture process is started, the captured audio data is temporarily stored in a corresponding variable circular buffer, and the latest stored audio data is read when needed.
[0015] Preferably, controlled by a preset switching instruction, adjusting the processing pipeline configuration based on the corresponding audio data in the preset buffer further comprises:
[0016] Capturing parameters about the processing pipeline configuration in the switching command, and adjusting the output mode and output mode parameters based on the parameters of the processing pipeline configuration, wherein the output mode parameters include noise reduction module parameters, equalizer parameters, and compressor parameters in the processing pipeline;
[0017] A state machine is used to manage the processing pipeline configuration adjustment of the mode switching process to ensure that the components work in coordination.
[0018] Preferably, the noise reduction module uses a spectrum subtraction algorithm to subtract the noise spectrum dynamically estimated using the recursive averaging method from the noisy signal spectrum, s(n) represents the pure signal, n(n) is the additive noise, and x(n) is the observed noisy signal:
[0019] x(n)=s(n)+n(n),
[0020] In the frequency domain it is expressed as:
[0021] X(k)=S(k)+N(k), where X(k), S(k) and N(k) are the discrete Fourier transforms of x(n), s(n) and n(n), respectively;
[0022] The estimated signal of the spectrum subtraction is:
[0023] where E[|N(k)|2] is an estimate of the noise power spectrum;
[0024] Wherein, for the spectrum subtraction algorithm:
[0025] Introducing frequency-dependent over-reduction factors to adopt different suppression strengths in different frequency bands;
[0026] Preserve the details of the music signal by detecting the harmonic structure to suppress the music residue;
[0027] Power-law spectrum subtraction is used to improve the protection of weak signals;
[0028] Minimum statistical phase estimation is introduced to perform phase compensation to improve the naturalness of the reconstructed signal.
[0029] Preferably, the playing module switches to the target mode of the switching instruction based on the preset smooth switching module to play the audio further includes:
[0030] Smoothly adjusting processing parameters, the processing parameters including equalizer setting parameters and compression ratio parameters;
[0031] Performing a smooth transition of the signal level of the audio data to avoid popping sounds caused by sudden changes;
[0032] When switching modes, the processing parameters are first adjusted gradually, and the audio signal is faded out at the same time. After the switching is completed, the audio processed by the new mode is faded in.
[0033] Preferably, the smooth adjustment processing parameters further include:
[0034] Based on the basic formula of linear interpolation y=y1+(x-x1)*(y2-y1) / (x2-x1), linear interpolation is implemented to complete mode switching within 500ms, where (x1, y1) and (x2, y2) are two known points, x is the independent variable representing time, and y is the dependent variable to be calculated representing the mixing ratio of the new and old modes.
[0035] Preferably, fading out the audio signal and fading in the audio processed in the new mode after the switching is completed further comprises:
[0036] To gradually reduce the volume of old audio while increasing the volume of new audio over a period of time, you can use the following formula:
[0037] result(t)=old_audio(t)*(1-fade(t))+new_audio(t)*fade(t), where fade(t) is a function from 0 to 1, t is the normalized time (0 to 1), and the fade function is a cosine function: fade(t)=(1-cos(π*t)) / 2.
[0038] Preferably, continuously capturing audio data and storing it in a preset buffer further includes dynamically adjusting the buffer size:
[0039] This is achieved through modulo operation: index=(write_pointer+i)%buffer_size, where write_pointer is the current write position, i is the offset, and buffer_size is the buffer size.
[0040] Preferably, the method further comprises performing dynamic thread management while the persistent audio capture session is active:
[0041] Dynamically adjust the task allocation granularity according to the computational complexity of the processing module;
[0042] The machine learning model predicts future load and adjusts the number of threads in advance;
[0043] Consider the energy efficiency characteristics of the processor and optimize energy consumption while ensuring performance;
[0044] Dynamically distribute processing tasks between the CPU and GPU based on task characteristics.
[0045] Preferably, the method further comprises recovering based on a preset automatic recovery mechanism during the active process of the persistent audio capture session:
[0046] Categorize preset types of hardware errors, software anomalies, and resource exhaustion errors;
[0047] When an error occurs, select the corresponding recovery strategy from the recovery strategy library to restart the service, release resources, or perform downgrade processing;
[0048] Periodically save key status information to quickly rebuild the system status during recovery;
[0049] Based on a preset progressive multi-level recovery strategy, it gradually escalates from light intervention to full restart;
[0050] Record the effect of each recovery and use machine learning algorithms to optimize the recovery strategy.
[0051] A second aspect of the present invention provides a mode switching optimization system for an audio input player, comprising:
[0052] A startup unit, configured to create a persistent audio capture session and call a background service process to maintain the persistent audio capture session;
[0053] A capture unit, used for continuously capturing audio data and storing it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used for monitoring and caching audio data of a corresponding audio input interface;
[0054] a configuration adjustment unit, configured to be controlled by a preset switching instruction and to adjust a processing pipeline configuration based on corresponding audio data in the preset buffer;
[0055] The playing unit is used to switch to the target mode of the switching instruction to play audio based on a preset smooth switching module.
[0056] A third aspect of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned mode switching optimization method of the audio input player when executed by the processor.
[0057] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the above-mentioned method for optimizing mode switching of an audio input player.
[0058] In the technical solution provided by the present invention, by maintaining a persistent audio capture session and a dynamic audio processing pipeline, not only the problem of reopening the capture is solved, but also seamless mode switching is achieved. It also provides a smoother user experience while taking into account multiple aspects such as resource management, error handling, and personalized needs. This comprehensive solution will greatly improve the performance and usability of the audio input player. Gradual switching and cross-fade technology ensure audio continuity and smooth transition. In addition, intelligent resource management strategies such as circular buffers, dynamic thread management, and intelligent power consumption control are introduced to optimize system performance and battery life. Robust error detection and automatic recovery mechanisms enhance system stability, while a detailed log system facilitates problem diagnosis and subsequent optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 Schematic diagram of the flow of the mode switching optimization method of the audio input player in this embodiment;
[0060] Figure 2 This is a flow chart of continuously capturing audio data and storing it in a preset buffer in this embodiment;
[0061] Figure 3 FIG. 4 is a schematic diagram of an embodiment of a computer device in this embodiment. DETAILED DESCRIPTION
[0062] The present invention provides a mode switching optimization method, system, device and storage medium for an audio input player, which effectively solves the problem of reopening capture when the audio input player switches modes through a persistent audio capture session and a dynamic audio processing pipeline.
[0063] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0064] Embodiment 1
[0065] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , provides a mode switching optimization method for an audio input player, comprising the following steps:
[0066] S1: Create a persistent audio capture session, and call a background service process to maintain the persistent audio capture session.
[0067] By innovatively creating a persistent audio capture session, the problem of the audio input player reopening the capture when switching modes is effectively solved. Maintaining a persistent audio capture session enables seamless mode switching, greatly reducing delays and instability during the switching process.
[0068] Preferably, creating a persistent audio capture session, calling a background service process to maintain the persistent audio capture session further comprises:
[0069] Use system-level APIs to create a persistent audio capture session. The background service process runs automatically at system startup and remains active after the application exits.
[0070] Since there is no need to reopen the capture when switching modes, there is almost no delay when switching between different modes, and audio playback is continuous and uninterrupted. At the same time, this method also reduces the consumption of device resources and improves the performance and reliability of the overall system.
[0071] More specifically, on Windows, use the IAudioClient interface of WASAPI and specify the AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag when calling the Initialize method to run in event-driven mode.
[0072] Alternatively, if it is a Linux system, create an audio capture session in the audio API provided by ALSA in the Linux system.
[0073] And set the basic parameters of audio capture, such as sampling rate, bit depth, number of channels, etc. These parameters should be set to the highest specifications that support all possible modes. For example, configure 44.1kHz sampling rate, 24-bit depth, and dual-channel audio capture.
[0074] Then the audio capture process begins. It should be noted that the captured audio data will not be processed temporarily to reduce system resource consumption. Continuous processing may occupy a lot of CPU and memory resources. Only the original data is captured, which can be flexibly processed according to different mode requirements to improve flexibility. In addition, real-time processing will introduce additional delays, while directly caching the original data can minimize delays. Keeping the original data facilitates reprocessing when switching modes to achieve seamless transition.
[0075] S2: continuously capture audio data and store it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used to monitor and cache audio data of a corresponding audio input interface;
[0076] Specifically, continuously capturing audio data and storing it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used to monitor and cache audio data of a corresponding audio input interface, further comprising:
[0077] S21: monitoring and capturing audio data of each audio input interface based on configured basic parameters, where the basic parameters include at least: sampling rate, bit depth, and number of channels;
[0078] S22: Start the audio capture process, temporarily store the captured audio data in a corresponding variable circular buffer, and read the latest stored audio data when needed.
[0079] It can capture and cache real-time audio data from multiple audio input interfaces, and flexibly configure parameters. It can adjust parameters such as sampling rate, bit depth and number of channels according to actual needs, process audio data in advance, and play audio data immediately when it is needed to play audio data input from a certain interface, thus improving the efficiency and real-time performance of audio processing. At the same time, by using a variable circular buffer, it can effectively manage memory resources and avoid memory overflow caused by an overly large buffer, so as to meet the audio processing needs in different scenarios.
[0080] Preferably, continuously capturing audio data and storing it in a preset buffer further includes dynamically adjusting the buffer size:
[0081] This is achieved through modulo operation: index=(write_pointer+i)%buffer_size, where write_pointer is the current write position, i is the offset, and buffer_size is the buffer size.
[0082] In order to reduce memory usage and improve efficiency, a smart audio buffer management is implemented, using a circular buffer to manage audio data and dynamically adjusting the buffer size based on the current mode. A circular buffer is a fixed-size buffer that overwrites old data from the beginning when the end is reached.
[0083] For example, suppose we have a circular buffer of size 1000, the current write_pointer is 800, and we want to write 300 new samples. Then the first 200 samples will be written to positions 800-999, and the next 100 samples will be written to positions 0-99.
[0084] When a mode switching instruction is received, the mode switching is performed.
[0085] S3: controlled by a preset switching instruction, adjusting the processing pipeline configuration based on the corresponding audio data in the preset buffer;
[0086] Design a pipeline with multiple processing modules, such as noise reduction, equalizer, compressor, etc., which can be turned on or off according to the mode. Thanks to the configurable audio processing pipeline, the processing steps can be dynamically adjusted according to different modes.
[0087] Specifically, controlled by the preset switching instruction, adjusting the processing pipeline configuration based on the corresponding audio data in the preset buffer further includes:
[0088] Capturing parameters about the processing pipeline configuration in the switching command, and adjusting the output mode and output mode parameters based on the parameters of the processing pipeline configuration, wherein the output mode parameters include noise reduction module parameters, equalizer parameters, and compressor parameters in the processing pipeline;
[0089] A state machine is used to manage the processing pipeline configuration adjustment of the mode switching process to ensure that the components work in coordination.
[0090] By adjusting the configuration of the processing pipeline by presetting switching instructions, audio processing parameters can be quickly switched for different scenarios or different needs. For example, when switching between speech recognition and music playback, you can quickly switch from one parameter configuration to another to optimize the audio processing effect for each scenario. The system dynamically adjusts these parameters according to different input audio and application scenarios. Doing so can optimize audio quality and improve the system's ability to adapt to different environmental conditions. Because the system can dynamically adjust according to real-time captured audio data and instant switching instructions, this can improve processing efficiency and reduce resource waste or processing delays caused by manual or static configuration. Using a state machine to manage the switching process ensures that the components of the system can work in coordination and reduce possible errors or conflicts when switching states. The state machine can define clear transition conditions and behaviors for each possible state of the system, making the system behavior more predictable and stable. In addition, using a variable circular buffer and dynamically adjusting the configuration of the processing pipeline can effectively use system resources such as memory and processor power while ensuring audio quality and processing effects.
[0091] For example, you can switch between "call mode" and "music mode". In call mode, enable noise reduction and echo cancellation modules; in music mode, enable equalizer and dynamic range compression modules. The mode switching trigger mechanism can be a manual switch by the user or an automatic switch based on certain conditions. Implement a simple user interface that allows the user to switch modes with a button. Alternatively, design an automatic switching logic, such as automatically switching to call mode when continuous human voice input is detected.
[0092] Furthermore, the noise reduction module uses a spectrum subtraction algorithm to subtract the noise spectrum dynamically estimated using the recursive averaging method from the noisy signal spectrum, s(n) represents the pure signal, n(n) is the additive noise, and x(n) is the observed noisy signal:
[0093] x(n)=s(n)+n(n),
[0094] In the frequency domain it is expressed as:
[0095] X(k)=S(k)+N(k), where X(k), S(k) and N(k) are the discrete Fourier transforms of x(n), s(n) and n(n), respectively;
[0096] The estimated signal of the spectrum subtraction is:
[0097] where E[|N(k)|2] is an estimate of the noise power spectrum;
[0098] Wherein, for the spectrum subtraction algorithm:
[0099] Introducing frequency-dependent over-reduction factors to adopt different suppression strengths in different frequency bands;
[0100] Preserve the details of the music signal by detecting the harmonic structure to suppress the music residue;
[0101] Power-law spectrum subtraction is used to improve the protection of weak signals;
[0102] Minimum statistical phase estimation is introduced to perform phase compensation to improve the naturalness of the reconstructed signal.
[0103] In traditional spectrum subtraction, a single over-subtraction factor may not be able to adapt to the specific characteristics of different frequency bands, resulting in excessive noise reduction in some frequency bands and loss of details, or insufficient noise reduction with residual noise. By introducing frequency-related over-subtraction factors, the suppression strength can be adjusted according to the characteristics of different frequency bands, thereby improving the noise reduction effect while retaining audio details. For example, low-frequency bands may require stronger noise reduction processing, while high-frequency bands may need to reduce the processing intensity in order to retain speech details such as fricative sounds. Traditional spectrum subtraction may cause so-called "music noise", that is, residual noise similar to the sound of musical instruments appears in the processed signal, which affects the audio quality after noise reduction. By detecting the harmonic structure and retaining the details of the music signal, the generation of music noise can be reduced while suppressing noise, thereby improving the listening quality. In specific implementation, the harmonic structure can be identified through spectrum analysis and excluded from the noise reduction process. Power-law spectrum subtraction is an improvement on traditional linear spectrum subtraction. By amplifying the difference in the spectrum subtraction formula to a power, low-energy components (such as the soft part of speech) can be better protected from being over-reduced. This method is suitable for processing audio with weak signals, and can increase its retention probability during the noise reduction process, thereby ensuring that important voice information is not lost while noise reduction is performed. In addition. Traditional spectral subtraction mainly processes the amplitude spectrum and ignores the phase information, which may lead to insufficient naturalness of the reconstructed signal. By introducing the minimum statistical phase estimation, phase compensation can be performed to make the processed audio signal more natural and smooth. The specific method is to perform phase estimation and compensation in the frequency domain, and then reconstruct the time domain signal through inverse Fourier transform, which not only improves the naturalness of the signal, but also helps to further reduce music noise.
[0104] Next, the audio data is played.
[0105] S4: The playing module switches to the target mode of the switching instruction based on the preset smooth switching module to play the audio.
[0106] Specifically, the playing module switches to the target mode of the switching instruction based on the preset smooth switching module to play the audio further includes:
[0107] Smoothly adjusting processing parameters, the processing parameters including equalizer setting parameters and compression ratio parameters;
[0108] Performing a smooth transition of the signal level of the audio data to avoid popping sounds caused by sudden changes;
[0109] When the mode is switched, the processing parameters are first adjusted gradually, and the audio signal is faded out at the same time. After the switch is completed, the audio processed by the new mode is faded in.
[0110] In order to achieve a smoother switching effect, a gradual transition mechanism can be implemented to gradually transition from the old mode to the new mode in a short period of time. For example, a linear interpolation gradual transition effect can be implemented to complete the mode switching within 500ms.
[0111] More specifically, the smoothing adjustment processing parameters further include:
[0112] Based on the basic formula of linear interpolation y=y1+(x-x1)*(y2-y1) / (x2-x1), linear interpolation is implemented to complete mode switching within 500ms, where (x1, y1) and (x2, y2) are two known points, x is the independent variable representing time, and y is the dependent variable to be calculated representing the mixing ratio of the new and old modes.
[0113] The linear interpolation formula is used to smoothly complete the mode switching within the specified time, achieving seamless transition and dynamic adjustment of parameters in audio processing. This time-based linear interpolation method can calculate the new state between two known states, ensuring that the system smoothly transitions from one working mode to another within 500 milliseconds. Through the linear interpolation formula, the system smoothly transitions between the two modes within the specified 500ms, avoiding the discontinuity or distortion of the audio signal caused by sudden switching. This smooth transition improves the user's listening experience and makes the audio signal more natural and smooth during the processing process. Through the precise control of the independent variable x (representing time), the mode switching can be completed according to the predetermined time plan. This method ensures that the system switches between different working states quickly and accurately, reducing unnecessary delays or confusion caused by state switching. The mixed ratio of the new and old modes is calculated through the dependent variable y, realizing the dynamic adjustment of audio processing parameters. This process allows the system to automatically adjust the configuration of audio processing according to real-time needs, so as to adapt to different application scenarios and environmental changes. For example, when switching between speech recognition and music playback, the system can quickly adjust the configuration of modules such as noise reduction, equalization and compression according to the current working mode and preset parameters. By properly selecting two known points (x1, y1) and (x2, y2), a smooth transition between strong and weak signals can be achieved, especially protecting weak signals from being covered or over-processed. This fine control mechanism helps preserve important details in the audio and improves the overall sound quality.
[0114] Furthermore, fading out the audio signal and fading in the audio processed by the new mode after the switching is completed further includes:
[0115] To gradually reduce the volume of old audio while increasing the volume of new audio over a period of time, you can use the following formula:
[0116] result(t)=old_audio(t)*(1-fade(t))+new_audio(t)*fade(t), where fade(t) is a function from 0 to 1, t is the normalized time (0 to 1), and the fade function is a cosine function: fade(t)=(1-cos(π*t)) / 2.
[0117] When fading in and out is to be completed within 0.5 seconds, the sampling rate is 44100Hz, and a total of 22050 samples will participate in the fading process. For the i-th sample, t = i / 22050, and then we can calculate fade(t) and the final output sample value. By introducing the fade-in and fade-out effect, a smooth and coherent transition is achieved when switching audio processing modes, which improves the naturalness of audio processing and user experience.
[0118] Preferably, the method further comprises performing dynamic thread management while the persistent audio capture session is active:
[0119] Dynamically adjust the task allocation granularity according to the computational complexity of the processing module;
[0120] The machine learning model predicts future load and adjusts the number of threads in advance;
[0121] Consider the energy efficiency characteristics of the processor and optimize energy consumption while ensuring performance;
[0122] Dynamically distribute processing tasks between the CPU and GPU based on task characteristics.
[0123] By dynamically adjusting the task allocation granularity according to the computational complexity of the processing module, the system can allocate computing resources more reasonably, ensuring that each task obtains appropriate computing power, thereby improving the overall processing speed and response speed. The machine learning model predicts future loads and adjusts the number of threads in advance, which helps the system better cope with upcoming computing needs, avoid excess or insufficient resources, and achieve efficient use of resources. Dynamically allocating processing tasks between the CPU and GPU based on task characteristics can fully utilize the advantages of both processors. For example, complex signal processing tasks can be assigned to the GPU, while control and management tasks can be left to the CPU, thereby improving processing performance. The dynamic thread management and task allocation mechanism enables the system to adapt to different workloads and computing needs, improving the stability and reliability of the system in a changing environment.
[0124] Preferably, the method further comprises recovering based on a preset automatic recovery mechanism during the active process of the persistent audio capture session:
[0125] Categorize preset types of hardware errors, software anomalies, and resource exhaustion errors;
[0126] When an error occurs, select the corresponding recovery strategy from the recovery strategy library to restart the service, release resources, or perform downgrade processing;
[0127] Periodically save key status information to quickly rebuild the system status during recovery;
[0128] Based on a preset progressive multi-level recovery strategy, it gradually escalates from light intervention to full restart;
[0129] Record the effect of each recovery and use machine learning algorithms to optimize the recovery strategy.
[0130] By classifying and processing errors such as hardware errors, software anomalies, and resource exhaustion, and taking corresponding recovery strategies, the system can quickly recover from various faults, ensuring the continuity and stability of audio capture and processing. The comprehensive error detection system can detect anomalies in the audio processing process in a timely manner. It can detect anomalies in audio signals, such as silence, clipping, noise, etc. For example:
[0131] Silence detection: Calculate the RMS (root mean square) value of the audio clip, and if it is lower than the threshold, it is considered silent. RMS = sqrt(sum(x^2) / n), where x is the audio sample value and n is the number of samples.
[0132] Clipping detection: Checks if the sample value is close to or reaches the maximum / minimum possible value. For example, for 16-bit audio, if the absolute sample value is greater than 32760 (99% of 32767), it is considered clipping.
[0133] Noise detection: Calculate the signal-to-noise ratio (SNR). If it is lower than the threshold, it is considered noise. SNR = 10*log10(signal_power / noise_power).
[0134] Design a system that can automatically recover from errors to ensure the continued stable operation of the audio input player. Appropriate recovery measures can be taken based on the type of error detected. For example, for a mute error, try to reinitialize the audio session; for a clipping error, automatically reduce the gain; for a noise error, enhance the noise reduction process. A progressive multi-level recovery strategy that gradually escalates from light intervention to a full restart can effectively reduce the service interruption time caused by serious failures. This strategy can provide corresponding solutions when problems occur at different levels, avoiding overreaction or under-processing. In the event of resource exhaustion, the system can automatically release resources or perform downgrade processing to ensure the continued operation of key services while avoiding system crashes caused by resource competition. By periodically saving key state information, the system can quickly rebuild to the most recent state point when a failure occurs, reducing data loss and recovery time, and improving the system's recovery efficiency. By recording the effect of each recovery and using machine learning algorithms to optimize the recovery strategy, the system's recovery mechanism can become more intelligent and efficient over time. This self-learning ability enables the system to develop more accurate recovery strategies for frequently occurring problems. The stability and rapid recovery capabilities of the system directly affect the end-user experience. Through an effective recovery mechanism, the inconvenience suffered by users due to system failures can be reduced and user satisfaction with service quality can be improved.
[0135] In some embodiments, a detailed log system is created to record all errors, warnings, and important events for subsequent analysis and debugging. Logs of different levels can be recorded, and local storage and remote upload are supported. Each log contains information such as timestamp, log level, event description, etc.
[0136] In some embodiments, intelligent mode recommendation can be performed to automatically recommend the most suitable audio mode based on user behavior and environmental factors. Specifically, a more natural operating experience is provided to achieve multimodal interaction by combining multiple interaction methods such as voice commands and gesture recognition. Using deep learning algorithms, comprehensive analysis of user behavior patterns, environmental characteristics, etc., more accurate mode recommendations are provided to achieve context-aware recommendations. Drawing on recommendation system technology, based on the preferences of similar users, personalized setting recommendations are optimized to achieve collaborative filtering personalization. Using AR technology, the audio processing status and environmental acoustic characteristics are visualized, and intuitive feedback is provided to achieve augmented reality visualization. Analyze the user's emotional state and automatically adjust audio parameters to enhance the user experience. These innovations will greatly enhance the user experience and make the product smarter and more user-friendly.
[0137] Recommends the appropriate audio mode based on factors such as time, location, ambient noise, etc. For example, the "Focus" mode is recommended during office hours and office locations; the "Relax" mode is recommended at home in the evening; and the "Noise Reduction" mode is recommended in noisy environments.
[0138] In some embodiments, users are allowed to customize audio processing parameters and save them as personal configuration files. A user configuration manager is implemented to allow users to save and load customized audio processing settings. This may include parameters such as equalizer settings, noise reduction strength, volume, etc.
[0139] In some embodiments, real-time audio quality and processing status feedback is provided to the user. A real-time monitoring system is implemented that can display current audio quality indicators and processing status. This may include indicators such as volume level, signal-to-noise ratio, and processing load. For example, a VU meter can be used to display the volume, a numerical value can be used to display the current signal-to-noise ratio, and a percentage can be used to display the processor load.
[0140] In some embodiments, processor frequency and audio processing complexity are adjusted according to the current mode and battery status to optimize power consumption. A power manager is configured to adjust the CPU frequency and audio processing quality according to the battery level and the current mode. The power consumption policy is dynamically adjusted according to contextual information such as user activity and environmental noise to achieve context-aware power consumption control. The dynamic voltage frequency scaling (DVFS) feature of the processor is used to achieve fine-grained energy consumption optimization to achieve micro-architecture level optimization. In a multi-core system, tasks are dynamically migrated according to energy efficiency characteristics to balance performance and power consumption to achieve task migration. In low power mode, the audio quality parameters are adjusted to seek the best balance between experience and energy consumption to achieve adaptive quality control. For example, when the battery power is less than 20%, the CPU frequency is reduced to 800MHz and the audio processing quality is reduced; when the battery power is between 20%-50%, the CPU frequency is set to 1600MHz and medium audio processing quality is used; when the battery power is above 50%, the CPU frequency is set to 2400MHz and high-quality audio processing is used.
[0141] This embodiment can implement an efficient, stable, and user-friendly audio input player mode switching optimization method, which not only solves the problem of reopening capture and realizes seamless mode switching by maintaining a persistent audio capture session and a dynamic audio processing pipeline. It also provides a smoother user experience while taking into account multiple aspects such as resource management, error handling, and personalized needs. This comprehensive solution will greatly improve the performance and usability of the audio input player. Gradual switching and cross-fade technology ensure audio continuity and smooth transition. In addition, intelligent resource management strategies such as circular buffers, dynamic thread management, and intelligent power consumption control are introduced to optimize system performance and battery life. Robust error detection and automatic recovery mechanisms enhance system stability, while a detailed log system facilitates problem diagnosis and subsequent optimization.
[0142] Second embodiment
[0143] Based on the same inventive concept, this embodiment provides a mode switching optimization system for an audio input player, comprising:
[0144] A startup unit, configured to create a persistent audio capture session and call a background service process to maintain the persistent audio capture session;
[0145] A capture unit, used for continuously capturing audio data and storing it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used for monitoring and caching audio data of a corresponding audio input interface;
[0146] a configuration adjustment unit, configured to be controlled by a preset switching instruction and to adjust a processing pipeline configuration based on corresponding audio data in the preset buffer;
[0147] The playing unit is used to switch to the target mode of the switching instruction to play audio based on a preset smooth switching module.
[0148] Based on the same inventive concept, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that when the computer program is executed by the processor, the steps of the mode switching optimization method of the audio input player described in any one of the above items are implemented.
[0149] Based on the same inventive concept, this embodiment provides a computer-readable storage medium on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps of the mode switching optimization method of the audio input player described in any one of the above items are implemented.
[0150] The computer device in this embodiment is described in detail from the perspective of hardware processing.
[0151] See also Figure 3 As shown, the computer device includes a processor 300 and a memory 301, wherein the memory 301 stores machine executable instructions that can be executed by the processor 300, and the processor 300 executes the machine executable instructions to implement the above-mentioned mode switching optimization method of the audio input player.
[0152] further, Figure 3 The computer device shown further includes a bus 302 and a communication interface 303 , and the processor 300 , the communication interface 303 and the memory 301 are connected via the bus 302 .
[0153] The memory 301 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), for example, at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 303 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 302 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0154] The processor 300 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 300. The above processor 300 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor to execute, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 301 , and the processor 300 reads the information in the memory 301 and completes the method steps of the above-mentioned embodiment in combination with its hardware.
[0155] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the mode switching optimization method for an audio input player.
[0156] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, systems and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0157] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0158] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A mode switching optimization method for an audio input player, characterized in that: The steps include: Creating a persistent audio capture session, and calling a background service process to maintain the persistent audio capture session; Continuously capture audio data and store it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used to monitor and cache audio data of a corresponding audio input interface; Controlled by a preset switching instruction, adjusting a processing pipeline configuration based on corresponding audio data in the preset buffer; The playing module switches to the target mode of the switching instruction based on the preset smooth switching module to play the audio.
2. The mode switching optimization method of the audio input player according to claim 1, characterized in that: Creating a persistent audio capture session, calling a background service process to maintain the persistent audio capture session further comprises: Use system-level APIs to create a persistent audio capture session. The background service process runs automatically at system startup and remains active after the application exits.
3. The mode switching optimization method of the audio input player according to claim 2, characterized in that: Use the IAudioClient interface of WASAPI on Windows and specify the AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag when calling the Initialize method to run in event-driven mode.
4. The mode switching optimization method of the audio input player according to claim 1, characterized in that: Continuously capturing audio data and storing it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used to monitor and cache audio data of a corresponding audio input interface, further comprising: Monitor and capture audio data of each audio input interface based on configured basic parameters, wherein the basic parameters include at least: sampling rate, bit depth, and number of channels; The audio capture process is started, the captured audio data is temporarily stored in a corresponding variable circular buffer, and the latest stored audio data is read when needed.
5. The mode switching optimization method of the audio input player according to claim 1, characterized in that: Controlled by the preset switching instruction, adjusting the processing pipeline configuration based on the corresponding audio data in the preset buffer further includes: Capturing parameters about the processing pipeline configuration in the switching command, and adjusting the output mode and output mode parameters based on the parameters of the processing pipeline configuration, wherein the output mode parameters include noise reduction module parameters, equalizer parameters, and compressor parameters in the processing pipeline; A state machine is used to manage the processing pipeline configuration adjustment of the mode switching process to ensure that the components work in coordination.
6. The mode switching optimization method of the audio input player according to claim 5, characterized in that: The noise reduction module uses a spectrum subtraction algorithm to subtract the noise spectrum dynamically estimated using the recursive averaging method from the noisy signal spectrum. s(n) represents the pure signal, n(n) is the additive noise, and x(n) is the observed noisy signal. Then: x(n)=s(n)+n(n), In the frequency domain it is expressed as: X(k)=S(k)+N(k), where X(k), S(k) and N(k) are the discrete Fourier transforms of x(n), s(n) and n(n), respectively; The estimated signal of the spectrum subtraction is: where E[|N(k)|2] is an estimate of the noise power spectrum; Wherein, for the spectrum subtraction algorithm: Introducing frequency-dependent over-reduction factors to adopt different suppression strengths in different frequency bands; Preserve the details of the music signal by detecting the harmonic structure to suppress the music residue; Power-law spectrum subtraction is used to improve the protection of weak signals; Minimum statistical phase estimation is introduced to perform phase compensation to improve the naturalness of the reconstructed signal.
7. The mode switching optimization method of the audio input player according to claim 1, characterized in that: The playback module switches to the target mode of the switching instruction based on the preset smooth switching module to perform audio playback, further comprising: Smoothly adjusting processing parameters, the processing parameters including equalizer setting parameters and compression ratio parameters; Performing a smooth transition of the signal level of the audio data to avoid popping sounds caused by sudden changes; When switching modes, the processing parameters are first adjusted gradually, and the audio signal is faded out at the same time. After the switching is completed, the audio processed by the new mode is faded in.
8. The mode switching optimization method of the audio input player according to claim 7, characterized in that: The smoothing adjustment processing parameters further include: Based on the basic formula of linear interpolation y=y1+(x-x1)*(y2-y1) / (x2-x1), linear interpolation is implemented to complete mode switching within 500ms, where (x1, y1) and (x2, y2) are two known points, x is the independent variable representing time, and y is the dependent variable to be calculated representing the mixing ratio of the new and old modes.
9. The mode switching optimization method of the audio input player according to claim 7, characterized in that: Fading out the audio signal, and fading in the audio processed by the new mode after the switching further includes: To gradually reduce the volume of old audio while increasing the volume of new audio over a period of time, you can use the following formula: result(t)=old_audio(t)*(1-fade(t))+new_audio(t)*fade(t), where fade(t) is a function from 0 to 1, t is the normalized time (0 to 1), and the fade function is a cosine function: fade(t)=(1-cos(π*t)) / 2.
10. The mode switching optimization method of the audio input player according to claim 1, characterized in that: Continuously capturing audio data and storing it in a preset buffer further includes dynamically adjusting the buffer size: This is achieved through modulo operation: index=(write_pointer+i)%buffer_size, where write_pointer is the current write position, i is the offset, and buffer_size is the buffer size.
11. The mode switching optimization method of the audio input player according to claim 1, characterized in that: The method further includes performing dynamic thread management while the persistent audio capture session is active: Dynamically adjust the task allocation granularity according to the computational complexity of the processing module; The machine learning model predicts future load and adjusts the number of threads in advance; Consider the energy efficiency characteristics of the processor and optimize energy consumption while ensuring performance; Dynamically distribute processing tasks between the CPU and GPU based on task characteristics.
12. The mode switching optimization method of the audio input player according to claim 1, characterized in that: The method further includes restoring based on a preset automatic recovery mechanism during the active state of the persistent audio capture session: Categorize preset types of hardware errors, software anomalies, and resource exhaustion errors; When an error occurs, select the corresponding recovery strategy from the recovery strategy library to restart the service, release resources, or perform downgrade processing; Periodically save key status information to quickly rebuild the system status during recovery; Based on a preset progressive multi-level recovery strategy, it gradually escalates from light intervention to full restart; Record the effect of each recovery and use machine learning algorithms to optimize the recovery strategy.
13. A mode switching optimization system for an audio input player, characterized in that: include: A startup unit, configured to create a persistent audio capture session and call a background service process to maintain the persistent audio capture session; A capture unit, used for continuously capturing audio data and storing it in a preset buffer, wherein the preset buffer has a plurality of variable circular buffers with controlled sizes, each of which is used for monitoring and caching audio data of a corresponding audio input interface; a configuration adjustment unit, configured to be controlled by a preset switching instruction and to adjust a processing pipeline configuration based on corresponding audio data in the preset buffer; The playing unit is used to switch to the target mode of the switching instruction to play audio based on a preset smooth switching module.
14. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is executed by a processor, the steps of the mode switching optimization method of the audio input player as described in any one of claims 1-12 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the mode switching optimization method of the audio input player as described in any one of claims 1-12 are implemented.
Citation Information
Cited By
White noise seamless loop playing method and system based on audio frame pre-caching
CN120295601A
Audio stream pushing crash prevention method and system, storage medium and equipment
CN120321294A
Method and system for realizing Device mode of USB audio equipment, storage medium and equipment
CN120872885A
Audio playing switching control method and device and aircraft
CN122027607A
Audio processing method, audio processing apparatus, electronic device, and program product
CN122756613A