diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/adlmidi.cpp | 12 | ||||
-rw-r--r-- | src/adlmidi_midiplay.cpp | 45 | ||||
-rw-r--r-- | src/adlmidi_private.hpp | 8 |
3 files changed, 65 insertions, 0 deletions
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp index 32872ef..3a1923a 100644 --- a/src/adlmidi.cpp +++ b/src/adlmidi.cpp @@ -757,6 +757,18 @@ ADLMIDI_EXPORT void adl_setTempo(struct ADL_MIDIPlayer *device, double tempo) } +ADLMIDI_EXPORT int adl_describeChannels(struct ADL_MIDIPlayer *device, char *str, char *attr, size_t size) +{ + if(!device) + return -1; + MIDIplay *play = reinterpret_cast<MIDIplay *>(device->adl_midiPlayer); + if(!play) + return -1; + play->describeChannels(str, attr, size); + return 0; +} + + ADLMIDI_EXPORT const char *adl_metaMusicTitle(struct ADL_MIDIPlayer *device) { #ifndef ADLMIDI_DISABLE_MIDI_SEQUENCER diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index 9841f73..76d54ab 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -1722,6 +1722,51 @@ void MIDIplay::updateGlide(double amount) } } +void MIDIplay::describeChannels(char *str, char *attr, size_t size) +{ + if (!str || size <= 0) + return; + + OPL3 &synth = m_synth; + uint32_t numChannels = synth.m_numChannels; + + uint32_t index = 0; + for(uint32_t i = 0; index < numChannels && index < size - 1; ++i) + { + const AdlChannel &adlChannel = m_chipChannels[i]; + + AdlChannel::LocationData *loc = adlChannel.users_first; + if(!loc) // off + { + str[index++] = '-'; + } + else if(loc->next) // arpeggio + { + str[index++] = '@'; + } + else // on + { + switch(synth.m_channelCategory[i]) + { + case OPL3::ChanCat_Regular: + str[index++] = '+'; + break; + case OPL3::ChanCat_4op_Master: + case OPL3::ChanCat_4op_Slave: + str[index++] = '#'; + break; + default: // rhythm-mode percussion + str[index++] = 'r'; + break; + } + } + + attr[index] = '\0'; // TODO + } + + str[index] = 0; + attr[index] = 0; +} #ifndef ADLMIDI_DISABLE_CPP_EXTRAS diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 7b59003..858e33d 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -1428,6 +1428,14 @@ public: * @return Offset of the MIDI Channels, multiple to 16 */ size_t chooseDevice(const std::string &name); + + /** + * @brief Gets a textual description of the state of chip channels + * @param text character pointer for text + * @param attr character pointer for text attributes + * @param size number of characters available to write + */ + void describeChannels(char *text, char *attr, size_t size); }; // I think, this is useless inside of Library |