mirror of
https://github.com/haya3218/SDfmL.git
synced 2024-08-14 23:57:09 +00:00
🤔 2
hmmmmmmmmmm
This commit is contained in:
parent
6c36023d5d
commit
34bb25d838
6 changed files with 31 additions and 15 deletions
|
@ -92,4 +92,12 @@ file(REMOVE_RECURSE "${BUILD_DIRECTORY}/SDL2_gpu.lib")
|
|||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/soloud_static.lib")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/libmodplug.lib")
|
||||
|
||||
if (PREFER_MODPLUG)
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/libopenmpt.dll")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/openmpt-mpg123.dll")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/openmpt-ogg.dll")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/openmpt-vorbis.dll")
|
||||
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/openmpt-zlib.dll")
|
||||
endif()
|
||||
|
||||
# :)
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace SoLoud
|
|||
return loadFile(&f, sf);
|
||||
}
|
||||
|
||||
result Midi::load(const char *aFilename, SoundFont &sf)
|
||||
result Midi::load(const char *aFilename, SoundFont sf)
|
||||
{
|
||||
DiskFile f;
|
||||
int res = f.open(aFilename);
|
||||
|
@ -195,13 +195,8 @@ namespace SoLoud
|
|||
return loadFile(&f, sf);
|
||||
}
|
||||
|
||||
result Midi::loadFile(File *aFile, SoundFont &sf)
|
||||
result Midi::loadFile(File *aFile, SoundFont sf)
|
||||
{
|
||||
if (mData)
|
||||
{
|
||||
delete[] mData;
|
||||
}
|
||||
|
||||
mDataLen = aFile->length();
|
||||
mData = new char[mDataLen];
|
||||
if (!mData)
|
||||
|
@ -227,7 +222,7 @@ namespace SoLoud
|
|||
Midi::Midi()
|
||||
{
|
||||
mBaseSamplerate = 44100;
|
||||
mChannels = 1;
|
||||
mChannels = 2;
|
||||
mData = 0;
|
||||
mDataLen = 0;
|
||||
mSoundFont = 0;
|
||||
|
|
|
@ -52,9 +52,9 @@ namespace SoLoud
|
|||
public:
|
||||
Midi();
|
||||
virtual ~Midi();
|
||||
result load(const char* aFilename, SoundFont &sf);
|
||||
result load(const char* aFilename, SoundFont sf);
|
||||
result loadMem(unsigned char *aMem, unsigned int aLength, SoundFont &sf, bool aCopy = false, bool aTakeOwnership = true);
|
||||
result loadFile(File *aFile, SoundFont &sf);
|
||||
result loadFile(File *aFile, SoundFont sf);
|
||||
virtual AudioSourceInstance *createInstance();
|
||||
};
|
||||
};
|
||||
|
|
|
@ -410,8 +410,6 @@ namespace sdfml {
|
|||
});
|
||||
soundfont = tomlParse<string>("conf.toml", "config", "soundfont");
|
||||
|
||||
sound.init();
|
||||
llog("SoLoud", " is now initialized.", NORMAL, __FILENAME__, __LINE__);
|
||||
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
|
||||
return llog("SDL", " has failed to initialize.", ERROR_, __FILENAME__, __LINE__);
|
||||
llog("SDL", " is now initialized.", NORMAL, __FILENAME__, __LINE__);
|
||||
|
@ -430,6 +428,10 @@ namespace sdfml {
|
|||
SDL_GetWindowWMInfo(SDL_GetWindowFromID(mContext.gpu_render->context->windowID), &wmInfo);
|
||||
mContext.direct_win = wmInfo.info.win.window;
|
||||
|
||||
sound.init();
|
||||
sound.initSF(soundfont);
|
||||
llog("SoLoud", " is now initialized.", NORMAL, __FILENAME__, __LINE__);
|
||||
|
||||
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
|
||||
|
||||
mContext.size = {width, height};
|
||||
|
|
|
@ -6,5 +6,7 @@ std::pair<SoLoud::WavStream, SoLoud::Modplug> sdfml::musicBank;
|
|||
#else
|
||||
std::pair<SoLoud::WavStream, SoLoud::Openmpt> sdfml::musicBank;
|
||||
#endif
|
||||
SoLoud::Midi sdfml::midiBank;
|
||||
SoLoud::SoundFont sdfml::midiSF;
|
||||
SoLoud::Soloud sdfml::audio;
|
||||
sdfml::AudioHandler sdfml::sound;
|
|
@ -20,11 +20,18 @@ namespace sdfml {
|
|||
#else
|
||||
extern std::pair<SoLoud::WavStream, SoLoud::Openmpt> musicBank;
|
||||
#endif
|
||||
|
||||
extern SoLoud::Midi midiBank;
|
||||
extern SoLoud::SoundFont midiSF;
|
||||
|
||||
extern SoLoud::Soloud audio;
|
||||
|
||||
class MusicHandler {
|
||||
public:
|
||||
|
||||
void playMidi(std::string path) {
|
||||
|
||||
}
|
||||
|
||||
void playMusic(std::string path) {
|
||||
musicBank.first.stop();
|
||||
|
@ -48,7 +55,11 @@ namespace sdfml {
|
|||
MusicHandler music;
|
||||
|
||||
void init() {
|
||||
audio.init();
|
||||
audio.init(audio.CLIP_ROUNDOFF, audio.MINIAUDIO);
|
||||
}
|
||||
|
||||
void initSF(std::string path) {
|
||||
midiSF.load(path.c_str());
|
||||
}
|
||||
|
||||
void deinit() {
|
||||
|
@ -65,8 +76,6 @@ namespace sdfml {
|
|||
} else {
|
||||
sfxBanks[i].stop();
|
||||
audio.stopAudioSource(sfxBanks[i]);
|
||||
sfxBanks[i].load(path.c_str());
|
||||
audio.play(sfxBanks[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue