diff options
Diffstat (limited to 'libs/evoral')
-rw-r--r-- | libs/evoral/evoral/SMF.hpp | 1 | ||||
-rw-r--r-- | libs/evoral/src/SMF.cpp | 22 | ||||
-rw-r--r-- | libs/evoral/test/SequenceTest.cpp | 2 |
3 files changed, 24 insertions, 1 deletions
diff --git a/libs/evoral/evoral/SMF.hpp b/libs/evoral/evoral/SMF.hpp index 91bc928d9a..fe81b8f044 100644 --- a/libs/evoral/evoral/SMF.hpp +++ b/libs/evoral/evoral/SMF.hpp @@ -52,6 +52,7 @@ public: SMF() : _smf(0), _smf_track(0), _empty(true) {}; virtual ~SMF(); + static bool test(const std::string& path); int open(const std::string& path, int track=1) THROW_FILE_ERROR; int create(const std::string& path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR; void close() THROW_FILE_ERROR; diff --git a/libs/evoral/src/SMF.cpp b/libs/evoral/src/SMF.cpp index 51ccda583e..dc3512a0f6 100644 --- a/libs/evoral/src/SMF.cpp +++ b/libs/evoral/src/SMF.cpp @@ -71,6 +71,28 @@ SMF::seek_to_track(int track) } } +/** Attempt to open the SMF file just to see if it is valid. + * + * \return true on success + * false on failure + */ +bool +SMF::test(const std::string& path) +{ + PBD::StdioFileDescriptor d (path, "r"); + FILE* f = d.allocate (); + if (f == 0) { + return false; + } + + smf_t* test_smf; + if ((test_smf = smf_load (f)) == NULL) { + return false; + } + smf_delete (test_smf); + return true; +} + /** Attempt to open the SMF file for reading and/or writing. * * \return 0 on success diff --git a/libs/evoral/test/SequenceTest.cpp b/libs/evoral/test/SequenceTest.cpp index 69931b8e0d..6e07776fdb 100644 --- a/libs/evoral/test/SequenceTest.cpp +++ b/libs/evoral/test/SequenceTest.cpp @@ -23,7 +23,7 @@ SequenceTest::preserveEventOrderingTest () seq->start_write(); for (Notes::const_iterator i = test_notes.begin(); i != test_notes.end(); ++i) { - uint8_t buffer[2]; + uint8_t buffer[3]; Event<Time>* event = new Event<Time>( DummyTypeMap::CONTROL, (*i)->on_event().time(), 3, buffer, true ); |