summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-12-14 11:42:54 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2016-12-14 11:46:26 +0000
commitd2fd01c2415c911a07598f4c84a457109885fe70 (patch)
tree0c1a7808f22a2b0cddb05d83e4ad30e07416aa95 /libs/evoral
parent7e0dbd06dbecd400a9ea3b05566b757982596e69 (diff)
add API to Evoral::SMF to retrieve all track/instrument names for use when importing
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