Multichannel noise simulation system based on XAudio 2

Through the multi-channel noise simulation system based on XAudio2, independent volume control and mute of each channel is achieved, which solves the problems of inaccurate sound positioning and complex system in the prior art, improves user experience and reduces costs, and adapts to diverse application scenarios.

CN120412601APending Publication Date: 2025-08-01AVIC HUADONG OPTOELECTRONICS (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510275101.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-10
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing noise simulation systems cannot effectively solve the problems of independent control and flexible adjustment of multi-channel audio, resulting in inaccurate sound positioning, poor user experience, and complex system and high cost, making it difficult to widely use in various scenarios.

Method used

Using a multi-channel noise simulation system based on XAudio2, the XAudio2 engine initialization module, main audio mixer creation module, audio data loading module, source voice creation and playback module and volume control module are used to realize independent volume control and mute each channel, and support audio control of 12 or more channels.

Benefits of technology

It improves the flexibility and reality of noise simulation, achieves accurate sound positioning and highly realistic audio effects, reduces dependence on complex hardware, simplifies the difficulty of system implementation, and improves ease of use and scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120412601A_ABST
    Figure CN120412601A_ABST
Patent Text Reader

Abstract

The invention provides a multichannel noise simulation system based on XAudio 2, and the system comprises an XAudio 2 engine initialization module which is used for initializing a COM assembly and creating an XAudio 2 engine instance; the main audio frequency sound mixer creating module is used for calling a CreateMasteringVoice method to create a main audio frequency sound mixer; the audio data loading module is used for reading an audio stream from an audio file and filling the audio stream into the XAUDIO2BUFFER structure; the source voice creating and playing module is used for calling a CreateSourceVoice method to create source voice, submitting the source voice to XAUDIO2BUFFER and starting playing; and the volume control module is used for independently adjusting the volume of each sound channel through a SetChannelVolumes function and muting other sound channels when the target sound channel is played. According to the invention, the accuracy of sound positioning and the user experience can be improved, and the system cost is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of audio processing and noise simulation, and more specifically, the present invention relates to a multi-channel noise simulation system based on XAudio2. Background Art

[0002] In modern audio simulation technology, noise simulation systems are commonly used in fields such as training, entertainment, and research, such as military training, driving simulation, and virtual reality scenarios. These systems simulate sound environments in different directions through multi-channel audio output to enhance the user experience and realism. However, there are many limitations in the technical implementation of existing noise simulation systems. First, the flexibility of audio output is insufficient. Existing systems mostly use simple volume adjustment methods, making it difficult to accurately and independently control each speaker in real time, resulting in the inability to achieve real noise localization or environmental simulation. Second, multi-channel audio management is complex, relying on complex hardware or expensive software systems, requiring professional configuration and operation, which limits its popularity and ease of use. In addition, the user experience is poor. Existing systems cannot flexibly control the playback of noise in different directions, which may interfere with the user's perception of sounds in the real environment. Finally, the adaptability of existing technologies is poor. Most advanced audio processing software is complex and expensive, making it difficult to efficiently integrate with mainstream audio development tools, and the technical barriers are high.

[0003] In the process of implementing the embodiments of the present invention, the inventors found that there are at least the following problems or defects in the prior art: Existing noise simulation systems cannot effectively solve the problems of independent control and flexible adjustment of multi-channel audio, resulting in inaccurate sound localization, poor user experience, and complex and costly systems, making it difficult to be widely applied to various scenarios. Summary of the Invention

[0004] The present invention provides a multi-channel noise simulation system based on XAudio2, including:

[0005] An XAudio2 engine initialization module for initializing COM components and creating an XAudio2 engine instance;

[0006] A main audio mixer creation module that calls the CreateMasteringVoice method of the XAudio2 engine to create a main audio mixer;

[0007] An audio data loading module for reading audio stream data from an audio file and filling it into the XAUDIO2_BUFFER structure;

[0008] A source voice creation and playback module that calls the CreateSourceVoice method of the XAudio2 engine to create a source voice, submits the XAUDIO2_BUFFER, and starts playback;

[0009] The volume control module independently adjusts the volume of each channel by calling the SetChannelVolumes function and mutes the remaining channels when playing the target channel.

[0010] Furthermore, the XAudio2 engine initialization module specifically performs the following steps:

[0011] Call the ColinitializeEx function to initialize the COM component;

[0012] Call the XAudio2Create function to create an XAudio2 engine instance and store it as an IXAudio2 interface pointer.

[0013] Furthermore, the audio data loading module includes:

[0014] Open the audio file through the CreateFile function;

[0015] Parse the RIFF block, fmt block, and data block of the audio file;

[0016] Read the content of the data block into the buffer and fill it into the XAUDIO2_BUFFER structure.

[0017] Furthermore, the volume control module defines the volume value of each channel through a floating-point array, and the dimension of the floating-point array is consistent with the number of channels supported by the system.

[0018] Furthermore, the volume value of the target channel in the floating-point array is set to a non-zero value, and the volume values of the remaining channels are set to zero to achieve muting.

[0019] Furthermore, the number of channels supported by the system is 12, including 8 channels of 7.1 channels and 4 auxiliary channels.

[0020] Furthermore, in the source voice creation and playback module, the control of each channel is executed by an independent thread, and each thread reads the audio stream data from the audio file and plays it.

[0021] Furthermore, the volume control module supports real-time switching of the volume values of the channels and dynamically adjusts the playback states of different channels.

[0022] Furthermore, the system receives the channel volume configuration parameters input by the user through a software interface or external instructions.

[0023] Furthermore, the main audio mixer encapsulates the audio device through the IXAudio2MasteringVoice interface and transmits the processed audio data to the physical speakers.

[0024] The above embodiments of the present invention have at least the following beneficial effects: The multi-channel noise simulation system of the present invention can significantly improve the flexibility and realism of noise simulation. By independently adjusting the volume of each channel, the system can mute other channels when playing noise from a specific direction, thereby achieving precise sound localization and highly realistic audio effects. This design not only enhances the user's immersion in training, simulation, or entertainment environments but also supports real-time switching of channel volumes and dynamically adjusting the playback status of different channels to adapt to diverse application scenarios. In addition, the system uses software to implement multi-channel volume control, reducing the dependence on complex hardware devices, lowering the hardware complexity, and system maintenance costs.

[0025] The present invention can also simplify the implementation difficulty of the noise simulation system and improve the usability and scalability of the technology. Using the existing XAudio2 engine, developers can easily control the volume of each channel without the need for expensive custom hardware, thereby significantly reducing the system's deployment and operation costs. At the same time, the system supports audio control for 12 or more channels, has a high degree of scalability, and can meet the wide range of requirements from small-scale simulation environments to large sound fields. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features, and advantages of the exemplary embodiments of the present invention will become readily understood. In the drawings, several embodiments of the present invention are shown by way of example and not limitation, wherein:

[0027] Figure 1 FIG. [FIG. number not provided] is a schematic structural diagram of a multi-channel noise simulation system based on XAudio2 provided by an embodiment of the present invention;

[0028] Figure 2 FIG. [FIG. number not provided] is a schematic diagram of a channel layout provided by an embodiment of the present invention;

[0029] Figure 3 FIG. [FIG. number not provided] is a schematic diagram of channel control provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0030] The principles and spirit of the present invention will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and not to limit the scope of the present invention in any way. On the contrary, these embodiments are provided to make the present invention more thorough and complete, and to convey the scope of the present invention fully to those skilled in the art.

