I am making a C++, SDL based game engine, currently doing the audio system, using…
- User
I am making a C++, SDL based game engine, currently doing the audio system, using SDL_Mixer X fork, which add support to many new types compared to the original SDL_Mixer.
I need help in some things:
- The new fork support both multi and single music streams, my default music class offers multi streams to play it, but there is it only work when there is a warning to use it: CAUTION: You can’t use this function with MIDI played through Native MIDI interface: this interface doesn’t support parallel playing of multiple music files. Please use the Mix_PlayMusic function to playNativeMidi as a single-stream music.
How could I deal with this? Should I remove its support? or create a new MusicMidi class that deals with this cases when there is a native or not midi file, so I could add soundfonts or something else?
- Write the missing doxygen comment block to the class.
#include <SDL_mixer_ext.h>
class Music { public: Music(const std::string& filePath); ~Music(); int GetVolume() const; void SetVolume(int volume); double GetTempo() const; void SetTempo(double tempo); double GetSpeed() const; void SetSpeed(double speed); double GetPitch() const; void SetPitch(double pitch); double GetDuration() const; void Play(int loops = -1); void PlayFadeIn(int loops, int ms); void Pause(); void Resume(); void Rewind(); void Stop(); void StopFadeOut(int ms); bool IsPlaying() const; bool IsFading() const; std::string GetTitleTag() const; std::string GetArtistTag() const; std::string GetAlbumTag() const;
private: Mix_Music* music; int volume; double tempo; double speed; double pitch;};
- Assistant
- User
OK, I found something else that could change the opinion to specific creating a MIDI class, the soundfont is only supported in one specific MIDI backend but not in the others:
Mix_SetSoundFonts: Set the paths list to sound font files will be used by FluidSynth MIDI backend.
So that means, this means the main reason for creating this class was lost. Maybe I should check if the file is .mid and if the current backend is native and just play it as a single stream, although it will defeat the purpose of the class itself, at least it won't drop the support...
From SDL Mixer X docs:
Since SDL_mixer 2.x MIDI files can be played through native MIDI API of operating system (supported Windows, macOS and Haiku) or through FluidSynth. With SDL Mixer X fork you can use libADLMIDI and libOPNMIDI synthesizers are working always and doesn’t requiring any external sound fonts or banks. libADLMIDI and libOPNMIDI are FM synthesizers using emulators of YMF232 by libADLMIDI (OPL3), and YM2612 (OPN2) or YM2608 (OPNA) by libOPNMIDI. With SDL Mixer X it’s possible to switch MIDI synthesizer in real time while with original SDL Mixer it’s only possible to set MIDI synthesizer by environment variable only in a moment of library loading.
SDL Mixer X supports playing music and sound samples from the following formats:
- Assistant