For any decent-sized game, there will be a lot of audio resources. Generally, we keep these in the assets folder, sorted into appropriate folders, such as audio/bgm
for background music, audio/sfx
for sound effects, and so on. Within the application, we would want to load only those audio resources that we need for a level, which means that upon a level transition, we unload any unnecessary resources and load new resources.
Which resources are needed would be described in some kind of level description file (XML file, INI file, or similar) or structure. Then, during a loading screen, you can compare the loaded versus required resources and unload or load as needed. How to load and unload audio depends on which API you use: MusicManager
, SoundManager
, the lower-level APIs covered earlier, or an external API (such as OpenSL ES).