summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
Diffstat (limited to 'libs/evoral')
-rw-r--r--libs/evoral/evoral/SMF.hpp4
-rw-r--r--libs/evoral/src/SMF.cpp51
2 files changed, 54 insertions, 1 deletions
diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp
index 0cbd5bb638..1a9d2c1084 100644
--- a/libs/evoral/evoral/SMF.hpp
+++ b/libs/evoral/evoral/SMF.hpp
@@ -78,8 +78,10 @@ public:
bool is_type0 () const { return _type0; }
std::set<uint8_t> channels () const { return _type0channels; }
+ void track_names (std::vector<std::string>&) const;
+ void instrument_names (std::vector<std::string>&) const;
-private:
+ private:
smf_t* _smf;
smf_track_t* _smf_track;
bool _empty; ///< true iff file contains(non-empty) events
diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp
index f5dc4fa1e0..4abd69796c 100644
--- a/libs/evoral/src/SMF.cpp
+++ b/libs/evoral/src/SMF.cpp
@@ -472,4 +472,55 @@ SMF::round_to_file_precision (double val) const
return round (val * div) / div;
}
+void
+SMF::track_names(vector<string>& names) const
+{
+ if (!_smf) {
+ return;
+ }
+
+ names.clear ();
+
+ Glib::Threads::Mutex::Lock lm (_smf_lock);
+
+ for (uint16_t n = 0; n < _smf->number_of_tracks; ++n) {
+ smf_track_t* trk = smf_get_track_by_number (_smf, n+1);
+ if (!trk) {
+ names.push_back (string());
+ } else {
+ if (trk->name) {
+ names.push_back (trk->name);
+ } else {
+ names.push_back (string());
+ }
+ }
+ }
+}
+
+void
+SMF::instrument_names(vector<string>& names) const
+{
+ if (!_smf) {
+ return;
+ }
+
+ names.clear ();
+
+ Glib::Threads::Mutex::Lock lm (_smf_lock);
+
+ for (uint16_t n = 0; n < _smf->number_of_tracks; ++n) {
+ smf_track_t* trk = smf_get_track_by_number (_smf, n+1);
+ if (!trk) {
+ names.push_back (string());
+ } else {
+ if (trk->instrument) {
+ names.push_back (trk->instrument);
+ } else {
+ names.push_back (string());
+ }
+ }
+ }
+}
+
+
} // namespace Evoral