Giter Site home page Giter Site logo

wohlsoft / sdl-mixer-x Goto Github PK

View Code? Open in Web Editor NEW
99.0 99.0 24.0 7.64 MB

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

Shell 0.02% C 83.73% C++ 12.24% CMake 3.31% Visual Basic 6.0 0.69%
audio audio-library music sound submodule

sdl-mixer-x's People

Contributors

bluenaxela avatar dbarkar avatar ds-sloth avatar jpcima avatar kcgen avatar knight-ryu12 avatar nikitalita avatar sezero avatar suicvne avatar v-atamanenko avatar wohlstand avatar xavieran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdl-mixer-x's Issues

Timed play for music streams

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

Trouble/help building on Windows (msys2-64bit)

Steps to reproduce:

  1. Fresh Windows 7 / 10 installation or VM (Git for Windows is not installed)

  2. Download latest msys2 64-bit installer (http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20180531.exe)

  3. Install to default path: c:\msys64

  4. Answer 'yes' to launch, within the bash terminal:

  5. pacman -Syu, when instructed close the terminal

  6. Reopen the terminal and run pacman -Su, wait till done

  7. Install dev stack: pacman -S --noconfirm p7zip upx zip unzip lzip git gcc cmake base-devel

  8. git clone --depth=1 https://github.com/WohlSoft/SDL-Mixer-X.git

  9. cd SDL-Mixer-X

  10. mkdir build && cd build

  11. cmake -DCMAKE_INSTALL_PREFIX=$HOME/local -DDOWNLOAD_AUDIO_CODECS_DEPENDENCY=YES ..

  12. 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

In-system OPUS can't find the header path

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.

Compatibility with Android?

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.

One GME issue on SPC

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.

GetMusicTotalTime and SetMusicPosition both fail (-1) for FLAC, MP3, Ogg Vorbis, and OPUS codecs

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

Add support for PMD .M/.M2 format

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.

Implement Multi-Music API

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.

  • Provide alternative music functions to those are lack the Mix_Music pointer argument and deprecate old.
  • Add into the mixer stream the array of playing multi-musics
  • Provide public API to manage to play multi-music streams
  • Add music individual effect hooks
  • Implement effects API to allow the panning and position effects to be applied in the same way as Chunks
  • Make music individual effects work also for old music API
  • Document all new-added calls

Build with libstdc++ statically linked?

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.

libMAD: Implement the support for a faster length detection via Xing frames

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

Create documentation

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.

NativeMidi: music volume change affects master application volume with using of "Microsoft GS" on Windows

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.

[FluidSynth] Provide support for FluidSynth 2.x

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.

Add support for Tinysoundfont 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:

  1. Built in SF2 support,
  2. Very lightweight library,
  3. Non copyleft license.

Although it still under development and some MIDI feature not yet implemented, but it looks promising.

https://github.com/schellingb/TinySoundFont

Add the ability to get any meta-tags by textual name

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:

  • Make the cache of all tags while loading the song
  • When requesting a tag, seek in the cache, don't request the tag from the library every time, that will waste the computer time a lot
  • Extend the existing Mix_MusicMetaTags structure, make it be able to store the key=value cache which can be used to store loaded tags

VOC_EXTENDED divide by zero crash

When 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.

Move the build into GitHub Actions

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.

Merge with upgrated official SDL Mixer

  • Various Bugfixes
  • MPG123 codec
  • Rework of music.c, added super-different Music Interface than implemented in current version of SDL Mixer X
  • Using of new SDL's Streamer thing with a clean resampling and a sound conversion

https://hg.libsdl.org/SDL_mixer/shortlog

TODO List:

  • Extend Mix_MusicInterface structure with Mixer-X specific functions
  • Repair a support for meta-tags printing for OGG, GME, and added for ADLMIDI and OPNMIDI
  • Add splitting of post-path extra arguments
  • Improve the support for a dynamical MIDI device switching
  • Add Mix_PlayChannelTimedVolume and Mix_FadeInChannelTimedVolume, again
  • Fix an ability to set limited count of loops on looping OGG files
  • Implement missing functions in the header
  • Repair VB6 Binding on the Windows
  • Re-Implement full seekability for the Wave player
  • Re-Implement full seekability for MAD MP3 codec
  • Try to implement a full seekability for MPG123
  • Re-Implement support for ID3 Tags to retreive Meta-Tags from MP3 files
  • Repair seekability support for ModPlug
  • Repair meta-tags for ModPlug module
  • Re-Implement FLAC meta-tags and full seekability
  • Repair full support for path arguments and Open*Ex music interface functions
  • Fix broken SMPEG support
  • Fix broken Timidity custom paths support
  • Repair QMake build
  • Fix missing reset of ADLMIDI settings after using of path arguments
  • Fix handling of RMI MIDI files

Send all changes of fork to official SDL Mixer

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

Todo

  • Main part (Features, improvements)
  • Customized libID3Tag library into "external" folder with revived autotools support (which was dropped away) Replaced with own code to parse ID3 and other tags in MP3 files
  • Autotools build support for GME, ADLMIDI, and OPNMIDI
  • New audio codecs (GME, ADLMIDI, OPNMIDI) into "external" folder
  • Mix_InitMixer(), Mix_FreeMixer(), and callback retrievers
  • Multi-Music system and new *Stream* calls

Stuff

Toolchains

  • Automake
  • Visual Studio projects of various versions
  • XCode project(s)

.brtsm and other streamed music formats support

Title 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?

Implement public API for music tempo changing

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.

Replace ID3Tag with own-coded thing

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.

  • Use the tag skipping base made in music_mad.c by @sezero previously
  • Make parsing of ID3v1 tags (don't parse when ID3v2 or APE was successfully parsed)
  • Make parsing of ID3v2.3 (specification)
  • Make parsing of ID3v2.4 (specification of main structure, frames)
  • Make parsing of ID3v2.2 (specification)
  • Make parsing of APE tags (don't parse when ID3v2 was successfully parsed) (specification)
  • Find a way to skip the Lyrics3v2 tag that appears in some MP3 files (specification)
  • Find a way to skip the Lyrics3v1 tag that may appear in some MP3s (specification)
  • Fix the incorrect logic of ID3v1ext (TAG+): the content of TAG+ should be added to end of ID3v1, it shouldn't replace it with self
  • Prevent MPG123 to see tags, otherwise, it may spawn "Invalid frame, re-syncing" error message into stdout. Is not critical as MPG123 is smart to don't decode crap that tries to look like a frame.
  • Check out for Musicmatch tag format

Example of Lyrics tag from "v22obsolete.mp3":

LYRICSBEGININD0000200ETT00034LYRIC01234567890123456789012345678000063LYRICS200

Idk where is a specification that explains it more accurate Found it at id3-org, phew...

Implement support for libXMP codec

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:

  1. LGPL for full version, suitable for user who need to play various module format;
  2. MIT for lite version, suitable for user who prefer non copyleft license and doesn't need too many format support.

Disable GPL components by default

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.

Question about loop points handling for SFX from RIFF WAV sample chunk

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.

Provide CMake building system

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.

Idea: organize file type detectors

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).

Paused music playing state won't reset on opening of another music track

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.