2013-04-02 20:46:07 +02:00
|
|
|
//=============================================================================
|
|
|
|
// MuseScore
|
|
|
|
// Music Composition & Notation
|
|
|
|
//
|
|
|
|
// Copyright (C) 2002-2012 Werner Schweer
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2
|
|
|
|
// as published by the Free Software Foundation and appearing in
|
|
|
|
// the file LICENCE.GPL
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
#ifndef __EXPORTMIDI_H__
|
|
|
|
#define __EXPORTMIDI_H__
|
|
|
|
|
2013-04-15 10:38:16 +02:00
|
|
|
#include "midi/midifile.h"
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
namespace Ms {
|
|
|
|
|
2013-04-15 10:38:16 +02:00
|
|
|
class Score;
|
2017-07-07 00:11:51 +02:00
|
|
|
class TempoMap;
|
2013-04-02 20:46:07 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------
|
|
|
|
// ExportMidi
|
|
|
|
//---------------------------------------------------------
|
|
|
|
|
|
|
|
class ExportMidi {
|
|
|
|
QFile f;
|
|
|
|
Score* cs;
|
|
|
|
|
2017-07-07 00:11:51 +02:00
|
|
|
//---------------------------------------------------
|
|
|
|
// PauseMap
|
|
|
|
// MIDI files cannot contain pauses so need to insert
|
|
|
|
// extra ticks extra ticks and tempo changes instead.
|
|
|
|
//---------------------------------------------------
|
|
|
|
|
|
|
|
class PauseMap : std::map<int, int> {
|
|
|
|
int offsetAtUTick(int utick) const;
|
|
|
|
|
|
|
|
public:
|
|
|
|
TempoMap* tempomapWithPauses;
|
|
|
|
|
|
|
|
void calculate(const Score* s);
|
|
|
|
inline int addPauseTicks(int utick) const { return utick + this->offsetAtUTick(utick); }
|
|
|
|
};
|
|
|
|
|
|
|
|
PauseMap pauseMap;
|
|
|
|
|
2013-04-02 20:46:07 +02:00
|
|
|
void writeHeader();
|
|
|
|
|
|
|
|
public:
|
|
|
|
MidiFile mf;
|
|
|
|
|
|
|
|
ExportMidi(Score* s) { cs = s; }
|
2017-11-29 08:21:36 +01:00
|
|
|
bool write(const QString& name, bool midiExpandRepeats, bool exportRPNs);
|
2013-04-02 20:46:07 +02:00
|
|
|
};
|
|
|
|
|
2013-05-13 18:49:17 +02:00
|
|
|
} // namespace Ms
|
2013-04-02 20:46:07 +02:00
|
|
|
#endif
|
|
|
|
|