[0031] Those skilled in the art know that the embodiments of the present invention can be implemented as a system, device, equipment, method, or computer program product. Therefore, the present invention can be specifically implemented in the following forms, namely: completely hardware, completely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.

[0032] It should be noted that any number of elements in the drawings is for illustration rather than limitation, and any naming is only for distinction and does not have any limiting meaning.

[0033] The following refers to Figure 1 , Figure 1 which is a schematic structural diagram of a multi-channel noise simulation system based on XAudio2 provided for an embodiment of the present invention. As Figure 1 shown, a multi-channel noise simulation system 100 based on XAudio2 includes:

[0034] The XAudio2 engine initialization module 101 is used to initialize the COM component and create an XAudio2 engine instance;

[0035] The main audio mixer creation module 102 calls the CreateMasteringVoice method of the XAudio2 engine to create a main audio mixer;

[0036] The audio data loading module 103 is used to read audio stream data from an audio file and fill it into the XAUDIO2_BUFFER structure;

[0037] The source voice creation and playback module 104 calls the CreateSourceVoice method of the XAudio2 engine to create a source voice, submits the XAUDIO2_BUFFER, and starts playback;

[0038] The volume control module 105 independently adjusts the volume of each channel by calling the SetChannelVolumes function and mutes the remaining channels when playing the target channel.

