Add a missing 'typename' specifier to the declaration for 'Evoral::Sequence::set_notes()'
[ardour.git] / libs / evoral / test / SMFTest.cpp
1 #include "SMFTest.hpp"
2
3 #include <glibmm/fileutils.h>
4 #include <glibmm/miscutils.h>
5
6 #include "pbd/file_utils.h"
7
8 using namespace std;
9
10 CPPUNIT_TEST_SUITE_REGISTRATION( SMFTest );
11
12 void
13 SMFTest::createNewFileTest ()
14 {
15         TestSMF smf;
16
17         string output_dir_path = PBD::tmp_writable_directory (PACKAGE, "createNewFileTest");
18         string new_file_path = Glib::build_filename (output_dir_path, "NewFile.mid");
19         smf.create(new_file_path);
20         smf.close();
21         CPPUNIT_ASSERT(Glib::file_test (new_file_path, Glib::FILE_TEST_IS_REGULAR));
22 }
23
24 PBD::Searchpath
25 test_search_path ()
26 {
27 #ifdef PLATFORM_WINDOWS
28         string wsp(g_win32_get_package_installation_directory_of_module(NULL));
29         return Glib::build_filename (wsp,  "evoral_testdata");
30 #else
31         return Glib::getenv("EVORAL_TEST_PATH");
32 #endif
33 }
34
35 void
36 SMFTest::takeFiveTest ()
37 {
38         TestSMF smf;
39         string testdata_path;
40         CPPUNIT_ASSERT (find_file (test_search_path (), "TakeFive.mid", testdata_path));
41         smf.open(testdata_path);
42         CPPUNIT_ASSERT(!smf.is_empty());
43
44         seq->start_write();
45         smf.seek_to_start();
46
47         uint64_t time = 0; /* in SMF ticks */
48         Evoral::Event<Evoral::Beats> ev;
49
50         uint32_t delta_t = 0;
51         uint32_t size    = 0;
52         uint8_t* buf     = NULL;
53         int ret;
54         while ((ret = smf.read_event(&delta_t, &size, &buf)) >= 0) {
55                 ev.set(buf, size, Evoral::Beats());
56                 time += delta_t;
57
58                 if (ret > 0) { // didn't skip (meta) event
59                         //cerr << "read smf event type " << hex << int(buf[0]) << endl;
60                         ev.set_time(Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
61                         ev.set_event_type(type_map->midi_event_type(buf[0]));
62                         seq->append(ev, next_event_id ());
63                 }
64         }
65
66         seq->end_write (Sequence<Time>::Relax,
67                         Evoral::Beats::ticks_at_rate(time, smf.ppqn()));
68         CPPUNIT_ASSERT(!seq->empty());
69 }