From 599bfa0331e9f7457c6b4e2d5bb85a91ae81ab82 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 4 May 2023 11:03:48 +0200 Subject: [PATCH] Check if no MIDI sounds could be played --- README.md | 2 +- src/audio.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6769936..ae2e298 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Aucune... > > ```bash > sudo mkdir -p /usr/share/sounds/sf2 - > sudo ln -sf /usr/share/soundfonts/*.sf2 /usr/share/sounds/sf2/ + > sudo ln -s /usr/share/soundfonts/*.sf2 /usr/share/sounds/sf2/ > ``` - `SDL2_ttf` - `SDL2_image` diff --git a/src/audio.c b/src/audio.c index a9ecee6..51bdacc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -26,6 +26,17 @@ void initMusic(Mix_Chunk *music, const char *filename) { exit(_errStatus); } + if (!Mix_GetSoundFonts()) { + fprintf(stderr, + "Aucun soundfonts, mettez les dans /usr/share/sounds/sf2\n"); + fprintf(stderr, + "S'ils sont dans /usr/share/soundfonts, " + "vous pouvez faire :\n" + "sudo mkdir -p /usr/share/sounds/sf2 && " + "sudo ln -s /usr/share/soundfonts/*.sf2 /usr/share/sounds/sf2/\n"); + exit(_errStatus); + } + if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 2048)) { fprintf(stderr, "Erreur Mix_OpenAudio\n"); exit(_errStatus);