[0039] It should be noted that in the present invention, the system realizes independent control of multi-channel noise through the XAudio2 engine. XAudio2 is a low-latency, multi-channel audio processing engine developed by Microsoft and is widely used in game development and multimedia applications. By providing rich audio processing functions, it can achieve precise control of multi-channel audio. In this system, by calling the volume control interface of XAudio2, independent control of each channel is achieved, so that when playing noise in a specific direction, the volume of other channels can be flexibly adjusted, or even muted, to enhance the realism of sound localization and the user experience. This design breaks through the limitations of traditional multi-channel audio systems in terms of flexibility and usability.

[0040] Specifically, the system initializes the XAudio2 engine to establish the basic framework for audio processing. During the initialization process, first, the `CoInitializeEx` function needs to be called to initialize the COM component, which is a necessary condition for the operation of XAudio2. Subsequently, an XAudio2 engine instance is created by calling the `XAudio2Create` function and stored as an `IXAudio2` interface pointer. This interface is the core of the interaction between the system and the XAudio2 engine and is used for subsequent audio processing operations. In addition, the system creates a master audio mixer by calling the `CreateMasteringVoice` method, which is responsible for finally transmitting all audio data to the physical speakers. The loading of audio data is completed by parsing the RIFF block, fmt block, and data block of the WAV file, where the fmt block contains audio format information and the data block stores the actual audio data. After these data are read into the buffer, they are filled into the `XAUDIO2_BUFFER` structure, and then the audio playback is started by creating a source voice and submitting this buffer.

[0041] Preferably, the system uses a floating-point array to define the volume value of each channel in terms of volume control. The dimension of this array is consistent with the number of channels supported by the system. For example, in a 12-channel system, the array contains 12 floating-point values. When playing noise in a specific direction, the volume value of the target channel is set to a non-zero value (such as 1.0 representing the normal playback volume), while the volume values of other channels are set to zero to achieve muting. This control method can not only achieve precise sound localization but also be dynamically adjusted through the software interface or external instructions to adapt to different application scenarios and user needs. In addition, the system supports the control of each channel to be executed by independent threads, and each thread reads the audio stream data from the audio file and plays it respectively, thus ensuring the synchronization and independence of multi-channel audio.

[0042] In some embodiments, the XAudio2 engine initialization module specifically performs the following steps:

[0043] Call the ColinitializeEx function to initialize the COM component;

[0044] Call the XAudio2Create function to create an XAudio2 engine instance and store it as an IXAudio2 interface pointer.

[0045] It should be noted that the XAudio2 engine initialization module mentioned in the present invention is the basis for the system to run, and its main function is to ensure that the XAudio2 engine can work properly. The XAudio2 engine is a high-performance audio processing framework for processing multi-channel audio data. During the initialization process, first, the `CoInitializeEx` function needs to be called to initialize the COM component, which is a prerequisite for the XAudio2 engine to run. The COM component is a software architecture for implementing communication and dynamic linking between components. By calling the `CoInitializeEx` function, it can be ensured that the system environment supports multi-threaded operations. Subsequently, an XAudio2 engine instance is created by calling the `XAudio2Create` function and stored as an `IXAudio2` interface pointer. The `IXAudio2` interface is the core interface of the XAudio2 engine for subsequent audio processing operations, such as creating audio voices and submitting audio data.

[0046] Specifically, when initializing the COM component, the parameter of the `CoInitializeEx` function is set to `COINIT_MULTITHREADED`, indicating that the system will run in a multi-threaded mode, which is particularly important for audio processing because audio processing usually requires high concurrency and low latency. When creating an XAudio2 engine instance, the second parameter of the `XAudio2Create` function is set to `0`, indicating the use of the default processor configuration, which is suitable for most general scenarios. The `XAUDIO2_DEFAULT_PROCESSOR` macro is used to specify the default audio processing unit, which is usually associated with the system's default audio device. In this way, the system can ensure stable operation under different hardware configurations. In addition, the `IXAudio2` interface pointer can be stored as a smart pointer (such as `winrt::com_ptr` in C++ / WinRT) or a raw pointer, depending on the development environment and programming language choice.

[0047] Preferably, in order to improve the compatibility and stability of the system, an error detection mechanism can be added during the initialization process. For example, after calling the `CoInitializeEx` and `XAudio2Create` functions, check whether the return value is successful (`S_OK`). If the return value indicates failure, the error information can be recorded and the initialization process can be terminated. In addition, for a multi-threaded environment, the thread management strategy can be further optimized, such as by setting the thread priority or using a thread pool to improve the efficiency of audio processing. In some cases, if the system runs on a specific hardware platform (such as Xbox), the initialization step of the COM component can be omitted because these platforms may have pre-initialized the COM environment.

[0048] In some embodiments, the audio data loading module includes:

