#include "MidiDocument.h"

#include "MidiTrack.h"

MidiDocument::MidiDocument()
{

}

std::unique_ptr<MidiDocument> MidiDocument::Create()
{
    return std::make_unique<MidiDocument>();
}

void MidiDocument::AddTrack(MidiTrackPtr track)
{
    mTracks.push_back(std::move(track));
}

void MidiDocument::SetFormatType(int format)
{
    mFormatType = format;
}

void MidiDocument::SetExpectedTracks(int expected)
{
    mExpectedTracks = expected;
}

void MidiDocument::SetTimeDivision(const MidiTimeDivision& timeDivision)
{
    mTimeDivision = timeDivision;
}

std::string MidiDocument::Serialize() const
{
    std::string output = "MidiDocument\n";
    output += "Format type: " + std::to_string(mFormatType) + "\n";
    output += "Expected Tracks: " + std::to_string(mExpectedTracks) + "\n";
    output += "Use fps: " + std::to_string(mTimeDivision.mUseFps) + "\n";
    output += "fps: " + std::to_string(mTimeDivision.mFps) + "\n";
    output += "Ticks per frame: " + std::to_string(mTimeDivision.mTicks) + "\n";
    output += "Num tracks: " + std::to_string(mTracks.size()) + "\n";
    for(const auto& track : mTracks)
    {
        output += track->Serialize();
        output += "------------------------\n";
    }
    return output;
}
