From 12e82351936efd066ff063b7f59dd869314e3e27 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 5 Feb 2022 00:06:19 +0100 Subject: [PATCH] Add API to query set of used MIDI channels in a SMF --- libs/evoral/SMF.cc | 5 +++-- libs/evoral/evoral/SMF.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/evoral/SMF.cc b/libs/evoral/SMF.cc index 2509970cb9..0120815b7f 100644 --- a/libs/evoral/SMF.cc +++ b/libs/evoral/SMF.cc @@ -126,6 +126,7 @@ SMF::open(const std::string& path, int track) Glib::Threads::Mutex::Lock lm (_smf_lock); _num_channels = 0; + _used_channels.clear (); assert(track >= 1); if (_smf) { @@ -185,10 +186,10 @@ SMF::open(const std::string& path, int track) uint8_t type = buf[0] & 0xf0; uint8_t chan = buf[0] & 0x0f; if (type >= 0x80 && type <= 0xE0) { - used.insert(chan); + _used_channels.insert(chan); } } - _num_channels += used.size(); + _num_channels += _used_channels.size(); free (buf); } diff --git a/libs/evoral/evoral/SMF.h b/libs/evoral/evoral/SMF.h index 641a00f736..975ce15707 100644 --- a/libs/evoral/evoral/SMF.h +++ b/libs/evoral/evoral/SMF.h @@ -88,6 +88,8 @@ public: int smf_format () const; int num_channels () const { return _num_channels; } + std::set const& used_channels () const { return _used_channels; } + void track_names (std::vector&) const; void instrument_names (std::vector&) const; @@ -136,6 +138,7 @@ public: mutable Glib::Threads::Mutex _smf_lock; int _num_channels; + std::set _used_channels; mutable Markers _markers; };