wohlsoft / sdl-mixer-x Goto Github PK
View Code? Open in Web Editor NEWSDL Mixer X (Or "MixerX" shortly) - An audio mixer library based on the SDL library, a fork of SDL_mixer
Home Page: https://wohlsoft.github.io/SDL-Mixer-X/
License: Other
SDL Mixer X (Or "MixerX" shortly) - An audio mixer library based on the SDL library, a fork of SDL_mixer
Home Page: https://wohlsoft.github.io/SDL-Mixer-X/
License: Other
First up - I'm enjoying the per-stream-specific music improvements. It's much easier (and clearer) to manage state now that it's performed explicitly per stream. Thank you!
This feature is similar to loops, but uses a time duration instead.
Background on this feature request: in this Dosbox migration to Mixer X, games play audio at a given sector (seek offset) for a given number of sectors (duration). That duration might only be seconds while others it can be tens of minutes.
So this feature would allow specifying a playback duration after which the stream would automatically pause itself.
Playback duration would take precedence when looping exceeds the duration. For example, a 22-second stream is set to loop infinite (-1) times and the playback duration is set to 5 minutes. After 5 minutes, the looping track is paused.
If someone externally pauses or halts the stream before the duration is reached, then the playback duration timer is cancelled and no further action taken: the stream simply remains in its paused or halted state.
If the specified playback duration accidentally exceeds the actual playback length (music total length * loops), then the existing behavior remains and the track naturally stops playing after the number of specified loops is met.
Let me know what you think!
regards,
Kevin
Make readme be more detailed, accurate, and clean
Steps to reproduce:
Fresh Windows 7 / 10 installation or VM (Git for Windows is not installed)
Download latest msys2 64-bit installer (http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe)
Install to default path: c:\msys64
Answer 'yes' to launch, within the bash terminal:
pacman -Syu
, when instructed close the terminal
Reopen the terminal and run pacman -Su
, wait till done
Install dev stack: pacman -S --noconfirm p7zip upx zip unzip lzip git gcc cmake base-devel
git clone --depth=1 https://github.com/WohlSoft/SDL-Mixer-X.git
cd SDL-Mixer-X
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=$HOME/local -DDOWNLOAD_AUDIO_CODECS_DEPENDENCY=YES ..
make
Eventually fails here:
Performing download step (download, verify and extract) for 'SDL2HG'
-- File already exists but no hash specified (use URL_HASH):
file='/home/kcroft/src/SDL-Mixer-X/build/external/AudioCodecs/src/AudioCodecs-build/external/SDL2/src/default.tar.bz2'
Old file will be removed and new file downloaded from URL.
-- Downloading...
dst='/home/kcroft/src/SDL-Mixer-X/build/external/AudioCodecs/src/AudioCodecs-build/external/SDL2/src/default.tar.bz2'
timeout='none'
-- Using src='https://hg.libsdl.org/SDL/archive/default.tar.bz2'
-- Downloading... done
-- extracting...
src='/home/kcroft/src/SDL-Mixer-X/build/external/AudioCodecs/src/AudioCodecs-build/external/SDL2/src/default.tar.bz2'
dst='/home/kcroft/src/SDL-Mixer-X/build/external/AudioCodecs/src/AudioCodecs-build/external/SDL2/src/SDL2HG'
-- extracting... [tar xfz]
CMake Error: Problem with archive_write_header(): Can't create 'SDL-default/android-project-ant/AndroidManifest.xml'
CMake Error: Current file: SDL-default/android-project-ant/AndroidManifest.xml
CMake Error: Problem extracting tar: /home/kcroft/src/SDL-Mixer-X/build/external/AudioCodecs/src/AudioCodecs-build/external/SDL2/src/default.tar.bz2
-- extracting... [error clean up]
CMake Error at SDL2HG-stamp/extract-SDL2HG.cmake:33 (message):
error: extract of
'/home/kcroft/src/SDL-Mixer-X/build/external/AudioCodecs/src/AudioCodecs-build/external/SDL2/src/default.tar.bz2'
failed
make[5]: *** [CMakeFiles/SDL2HG.dir/build.make:92: external/SDL2/src/SDL2HG-stamp/SDL2HG-download] Error 1
make[4]: *** [CMakeFiles/Makefile2:68: CMakeFiles/SDL2HG.dir/all] Error 2
make[3]: *** [Makefile:130: all] Error 2
make[2]: *** [CMakeFiles/AudioCodecs.dir/build.make:111: external/AudioCodecs/src/AudioCodecs-stamp/AudioCodecs-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/AudioCodecs.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
It's need to make the CORRECT detection of system-wide installed OPUS library
/usr/local/include/opus/opusfile.h:110:31: fatal error: opus_multistream.h: No such file or directory
# include <opus_multistream.h>
for now it's incorrect and won't work right.
This is a better libModPlug which supports more formats and gives better sound quality. Library is licensed under BSD license. It is developing in same repository as Open ModPlug Tracker project.
First, thanks a lot for this, I've been looking for playing several music tracks at once and doing cross-fades with SDL Mixer, and this fork works like a charm!
I've been wondering if this fork kept the Android compatibility from SDL MIxer? The configuration file Android.mk
provided by SDL Mixer is not available on this version. Do you know if SDL Mixer X is also compatible with Android? If so, is there a reason why it does not provide this Android.mk
file?
Thanks for your help.
Idea no Hi's title screen music (01 Day of the Idea) on SDL Mixer X has unpleasure audio bursting (?) effect, but other place of GME such as kode54's GME plugin for FB2K didn't has this issue.
CMake is good and flexible, however, on some platforms autotools are feeling better and doesn't requires to install extra dependencies.
It's another popular chiptune format that we can also support, it's for the Commodore 64 platform.
The first suggested library https://github.com/libsidplayfp/libsidplayfp (Licensed under GPLv2+). If there are others with a better emulation and more permissive license, you can note me about them too.
I noticed that seek and get length code exists for the codecs, so was surprised that Mix_GetMusicTotalTime and Mix_SetMusicPosition always return -1.
Mix_GetMusicTotalTime for audio-flac/audio02.flac is -1.000000 seconds
Mix_GetMusicTotalTime for audio-mp3/audio02.mp3 is -1.000000 seconds
Mix_GetMusicTotalTime for audio-vorbis/audio02.ogg is -1.000000 seconds
Mix_GetMusicTotalTime for audio-opus/audio02.opus is -1.000000 seconds
Reproduce it with this code:
Note - add your own audio files to the track listing.
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer_ext.h>
static const char* const TRACKS[] = {
"audio-flac/audio02.flac",
"audio-mp3/audio02.mp3",
"audio-vorbis/audio02.ogg",
"audio-opus/audio02.opus",
0
};
int main(int argc, char **argv) {
int result = 0;
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
printf("Failed to init SDL\n");
exit(1);
}
int flags = MIX_INIT_FLAC|MIX_INIT_MP3|MIX_INIT_OGG|MIX_INIT_OPUS;
if (flags != (result = Mix_Init(flags))) {
printf("Could not initialize mixer (result: %d).\n", result);
printf("Mix_Init: %s\n", Mix_GetError());
exit(1);
}
Mix_OpenAudio(48000, AUDIO_S16SYS, 2, 4096);
unsigned char i=0;
while(TRACKS[i] != 0) {
Mix_Music *music = Mix_LoadMUS(TRACKS[i]);
if(music != NULL) {
double duration = Mix_GetMusicTotalTime(music);
printf("Mix_GetMusicTotalTime for %s is %f seconds\n", TRACKS[i], duration);
Mix_FreeMusic(music);
}
else {
printf("Failed to load track: %s, skipping", TRACKS[i]);
}
i++;
}
SDL_Quit();
return 0;
}
Link with (assuming SDL2 and SDL-Mixer-X are both installed in --prefix=/usr/local):
g++ -I/usr/local/include test.cpp
sdl2-config --libs -lSDL2_mixer_ext -lvorbis -lFLAC -logg -lmad -lADLMIDI -lOPNMIDI -ltimidity -lmodplug -lgme -lzlib
refer to #38, it'd be much easier to get it going.
Regarding popular formats that can be supported here, I can recommend PMD's .M/.M2/MZ songs.
These are compiled MML sequences for PC-9801 computers, targetting YM2203 and YM2608, together with PC-9801-86 PCM sound, providing extra 8 channels for use with YM2608 and ability to play PCM samples through PSG.
I used MusPlay for example:
PS: Tested via Windows 10 and Virtual MIDI Synth
This API will allow playing multiple parallel sound streams without loading the entire sound into memory. This will allow the creation of a complex sound atmosphere, cross-fade of two kinds of music, etc.
Mix_Music
pointer argument and deprecate old.Hi, have you had success building with -static-libstdc++
or -Bstatic -lstdc++
?
I'm trying to eliminate both the GCC and libstdc++ dependencies. I can successfully eliminate the GCC dependency with -static-libgcc
, but my efforts to eliminate libstdc++ have failed.
I'm using on Windows: i686 mingw-w64 sjlj, GCC 5.4.0 from SourceForge. I also have FluidSynth and Timidity enabled, among others.
On another note, your official builds have both dependencies. SDL2_mixer has neither dependency.
Current implementation of a length detection does a full scan of the file which would give a lag on an attempt to open a big file.
Some more details: https://bugzilla.libsdl.org/show_bug.cgi?id=4902
Useful links:
@sezero: Some links from the web: (there are certainly more.)
https://www.mars.org/pipermail/mad-dev/2009-January/001385.html
https://wiki.hydrogenaud.io/index.php?title=MP3#VBRI.2C_XING.2C_and_LAME_headers
http://gabriel.mp3-tech.org/mp3infotag.html
https://www.codeproject.com/Articles/8295/MPEG-Audio-Frame-Header#VBRHeaders
Since is only one official documentation for SDL Mixer library, we need to provide extended documentaion which provides documentation for new-added functions and APIs.
Currently it's only possible via raw MIDI arguments only, but that way there is no way to pass custom bank path. Default value for OPNMIDI seems to be too low and it causes problem with choppy sound on some songs.
Since both ADLMIDI and OPNMIDI support two cores (less acurate but faster DOSbox/Gens and more accutare but resource-hungry Nuked cores) would it be possible to have the option for choosing between them?
sorry if it has more to do with audiocodecs rather than mixer library itself
It's the weird and clunky imperfection of Microsoft GS Synthesizer which causes application master volume change while trying to change volume of MIDI stream itself. This clunky bug is reproducible on Windows 7, on Windows XP is fine. On Windows 8/8.1/10 is not checked yet.
The workaround to fix this thing: inject an extra CC events sequence into raw MIDI stream for all MIDI channels on every volume change request to control MIDI channels volume. The input volume value will be a multiplier that will affect current volume level of each channel to proportionally modify them. This will avoid a usage of master MIDI volume function that causes so clunky behavior.
VGMStream - A library for playback of various streamed audio formats used in video games.
https://sourceforge.net/projects/vgmstream/
https://github.com/FluidSynth/fluidsynth
Example:
Those files are containing multi-channel support and support of formats such as PCM-32-bit are can be handled through existing API (support of that sample formats is already implemented in recent changes).
FluidSynth 1 and 2 are not compatible:
/home/stephane/extsvn/SDL-Mixer-X.git/trunk/src/codecs/music_fluidsynth.c: In function 'FLUIDSYNTH_Load':
/home/stephane/extsvn/SDL-Mixer-X.git/trunk/src/codecs/music_fluidsynth.c:69:21: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
fluidsynth.FUNC = FUNC;
^
/home/stephane/extsvn/SDL-Mixer-X.git/trunk/src/codecs/music_fluidsynth.c:81:9: note: in expansion of macro 'FUNCTION_LOADER'
FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*))
^~~~~~~~~~~~~~~
/home/stephane/extsvn/SDL-Mixer-X.git/trunk/src/codecs/music_fluidsynth.c:69:21: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
fluidsynth.FUNC = FUNC;
^
/home/stephane/extsvn/SDL-Mixer-X.git/trunk/src/codecs/music_fluidsynth.c:83:9: note: in expansion of macro 'FUNCTION_LOADER'
FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*))
It's need to provide the dual support of both FS 1 and 2 with accurate identification of each FluidSynth version.
Trying to play any AIFF file causes a crash of the library.
Tinysoundfont is a library that has 2 functions: to add support for SF2 for any existing MIDI library, and to provide MIDI playback itself.
It has some advantages over other libraries:
Although it still under development and some MIDI feature not yet implemented, but it looks promising.
Such as brstm, they like special looped wav.
Regarding stale #36, there is an idea to add an ability to get any meta-tag just by its textual name. The solution at the pull request wasn't effective, but the idea is good.
So, the way on how to implement that:
Mix_MusicMetaTags
structure, make it be able to store the key=value
cache which can be used to store loaded tagsWhen a Creative Labs VOC file contains both a mono sample and a VOC_EXTENDED block, spec->channels is never set to 1, so this line will divide by zero and crash the program.
There is a bug report on libsdl.org with a test case voc file (just use the playwave example programm) that was unfortunately never acknowledged.
Using of system libraries will allow to distribute light-weight library build which would be shipped any of Linux distributives.
Let's do the Windows and other builds on the Github Actions? AppVeyor seems very and VERY slow while it builds the set of changes. I should try out the Github Actions for that.
https://hg.libsdl.org/SDL_mixer/shortlog
All changes made on this fork are will be useful on original SDL Mixer too. Changes are must be applied accurate and result must be build-able through same set of toolchains as supported on original SDL Mixer
*Stream*
callsTitle says all. SmashCustomMusic site hosts huge music archive from 5-8th generation console games. And upon downloading you get not only high quality, but also proper looping free of charge. Any thoughts?
line 3364 of src/music.c should be
(void)aa_en;
not
(void)frb;
Thank's for the great work!
Some music formats (and their playing libraries and codecs) are supports tempo changing on the fly: MIDI (via libADLMIDI and libOPNMIDI), Game music emulators, and tracker musics. It's would be nice to have an ability to change the tempo of given music.
NSF (8-bit chiptune, Famistudio doable) is only supports N163, VRC6 and S5B. Other version of GME may supports other FC chips like FDS, MMC5, etc...?
libID3TAG is a GPL-licensed dependency that shouldn't be. Also, it gives lots of unneeded stuff and lacks support for some other. So, on the "wip-build-polishing" here is a work on a new thing.
music_mad.c
by @sezero previouslyExample of Lyrics tag from "v22obsolete.mp3":
LYRICSBEGININD0000200ETT00034LYRIC01234567890123456789012345678000063LYRICS200
Idk where is a specification that explains it more accurate Found it at id3-org, phew...
Libxmp is a library that renders module files to PCM data. It supports
over 90 mainstream and obscure module formats including Protracker (MOD),
Scream Tracker 3 (S3M), Fast Tracker II (XM), and Impulse Tracker (IT).
It is written in C and has 2 license options:
As an addition to #39, to simplify the future use of the library, take the way of the FFMPEG project: by default, the configure script produces the LGPL v2.1+ code. However, configuring the script allows enables some GPL modules, and in some cases it allows enabling non-free modules, causing the library's license to be "non-free, non-redistributable". In all cases, users have to explicitly enable support for modules with viral GPL or non-free licenses. This should avoid any unexpected cases when GPL modules got used with non-free projects, or LGPL modules got statically linked into GPL-incompatible projects.
Hello @Wohlstand ,
I am porting an MS-DOS HMI S.O.S v3 based game to SDL2 backend. The game uses only digital audio samples for music, sound effects and voice over. The audio samples are stored in RIFF WAV files. Out of ~300 samples about ~80 has a "smpl" chunk at the end of the audio file right after the "data" chunk. Loop points are not only used for music tracks, but also for many sound effects.
E.g. to move a unit from one location to another the game first ramps up the unit's movement speed, keeps a constant maximum speed, and then finally slows down quickly to a stand still. This visual effect is also simulated in the related sound effect for unit movement. First there is a section for the speed up, then comes the part that is looped which is played as long as the unit moves at full speed and then comes an after loop part which is additionally faded out during timed playback.
In the past couple of years there were many improvements in SDL2_mixer thanks to you and SDL-Mixer-X with respect to loop point support in various formats, but as far as I can tell the feature is only available for music tracks.
What I gathered from the various bits and pieces of documentation, change history and community discussions it seems to me that even if I would try to load the special SFX samples manually into three dedicated Mix_chunks (startup, loop, fade out) there is no way to play these parts in a seamless manner one after the other without undesired pauses in the audio stream. Please correct me if I am wrong.
With your deep understanding of SDL Mixer's inner workings and keeping the roadmap of the library in mind, do you see any chance that what I would need to mimic HMI S.O.S could be pulled off by SDL Mixer now (latest master) or in the foreseeable future? Or would it be better to look for an alternative audio mixer as this will not be feasible for a long time to come for sure.
Thanks for your kind response in advance.
Library must be buildable through CMake as indepedent library. Automatize fetching of AudioCodecs repository and looking up for libSDL (or downloading latest dev stuff from hg.libsdl.org, by choice or automatically when libSDL is not detected on host machine). Also provide CMake build for AudioCodecs repository too.
It seems that .vgm files that are not just Genesis/MD rips from https://project2612.org/ don't 100% play correctly.
Stuff from https://vgmrips.net/ or made with Deflemask won't seem to play right, for example the drum track in the below vgm:
https://www.dropbox.com/s/agvzwoyips9sgdg/Castlevania%20Dracula%20X%20-%20Bloodlines.vgm?dl=0
For a better organizing, it's would be cool to move any format detectors into music_*.c as a helper function to make the file type detection process be more organized?
I mean something to like here:
https://github.com/Wohlstand/OPL3BankEditor/tree/master/src/FileFormats
This will improve scalability and allows easier adding of new file formats without of extra "music.c" hacking (to add more type detection codes into specific calls).
StefG
Hello again,
In the official SDL_mixer, the code for AIFF files in LoadMUS is awful. I doubt anyone even tried to play an AIFF file with it.
Yours is much better. But still a few problems are present, or they are kind of corrected but not really for the good reason.
https://wohlsoft.ru/forum/viewtopic.php?f=11&t=2803&p=17813
Patch and sample file also included
On upgrated backend of official SDL Mixer found a new bug: when you have opened a music and played it. Then, paused it. And when you opening another track and calling Play Music
, it won't start until you will call Resume music
to clear the paused state from previous track.
The paused state must be cleared on opening of another song or on call of Play Music
.
This will much appreciate everyone who need to compile MixerX with specific licensing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.