Add API to query set of used MIDI channels in a SMF
This commit is contained in:
parent
fa29647246
commit
12e8235193
@ -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);
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,8 @@ public:
|
||||
|
||||
int smf_format () const;
|
||||
int num_channels () const { return _num_channels; }
|
||||
std::set<uint8_t> const& used_channels () const { return _used_channels; }
|
||||
|
||||
void track_names (std::vector<std::string>&) const;
|
||||
void instrument_names (std::vector<std::string>&) const;
|
||||
|
||||
@ -136,6 +138,7 @@ public:
|
||||
mutable Glib::Threads::Mutex _smf_lock;
|
||||
|
||||
int _num_channels;
|
||||
std::set<uint8_t> _used_channels;
|
||||
|
||||
mutable Markers _markers;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user