[0049] Open the audio file through the CreateFile function;

[0050] Parse the RIFF block, fmt block, and data block of the audio file;

[0051] Read the content of the data block into the buffer and fill it into the `XAUDIO2_BUFFER` structure.

[0052] It should be noted that the audio data loading module is a key component in the multi-channel noise simulation system of the present invention. Its main function is to read the audio stream data from the audio file and fill it into the `XAUDIO2_BUFFER` structure. This process ensures that the audio data can be correctly processed and played by the XAudio2 engine. In the present invention, the audio file usually adopts the WAV format, which is widely used because of its simplicity and wide compatibility. The WAV file consists of multiple blocks, where the RIFF block is used to identify the file type, the fmt block contains the audio format information, and the data block stores the actual audio sample data. By parsing these blocks, the system can correctly load the audio file and prepare the audio data required for playback.

[0053] Specifically, the workflow of the audio data loading module includes the following key steps. First, the `CreateFile` function is used to open the target audio file. The parameters of this function include the file path, access permissions (such as `GENERIC_READ`), and file sharing mode, etc. The file path can be configured according to the system environment. For example, in the Windows system, the path can be a local path or a network path. Next, the system confirms whether the file type is a valid WAV file by looking for the RIFF chunk. If the file type does not meet the expectation (such as `filetype != fourccWAVE`), the loading process will terminate. Subsequently, the system locates and parses the fmt chunk, and copies its content into the `WAVEFORMATEXTENSIBLE` structure, which is used to store audio format information such as sample rate, bit depth, and number of channels, etc. Finally, the system reads the content of the data chunk and stores it in a buffer, and the data in this buffer is then filled into the `XAUDIO2_BUFFER` structure to prepare for audio playback.

[0054] Preferably, to improve the efficiency and reliability of audio data loading, the loading process can be further optimized. For example, when reading the audio file, an asynchronous loading method can be adopted to avoid blocking the main thread, thereby improving the system's response speed. In addition, for large files or audio files with network paths, the data can be read in chunks to reduce memory occupancy and increase the loading speed. When processing multi-channel audio, the number of channels and format in the `WAVEFORMATEXTENSIBLE` structure can be adjusted according to actual needs to ensure that the audio data matches the system's channel configuration. For example, for a 7.1-channel audio file, the system can dynamically adjust the channel mapping to adapt to different speaker layouts. In addition, to enhance the system's compatibility, multiple audio formats (such as MP3 or OGG) can be supported by adding a format conversion function in the loading module to convert these formats to the WAV format before processing.

[0055] In some embodiments, the volume control module defines the volume value of each channel through a floating-point array, and the dimension of the floating-point array is consistent with the number of channels supported by the system.

[0056] It should be noted that the volume control module is one of the core functions of the multi-channel noise simulation system of the present invention. It realizes independent volume control for each channel by calling the `SetChannelVolumes` function. This function enables the system to flexibly adjust the volume of other channels, or even mute them, when playing noise in a specific direction, thereby achieving precise sound localization and highly realistic audio effects. In the present invention, volume control is implemented through a floating-point array. The dimension of this array is the same as the number of channels supported by the system. The volume value of each channel is represented by a floating-point number in the array, usually in the range of 0 to 1, where 0 represents mute and 1 represents the maximum volume.

[0057] Specifically, the floating-point array in the volume control module is the key to realizing multi-channel independent control. For example, in a 12-channel system, the floating-point array contains 12 elements, and each element corresponds to the volume value of a channel. When simulating noise in a specific direction, the volume value of the target channel is set to a non-zero value (such as 1.0), while the volume values of other channels are set to 0 to achieve the mute effect. This control method can not only achieve precise sound localization but also be dynamically adjusted through the software interface or external instructions to adapt to different application scenarios and user requirements. In addition, the parameter settings of the `SetChannelVolumes` function need to match the number of channels and audio format of the system. For example, for a 7.1-channel system, the size of the floating-point array is 8, and for a system extended to 12 channels, the size of the array needs to be extended and the channel mapping needs to be adjusted.

[0058] Preferably, in order to further optimize the flexibility and precision of volume control, a dynamic volume adjustment mechanism can be introduced. For example, the system can dynamically adjust the volume values in the floating-point array according to the real-time requirements of the simulation scenario without reloading the audio data. In addition, in order to adapt to different audio formats and channel layouts, a channel mapping function can be added to the volume control module to flexibly map the channels of the audio data to the channels of the physical speakers. For example, in some scenarios, the system can merge the audio data of multiple channels and play them on one speaker, or adjust the channel priority according to user needs. In addition, in order to improve the usability of the system, visual control options can be provided in the software interface, allowing users to directly adjust the volume of each channel through the graphical interface without manually editing the floating-point array.

