|  |  | @ -1,6 +1,6 @@ | 
		
	
		
			
			|  |  |  | /******************************************************************************************* | 
		
	
		
			
			|  |  |  | * | 
		
	
		
			
			|  |  |  | *   raylib [audio] example - Playing sound multiple times | 
		
	
		
			
			|  |  |  | *   raylib [audio] example - sound alias | 
		
	
		
			
			|  |  |  | * | 
		
	
		
			
			|  |  |  | *   Example complexity rating: [★★☆☆] 2/4 | 
		
	
		
			
			|  |  |  | * | 
		
	
	
		
			
				|  |  | @ -31,18 +31,18 @@ int main(void) | 
		
	
		
			
			|  |  |  | const int screenWidth = 800; | 
		
	
		
			
			|  |  |  | const int screenHeight = 450; | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | InitWindow(screenWidth, screenHeight, "raylib [audio] example - playing sound multiple times"); | 
		
	
		
			
			|  |  |  | InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound alias"); | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | InitAudioDevice();      // Initialize audio device | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // load the sound list | 
		
	
		
			
			|  |  |  | n">soundArray[0] = LoadSound("resources/sound.wav");         // Load WAV audio file into the first slot as the 'source' sound | 
		
	
		
			
			|  |  |  | // this sound owns the sample data | 
		
	
		
			
			|  |  |  | for (int i = 1; i < MAX_SOUNDS; i++) | 
		
	
		
			
			|  |  |  | p">{ | 
		
	
		
			
			|  |  |  | soundArray[i] = LoadSoundAlias(soundArray[0]);        // Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | currentSound = 0;                                         // set the sound list to the start | 
		
	
		
			
			|  |  |  | // Load audio file into the first slot as the 'source' sound, | 
		
	
		
			
			|  |  |  | o">// this sound owns the sample data | 
		
	
		
			
			|  |  |  | soundArray[0] = LoadSound("resources/sound.wav"); | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | o">// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played | 
		
	
		
			
			|  |  |  | for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]); | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | currentSound = 0;               // Set the sound list to the start | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | SetTargetFPS(60);               // Set our game to run at 60 frames-per-second | 
		
	
		
			
			|  |  |  | //-------------------------------------------------------------------------------------- | 
		
	
	
		
			
				|  |  | @ -54,14 +54,15 @@ int main(void) | 
		
	
		
			
			|  |  |  | //---------------------------------------------------------------------------------- | 
		
	
		
			
			|  |  |  | if (IsKeyPressed(KEY_SPACE)) | 
		
	
		
			
			|  |  |  | { | 
		
	
		
			
			|  |  |  | PlaySound(soundArray[currentSound]);            // play the next open sound slot | 
		
	
		
			
			|  |  |  | currentSound++;                                 // increment the sound slot | 
		
	
		
			
			|  |  |  | if (currentSound >= MAX_SOUNDS)                 // if the sound slot is out of bounds, go back to 0 | 
		
	
		
			
			|  |  |  | currentSound = 0; | 
		
	
		
			
			|  |  |  | PlaySound(soundArray[currentSound]);    // Play the next open sound slot | 
		
	
		
			
			|  |  |  | currentSound++;                         // Increment the sound slot | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // l">Note: a better way would be to look at the list for the first sound that is not playing and use that slot | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | // If the sound slot is out of bounds, go back to 0 | 
		
	
		
			
			|  |  |  | if (currentSound >= MAX_SOUNDS) currentSound = 0; | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // NOTE: Another approach would be to look at the list for the first sound | 
		
	
		
			
			|  |  |  | // that is not playing and use that slot | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | //---------------------------------------------------------------------------------- | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // Draw | 
		
	
	
		
			
				|  |  | @ -78,9 +79,8 @@ int main(void) | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | // De-Initialization | 
		
	
		
			
			|  |  |  | //-------------------------------------------------------------------------------------- | 
		
	
		
			
			|  |  |  | for (int i = 1; i < MAX_SOUNDS; i++) | 
		
	
		
			
			|  |  |  | UnloadSoundAlias(soundArray[i]);     // Unload sound aliases | 
		
	
		
			
			|  |  |  | UnloadSound(soundArray[0]);              // Unload source sound data | 
		
	
		
			
			|  |  |  | for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases | 
		
	
		
			
			|  |  |  | UnloadSound(soundArray[0]); // Unload source sound data | 
		
	
		
			
			|  |  |  |  | 
		
	
		
			
			|  |  |  | CloseAudioDevice();     // Close audio device | 
		
	
		
			
			|  |  |  |  | 
		
	
	
		
			
				|  |  |  |