aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-08-01 12:49:17 +0200
committerraysan5 <raysan5@gmail.com>2016-08-01 12:49:17 +0200
commit02c456432d7f284c41519f6d540ad6c4dfb4a065 (patch)
tree2c59dab7bc67e2ae7164d942535bd3d77f3809cf /examples
parenta61b832c4ad976ab083cfebf8039149c2a7022f8 (diff)
downloadraylib-02c456432d7f284c41519f6d540ad6c4dfb4a065.tar.gz
raylib-02c456432d7f284c41519f6d540ad6c4dfb4a065.zip
Complete review of audio system
Still some work left...
Diffstat (limited to 'examples')
-rw-r--r--examples/audio_module_playing.c10
-rw-r--r--examples/audio_music_stream.c20
2 files changed, 19 insertions, 11 deletions
diff --git a/examples/audio_module_playing.c b/examples/audio_module_playing.c
index 6189b866..07165c76 100644
--- a/examples/audio_module_playing.c
+++ b/examples/audio_module_playing.c
@@ -57,7 +57,9 @@ int main()
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
- PlayMusicStream(0, "resources/audio/2t2m_spa.xm"); // Play module stream
+ Music xm = LoadMusicStream("resources/audio/2t2m_spa.xm");
+
+ PlayMusicStream(xm);
float timePlayed = 0.0f;
@@ -88,9 +90,9 @@ int main()
}
// Get timePlayed scaled to bar dimensions
- timePlayed = (GetMusicTimePlayed(0)/GetMusicTimeLength(0)*(screenWidth - 40))*2;
+ timePlayed = (GetMusicTimePlayed(xm)/GetMusicTimeLength(xm)*(screenWidth - 40))*2;
- UpdateMusicStream(0); // Update music buffer with new stream data
+ UpdateMusicStream(xm); // Update music buffer with new stream data
//----------------------------------------------------------------------------------
// Draw
@@ -129,6 +131,8 @@ int main()
UnloadShader(shader); // Unload shader
UnloadRenderTexture(target); // Unload render texture
+ UnloadMusicStream(xm); // Unload music stream buffers from RAM
+
CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
CloseWindow(); // Close window and OpenGL context
diff --git a/examples/audio_music_stream.c b/examples/audio_music_stream.c
index e135a6e4..b96b85f7 100644
--- a/examples/audio_music_stream.c
+++ b/examples/audio_music_stream.c
@@ -24,7 +24,9 @@ int main()
InitAudioDevice(); // Initialize audio device
- PlayMusicStream(0, "resources/audio/guitar_noodling.ogg"); // Play music stream
+ Music music = LoadMusicStream("resources/audio/guitar_noodling.ogg");
+
+ PlayMusicStream(music);
int framesCounter = 0;
float timePlayed = 0.0f;
@@ -58,12 +60,12 @@ int main()
SetMusicVolume(volume);
}
*/
- if (IsWindowMinimized()) PauseMusicStream(0);
- else ResumeMusicStream(0);
+ if (IsWindowMinimized()) PauseMusicStream(music);
+ else ResumeMusicStream(music);
- timePlayed = GetMusicTimePlayed(0)/GetMusicTimeLength(0)*100*4; // We scale by 4 to fit 400 pixels
-
- UpdateMusicStream(0); // Update music buffer with new stream data
+ timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music)*100*4; // We scale by 4 to fit 400 pixels
+
+ UpdateMusicStream(music); // Update music buffer with new stream data
//----------------------------------------------------------------------------------
// Draw
@@ -83,9 +85,11 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
- CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
+ UnloadMusicStream(music); // Unload music stream buffers from RAM
+
+ CloseAudioDevice(); // Close audio device (music streaming is automatically stopped)
- CloseWindow(); // Close window and OpenGL context
+ CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;