OpenShot Audio Library | OpenShotAudio 0.4.0
Loading...
Searching...
No Matches
juce_MidiFile.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
41class JUCE_API MidiFile
42{
43public:
44 //==============================================================================
46 MidiFile();
47
49 MidiFile (const MidiFile&);
50
52 MidiFile& operator= (const MidiFile&);
53
56
58 MidiFile& operator= (MidiFile&&);
59
60 //==============================================================================
64 int getNumTracks() const noexcept;
65
70 const MidiMessageSequence* getTrack (int index) const noexcept;
71
76 void addTrack (const MidiMessageSequence& trackSequence);
77
81 void clear();
82
95 short getTimeFormat() const noexcept;
96
106 void setTicksPerQuarterNote (int ticksPerQuarterNote) noexcept;
107
120 void setSmpteTimeFormat (int framesPerSecond,
121 int subframeResolution) noexcept;
122
123 //==============================================================================
128 void findAllTempoEvents (MidiMessageSequence& tempoChangeEvents) const;
129
134 void findAllTimeSigEvents (MidiMessageSequence& timeSigEvents) const;
135
139 void findAllKeySigEvents (MidiMessageSequence& keySigEvents) const;
140
144 double getLastTimestamp() const;
145
146 //==============================================================================
165 bool readFrom (InputStream& sourceStream,
166 bool createMatchingNoteOffs = true,
167 int* midiFileType = nullptr);
168
178 bool writeTo (OutputStream& destStream, int midiFileType = 1) const;
179
185 void convertTimestampTicksToSeconds();
186
187private:
188 //==============================================================================
190 short timeFormat;
191
192 void readNextTrack (const uint8*, int, bool);
193 bool writeTrack (OutputStream&, const MidiMessageSequence&) const;
194
195 JUCE_LEAK_DETECTOR (MidiFile)
196};
197
198} // namespace juce