Skip to content

Commit

Permalink
DUMB 2.0 and DUMB 0.9.3 compatibility
Browse files Browse the repository at this point in the history
We support two versions of DUMB to play tracked music:

* 0.9.3 from Sourceforge <http://dumb.sourceforge.net>
* 2.0.0 by kode54 on github  <https://github.com/kode54/dumb>

The DUMB homepage on Sourceforge endorses kode54's fork and links to it.
The Allegro source tests the DUMB version and supports either API.
Supported tracker formats in DUMB 2.0 that Allegro 5 can now play:

* IT (Impulse Tracker)
* XM (Fasttracker II)
* MOD (Ultimate SoundTracker, ProTracker)
* STM (Scream Tracker)
* S3M (Scream Tracker 3)
* 669 (Composer 669)
* AMF (Asylum Music Format)
* AMF (Digital Sound and Music Interface Advanced Music Format)
* DSM (Digital Sound Interface Kit module format)
* MTM (MultiTracker)
* OKT (Oktalyzer)
* PSM (Protracker Studio, both the older PSM16 and the newer PSM)
* PTM (PolyTracker)
* RIFF AM/AMFF (Galaxy Music System internal format)

The CMake build script uses -lm on all platforms for the compile test.
Without -lm, cmake finds the include paths and libraries, can compile
the test program, but couldn't link it on Arch Linux.
  • Loading branch information
SimonN committed Sep 28, 2017
1 parent c97f009 commit b08f5f4
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 35 deletions.
9 changes: 7 additions & 2 deletions addons/acodec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ if(WANT_MODAUDIO)
set(CMAKE_REQUIRED_LIBRARIES ${DUMB_LIBRARIES})
run_c_compile_test("
#include <dumb.h>
#if (DUMB_MAJOR_VERSION) == 1
#error libdumb 1.0 not supported, get >= 2.0 or 0.9.3
#endif
int main(void)
{
dumb_register_stdfiles();
Expand All @@ -155,8 +158,10 @@ if(WANT_MODAUDIO)
endif(DUMB_COMPILES)
endif(DUMB_FOUND)
if(NOT SUPPORT_MODAUDIO)
message("WARNING: libdumb not found or compile test failed, "
"disabling support. <http://dumb.sourceforge.net/>")
message("WARNING: libdumb >= 2.0 or <= 0.9.3 not found or compile "
"test failed, disabling support. See "
"<https://github.com/kode54/dumb> for 2.0 or "
"<http://dumb.sourceforge.net/> for 0.9.3.")
endif(NOT SUPPORT_MODAUDIO)
endif(WANT_MODAUDIO)

Expand Down
45 changes: 44 additions & 1 deletion addons/acodec/acodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "allegro5/internal/aintern_acodec_cfg.h"
#include "acodec.h"

#ifdef ALLEGRO_CFG_ACODEC_MODAUDIO
#include <dumb.h>
#endif

/* Function: al_get_allegro_acodec_version
*/
Expand Down Expand Up @@ -38,6 +41,45 @@ bool al_init_acodec_addon(void)
#endif

#ifdef ALLEGRO_CFG_ACODEC_MODAUDIO
#if (DUMB_MAJOR_VERSION) >= 2
/*
* DUMB 2.0 offers a single loader for at least 13 formats, see their
* readme. Amiga NoiseTracker isn't listed there, but it's DUMB-supported.
* It merely has no common extensions, see:
* https://github.com/kode54/dumb/issues/53
*/
ret &= al_register_audio_stream_loader(".669", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".669", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".amf", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".amf", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".asy", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".asy", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".it", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".it", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".mod", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".mod", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".mtm", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".mtm", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".okt", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".okt", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".psm", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".psm", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".ptm", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".ptm", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".riff", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".riff", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".s3m", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".s3m", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".stm", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".stm", _al_load_dumb_audio_stream_f);
ret &= al_register_audio_stream_loader(".xm", _al_load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".xm", _al_load_dumb_audio_stream_f);
#else
/*
* DUMB 0.9.3 supported only these 4 formats and had no *_any loader.
* Avoid DUMB 1.0 because of versioning problems: dumb.h from git tag 1.0
* reports 0.9.3 in its version numbers.
*/
ret &= al_register_audio_stream_loader(".xm", _al_load_xm_audio_stream);
ret &= al_register_audio_stream_loader_f(".xm", _al_load_xm_audio_stream_f);
ret &= al_register_audio_stream_loader(".it", _al_load_it_audio_stream);
Expand All @@ -46,7 +88,8 @@ bool al_init_acodec_addon(void)
ret &= al_register_audio_stream_loader_f(".mod", _al_load_mod_audio_stream_f);
ret &= al_register_audio_stream_loader(".s3m", _al_load_s3m_audio_stream);
ret &= al_register_audio_stream_loader_f(".s3m", _al_load_s3m_audio_stream_f);
#endif
#endif // DUMB_MAJOR_VERSION
#endif // ALLEGRO_CFG_ACODEC_MODAUDIO

#ifdef ALLEGRO_CFG_ACODEC_VORBIS
ret &= al_register_sample_loader(".ogg", _al_load_ogg_vorbis);
Expand Down
10 changes: 9 additions & 1 deletion addons/acodec/acodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ ALLEGRO_AUDIO_STREAM *_al_load_flac_audio_stream_f(ALLEGRO_FILE* f,
#endif

#ifdef ALLEGRO_CFG_ACODEC_MODAUDIO
#include <dumb.h>
#if (DUMB_MAJOR_VERSION) >= 2
ALLEGRO_AUDIO_STREAM *_al_load_dumb_audio_stream(const char *filename,
size_t buffer_count, unsigned int samples);
ALLEGRO_AUDIO_STREAM *_al_load_dumb_audio_stream_f(ALLEGRO_FILE *f,
size_t buffer_count, unsigned int samples);
#else
ALLEGRO_AUDIO_STREAM *_al_load_mod_audio_stream(const char *filename,
size_t buffer_count, unsigned int samples);
ALLEGRO_AUDIO_STREAM *_al_load_it_audio_stream(const char *filename,
Expand All @@ -47,7 +54,8 @@ ALLEGRO_AUDIO_STREAM *_al_load_xm_audio_stream_f(ALLEGRO_FILE *f,
size_t buffer_count, unsigned int samples);
ALLEGRO_AUDIO_STREAM *_al_load_s3m_audio_stream_f(ALLEGRO_FILE *f,
size_t buffer_count, unsigned int samples);
#endif
#endif // DUMB_MAJOR_VERSION
#endif // ALLEGRO_CFG_ACODEC_MODAUDIO

#ifdef ALLEGRO_CFG_ACODEC_VORBIS
ALLEGRO_SAMPLE *_al_load_ogg_vorbis(const char *filename);
Expand Down
Loading

0 comments on commit b08f5f4

Please sign in to comment.