LMMS
Loading...
Searching...
No Matches
mdi.h
Go to the documentation of this file.
1/*
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2005 Simon Peter <dn.tlp@gmx.net>, et al.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * mdi.h - AdLib SMF (MDI) Player by Stas'M <binarymaster@mail.ru>
20 *
21 * Based on MIDIPLAY.C by Dale Glowinski, Ad Lib Inc.
22 *
23 * REFERENCES:
24 * http://www.shikadi.net/moddingwiki/MDI_Format
25 * http://www.vgmpf.com/Wiki/index.php?title=MDI
26 */
27
28#ifndef H_ADPLUG_MDIPLAYER
29#define H_ADPLUG_MDIPLAYER
30
31#include "player.h"
32#include "adlib.h"
33
34#define MIDI_CHUNK_SIZE 4 /* FOURCC size */
35#define MIDI_HEAD_SIZE 6 /* MThd data size */
36#define MIDI_MIN_SIZE MIDI_CHUNK_SIZE + sizeof(uint32_t) + MIDI_HEAD_SIZE + MIDI_CHUNK_SIZE + sizeof(uint32_t)
37#define MIDI_DEF_TEMPO 500000
38
39#define NR_CHANS 16
40
41#define NOTE_OFF 0x80
42#define NOTE_ON 0x90
43#define AFTER_TOUCH 0xA0
44#define CONTROL_CHANGE 0xB0
45#define PROG_CHANGE 0xC0
46#define CHANNEL_PRESSURE 0xD0
47#define PITCH_BEND 0xE0
48#define SYSEX_F0 0xf0
49#define SYSEX_F7 0xf7
50#define STOP_FC 0xfc
51#define META 0xff
52
53#define END_OF_TRACK 0x2f
54#define TEMPO 0x51
55#define SEQ_SPECIFIC 0x7f
56
57#define META_SIGN_LEN 3
58#define META_CODE_LEN 2
59#define META_MIN_SIZE META_SIGN_LEN + META_CODE_LEN + 1
60
61#define ADLIB_TIMBRE 1
62#define ADLIB_RHYTHM 2
63#define ADLIB_PITCH 3
64
65class CmdiPlayer: public CPlayer
66{
67public:
68 static CPlayer *factory(Copl *newopl);
69
71 : CPlayer(newopl), data(0)
72 { }
74 {
75 if(data) delete [] data;
76 if (drv) drv->~CadlibDriver();
77 };
78
79 bool load(const std::string &filename, const CFileProvider &fp);
80 bool update();
81 void rewind(int subsong);
82
83 float getrefresh()
84 {
85 return timer;
86 };
87
88 std::string gettype()
89 {
90 return std::string("AdLib MIDIPlay File");
91 }
92
93private:
94 void SetTempo(uint32_t tempo);
96 void executeCommand();
98
99protected:
100 unsigned long pos, size;
102 float timer;
103 uint16_t division; /* division in PPQN */
104 uint8_t * data; /* MIDI data */
105
106 uint32_t counter; /* tick counter */
107 uint32_t ticks; /* ticks to wait for next event */
108 uint8_t status; /* running status byte */
109 uint8_t volume[MAX_VOICES]; /* actual volume of all voices */
110};
111
112#endif
#define MAX_VOICES
Definition adlib.h:72
Definition fprovide.h:29
CPlayer(Copl *newopl)
Definition player.cpp:34
Definition adlib.h:92
uint32_t ticks
Definition mdi.h:107
~CmdiPlayer()
Definition mdi.h:73
bool update()
Definition mdi.cpp:298
float timer
Definition mdi.h:102
void SetTempo(uint32_t tempo)
Definition mdi.cpp:118
uint8_t volume[MAX_VOICES]
Definition mdi.h:109
std::string gettype()
Definition mdi.h:88
unsigned long pos
Definition mdi.h:100
bool songend
Definition mdi.h:101
void rewind(int subsong)
Definition mdi.cpp:100
uint8_t * data
Definition mdi.h:104
unsigned long size
Definition mdi.h:100
CadlibDriver * drv
Definition mdi.h:97
uint32_t counter
Definition mdi.h:106
uint16_t division
Definition mdi.h:103
float getrefresh()
Definition mdi.h:83
CmdiPlayer(Copl *newopl)
Definition mdi.h:70
bool load(const std::string &filename, const CFileProvider &fp)
Definition mdi.cpp:39
uint8_t status
Definition mdi.h:108
static CPlayer * factory(Copl *newopl)
Definition mdi.cpp:34
void executeCommand()
Definition mdi.cpp:135
uint32_t GetVarVal()
Definition mdi.cpp:124
Definition opl.h:26
static char filename[]
Definition features.c:5
unsigned short uint16_t
Definition mid.cpp:99
unsigned int uint32_t
Definition mid.cpp:100
unsigned char uint8_t
Definition mid.cpp:98