aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKikooDX <kikoodx@paranoici.org>2022-03-06 19:19:51 +0100
committerKikooDX <kikoodx@paranoici.org>2022-03-06 19:19:51 +0100
commita7175973b74bc320736b73ac2a7bc976b9d83fb7 (patch)
tree038a5aef4a34457ae72b4484d7f4f325b89920dd
parente097d0de738d6f0b29d7cf3ff4dcb06d19933a12 (diff)
downloadlzy-a7175973b74bc320736b73ac2a7bc976b9d83fb7.tar.gz
set sound volume
-rw-r--r--inc/lzy.h41
1 files changed, 26 insertions, 15 deletions
diff --git a/inc/lzy.h b/inc/lzy.h
index 577ec3c..aced5dd 100644
--- a/inc/lzy.h
+++ b/inc/lzy.h
@@ -100,6 +100,7 @@ int LZY_MusicDestroy(LZY_Music *music);
int LZY_MusicPlay(LZY_Music *music, int loops);
LZY_Sound *LZY_SoundLoad(const char *path);
int LZY_SoundDestroy(LZY_Sound *sound);
+void LZY_SoundSetVolume(LZY_Sound *sound, float volume);
int LZY_SoundPlay(LZY_Sound *sound, int loops);
int LZY_PollEvent(LZY_Event *);
void LZY_CycleEvents(void);
@@ -371,6 +372,11 @@ int LZY_SoundDestroy(LZY_Sound *sound) {
return -1;
}
+void LZY_SoundSetVolume(LZY_Sound *sound, float volume) {
+ LZY_UNUSED(sound);
+ LZY_UNUSED(volume);
+}
+
int LZY_SoundPlay(LZY_Sound *sound, int loops) {
LZY_UNUSED(sound);
LZY_UNUSED(loops);
@@ -741,26 +747,26 @@ LZY_Music *LZY_MusicLoad(const char *path) {
return music;
}
-int LZY_MusicPlay(LZY_Music *music, int loops) {
+int LZY_MusicDestroy(LZY_Music *music) {
if (music == NULL) {
error = "music is NULL";
return -1;
}
- if (Mix_PlayMusic(music, loops) < 0) {
- error = Mix_GetError();
- return -2;
- }
+ Mix_FreeMusic(music);
return 0;
}
-int LZY_MusicDestroy(LZY_Music *music) {
+int LZY_MusicPlay(LZY_Music *music, int loops) {
if (music == NULL) {
error = "music is NULL";
return -1;
}
- Mix_FreeMusic(music);
+ if (Mix_PlayMusic(music, loops) < 0) {
+ error = Mix_GetError();
+ return -2;
+ }
return 0;
}
@@ -771,27 +777,32 @@ LZY_Sound *LZY_SoundLoad(const char *path) {
return sound;
}
-int LZY_SoundPlay(LZY_Sound *sound, int loops) {
+int LZY_SoundDestroy(LZY_Sound *sound) {
if (sound == NULL) {
error = "sound is NULL";
return -1;
}
- if (Mix_PlayChannel(-1, sound, loops) < 0) {
- error = Mix_GetError();
- return -2;
- }
-
+ Mix_FreeChunk(sound);
return 0;
}
-int LZY_SoundDestroy(LZY_Sound *sound) {
+void LZY_SoundSetVolume(LZY_Sound *sound, float volume) {
+ if (sound != NULL)
+ Mix_VolumeChunk(sound, MIX_MAX_VOLUME * volume);
+}
+
+int LZY_SoundPlay(LZY_Sound *sound, int loops) {
if (sound == NULL) {
error = "sound is NULL";
return -1;
}
- Mix_FreeChunk(sound);
+ if (Mix_PlayChannel(-1, sound, loops) < 0) {
+ error = Mix_GetError();
+ return -2;
+ }
+
return 0;
}