36 lines
722 B
C++
36 lines
722 B
C++
#pragma once
|
|
|
|
#include "MidiDocument.h"
|
|
#include "MetaMidiEvent.h"
|
|
#include "MidiTrack.h"
|
|
#include "MidiChannelEvent.h"
|
|
#include "File.h"
|
|
|
|
#include <filesystem>
|
|
#include "String.h"
|
|
|
|
using Path = std::filesystem::path;
|
|
|
|
class MidiReader
|
|
{
|
|
static constexpr const char TrackChunkLabel[] = "MTrk";
|
|
static constexpr const char HeaderLabel[] = "MThd";
|
|
|
|
public:
|
|
MidiReader();
|
|
|
|
MidiDocument* getDocument() const;
|
|
|
|
void read(const Path& path);
|
|
|
|
private:
|
|
bool processHeader();
|
|
bool processTrackChunk(bool debug=false);
|
|
int processEvent(MidiTrack* track);
|
|
|
|
private:
|
|
Ptr<File> mFile;
|
|
MidiDocumentPtr mDocument;
|
|
int mLastMidiChannel {0};
|
|
MidiChannelEvent::Type mLastChannelEventType;
|
|
};
|