Skip to content

Commit

Permalink
Merge pull request #2703 from pygame-community/ankith26-bump-sdl-mixer
Browse files Browse the repository at this point in the history
Bump SDL_mixer to 2.8.0 (Adds wavpack support)
  • Loading branch information
Starbuck5 committed Feb 18, 2024
1 parent 3326c57 commit 5f5c0d4
Show file tree
Hide file tree
Showing 22 changed files with 214 additions and 27 deletions.
5 changes: 5 additions & 0 deletions buildconfig/config_win.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ def __iter__(self):
def _add_sdl2_dll_deps(DEPS):
# MIXER
DEPS.add_dll(r'(libogg-0|ogg)\.dll$', 'ogg', ['libogg-[1-9].*'])
# modplug replaced with libxmp after SDL_mixer 2.6.3
DEPS.add_dll(r'(lib)?modplug[-0-9]*\.dll$', 'modplug', ['*modplug-[0-9]*'])
DEPS.add_dll(r'libxmp.dll$', 'xmp', ['libxmp*'])
DEPS.add_dll(r'libwavpack[-0-9]*\.dll$', 'wavpack', ['libwavpack-[1-9].*'])
DEPS.add_dll(r'(lib)?opus[-0-9]*\.dll$', 'opus', ['*opus-[0-9]*'])
DEPS.add_dll(r'(lib)?opusfile[-0-9]*\.dll$', 'opusfile', ['*opusfile-[0-9]*'])
# IMAGE
Expand Down Expand Up @@ -431,6 +434,8 @@ def setup_prebuilt_sdl2(prebuilt_dir):

