Files
@ r28520:f9aebe299cae
Branch filter:
Location: cpp/openttd-patchpack/source/src/music/midifile.hpp - annotation
r28520:f9aebe299cae
2.1 KiB
text/x-c++hdr
Codechange: MacOS already has MIN/MAX macros defined
This is caused because we use PreCompile Headers, and one of them
includes a system headers which defines MIN/MAX.
This is caused because we use PreCompile Headers, and one of them
includes a system headers which defines MIN/MAX.
r22853:032eed6d4c1b r28074:fffdbfe84aad r28074:fffdbfe84aad r28074:fffdbfe84aad r28074:fffdbfe84aad r28074:fffdbfe84aad r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22884:72bcc81ae179 r22884:72bcc81ae179 r22853:032eed6d4c1b r22853:032eed6d4c1b r27737:728d55b97775 r27737:728d55b97775 r23538:8df50944b27a r27737:728d55b97775 r22853:032eed6d4c1b r22853:032eed6d4c1b r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r27737:728d55b97775 r22853:032eed6d4c1b r22886:24e998dafee5 r22886:24e998dafee5 r22886:24e998dafee5 r27497:a772aa0e9df5 r22884:72bcc81ae179 r22884:72bcc81ae179 r22853:032eed6d4c1b r22853:032eed6d4c1b r27497:a772aa0e9df5 r22886:24e998dafee5 r22888:a5ba89e2c64e r27497:a772aa0e9df5 r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b r22853:032eed6d4c1b | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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/>.
*/
/* @file midifile.hpp Parser for standard MIDI files */
#ifndef MUSIC_MIDIFILE_HPP
#define MUSIC_MIDIFILE_HPP
#include "../stdafx.h"
#include "midi.h"
struct MusicSongInfo;
struct MidiFile {
struct DataBlock {
uint32_t ticktime; ///< tick number since start of file this block should be triggered at
uint32_t realtime; ///< real-time (microseconds) since start of file this block should be triggered at
std::vector<byte> data; ///< raw midi data contained in block
DataBlock(uint32_t _ticktime = 0) : ticktime(_ticktime) { }
};
struct TempoChange {
uint32_t ticktime; ///< tick number since start of file this tempo change occurs at
uint32_t tempo; ///< new tempo in microseconds per tick
TempoChange(uint32_t _ticktime, uint32_t _tempo) : ticktime(_ticktime), tempo(_tempo) { }
};
std::vector<DataBlock> blocks; ///< sequential time-annotated data of file, merged to a single track
std::vector<TempoChange> tempos; ///< list of tempo changes in file
uint16_t tickdiv; ///< ticks per quarter note
MidiFile();
~MidiFile();
bool LoadFile(const std::string &filename);
bool LoadMpsData(const byte *data, size_t length);
bool LoadSong(const MusicSongInfo &song);
void MoveFrom(MidiFile &other);
bool WriteSMF(const std::string &filename);
static std::string GetSMFFile(const MusicSongInfo &song);
static bool ReadSMFHeader(const std::string &filename, SMFHeader &header);
static bool ReadSMFHeader(FILE *file, SMFHeader &header);
};
#endif /* MUSIC_MIDIFILE_HPP */
|