diff --git a/libs/evoral/SMF.cc b/libs/evoral/SMF.cc index 0120815b7f..db62d07a3a 100644 --- a/libs/evoral/SMF.cc +++ b/libs/evoral/SMF.cc @@ -125,7 +125,9 @@ SMF::open(const std::string& path, int track) { Glib::Threads::Mutex::Lock lm (_smf_lock); - _num_channels = 0; + _num_channels = 0; + _n_note_on_events = 0; + _has_pgm_change = false; _used_channels.clear (); assert(track >= 1); @@ -185,8 +187,19 @@ 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_channels.insert(chan); + switch (type) { + case MIDI_CMD_NOTE_ON: + ++_n_note_on_events; + break; + case MIDI_CMD_PGM_CHANGE: + _has_pgm_change = true; + break; + default: + break; + } } } _num_channels += _used_channels.size(); diff --git a/libs/evoral/evoral/SMF.h b/libs/evoral/evoral/SMF.h index 975ce15707..4000ee359b 100644 --- a/libs/evoral/evoral/SMF.h +++ b/libs/evoral/evoral/SMF.h @@ -87,8 +87,11 @@ public: double round_to_file_precision (double val) const; int smf_format () const; + int num_channels () const { return _num_channels; } std::set const& used_channels () const { return _used_channels; } + uint64_t n_note_on_events () const { return _n_note_on_events; } + bool has_pgm_change () const { return _has_pgm_change; } void track_names (std::vector&) const; void instrument_names (std::vector&) const; @@ -140,6 +143,9 @@ public: int _num_channels; std::set _used_channels; + uint64_t _n_note_on_events; + bool _has_pgm_change; + mutable Markers _markers; };