[0059] In some embodiments, the volume value of the target channel in the floating-point array is set to a non-zero value, and the volume values of the remaining channels are set to zero to achieve mute.

[0060] It should be noted that the floating-point array mentioned in the present invention is a key technical means for implementing the volume control of a multi-channel noise simulation system. This array is used to define the volume values of each channel, and its dimension is consistent with the number of channels supported by the system. In this way, the system can flexibly control the volume of each channel, so that when playing noise in a specific direction, the volume of the channels in other directions can be muted. This muting function is achieved by setting the volume value of the corresponding channel in the floating-point array to zero, while the volume value of the target channel is set to a non-zero value, such as 1.0, indicating the normal playing volume. This design enables the system to flexibly adjust the sense of sound orientation and spatial sense in different scenarios, enhancing the authenticity of the simulation and the user experience.

[0061] Specifically, each element in the floating-point array corresponds to the volume control of a channel. For example, in a system that supports 12 channels, the floating-point array contains 12 elements, and the value range of each element is usually between 0 and 1. When it is necessary to simulate the noise in a specific direction, the system will set the volume value of the corresponding channel in that direction to 1.0, while setting the volume values of other channels to 0. This setting can be achieved by calling the `SetChannelVolumes` function. The first parameter of this function is the number of channels, and the second parameter is a pointer to the floating-point array. For example, for an 8-channel system, call `SetChannelVolumes(8,SourceVoiceChannelVolumes)`, where `SourceVoiceChannelVolumes` is the floating-point array containing the volume values. In this way, the system can precisely control the volume of each channel to achieve muting or other volume adjustment functions.

[0062] Preferably, in order to further improve the flexibility and adaptability of the system, a dynamic adjustment mechanism can be introduced in the setting of the floating-point array. For example, the system can update the volume values in the floating-point array in real time according to the changes in the simulation scenario without re-initializing the audio playback. In addition, in order to meet the requirements of different application scenarios, a function for users to customize the volume configuration can be provided, allowing users to manually set the volume values of each channel through a software interface. For example, in some scenarios, users may want to set the volume of a specific direction channel to a lower value to simulate the sound effect of a long distance, rather than muting it completely. In addition, the system can also support multiple channel layouts, such as 5.1 channels, 7.1 channels or custom channel layouts, and support different numbers of channels by adjusting the size of the floating-point array and the channel mapping relationship.

[0063] As Figure 2 and Figure 3 shown, Figure 2 is a schematic diagram of the channel layout for some embodiments, Figure 3Schematic diagram of channel control for some embodiments, including: The number of channels supported by the system is 12, including 8 channels of 7.1 channels and 4 auxiliary channels.

[0064] It should be noted that the number of channels supported by the system mentioned in the present invention is 12, including 8 channels of 7.1 channels and 4 auxiliary channels. This channel configuration is to meet the high-precision simulation requirements for sound direction and spatial sense in different application scenarios. 7.1 channels is a common multi-channel audio configuration, including 8 main channels, which can provide surround sound effects, while the 4 auxiliary channels are used to further expand the spatial dimension of sound and enhance the realism of the simulation. This channel layout enables the system to flexibly adjust the audio output in a complex sound environment. For example, in scenarios such as military training, driving simulation, or virtual reality, by precisely controlling the volume of each channel, highly realistic sound localization can be achieved.

[0065] Specifically, the setting of the number of channels is determined according to the requirements of the application scenario. The 7.1-channel system includes 8 channels in total, namely front left, front right, center, subwoofer, surround left, surround right, rear left, and rear right. These channels can provide all-round surround sound effects. The 4 auxiliary channels can be expanded according to specific requirements. For example, they can be used to simulate noise sources in specific directions or enhance the sound intensity in specific areas. In the system, the parameter setting of the number of channels needs to match the audio processing engine (such as XAudio2) and the audio hardware device. For example, when initializing the audio system, it is necessary to specify the number of channels and the audio format to ensure that the audio data can be correctly distributed to each channel. In addition, the configuration of the channel layout also needs to consider the placement position of the physical speakers and the user's auditory experience.

