-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp.template
More file actions
57 lines (51 loc) · 1.43 KB
/
main.cpp.template
File metadata and controls
57 lines (51 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "file.hpp"
#include <filesystem>
#include <fstream>
#include <log/log.hpp>
auto main() -> int
{
auto test = midi::File{};
using recursive_directory_iterator = std::filesystem::recursive_directory_iterator;
auto good = 0;
auto bad = 0;
for (const auto &path : recursive_directory_iterator("/home/mika/Music/midi/"))
{
const auto m = path.path();
// const auto m = "/home/mika/Music/midi/11966.mid";
try
{
LOG("");
LOG(m);
auto fs = std::ifstream{m, std::ios::binary};
auto f = midi::File{fs};
LOG("format", midi::toStr(f.header.format));
LOG("ntrks", f.header.ntrks);
LOG("division", toStr(f.header.division));
for (const auto &trk : f.tracks)
{
LOG("events:", trk.events.size());
for (const auto &evnt : trk.events)
{
std::visit(
[&](auto &&e) {
using T = std::decay_t<decltype(e)>;
if constexpr (std::is_same_v<T, midi::NoteOn>) {}
else if constexpr (std::is_same_v<T, midi::NoteOff>)
{
}
else
LOG(std::to_string(getDeltaTime(evnt)), std::to_string(getChannel(evnt)), midi::toStr(e));
},
getEvent(evnt));
}
}
++good;
}
catch (const std::runtime_error &e)
{
LOG("Invalid file:", m, "Error:", e.what());
++bad;
}
}
LOG("good", good, "bad", bad);
}