'ogg': mixerDep.path,
'modplug': mixerDep.path,
'xmp': mixerDep.path,
'wavpack': mixerDep.path,
'opus': mixerDep.path,
'opusfile': mixerDep.path,
}
Expand Down
8 changes: 4 additions & 4 deletions buildconfig/download_win_prebuilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def get_urls(x86=True, x64=True):
'2d4f131909af2985b5ebc5ed296d28628c87c243'
],
[
'https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.6.2/SDL2_mixer-devel-2.6.2-VC.zip',
'000e3ea8a50261d46dbd200fb450b93c59ed4482',
'https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.8.0/SDL2_mixer-devel-2.8.0-VC.zip',
'a10411644e08cd94f29712f430c7b71c407ae76d',
],
])
if x86:
Expand Down Expand Up @@ -212,12 +212,12 @@ def copy(src, dst):
copy(
os.path.join(
temp_dir,
'SDL2_mixer-devel-2.6.2-VC/SDL2_mixer-2.6.2'
'SDL2_mixer-devel-2.8.0-VC/SDL2_mixer-2.8.0'
),
os.path.join(
move_to_dir,
prebuilt_dir,
'SDL2_mixer-2.6.2'
'SDL2_mixer-2.8.0'
)
)
copy(
Expand Down
3 changes: 2 additions & 1 deletion buildconfig/macdependencies/build_mac_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ bash bzip2/build-bzip2.sh
bash freetype/build-freetype.sh

# sdl_mixer deps
bash libmodplug/build-libmodplug.sh
bash libxmp/build-libxmp.sh
bash ogg/build-ogg.sh
bash flac/build-flac.sh
bash mpg123/build-mpg123.sh
bash opus/build-opus.sh # needs libogg (which is a container format)
bash wavpack/build-wavpack.sh

# fluidsynth (for sdl_mixer)
# bash gettext/build-gettext.sh
Expand Down
7 changes: 5 additions & 2 deletions buildconfig/manylinux-build/docker_base/Dockerfile-aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ RUN ["bash", "/sndfile_build/build-sndfile.sh"]
ADD pulseaudio /pulseaudio_build/
RUN ["bash", "/pulseaudio_build/build-pulseaudio.sh"]

ADD libmodplug /libmodplug_build/
RUN ["bash", "/libmodplug_build/build-libmodplug.sh"]
ADD libxmp /libxmp_build/
RUN ["bash", "/libxmp_build/build-libxmp.sh"]

ADD libffi /libffi_build/
RUN ["bash", "/libffi_build/build-libffi.sh"]
Expand All @@ -107,6 +107,9 @@ RUN ["bash", "/glib_build/build-glib.sh"]
ADD fluidsynth /fluidsynth_build/
RUN ["bash", "/fluidsynth_build/build-fluidsynth.sh"]

ADD wavpack /wavpack_build/
RUN ["bash", "/wavpack_build/build-wavpack.sh"]

ADD sdl_libs /sdl_build/
RUN ["bash", "/sdl_build/build-sdl2-libs.sh"]

Expand Down
7 changes: 5 additions & 2 deletions buildconfig/manylinux-build/docker_base/Dockerfile-i686
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ RUN ["linux32", "bash", "/sndfile_build/build-sndfile.sh"]
ADD pulseaudio /pulseaudio_build/
RUN ["linux32", "bash", "/pulseaudio_build/build-pulseaudio.sh"]

ADD libmodplug /libmodplug_build/
RUN ["linux32", "bash", "/libmodplug_build/build-libmodplug.sh"]
ADD libxmp /libxmp_build/
RUN ["linux32", "bash", "/libxmp_build/build-libxmp.sh"]

ADD libffi /libffi_build/
RUN ["bash", "/libffi_build/build-libffi.sh"]
Expand All @@ -107,6 +107,9 @@ RUN ["bash", "/glib_build/build-glib.sh"]
ADD fluidsynth /fluidsynth_build/
RUN ["linux32", "bash", "/fluidsynth_build/build-fluidsynth.sh"]

ADD wavpack /wavpack_build/
RUN ["linux32", "bash", "/wavpack_build/build-wavpack.sh"]

# Build and install SDL
ADD sdl_libs /sdl_build/
RUN ["linux32", "bash", "/sdl_build/build-sdl2-libs.sh"]
Expand Down
7 changes: 5 additions & 2 deletions buildconfig/manylinux-build/docker_base/Dockerfile-x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ RUN ["bash", "/sndfile_build/build-sndfile.sh"]
ADD pulseaudio /pulseaudio_build/
RUN ["bash", "/pulseaudio_build/build-pulseaudio.sh"]

ADD libmodplug /libmodplug_build/
RUN ["bash", "/libmodplug_build/build-libmodplug.sh"]
ADD libxmp /libxmp_build/
RUN ["bash", "/libxmp_build/build-libxmp.sh"]

ADD libffi /libffi_build/
RUN ["bash", "/libffi_build/build-libffi.sh"]
Expand All @@ -107,6 +107,9 @@ RUN ["bash", "/glib_build/build-glib.sh"]
ADD fluidsynth /fluidsynth_build/
RUN ["bash", "/fluidsynth_build/build-fluidsynth.sh"]

ADD wavpack /wavpack_build/
RUN ["bash", "/wavpack_build/build-wavpack.sh"]

ADD sdl_libs /sdl_build/
RUN ["bash", "/sdl_build/build-sdl2-libs.sh"]

Expand Down
19 changes: 19 additions & 0 deletions buildconfig/manylinux-build/docker_base/libxmp/build-libxmp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -e -x

cd $(dirname `readlink -f "$0"`)

XMP_VERSION=4.6.0
XMP="libxmp-${XMP_VERSION}"


curl -sL --retry 10 https://github.com/libxmp/libxmp/releases/download/${XMP}/${XMP}.tar.gz > ${XMP}.tar.gz

sha512sum -c libxmp.sha512
tar xzf ${XMP}.tar.gz
cd ${XMP}

cmake . $PG_BASE_CMAKE_FLAGS

make
make install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d287544c9b569515f1a3fa92d8d930097b252e84f86cba5dd70e9b4460d0fa70754ece45dcc7ec314e434d821b43207d700afb12c9df80b467d73e9d029baafe libxmp-4.6.0.tar.gz
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cd $(dirname `readlink -f "$0"`)
SDL2="SDL2-2.28.5"
IMG2="SDL2_image-2.8.2"
TTF2="SDL2_ttf-2.22.0"
MIX2="SDL2_mixer-2.6.3"
MIX2="SDL2_mixer-2.8.0"


# Download
Expand Down Expand Up @@ -94,22 +94,22 @@ cd $MIX2
# libraries into the wheel.
# We prefer libflac, mpg123 and ogg-vorbis over SDL vendored implementations
# at the moment. This can be changed later if need arises.
# For now, libmodplug is preferred over libxmp (but this may need changing
# in the future)
# We don't build with libgme for now
./configure $PG_BASE_CONFIGURE_FLAGS \
--disable-dependency-tracking \
--disable-music-ogg-stb --enable-music-ogg-vorbis \
--disable-music-flac-drflac --enable-music-flac-libflac \
--disable-music-mp3-drmp3 --enable-music-mp3-mpg123 \
--enable-music-mod-modplug --disable-music-mod-mikmod-shared \
--disable-music-mod-xmp --disable-music-mod-xmp-shared \
--disable-music-mp3-drmp3 --disable-music-mp3-minimp3 --enable-music-mp3-mpg123 \
--disable-music-mod-modplug \
--enable-music-mod-xmp --disable-music-mod-xmp-shared \
--enable-music-midi-fluidsynth --disable-music-midi-fluidsynth-shared \
--enable-music-opus --disable-music-opus-shared \
--enable-music-wavpack --disable-music-wavpack-shared \
--disable-music-ogg-vorbis-shared \
--disable-music-ogg-tremor-shared \
--disable-music-ogg-tremor \
--disable-music-flac-libflac-shared \
--disable-music-mp3-mpg123-shared \
--disable-music-mod-modplug-shared
--disable-music-gme

make
make install
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
12593eb78fcca877a8dfb78cf21a4e6feba7dc87c964de378ac462b36d8e41ecb587222cb41d5f56dd35b838e1b9867b8ae0cf2f4d2a01afaf23ac8c11edc84d SDL2-2.28.5.tar.gz
0ff345824f95158dfa72f83f9d4a540601c178cd759334bf849c14a2920b5330d0763413b58c08b3deba8d3a4ccb6ea2a8159f87efe4cbb0e8ea850f63d09454 SDL2_image-2.8.2.tar.gz
2e9da045d2fdab97236c3901b3d441834a67a47c8851ddfb817c9db6f23ed9fb355a5ef8d2158d0c9959a83934e8cd1b95db8a69eaddf8f7fcca115f01818740 SDL2_mixer-2.6.3.tar.gz
5ddbc4b0b5fad2e0844a503daa79564b912654192599ef8fa7698531f08323ce01801f6bb17b2b3905020a3df362a967b7566ae725eb085da991578cc0807aad SDL2_mixer-2.8.0.tar.gz
34a1d210d8f1b1e802139d65ba47e36033bb7881e75a8862c1b1c515565bef85e3d81ee42e952aa664de043debef387ba60088a9cf3ba3297413db39a13af912 SDL2_ttf-2.22.0.tar.gz
24 changes: 24 additions & 0 deletions buildconfig/manylinux-build/docker_base/wavpack/build-wavpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
set -e -x

cd $(dirname `readlink -f "$0"`)

WAVPACK_VERSION=5.6.0
WAVPACK="wavpack-${WAVPACK_VERSION}"

curl -sL --retry 10 https://github.com/dbry/WavPack/releases/download/${WAVPACK_VERSION}/${WAVPACK}.tar.xz > ${WAVPACK}.tar.xz

sha512sum -c wavpack.sha512
tar xf ${WAVPACK}.tar.xz
cd ${WAVPACK}

if [[ "$MAC_ARCH" == "arm64" ]]; then
# As of now, wavpack builds fail on arm64 cross compilation when ASM
# optimisations are enabled, so disable it
export WAVPACK_EXTRA_M1_FLAGS="-DWAVPACK_ENABLE_ASM=OFF"
fi

cmake . $PG_BASE_CMAKE_FLAGS $WAVPACK_EXTRA_M1_FLAGS

make
make install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7421eff1f6e18f2e698b367ca48f6773456d0fcb53241be70149a87eff2cdf14dd8a82845a016f59ed32c7df494d018e6e23495709d3a56500b0660f177d5c0f wavpack-5.6.0.tar.xz
20 changes: 20 additions & 0 deletions docs/reST/ref/mixer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ change the default buffer by calling :func:`pygame.mixer.pre_init` before
:func:`pygame.mixer.init` or :func:`pygame.init` is called. For example:
``pygame.mixer.pre_init(44100,-16,2, 1024)``

The following file formats are supported

* ``WAV``

* ``MP3``

* ``OGG``

* ``FLAC``

* ``OPUS``

* ``WV`` (WavPack)

* ``MOD`` ("Module file" family of music file formats)

* ``MIDI`` (see the :func:`get_soundfont` and :func:`set_soundfont` methods)

.. versionadded:: 2.5.0 Loading WV (Relies on SDL_mixer 2.8.0+)


.. function:: init

Expand Down
2 changes: 2 additions & 0 deletions docs/reST/ref/music.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ changed in pygame ``v2.0.2`` which got improved MP3 support. Consider using
``OGG`` file format for music as that can give slightly better compression than
MP3 in most cases.

For a complete list of supported file formats, see the :mod:`pygame.mixer` doc page.

.. function:: load

| :sl:`Load a music file for playback`
Expand Down
Binary file added examples/data/MIDI_sample.mid
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/data/attributions.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
surfonasinewave.xm:
By FearofDark
https://modarchive.org/index.php?request=view_by_moduleid&query=169104

MIDI_sample.mid
Dogman15 at English Wikipedia
https://en.wikipedia.org/wiki/File:MIDI_sample.mid
Binary file added examples/data/house_lo.flac
Binary file not shown.
Binary file added examples/data/house_lo.opus
Binary file not shown.
Binary file added examples/data/house_lo.wv
Binary file not shown.
17 changes: 15 additions & 2 deletions src_c/music.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,17 @@ _get_type_from_hint(char *namehint)
else if (SDL_strcasecmp(namehint, "OGG") == 0) {
type = MUS_OGG;
}
#ifdef MUS_OPUS
else if (SDL_strcasecmp(namehint, "OPUS") == 0) {
type = MUS_OPUS;
}
#endif
else if (SDL_strcasecmp(namehint, "FLAC") == 0) {
type = MUS_FLAC;
}
#if SDL_MIXER_VERSION_ATLEAST(2, 8, 0)
else if (SDL_strcasecmp(namehint, "WV") == 0) {
type = MUS_WAVPACK;
}
#endif
else if (SDL_strcasecmp(namehint, "MPG") == 0 ||
SDL_strcasecmp(namehint, "MPEG") == 0 ||
SDL_strcasecmp(namehint, "MP3") == 0 ||
Expand All @@ -334,6 +337,7 @@ _get_type_from_hint(char *namehint)
SDL_strcasecmp(namehint, "DBM") == 0 ||
SDL_strcasecmp(namehint, "DSM") == 0 ||
SDL_strcasecmp(namehint, "FAR") == 0 ||
SDL_strcasecmp(namehint, "GDM") == 0 ||
SDL_strcasecmp(namehint, "IT") == 0 ||
SDL_strcasecmp(namehint, "MED") == 0 ||
SDL_strcasecmp(namehint, "MDL") == 0 ||
Expand All @@ -351,6 +355,15 @@ _get_type_from_hint(char *namehint)
SDL_strcasecmp(namehint, "XM") == 0) {
type = MUS_MOD;
}
#if SDL_MIXER_VERSION_ATLEAST(2, 8, 0)
else if (SDL_strcasecmp(namehint, "GBS") == 0 ||
SDL_strcasecmp(namehint, "M3U") == 0 ||
SDL_strcasecmp(namehint, "NSF") == 0 ||
SDL_strcasecmp(namehint, "SPC") == 0 ||
SDL_strcasecmp(namehint, "VGM") == 0) {
type = MUS_GME;
}
#endif
return type;
}

Expand Down
Loading

0 comments on commit 5f5c0d4

Please sign in to comment.