mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
use 44100 sample rate by default and make the default configurable by the game
This commit is contained in:
parent
f701df6100
commit
63e5210796
3 changed files with 19 additions and 9 deletions
|
@ -189,14 +189,13 @@ SYMBOL_INTERNAL void ResizeGamestates(struct Game* game) {
|
|||
}
|
||||
|
||||
SYMBOL_INTERNAL int SetupAudio(struct Game* game) {
|
||||
int samplerate = strtol(GetConfigOptionDefault(game, "SuperDerpy", "samplerate", "48000"), NULL, 10);
|
||||
#ifdef __EMSCRIPTEN__
|
||||
game->audio.v = al_create_voice(samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.v = al_create_voice(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
#else
|
||||
game->audio.v = al_create_voice(samplerate, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.v = al_create_voice(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2);
|
||||
if (!game->audio.v) {
|
||||
// fallback
|
||||
game->audio.v = al_create_voice(samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.v = al_create_voice(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
}
|
||||
#endif
|
||||
al_set_default_voice(game->audio.v);
|
||||
|
|
|
@ -118,6 +118,7 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
game->config.voice = strtol(GetConfigOptionDefault(game, "SuperDerpy", "voice", "10"), NULL, 10);
|
||||
game->config.fx = strtol(GetConfigOptionDefault(game, "SuperDerpy", "fx", "10"), NULL, 10);
|
||||
game->config.mute = strtol(GetConfigOptionDefault(game, "SuperDerpy", "mute", "0"), NULL, 10);
|
||||
game->config.samplerate = strtol(GetConfigOptionDefault(game, "SuperDerpy", "samplerate", "0"), NULL, 10);
|
||||
game->config.width = strtol(GetConfigOptionDefault(game, "SuperDerpy", "width", GetDefaultWindowWidth(game)), NULL, 10);
|
||||
if (game->config.width < 100) { game->config.width = 100; }
|
||||
game->config.height = strtol(GetConfigOptionDefault(game, "SuperDerpy", "height", GetDefaultWindowHeight(game)), NULL, 10);
|
||||
|
@ -327,11 +328,17 @@ SYMBOL_EXPORT struct Game* libsuperderpy_init(int argc, char** argv, const char*
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int samplerate = strtol(GetConfigOptionDefault(game, "SuperDerpy", "samplerate", "48000"), NULL, 10);
|
||||
game->audio.mixer = al_create_mixer(samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.fx = al_create_mixer(samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.music = al_create_mixer(samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.voice = al_create_mixer(samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->_priv.samplerate = game->config.samplerate;
|
||||
if (!game->_priv.samplerate) {
|
||||
game->_priv.samplerate = params.samplerate;
|
||||
if (!game->_priv.samplerate) {
|
||||
game->_priv.samplerate = 44100;
|
||||
}
|
||||
}
|
||||
game->audio.mixer = al_create_mixer(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.fx = al_create_mixer(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.music = al_create_mixer(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game->audio.voice = al_create_mixer(game->_priv.samplerate, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
al_attach_mixer_to_mixer(game->audio.fx, game->audio.mixer);
|
||||
al_attach_mixer_to_mixer(game->audio.music, game->audio.mixer);
|
||||
al_attach_mixer_to_mixer(game->audio.voice, game->audio.mixer);
|
||||
|
|
|
@ -140,6 +140,7 @@ struct Params {
|
|||
bool depth_buffer; /*!< Request a depth buffer for the framebuffer's render target. */
|
||||
bool show_loading_on_launch; /*!< Whether the loading screen should be shown when loading the initial set of gamestates. */
|
||||
int samples; /*!< How many samples should be used for multisampling; 0 to disable. */
|
||||
int samplerate; /*!< Default sample rate of audio output; 0 to use engine default. */
|
||||
char* window_title; /*!< A title of the game's window. When NULL, al_get_app_name() is used. */
|
||||
struct Handlers handlers; /*!< A list of user callbacks to register. */
|
||||
};
|
||||
|
@ -170,6 +171,7 @@ struct Game {
|
|||
int music; /*!< Music volume. */
|
||||
int voice; /*!< Voice volume. */
|
||||
bool mute; /*!< Whether audio should be muted globally. */
|
||||
int samplerate; /*!< Sample rate of audio output. */
|
||||
bool fullscreen; /*!< Fullscreen toggle. */
|
||||
int width; /*!< Width of window as being set in configuration. */
|
||||
int height; /*!< Height of window as being set in configuration. */
|
||||
|
@ -266,6 +268,8 @@ struct Game {
|
|||
|
||||
int window_width, window_height;
|
||||
|
||||
int samplerate;
|
||||
|
||||
#ifdef ALLEGRO_MACOSX
|
||||
char cwd[MAXPATHLEN];
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue