aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--include/adlmidi.h9
-rw-r--r--src/adlmidi.cpp21
3 files changed, 31 insertions, 0 deletions
diff --git a/README.md b/README.md
index 449aea5..c28ae1e 100644
--- a/README.md
+++ b/README.md
@@ -181,6 +181,7 @@ To build that example you will need to have installed SDL2 library.
## 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)
+ * Added an ability to disable/enable playing of selected MIDI channels
## 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 53f57f8..11567f0 100644
--- a/include/adlmidi.h
+++ b/include/adlmidi.h
@@ -895,6 +895,15 @@ enum ADLMIDI_TrackOptions
extern ADLMIDI_DECLSPEC int adl_setTrackOptions(struct ADL_MIDIPlayer *device, size_t trackNumber, unsigned trackOptions);
/**
+ * @brief Sets the channel of the current sequence enable state
+ * @param device Instance of the library
+ * @param channelNumber Number of the channel (from 0 to 15)
+ * @param enabled 1 to enable and 0 to disable
+ * @return 0 on success, <0 when any error has occurred
+ */
+extern ADLMIDI_DECLSPEC int adl_setChannelEnabled(struct ADL_MIDIPlayer *device, size_t channelNumber, int enabled);
+
+/**
* @brief Handler of callback trigger events
* @param userData Pointer to user data (usually, context of something)
* @param trigger Value of the event which triggered this callback.
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index 621c385..99109eb 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -1569,6 +1569,27 @@ ADLMIDI_EXPORT int adl_setTrackOptions(struct ADL_MIDIPlayer *device, size_t tra
#endif
}
+ADLMIDI_EXPORT int adl_setChannelEnabled(struct ADL_MIDIPlayer *device, size_t channelNumber, int enabled)
+{
+#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER
+ if(!device)
+ return -1;
+
+ MidiPlayer *play = GET_MIDI_PLAYER(device);
+ assert(play);
+ MidiSequencer &seq = *play->m_sequencer;
+
+ if(!seq.setChannelEnabled(channelNumber, (bool)enabled))
+ return -1;
+ return 0;
+#else
+ ADL_UNUSED(device);
+ ADL_UNUSED(channelNumber);
+ ADL_UNUSED(enabled);
+ return -1;
+#endif
+}
+
ADLMIDI_EXPORT int adl_setTriggerHandler(struct ADL_MIDIPlayer *device, ADL_TriggerHandler handler, void *userData)
{
#ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER