aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2021-10-25 05:38:25 +0300
committerWohlstand <admin@wohlnet.ru>2021-10-25 05:38:25 +0300
commit50a8396eb61c665b07426c70a11c0b73ed950434 (patch)
tree4abdfe53b1910b1c977d8ac5687454384dd83803
parent57a8d528e877d3810deaa1ce24545512e1a46ac9 (diff)
downloadlibADLMIDI-50a8396eb61c665b07426c70a11c0b73ed950434.tar.gz
libADLMIDI-50a8396eb61c665b07426c70a11c0b73ed950434.tar.bz2
libADLMIDI-50a8396eb61c665b07426c70a11c0b73ed950434.zip
Added an ability to set number of loops
-rw-r--r--README.md1
-rw-r--r--include/adlmidi.h10
-rw-r--r--src/adlmidi.cpp15
3 files changed, 26 insertions, 0 deletions
diff --git a/README.md b/README.md
index d4cf7c1..449aea5 100644
--- a/README.md
+++ b/README.md
@@ -180,6 +180,7 @@ To build that example you will need to have installed SDL2 library.
# Changelog
## 1.5.1 dev
* Added an ability to disable the automatical arpeggio
+ * Added an ability to set the count of loops (how many times to play the song)
## 1.5.0.1 2020-10-11
* Fixed an incorrect timer processing when using a real-time interface
diff --git a/include/adlmidi.h b/include/adlmidi.h
index 2b68509..53f57f8 100644
--- a/include/adlmidi.h
+++ b/include/adlmidi.h
@@ -564,6 +564,16 @@ extern ADLMIDI_DECLSPEC void adl_setAutoArpeggio(struct ADL_MIDIPlayer *device,
extern ADLMIDI_DECLSPEC void adl_setLoopEnabled(struct ADL_MIDIPlayer *device, int loopEn);
/**
+ * @brief Set how many times loop will be played
+ *
+ * Note: The song will be played once if loop has been disabled with no matter which value of loop count was set
+ *
+ * @param device Instance of the library
+ * @param loopCount Number of loops or -1 to loop infinitely
+ */
+extern ADLMIDI_DECLSPEC void adl_setLoopCount(struct ADL_MIDIPlayer *device, int loopCount);
+
+/**
* @brief Enable or disable soft panning with chip emulators
* @param device Instance of the library
* @param softPanEn 0 - disabled, 1 - enabled
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index c62c2cb..621c385 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -574,6 +574,21 @@ ADLMIDI_EXPORT void adl_setLoopEnabled(ADL_MIDIPlayer *device, int loopEn)
#endif
}
+ADLMIDI_EXPORT void adl_setLoopCount(ADL_MIDIPlayer *device, int loopCount)
+{
+#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER
+ if(!device)
+ return;
+ MidiPlayer *play = GET_MIDI_PLAYER(device);
+ assert(play);
+ play->m_sequencer->setLoopsCount(loopCount);
+#else
+ ADL_UNUSED(device);
+ ADL_UNUSED(loopCount);
+#endif
+}
+
+
ADLMIDI_EXPORT void adl_setSoftPanEnabled(ADL_MIDIPlayer *device, int softPanEn)
{
if(!device)