[0066] Preferably, in order to further improve the flexibility and adaptability of the system, a scalability design can be introduced in the channel configuration. For example, the system can dynamically adjust the number of channels according to the actual application scenario, supporting from basic stereo (2 channels) to complex multi-channel configurations (such as 12 channels and above). In addition, the system can also allow users to customize the channel layout and function allocation through a software interface or external instructions. For example, in some scenarios, the user may only need to use some channels for simulation, and the system can then dynamically adjust the enabled and disabled states of the channels according to the user's needs. In addition, in order to improve the compatibility of the system, multiple audio formats and coding methods can be supported in the channel configuration to ensure that the system can process audio data from different sources.

[0067] In some embodiments, in the source voice creation and playback module, the control of each channel is executed by an independent thread, and each thread reads the audio stream data from the audio file and plays it.

[0068] It should be noted that the source voice creation and playback module mentioned in the present invention is a key link for realizing multi-channel noise simulation. Its core function is to create a source voice by calling the `CreateSourceVoice` method of the XAudio2 engine and submit audio data to this voice for playback. The source voice is a basic component in the XAudio2 audio processing chain and is used to process and play audio streams. In the present invention, the control of each channel is executed by an independent thread, which means that the audio streams of each channel can be read and played independently, thus ensuring the synchronization and flexibility of multi-channel audio. This design enables the system to dynamically adjust the playback status of different channels according to user needs, further enhancing the accuracy of sound localization and the user experience.

[0069] Specifically, the working process of the source voice creation and playback module includes the following key steps. First, call the `CreateSourceVoice` method to create a source voice. This method requires passing in audio format information (such as sample rate, bit depth, and number of channels), which is usually obtained from the `WAVEFORMATEXTENSIBLE` structure of the loaded audio file. After creating the source voice, submit the filled `XAUDIO2_BUFFER` structure to the source voice by calling the `SubmitSourceBuffer` method, thereby sending the audio data into the playback queue. Finally, call the `Start` method to start the source voice to begin playing the audio. In a multi-channel system, the audio streams of each channel are processed by independent threads, and these threads read data from the audio file and submit it to the corresponding source voice respectively. For example, in a 12-channel system, there will be 12 independent threads responsible for processing and playing the audio streams of each channel respectively. This multi-threaded design ensures the efficient processing and synchronous playback of audio data, and can maintain the coherence and consistency of the audio even in a complex multi-channel environment.

[0070] Preferably, in order to further optimize the process of creating and playing the source voice, some improvement measures can be introduced in the audio data submission and playback links. For example, when submitting audio data, the `Flags` parameter of the `XAUDIO2_BUFFER` structure can be set to `XAUDIO2_END_OF_STREAM` to identify the end of the audio stream, thereby simplifying the resource release process after playback is completed. In addition, in order to improve the real-time performance and response speed of the system, the audio data loading and submission strategy can be dynamically adjusted during audio playback. For example, for scenarios that require real-time switching of channel volume or playback status, the system can pre-load audio data segments and quickly switch the playback content according to real-time instructions. In addition, in order to enhance the fault tolerance of the system, when the source voice creation fails or the audio playback is interrupted, the error information can be captured and retry or fallback operations can be performed to ensure the stability and reliability of audio playback.

[0071] In some embodiments, the volume control module supports real-time switching of the volume values of the channels and dynamically adjusts the playback states of different channels.

[0072] It should be noted that the volume control module in the present invention supports real-time switching of the volume values of the channels and dynamically adjusts the playback states of different channels. This function enables the system to quickly change the direction and intensity of the sound according to the scene requirements during the simulation process, thereby providing a more realistic audio experience. For example, in military training or driving simulation, when the target turns from the left side to the right side, the system can adjust the channel volume in real time, causing the sound to transfer from the left speaker to the right speaker, enhancing the realism of sound localization. This dynamic adjustment ability is achieved through software control, and the user can modify the volume configuration of the channels in real time through the operation interface or external instructions without interrupting the audio playback.

[0073] Specifically, the dynamic adjustment function of the volume control module is implemented based on the `SetChannelVolumes` function. This function allows the system to modify the volume values of the channels in real time during audio playback. For example, when it is necessary to switch the sound from one direction to another, the system updates the volume values of the corresponding channels in the floating-point array and applies these new volume values to the audio output by calling the `SetChannelVolumes` function. Each value in the floating-point array ranges from 0 to 1, where 0 represents silence and 1 represents the maximum volume. In this way, the system can flexibly switch the volume between different channels to achieve the directional change of the sound. In addition, to ensure the real-time nature of the dynamic adjustment, the system needs to efficiently process the volume update instructions in the audio processing thread to avoid audio delay or interruption caused by volume switching.

