mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
use mixer gain to enable/disable music/fx
This commit is contained in:
parent
d8a6106157
commit
e874678081
3 changed files with 13 additions and 12 deletions
7
TODO
7
TODO
|
@ -1,8 +1,7 @@
|
||||||
- moar documentation
|
- moar documentation
|
||||||
- control settings
|
- moar video settings
|
||||||
- video settings
|
|
||||||
- command line options
|
- command line options
|
||||||
|
- sound volume settings
|
||||||
|
|
||||||
- playable levels :D
|
- playable levels :D
|
||||||
|
- control settings
|
||||||
- get allegro 5.1 Windows build and use al_set_mixer_gain
|
|
||||||
|
|
|
@ -343,8 +343,10 @@ int main(int argc, char **argv){
|
||||||
game.audio.fx = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
game.audio.fx = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||||
game.audio.music = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
game.audio.music = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||||
al_attach_mixer_to_voice(game.audio.mixer, game.audio.voice);
|
al_attach_mixer_to_voice(game.audio.mixer, game.audio.voice);
|
||||||
if (game.fx) al_attach_mixer_to_mixer(game.audio.fx, game.audio.mixer);
|
al_attach_mixer_to_mixer(game.audio.fx, game.audio.mixer);
|
||||||
if (game.music) al_attach_mixer_to_mixer(game.audio.music, game.audio.mixer);
|
al_attach_mixer_to_mixer(game.audio.music, game.audio.mixer);
|
||||||
|
if (!game.fx) al_set_mixer_gain(game.audio.fx, 0.0);
|
||||||
|
if (!game.music) al_set_mixer_gain(game.audio.music, 0.0);
|
||||||
|
|
||||||
al_register_event_source(game.event_queue, al_get_display_event_source(game.display));
|
al_register_event_source(game.event_queue, al_get_display_event_source(game.display));
|
||||||
al_register_event_source(game.event_queue, al_get_timer_event_source(game.timer));
|
al_register_event_source(game.event_queue, al_get_timer_event_source(game.timer));
|
||||||
|
|
12
src/menu.c
12
src/menu.c
|
@ -327,18 +327,18 @@ int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if ((game->music) && (game->fx)) { game->music=0; SetConfigOption("SuperDerpy", "music", "0");
|
if ((game->music) && (game->fx)) { game->music=0; SetConfigOption("SuperDerpy", "music", "0");
|
||||||
al_detach_mixer(game->audio.music);
|
al_set_mixer_gain(game->audio.music, 0.0);
|
||||||
}
|
}
|
||||||
else if (game->fx) { game->music=1; game->fx=0; SetConfigOption("SuperDerpy", "music", "1"); SetConfigOption("SuperDerpy", "fx", "0");
|
else if (game->fx) { game->music=1; game->fx=0; SetConfigOption("SuperDerpy", "music", "1"); SetConfigOption("SuperDerpy", "fx", "0");
|
||||||
al_attach_mixer_to_mixer(game->audio.music, game->audio.mixer);
|
al_set_mixer_gain(game->audio.music, 1.0);
|
||||||
al_detach_mixer(game->audio.fx);
|
al_set_mixer_gain(game->audio.fx, 0.0);
|
||||||
}
|
}
|
||||||
else if (game->music) { game->music=0; SetConfigOption("SuperDerpy", "music", "0");
|
else if (game->music) { game->music=0; SetConfigOption("SuperDerpy", "music", "0");
|
||||||
al_detach_mixer(game->audio.music);
|
al_set_mixer_gain(game->audio.music, 0.0);
|
||||||
}
|
}
|
||||||
else { game->music=1; game->fx=1; SetConfigOption("SuperDerpy", "music", "1"); SetConfigOption("SuperDerpy", "fx", "1");
|
else { game->music=1; game->fx=1; SetConfigOption("SuperDerpy", "music", "1"); SetConfigOption("SuperDerpy", "fx", "1");
|
||||||
al_attach_mixer_to_mixer(game->audio.fx, game->audio.mixer);
|
al_set_mixer_gain(game->audio.music, 1.0);
|
||||||
al_attach_mixer_to_mixer(game->audio.music, game->audio.mixer);
|
al_set_mixer_gain(game->audio.fx, 1.0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
Loading…
Reference in a new issue