2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /* @file midifile.hpp Parser for standard MIDI files */
10 #ifndef MUSIC_MIDIFILE_HPP
11 #define MUSIC_MIDIFILE_HPP
13 #include "../stdafx.h"
14 #include "../core/smallvec_type.hpp"
23 uint32 ticktime
; ///< tick number since start of file this block should be triggered at
24 uint32 realtime
; ///< real-time (microseconds) since start of file this block should be triggered at
25 std::vector
<byte
> data
; ///< raw midi data contained in block
26 DataBlock(uint32 _ticktime
= 0) : ticktime(_ticktime
) { }
29 uint32 ticktime
; ///< tick number since start of file this tempo change occurs at
30 uint32 tempo
; ///< new tempo in microseconds per tick
31 TempoChange(uint32 _ticktime
, uint32 _tempo
) : ticktime(_ticktime
), tempo(_tempo
) { }
34 std::vector
<DataBlock
> blocks
; ///< sequential time-annotated data of file, merged to a single track
35 std::vector
<TempoChange
> tempos
; ///< list of tempo changes in file
36 uint16 tickdiv
; ///< ticks per quarter note
41 bool LoadFile(const char *filename
);
42 bool LoadMpsData(const byte
*data
, size_t length
);
43 bool LoadSong(const MusicSongInfo
&song
);
44 void MoveFrom(MidiFile
&other
);
46 bool WriteSMF(const char *filename
);
48 static std::string
GetSMFFile(const MusicSongInfo
&song
);
49 static bool ReadSMFHeader(const char *filename
, SMFHeader
&header
);
50 static bool ReadSMFHeader(FILE *file
, SMFHeader
&header
);
53 #endif /* MUSIC_MIDIFILE_HPP */