[0074] Preferably, to further enhance the flexibility and response speed of volume control, the system can provide visual control options in the software interface, such as sliders or knobs, allowing the user to intuitively adjust the volume of each channel. In addition, the system can introduce preset volume configuration modes, such as left sound priority or right sound priority. The user can quickly adjust the channel volume by switching these preset modes with one key without manually modifying the volume value of each channel. To adapt to different application scenarios, the system can also support script- or API-based automated volume control. For example, in a virtual reality scenario, the channel volume is automatically adjusted according to the direction of the user's head rotation to enhance the immersion.

[0075] In some embodiments, the system receives the channel volume configuration parameters input by the user through the software interface or external instructions.

[0076] It should be noted that the multi-channel noise simulation system of the present invention receives the channel volume configuration parameters input by the user through a software interface or external instructions. This design enables the user to flexibly adjust the audio output according to specific application scenarios and requirements, enhancing the interactivity and adaptability of the system. The software interface refers to a visual operation platform provided by the system for the user, through which the user can directly operate parameters such as channel volume via a graphical interface; while external instructions allow the system to interact with other devices or software, receiving volume adjustment instructions through programming interfaces or automation scripts, thereby implementing more complex audio control logics.

[0077] Specifically, the software interface can be designed as a window containing multiple channel volume adjustment controls, such as sliders, input boxes, or buttons, etc., with each control corresponding to the volume adjustment of one channel. The user can set the volume value of a specific channel by dragging the slider or entering a value, and these values will be transmitted to the volume control module in real time and applied to the audio output by calling the `SetChannelVolumes` function. For external instructions, the system can provide an API interface that allows other applications or devices to send volume configuration instructions programmatically. For example, the instruction can be a JSON object containing the channel number and volume value, and after receiving the instruction, the system parses and executes the corresponding volume adjustment operation. In addition, the system can also support multiple communication protocols, such as TCP / IP, UDP, or serial communication, in order to receive external instructions from different devices.

[0078] Preferably, in order to further enhance the user experience and operation convenience of the system, the software interface can provide preset mode options, such as all-channel mute, specific direction playback, or surround sound mode, etc. The user can quickly switch between these modes by clicking a button without adjusting the channel volume one by one. In addition, the system can introduce an intelligent volume adjustment function that automatically recommends appropriate volume configurations according to the user's operation habits or scenarios. For example, in a military training scenario, the system can automatically adjust the volume according to the stage of the simulated task to enhance the realism of the training. For external instructions, the system can support event-triggered automated control. For example, in a virtual reality application, when the user enters a specific area, the channel volume is automatically adjusted to simulate environmental changes.

[0079] In some embodiments, the main audio mixer encapsulates the audio device through

[0080] the IXAudio2MasteringVoice interface and transmits the processed audio data to the physical speakers.

[0081] It should be noted that the main audio mixer mentioned in the present invention passes through

[0082] The `IXAudio2MasteringVoice` interface encapsulates the audio device and transmits the processed audio data to the physical speaker. The main audio mixer is a key component in the XAudio2 audio processing chain, responsible for finally mixing the audio data output by all SourceVoices and transmitting it to the audio hardware device (such as a speaker) for playback.

[0083] The `IXAudio2MasteringVoice` interface is an advanced interface provided by the XAudio2 engine for managing the main audio output path, ensuring that the audio data can be processed and optimized as necessary before final playback.

[0084] Specifically, the creation process of the main audio mixer is implemented by calling

[0085] the `IXAudio2::CreateMasteringVoice` method. This method requires a pointer to the `IXAudio2MasteringVoice` interface and some optional parameters, such as audio format and channel layout. For example, in a system supporting 7.1 channels, a main audio mixer matching it can be created by setting the corresponding audio format parameters. After creation, all processed audio data will be output to the physical speaker through this main audio mixer. In addition, the `IXAudio2MasteringVoice` interface also supports some advanced functions, such as audio effect processing and volume adjustment, which can optimize the audio data before it is finally output to meet the requirements of different application scenarios.

[0086] Preferably, to further enhance the flexibility and compatibility of the system, the main audio mixer can support multiple audio formats and channel layouts. For example, the system can dynamically adjust the number of channels of the main audio mixer according to the user's configuration, from common stereo (2 channels) to complex multi-channel configurations (such as 12 channels). In addition, to optimize the audio output quality, audio effect processing functions, such as dynamic range compression or echo cancellation, can be integrated into the main audio mixer, and these effects can be implemented through the audio effect framework of XAudio2. In practical applications, the system can also provide a user interface that allows users to configure the parameters of the main audio mixer according to their needs, such as selecting different audio effects or adjusting the output volume.

