From be81e00722f3590d4706956a656d28dc1640a260 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sat, 24 Mar 2018 22:45:54 +0300 Subject: [PATCH] ADLMIDI: Added built-in ability to disable unneeded MUS and XMI converters Also embedded MIDI sequencer has been disabled too as it is not needed in GZDoom I made that to allow easier updates of ADLMIDI into newer versions without of any future troubles and conflicts --- src/CMakeLists.txt | 3 + src/sound/adlmidi/adlmidi.cpp | 80 +++++++++++++++++++++++- src/sound/adlmidi/adlmidi.h | 2 +- src/sound/adlmidi/adlmidi_load.cpp | 86 +++++++++++++++++++++++++- src/sound/adlmidi/adlmidi_midiplay.cpp | 26 ++++++-- src/sound/adlmidi/adlmidi_mus2mid.h | 49 --------------- src/sound/adlmidi/adlmidi_private.hpp | 26 +++++--- src/sound/adlmidi/adlmidi_xmi2mid.h | 60 ------------------ 8 files changed, 206 insertions(+), 126 deletions(-) delete mode 100644 src/sound/adlmidi/adlmidi_mus2mid.h delete mode 100644 src/sound/adlmidi/adlmidi_xmi2mid.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8992e118f..964e220d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -648,6 +648,9 @@ endif() # OPLMIDI needs for USE_LEGACY_EMULATOR macro to be correctly built add_definitions(-DUSE_LEGACY_EMULATOR) +# Disable ADLMIDI's MIDI Sequencer, MUS and XMI converters +add_definitions(-DADLMIDI_DISABLE_MUS_SUPPORT -DADLMIDI_DISABLE_XMI_SUPPORT -DADLMIDI_DISABLE_MIDI_SEQUENCER) + # Project files should be aware of the header files. We can GLOB these since # there's generally a new cpp for every header so this file will get changed if( WIN32 ) diff --git a/src/sound/adlmidi/adlmidi.cpp b/src/sound/adlmidi/adlmidi.cpp index 5adad234a..e87835459 100644 --- a/src/sound/adlmidi/adlmidi.cpp +++ b/src/sound/adlmidi/adlmidi.cpp @@ -107,7 +107,7 @@ ADLMIDI_EXPORT int adl_setBank(ADL_MIDIPlayer *device, int bank) MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if(static_cast(bankno) >= NumBanks) { - #if 0 //ndef __WATCOMC__ + #ifndef __WATCOMC__ std::stringstream s; s << "bank number may only be 0.." << (NumBanks - 1) << ".\n"; play->setErrorString(s.str()); @@ -142,7 +142,7 @@ ADLMIDI_EXPORT int adl_setNumFourOpsChn(ADL_MIDIPlayer *device, int ops4) MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if((unsigned int)ops4 > 6 * play->m_setup.NumCards) { - #if 0 //ndef __WATCOMC__ + #ifndef __WATCOMC__ std::stringstream s; s << "number of four-op channels may only be 0.." << (6 * (play->m_setup.NumCards)) << " when " << play->m_setup.NumCards << " OPL3 cards are used.\n"; play->setErrorString(s.str()); @@ -272,6 +272,7 @@ ADLMIDI_EXPORT int adl_openFile(ADL_MIDIPlayer *device, const char *filePath) if(device && device->adl_midiPlayer) { MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER play->m_setup.tick_skip_samples_delay = 0; if(!play->LoadMIDI(filePath)) { @@ -281,6 +282,10 @@ ADLMIDI_EXPORT int adl_openFile(ADL_MIDIPlayer *device, const char *filePath) return -1; } else return 0; +#else + play->setErrorString("ADLMIDI: MIDI Sequencer is not supported in this build of library!"); + return -1; +#endif //ADLMIDI_DISABLE_MIDI_SEQUENCER } ADLMIDI_ErrorString = "Can't load file: ADL MIDI is not initialized"; @@ -292,6 +297,7 @@ ADLMIDI_EXPORT int adl_openData(ADL_MIDIPlayer *device, const void *mem, unsigne if(device && device->adl_midiPlayer) { MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER play->m_setup.tick_skip_samples_delay = 0; if(!play->LoadMIDI(mem, static_cast(size))) { @@ -301,6 +307,10 @@ ADLMIDI_EXPORT int adl_openData(ADL_MIDIPlayer *device, const void *mem, unsigne return -1; } else return 0; +#else + play->setErrorString("ADLMIDI: MIDI Sequencer is not supported in this build of library!"); + return -1; +#endif //ADLMIDI_DISABLE_MIDI_SEQUENCER } ADLMIDI_ErrorString = "Can't load file: ADL MIDI is not initialized"; return -1; @@ -348,7 +358,11 @@ ADLMIDI_EXPORT const char *adl_getMusicTitle(struct ADL_MIDIPlayer *device) MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if(!play) return ""; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return play->musTitle.c_str(); + #else + return ""; + #endif } ADLMIDI_EXPORT void adl_close(struct ADL_MIDIPlayer *device) @@ -375,49 +389,71 @@ ADLMIDI_EXPORT double adl_totalTimeLength(struct ADL_MIDIPlayer *device) { if(!device) return -1.0; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->timeLength(); + #else + return -1.0; + #endif } ADLMIDI_EXPORT double adl_loopStartTime(struct ADL_MIDIPlayer *device) { if(!device) return -1.0; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->getLoopStart(); + #else + return -1.0; + #endif } ADLMIDI_EXPORT double adl_loopEndTime(struct ADL_MIDIPlayer *device) { if(!device) return -1.0; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->getLoopEnd(); + #else + return -1.0; + #endif } ADLMIDI_EXPORT double adl_positionTell(struct ADL_MIDIPlayer *device) { if(!device) return -1.0; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->tell(); + #else + return -1.0; + #endif } ADLMIDI_EXPORT void adl_positionSeek(struct ADL_MIDIPlayer *device, double seconds) { if(!device) return; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER reinterpret_cast(device->adl_midiPlayer)->seek(seconds); + #endif } ADLMIDI_EXPORT void adl_positionRewind(struct ADL_MIDIPlayer *device) { if(!device) return; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER reinterpret_cast(device->adl_midiPlayer)->rewind(); + #endif } ADLMIDI_EXPORT void adl_setTempo(struct ADL_MIDIPlayer *device, double tempo) { if(!device || (tempo <= 0.0)) return; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER reinterpret_cast(device->adl_midiPlayer)->setTempo(tempo); + #endif } @@ -425,7 +461,11 @@ ADLMIDI_EXPORT const char *adl_metaMusicTitle(struct ADL_MIDIPlayer *device) { if(!device) return ""; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->musTitle.c_str(); + #else + return ""; + #endif } @@ -433,24 +473,37 @@ ADLMIDI_EXPORT const char *adl_metaMusicCopyright(struct ADL_MIDIPlayer *device) { if(!device) return ""; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->musCopyright.c_str(); + #else + return ""; + #endif } ADLMIDI_EXPORT size_t adl_metaTrackTitleCount(struct ADL_MIDIPlayer *device) { if(!device) return 0; +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->musTrackTitles.size(); +#else + return 0; +#endif } ADLMIDI_EXPORT const char *adl_metaTrackTitle(struct ADL_MIDIPlayer *device, size_t index) { if(!device) return 0; +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if(index >= play->musTrackTitles.size()) return "INVALID"; return play->musTrackTitles[index].c_str(); +#else + (void)device; (void)index; + return "NOT SUPPORTED"; +#endif } @@ -458,12 +511,17 @@ ADLMIDI_EXPORT size_t adl_metaMarkerCount(struct ADL_MIDIPlayer *device) { if(!device) return 0; +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER return reinterpret_cast(device->adl_midiPlayer)->musMarkers.size(); +#else + return 0; +#endif } ADLMIDI_EXPORT Adl_MarkerEntry adl_metaMarker(struct ADL_MIDIPlayer *device, size_t index) { struct Adl_MarkerEntry marker; + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER MIDIplay *play = reinterpret_cast(device->adl_midiPlayer); if(!device || !play || (index >= play->musMarkers.size())) { @@ -479,6 +537,12 @@ ADLMIDI_EXPORT Adl_MarkerEntry adl_metaMarker(struct ADL_MIDIPlayer *device, siz marker.pos_time = mk.pos_time; marker.pos_ticks = (unsigned long)mk.pos_ticks; } + #else + (void)device; (void)index; + marker.label = "NOT SUPPORTED"; + marker.pos_time = 0.0; + marker.pos_ticks = 0; + #endif return marker; } @@ -531,6 +595,7 @@ inline static void SendStereoAudio(int &samples_requested, ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out) { + #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER #ifdef ADLMIDI_HW_OPL (void)device; (void)sampleCount; @@ -633,6 +698,9 @@ ADLMIDI_EXPORT int adl_play(ADL_MIDIPlayer *device, int sampleCount, short *out) return static_cast(gotten_len); #endif + #else + return 0; + #endif //ADLMIDI_DISABLE_MIDI_SEQUENCER } @@ -720,22 +788,30 @@ ADLMIDI_EXPORT int adl_generate(struct ADL_MIDIPlayer *device, int sampleCount, ADLMIDI_EXPORT double adl_tickEvents(struct ADL_MIDIPlayer *device, double seconds, double granuality) { +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER if(!device) return -1.0; MIDIplay *player = reinterpret_cast(device->adl_midiPlayer); if(!player) return -1.0; return player->Tick(seconds, granuality); +#else + return -1.0; +#endif } ADLMIDI_EXPORT int adl_atEnd(struct ADL_MIDIPlayer *device) { +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER if(!device) return 1; MIDIplay *player = reinterpret_cast(device->adl_midiPlayer); if(!player) return 1; return (int)player->atEnd; +#else + return 1; +#endif } ADLMIDI_EXPORT void adl_panic(struct ADL_MIDIPlayer *device) diff --git a/src/sound/adlmidi/adlmidi.h b/src/sound/adlmidi/adlmidi.h index a1ac0f8ac..10fe4ddff 100644 --- a/src/sound/adlmidi/adlmidi.h +++ b/src/sound/adlmidi/adlmidi.h @@ -30,7 +30,7 @@ extern "C" { #define ADLMIDI_VERSION_MAJOR 1 #define ADLMIDI_VERSION_MINOR 3 -#define ADLMIDI_VERSION_PATCHLEVEL 1 +#define ADLMIDI_VERSION_PATCHLEVEL 2 #define ADLMIDI_TOSTR(s) #s #define ADLMIDI_VERSION \ diff --git a/src/sound/adlmidi/adlmidi_load.cpp b/src/sound/adlmidi/adlmidi_load.cpp index 3057a7e35..03206bcd6 100644 --- a/src/sound/adlmidi/adlmidi_load.cpp +++ b/src/sound/adlmidi/adlmidi_load.cpp @@ -23,8 +23,14 @@ #include "adlmidi_private.hpp" -#include "adlmidi_mus2mid.h" -#include "adlmidi_xmi2mid.h" +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER +# ifndef ADLMIDI_DISABLE_MUS_SUPPORT +# include "adlmidi_mus2mid.h" +# endif//MUS +# ifndef ADLMIDI_DISABLE_XMI_SUPPORT +# include "adlmidi_xmi2mid.h" +# endif//XMI +#endif //ADLMIDI_DISABLE_MIDI_SEQUENCER uint64_t MIDIplay::ReadBEint(const void *buffer, size_t nbytes) { @@ -339,6 +345,7 @@ tryAgain: return true; } +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER bool MIDIplay::LoadMIDI(const std::string &filename) { fileReader file; @@ -412,6 +419,80 @@ riffskip: fr.seek(7 - static_cast(HeaderSize), SEEK_CUR); is_GMF = true; } + #ifndef ADLMIDI_DISABLE_MUS_SUPPORT + else if(std::memcmp(HeaderBuf, "MUS\x1A", 4) == 0) + { + // MUS/DMX files (Doom) + fr.seek(0, SEEK_END); + size_t mus_len = fr.tell(); + fr.seek(0, SEEK_SET); + uint8_t *mus = (uint8_t *)malloc(mus_len); + if(!mus) + { + errorStringOut = "Out of memory!"; + return false; + } + fr.read(mus, 1, mus_len); + //Close source stream + fr.close(); + + uint8_t *mid = NULL; + uint32_t mid_len = 0; + int m2mret = AdlMidi_mus2midi(mus, static_cast(mus_len), + &mid, &mid_len, 0); + if(mus) free(mus); + if(m2mret < 0) + { + errorStringOut = "Invalid MUS/DMX data format!"; + return false; + } + cvt_buf.reset(mid); + //Open converted MIDI file + fr.openData(mid, static_cast(mid_len)); + //Re-Read header again! + goto riffskip; + } + #endif //ADLMIDI_DISABLE_MUS_SUPPORT + #ifndef ADLMIDI_DISABLE_XMI_SUPPORT + else if(std::memcmp(HeaderBuf, "FORM", 4) == 0) + { + if(std::memcmp(HeaderBuf + 8, "XDIR", 4) != 0) + { + fr.close(); + errorStringOut = fr._fileName + ": Invalid format\n"; + return false; + } + + fr.seek(0, SEEK_END); + size_t mus_len = fr.tell(); + fr.seek(0, SEEK_SET); + uint8_t *mus = (uint8_t*)malloc(mus_len); + if(!mus) + { + errorStringOut = "Out of memory!"; + return false; + } + fr.read(mus, 1, mus_len); + //Close source stream + fr.close(); + + uint8_t *mid = NULL; + uint32_t mid_len = 0; + int m2mret = AdlMidi_xmi2midi(mus, static_cast(mus_len), + &mid, &mid_len, XMIDI_CONVERT_NOCONVERSION); + if(mus) free(mus); + if(m2mret < 0) + { + errorStringOut = "Invalid XMI data format!"; + return false; + } + cvt_buf.reset(mid); + //Open converted MIDI file + fr.openData(mid, static_cast(mid_len)); + //Re-Read header again! + goto riffskip; + } + #endif //ADLMIDI_DISABLE_XMI_SUPPORT else if(std::memcmp(HeaderBuf, "CTMF", 4) == 0) { opl.dynamic_instruments.clear(); @@ -691,3 +772,4 @@ riffskip: ch.resize(opl.NumChannels); return true; } +#endif //ADLMIDI_DISABLE_MIDI_SEQUENCER diff --git a/src/sound/adlmidi/adlmidi_midiplay.cpp b/src/sound/adlmidi/adlmidi_midiplay.cpp index 432785f85..ea3b1fefb 100644 --- a/src/sound/adlmidi/adlmidi_midiplay.cpp +++ b/src/sound/adlmidi/adlmidi_midiplay.cpp @@ -133,6 +133,8 @@ void MIDIplay::AdlChannel::AddAge(int64_t ms) } } +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER + MIDIplay::MidiEvent::MidiEvent() : type(T_UNKNOWN), subtype(T_UNKNOWN), @@ -250,7 +252,9 @@ void MIDIplay::MidiTrackRow::sortEvents(bool *noteStates) events.insert(events.end(), controllers.begin(), controllers.end()); events.insert(events.end(), anyOther.begin(), anyOther.end()); } +#endif //ADLMIDI_DISABLE_MIDI_SEQUENCER +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER bool MIDIplay::buildTrackData() { fullSongTimeLength = 0.0; @@ -687,10 +691,13 @@ bool MIDIplay::buildTrackData() return true; } +#endif + MIDIplay::MIDIplay(unsigned long sampleRate): - cmf_percussion_mode(false), - fullSongTimeLength(0.0), + cmf_percussion_mode(false) +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER + , fullSongTimeLength(0.0), postSongWaitDelay(1.0), loopStartTime(-1.0), loopEndTime(-1.0), @@ -699,6 +706,7 @@ MIDIplay::MIDIplay(unsigned long sampleRate): loopStart(false), loopEnd(false), invalidLoop(false) +#endif { devices.clear(); @@ -781,7 +789,7 @@ uint64_t MIDIplay::ReadVarLenEx(uint8_t **ptr, uint8_t *end, bool &ok) return result; } - +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER double MIDIplay::Tick(double s, double granularity) { s *= tempoMultiplier; @@ -816,6 +824,7 @@ double MIDIplay::Tick(double s, double granularity) return CurrentPositionNew.wait; } +#endif void MIDIplay::TickIteratos(double s) { @@ -825,6 +834,8 @@ void MIDIplay::TickIteratos(double s) UpdateArpeggio(s); } +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER + void MIDIplay::seek(double seconds) { if(seconds < 0.0) @@ -930,6 +941,7 @@ void MIDIplay::setTempo(double tempo) { tempoMultiplier = tempo; } +#endif void MIDIplay::realTime_ResetState() { @@ -1608,7 +1620,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, Ch[MidCh].activenotes.erase(i); } - +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER bool MIDIplay::ProcessEventsNew(bool isSeek) { if(CurrentPositionNew.track.size() == 0) @@ -1720,7 +1732,9 @@ bool MIDIplay::ProcessEventsNew(bool isSeek) return true;//Has events in queue } +#endif +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER MIDIplay::MidiEvent MIDIplay::parseEvent(uint8_t **pptr, uint8_t *end, int &status) { uint8_t *&ptr = *pptr; @@ -1924,6 +1938,7 @@ MIDIplay::MidiEvent MIDIplay::parseEvent(uint8_t **pptr, uint8_t *end, int &stat return evt; } +#endif const std::string &MIDIplay::getErrorString() { @@ -1935,7 +1950,7 @@ void MIDIplay::setErrorString(const std::string &err) errorStringOut = err; } - +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER void MIDIplay::HandleEvent(size_t tk, const MIDIplay::MidiEvent &evt, int &status) { if(hooks.onEvent) @@ -2092,6 +2107,7 @@ void MIDIplay::HandleEvent(size_t tk, const MIDIplay::MidiEvent &evt, int &statu } } } +#endif long MIDIplay::CalculateAdlChannelGoodness(unsigned c, const MIDIchannel::NoteInfo::Phys &ins, uint16_t) const { diff --git a/src/sound/adlmidi/adlmidi_mus2mid.h b/src/sound/adlmidi/adlmidi_mus2mid.h deleted file mode 100644 index cc41b87a1..000000000 --- a/src/sound/adlmidi/adlmidi_mus2mid.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * MUS2MIDI: DMX (DOOM) MUS to MIDI Library Header - * - * Copyright (C) 2014-2016 Bret Curtis - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef MUSLIB_H -#define MUSLIB_H - -#include - -#ifdef __DJGPP__ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed long int32_t; -typedef unsigned long uint32_t; -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -int AdlMidi_mus2midi(uint8_t *in, uint32_t insize, - uint8_t **out, uint32_t *outsize, - uint16_t frequency); - -#ifdef __cplusplus -} -#endif - -#endif /* MUSLIB_H */ diff --git a/src/sound/adlmidi/adlmidi_private.hpp b/src/sound/adlmidi/adlmidi_private.hpp index 70cd9e30e..8b2bf19da 100644 --- a/src/sound/adlmidi/adlmidi_private.hpp +++ b/src/sound/adlmidi/adlmidi_private.hpp @@ -75,6 +75,7 @@ typedef int32_t ssize_t; #include #include #include +#include //#ifdef __WATCOMC__ //#include //TODO: Implemnet a workaround for OpenWatcom to fix a crash while using those containers //#include @@ -104,13 +105,6 @@ typedef int32_t ssize_t; #include #include -#ifdef _MSC_VER -#pragma warning(disable:4319) -#pragma warning(disable:4267) -#pragma warning(disable:4244) -#pragma warning(disable:4146) -#endif - #include "fraction.hpp" #ifndef ADLMIDI_HW_OPL @@ -583,6 +577,7 @@ public: void AddAge(int64_t ms); }; +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER /** * @brief MIDI Event utility container */ @@ -707,6 +702,7 @@ public: PositionNew(): began(false), wait(0.0), absTimePosition(0.0), track() {} }; +#endif//ADLMIDI_DISABLE_MIDI_SEQUENCER struct Setup { @@ -757,6 +753,8 @@ private: char ____padding[7]; std::vector ch; + +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER std::vector > TrackData; PositionNew CurrentPositionNew, LoopBeginPositionNew, trackBeginPositionNew; @@ -770,13 +768,16 @@ private: double loopStartTime; //! Loop end time double loopEndTime; +#endif //! Local error string std::string errorString; //! Local error string std::string errorStringOut; +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER //! Pre-processed track data storage std::vector trackDataNew; +#endif //! Missing instruments catches std::set caugh_missing_instruments; @@ -785,6 +786,7 @@ private: //! Missing percussion banks catches std::set caugh_missing_banks_percussion; +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER /** * @brief Build MIDI track data from the raw track data storage * @return true if everything successfully processed, or false on any error @@ -799,12 +801,14 @@ private: * @return Parsed MIDI event entry */ MidiEvent parseEvent(uint8_t **ptr, uint8_t *end, int &status); +#endif//ADLMIDI_DISABLE_MIDI_SEQUENCER public: const std::string &getErrorString(); void setErrorString(const std::string &err); +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER std::string musTitle; std::string musCopyright; std::vector musTrackTitles; @@ -818,6 +822,7 @@ public: loopEnd, invalidLoop; /*Loop points are invalid (loopStart after loopEnd or loopStart and loopEnd are on same place)*/ char ____padding2[2]; +#endif OPL3 opl; int16_t outBuf[1024]; @@ -846,6 +851,7 @@ public: bool LoadBank(const void *data, size_t size); bool LoadBank(fileReader &fr); +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER bool LoadMIDI(const std::string &filename); bool LoadMIDI(const void *data, size_t size); bool LoadMIDI(fileReader &fr); @@ -857,6 +863,7 @@ public: * @return desired number of seconds until next call */ double Tick(double s, double granularity); +#endif /** * @brief Process extra iterators like vibrato or arpeggio @@ -864,6 +871,7 @@ public: */ void TickIteratos(double s); +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER /** * @brief Change current position to specified time position in seconds * @param seconds Absolute time position in seconds @@ -904,6 +912,7 @@ public: * @param tempo Tempo multiplier: 1.0 - original tempo. >1 - faster, <1 - slower */ void setTempo(double tempo); +#endif//ADLMIDI_DISABLE_MIDI_SEQUENCER /* RealTime event triggers */ void realTime_ResetState(); @@ -942,8 +951,11 @@ private: MIDIchannel::activenoteiterator i, unsigned props_mask, int32_t select_adlchn = -1); + +#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER bool ProcessEventsNew(bool isSeek = false); void HandleEvent(size_t tk, const MidiEvent &evt, int &status); +#endif // Determine how good a candidate this adlchannel // would be for playing a note from this instrument. diff --git a/src/sound/adlmidi/adlmidi_xmi2mid.h b/src/sound/adlmidi/adlmidi_xmi2mid.h deleted file mode 100644 index 950d58ca6..000000000 --- a/src/sound/adlmidi/adlmidi_xmi2mid.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * XMIDI: Miles XMIDI to MID Library Header - * - * Copyright (C) 2001 Ryan Nunn - * Copyright (C) 2014-2016 Bret Curtis - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -/* XMIDI Converter */ - -#ifndef XMIDILIB_H -#define XMIDILIB_H - -#include - -#ifdef __DJGPP__ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed long int32_t; -typedef unsigned long uint32_t; -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -/* Conversion types for Midi files */ -#define XMIDI_CONVERT_NOCONVERSION 0x00 -#define XMIDI_CONVERT_MT32_TO_GM 0x01 -#define XMIDI_CONVERT_MT32_TO_GS 0x02 -#define XMIDI_CONVERT_MT32_TO_GS127 0x03 /* This one is broken, don't use */ -#define XMIDI_CONVERT_MT32_TO_GS127DRUM 0x04 /* This one is broken, don't use */ -#define XMIDI_CONVERT_GS127_TO_GS 0x05 - -int AdlMidi_xmi2midi(uint8_t *in, uint32_t insize, - uint8_t **out, uint32_t *outsize, - uint32_t convert_type); - -#ifdef __cplusplus -} -#endif - -#endif /* XMIDILIB_H */