# Virtual audio and real audio
Playing audio and real-time mixing will take up additional CPU resources. In order to reduce the impact of audio processing on game rendering, the mini game audio system supports virtual audio.
Compared with real audio, virtual audio CPU usage is lower. But the sound of the virtual audio will not be heard, because the audio system does not actually process the data of the virtual audio, and its data will not be processed by the audio hardware device.
For developers, real audio and virtual audio are almost identical. Developers can also use related APIs to obtain the playback status and playback information of virtual audio, and will also receive related audio event callbacks. Therefore, in actual game development, under normal circumstances, developers do not need to care about the virtual state of the audio, and just leave it to the system for processing.
The virtual audio strategy is as follows:
- The upper limit of the number of real audio —— indicates the upper limit of the number of sounds that can be heard at the same time, the default value is 20.
When the audioPriority property of Audio Source AudioSource is 0, the actual number of real audio may exceed this upper limit.
The upper limit of the number of real audio can be obtained and set through the API. When the upper limit is reset, it will not immediately have any impact on the currently playing audio, it will only affect the subsequent audio playback, pause, and stop processing. - audioPriority = 0
When the audioPriority property of AudioSource is set to 0, this audio must be real audio. In other words, the audio sound will definitely be heard.
When the audioPriority attribute value is reset, it will not immediately affect the virtual state of the audio. It will only affect the subsequent audio system's processing of the audio. - Play, scheduled play, replay
When performing the above processing on audio, the audio system will recalculate the virtual state of the audio according to the upper limit of the number of real audio and the priority of each audio (if the audio already has a corresponding virtual state, it will not be recalculated). The low-priority audio virtual state may change from real audio to virtual audio. - Pause and stop playback
When the audio playback is paused and stopped, this audio virtual state will be reset. Other high-priority audio virtual states may change from virtual audio to real audio. - seek
When a seek is executed during audio playback, since the audio already has a corresponding virtual state, its virtual state will not be recalculated.