MuseScore  3.4
Music composition and notation
exportmidi.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2002-2012 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __EXPORTMIDI_H__
14 #define __EXPORTMIDI_H__
15 
16 #include "midi/midifile.h"
17 
18 namespace Ms {
19 
20 class Score;
21 class TempoMap;
22 class SynthesizerState;
23 
24 //---------------------------------------------------------
25 // ExportMidi
26 //---------------------------------------------------------
27 
28 class ExportMidi {
29  QFile f;
31 
32  //---------------------------------------------------
33  // PauseMap
34  // MIDI files cannot contain pauses so need to insert
35  // extra ticks extra ticks and tempo changes instead.
36  //---------------------------------------------------
37 
38  class PauseMap : std::map<int, int> {
39  int offsetAtUTick(int utick) const;
40 
41  public:
43 
44  void calculate(const Score* s);
45  inline int addPauseTicks(int utick) const { return utick + this->offsetAtUTick(utick); }
46  };
47 
49 
50  void writeHeader();
51 
52  public:
54 
55  ExportMidi(Score* s) { cs = s; }
56  bool write(const QString& name, bool midiExpandRepeats, bool exportRPNs);
57  bool write(QIODevice* device, bool midiExpandRepeats, bool exportRPNs);
58  bool write(const QString& name, bool midiExpandRepeats, bool exportRPNs, const SynthesizerState& synthState);
59  bool write(QIODevice* device, bool midiExpandRepeats, bool exportRPNs, const SynthesizerState& synthState);
60  };
61 
62 } // namespace Ms
63 #endif
64 
QFile f
Definition: exportmidi.h:29
Definition: tempomap.h:22
Definition: exportmidi.h:28
Definition: score.h:391
ExportMidi(Score *s)
Definition: exportmidi.h:55
Definition: synthesizerstate.h:55
TempoMap * tempomapWithPauses
Definition: exportmidi.h:42
Definition: midifile.h:70
Definition: aeolus.cpp:26
Score * cs
Definition: exportmidi.h:30
void calculate(const Score *s)
Definition: exportmidi.cpp:364
Definition: tempo.h:45
Definition: exportmidi.h:38
MidiFile mf
Definition: exportmidi.h:53
int offsetAtUTick(int utick) const
Definition: exportmidi.cpp:412
void writeHeader()
Definition: exportmidi.cpp:34
bool write(const QString &name, bool midiExpandRepeats, bool exportRPNs)
Definition: exportmidi.cpp:352
PauseMap pauseMap
Definition: exportmidi.h:48
int addPauseTicks(int utick) const
Definition: exportmidi.h:45