[0087] The above embodiments of the present invention have the following beneficial effects: The multi-channel noise simulation system of the present invention can achieve independent volume control of multiple speakers. Through volume adjustment at the software level, other channels are muted when playing noise in a specific direction, thereby providing accurate sound localization and highly realistic audio effects. The system can support audio control of 12 channels, including 7.1 channels and 4 auxiliary channels, with good scalability and the ability to adapt to different scales of application scenarios. In addition, the control of each channel is executed by an independent thread, and each thread reads and plays audio stream data from the audio file respectively, which can ensure the efficiency and stability of the system. The volume control module defines the volume value of each channel through a floating-point array, and the user can dynamically adjust the channel volume through the software interface or external instructions to achieve flexible sound simulation effects and meet diverse requirements.

[0088] The system can simplify the implementation difficulty of the noise simulation system, avoid relying on complex hardware devices, and reduce the hardware complexity and system maintenance cost. By implementing multi-channel volume control through software, the need for external tuning devices can be reduced, making the operation of the system more intuitive and convenient and improving the usability of the technology. At the same time, the system supports real-time switching of channel volume, can quickly respond to user needs, and enhance the user experience. Using the existing XAudio2 engine, the present invention can be widely applied to various noise simulation and audio control scenarios, with extremely high practical value and market prospects.

[0089] Furthermore, the storage medium of the embodiment of the present application stores program instructions capable of implementing all the above methods. Among them, the program instructions can be stored in the above storage medium in the form of a software product, including several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of the present application. And the aforementioned storage medium includes: various media that can store program codes such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs, or terminal devices such as computers, servers, mobile phones, and tablets.

[0090] The above description is only some preferred embodiments of the present invention and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the embodiments of the present invention is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the technical solutions formed by mutually replacing the above features with the (but not limited to) technical features with similar functions disclosed in the embodiments of the present invention.

Claims

1. A multi-channel noise simulation system based on XAudio2, characterized in that Including: The XAudio2 engine initialization module, which is used to initialize the COM component and create an XAudio2 engine instance; The main audio mixer creation module, which calls the CreateMasteringVoice method of the XAudio2 engine to create the main audio mixer; The audio data loading module, which is used to read the audio stream data from the audio file and fill it into the XAUDIO2_BUFFER structure; The source voice creation and playback module, which calls the CreateSourceVoice method of the XAudio2 engine to create the source voice, submits the XAUDIO2_BUFFER and starts playback; The volume control module, which independently adjusts the volume of each channel by calling the SetChannelVolumes function and mutes the remaining channels when playing the target channel.

2. The multi-channel noise simulation system based on XAudio2 according to claim 1, wherein The XAudio2 engine initialization module specifically performs the following steps: Calls the ColinitializeEx function to initialize the COM component; Calls the XAudio2Create function to create an XAudio2 engine instance and stores it as an IXAudio2 interface pointer.

3. The multi-channel noise simulation system based on XAudio2 according to claim 1, characterized in that, The audio data loading module includes: Opens the audio file through the CreateFile function; Parses the RIFF block, fmt block, and data block of the audio file; Reads the content of the data block into the buffer and fills it into the XAUDIO2_BUFFER structure.

4. The multi-channel noise simulation system based on XAudio2 according to claim 1, characterized in that The volume control module defines the volume value of each channel through a floating-point array, and the dimension of the floating-point array is consistent with the number of channels supported by the system.

5. The multi-channel noise simulation system based on XAudio2 according to claim 4, characterized in that, The volume value of the target channel in the floating-point array is set to a non-zero value, and the volume values of the remaining channels are set to zero to achieve muting.

6. The multi-channel noise simulation system based on XAudio2 according to claim 1, characterized in that, The number of channels supported by the system is 12, including 8 channels of 7.1 channels and 4 auxiliary channels.

7. The multi-channel noise simulation system based on XAudio2 according to claim 1, wherein In the source voice creation and playback module, the control of each channel is executed by an independent thread, and each thread reads the audio stream data from the audio file and plays it.

8. The multi-channel noise simulation system based on XAudio2 according to claim 1, wherein The volume control module supports real-time switching of the volume values of channels and dynamically adjusts the playback states of different channels.

9. The multi-channel noise simulation system based on XAudio2 according to claim 1, characterized in that, The system receives the channel volume configuration parameters input by the user through a software interface or external instructions.

10. The multi-channel noise simulation system based on XAudio2 according to claim 1, characterized in that, The main audio mixer encapsulates the audio device through the IXAudio2MasteringVoice interface and transmits the processed audio data to the physical speakers.