Add API to query SMF note-count and pgm-changes
This information is useful for trigger-clips, in particular if the file can change synth-settings via patch-changes.
This commit is contained in:
parent
220b1386ab
commit
207ad2d369
@ -126,6 +126,8 @@ SMF::open(const std::string& path, int track)
|
||||
Glib::Threads::Mutex::Lock lm (_smf_lock);
|
||||
|
||||
_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();
|
||||
|
@ -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<uint8_t> 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<std::string>&) const;
|
||||
void instrument_names (std::vector<std::string>&) const;
|
||||
@ -140,6 +143,9 @@ public:
|
||||
int _num_channels;
|
||||
std::set<uint8_t> _used_channels;
|
||||
|
||||
uint64_t _n_note_on_events;
|
||||
bool _has_pgm_change;
|
||||
|
||||
mutable Markers _markers;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user