aboutsummaryrefslogtreecommitdiff
path: root/src/adlmidi.cpp
diff options
context:
space:
mode:
authorVitaly Novichkov <admin@wohlnet.ru>2018-03-24 22:41:44 +0300
committerVitaly Novichkov <admin@wohlnet.ru>2018-03-24 22:41:44 +0300
commitb303421864dc1cb2c48962e195dace6cdf7c4dc4 (patch)
tree9df016eb21ed3247e14a1f5a77e72cd6ea91a37d /src/adlmidi.cpp
parenta72d1f2efd0fe7dc259c318a39b1a67b5d188dd0 (diff)
downloadlibADLMIDI-b303421864dc1cb2c48962e195dace6cdf7c4dc4.tar.gz
libADLMIDI-b303421864dc1cb2c48962e195dace6cdf7c4dc4.tar.bz2
libADLMIDI-b303421864dc1cb2c48962e195dace6cdf7c4dc4.zip
Added ability to disable MUS and XMI converters and MIDI Sequencer
Diffstat (limited to 'src/adlmidi.cpp')
-rw-r--r--src/adlmidi.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index d40db53..e878354 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -272,6 +272,7 @@ ADLMIDI_EXPORT int adl_openFile(ADL_MIDIPlayer *device, const char *filePath)
if(device && device->adl_midiPlayer)
{
MIDIplay *play = reinterpret_cast<MIDIplay *>(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<MIDIplay *>(device->adl_midiPlayer);
+#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER
play->m_setup.tick_skip_samples_delay = 0;
if(!play->LoadMIDI(mem, static_cast<size_t>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<MIDIplay *>(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<int>(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<MIDIplay *>(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<MIDIplay *>(device->adl_midiPlayer);
if(!player)
return 1;
return (int)player->atEnd;
+#else
+ return 1;
+#endif
}
ADLMIDI_EXPORT void adl_panic(struct ADL_MIDIPlayer *device)