LMMS
Loading...
Searching...
No Matches
vgm.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 * vgm.h - VGM Player by Stas'M <binarymaster@mail.ru>
20 *
21 * REFERENCES:
22 * https://vgmrips.net/wiki/VGM_Specification
23 * http://www.smspower.org/uploads/Music/vgmspec160.txt
24 * http://www.smspower.org/uploads/Music/gd3spec100.txt
25 */
26
27#ifndef H_ADPLUG_VGMPLAYER
28#define H_ADPLUG_VGMPLAYER
29
30#include "player.h"
31
32#if !defined(UINT8_MAX)
33typedef signed char int8_t;
34typedef short int16_t;
35typedef int int32_t;
36typedef unsigned char uint8_t;
37typedef unsigned short uint16_t;
38typedef unsigned int uint32_t;
39#endif
40
41#define VGM_GZIP_MIN 8 // minimum size for GZip header
42#define VGM_HEADER_MIN 84 // minimum size for header (till YM3812 clock field)
43#define VGM_HEADER_ID "Vgm " // header ident
44#define OFFSET_EOF 0x04 // End Of File offset
45#define OFFSET_GD3 0x14 // GD3 tag offset
46#define OFFSET_LOOP 0x1C // Loop offset
47#define OFFSET_DATA 0x34 // VGM data offset
48#define OFFSET_YM3812 0x50 // YM3812 clock offset
49#define OFFSET_YMF262 0x5C // YMF262 clock offset
50#define OFFSET_LOOPBASE 0x7E // Loop base offset
51#define OFFSET_LOOPMOD 0x7F // Loop modifier offset
52#define VGM_DUAL_BIT 0x40000000 // VGM flag for dual-chip feature
53#define GD3_HEADER_ID "Gd3 " // GD3 tag header ident
54
55#define CMD_OPL2 0x5A // YM3812, write value <dd> to register <aa>
56#define CMD_OPL3_PORT0 0x5E // YMF262 port 0, write value <dd> to register <aa>
57#define CMD_OPL3_PORT1 0x5F // YMF262 port 1, write value <dd> to register <aa>
58#define CMD_WAIT 0x61 // Wait <n> samples, <n> can range from 0 to 65535 (approx 1.49 seconds)
59#define CMD_WAIT_735 0x62 // wait 735 samples (60th of a second)
60#define CMD_WAIT_882 0x63 // wait 882 samples (50th of a second)
61#define CMD_DATA_END 0x66 // end of sound data
62#define CMD_WAIT_N 0x70 // wait <n+1> samples, <n> can range from 0 to 15
63#define CMD_OPL2_2ND 0xAA // YM3812 chip 2, write value <dd> to register <aa>
64
65#define VGM_FREQUENCY 44100.0 // VGM base sample frequency
66
67class CvgmPlayer: public CPlayer
68{
69public:
70 static CPlayer *factory(Copl *newopl);
71
73 : CPlayer(newopl), vgmData(0)
74 { };
76 {
77 if (vgmData) delete[] vgmData;
78 };
79
80 bool load(const std::string &filename, const CFileProvider &fp);
81 bool update();
82 void rewind(int subsong);
83 float getrefresh();
84
85 std::string gettype();
86 std::string gettitle();
87 std::string getauthor();
88 std::string getdesc();
89
90protected:
96
97 struct GD3tag {
98 wchar_t title_en[256], title_jp[256];
99 wchar_t game_en[256], game_jp[256];
100 wchar_t system_en[256], system_jp[256];
101 wchar_t author_en[256], author_jp[256];
102 wchar_t date[256], ripper[256], notes[256];
103 };
105
106 int pos;
109};
110
111#endif
Definition fprovide.h:29
CPlayer(Copl *newopl)
Definition player.cpp:34
Definition opl.h:26
bool songend
Definition vgm.h:107
bool vgmDual
Definition vgm.h:93
int samples
Definition vgm.h:91
float getrefresh()
Definition vgm.cpp:270
uint8_t * vgmData
Definition vgm.h:95
uint16_t wait
Definition vgm.h:108
bool update()
Definition vgm.cpp:198
std::string getauthor()
Definition vgm.cpp:307
~CvgmPlayer()
Definition vgm.h:75
std::string gettitle()
Definition vgm.cpp:292
int loop_smp
Definition vgm.h:91
bool vgmOPL3
Definition vgm.h:93
void rewind(int subsong)
Definition vgm.cpp:264
uint8_t loop_mod
Definition vgm.h:92
int version
Definition vgm.h:91
CvgmPlayer(Copl *newopl)
Definition vgm.h:72
uint8_t loop_base
Definition vgm.h:92
static CPlayer * factory(Copl *newopl)
Definition vgm.cpp:38
std::string getdesc()
Definition vgm.cpp:322
int loop_ofs
Definition vgm.h:91
int pos
Definition vgm.h:106
int clock
Definition vgm.h:91
int data_sz
Definition vgm.h:94
int rate
Definition vgm.h:91
std::string gettype()
Definition vgm.cpp:275
GD3tag GD3
Definition vgm.h:104
bool load(const std::string &filename, const CFileProvider &fp)
Definition vgm.cpp:54
static char filename[]
Definition features.c:5
unsigned short uint16_t
Definition mid.cpp:99
int int32_t
Definition mid.cpp:97
unsigned int uint32_t
Definition mid.cpp:100
short int16_t
Definition mid.cpp:96
unsigned char uint8_t
Definition mid.cpp:98
signed char int8_t
Definition mid.cpp:95
Definition vgm.h:97
wchar_t system_en[256]
Definition vgm.h:100
wchar_t ripper[256]
Definition vgm.h:102
wchar_t author_jp[256]
Definition vgm.h:101
wchar_t date[256]
Definition vgm.h:102
wchar_t game_en[256]
Definition vgm.h:99
wchar_t title_jp[256]
Definition vgm.h:98
wchar_t game_jp[256]
Definition vgm.h:99
wchar_t system_jp[256]
Definition vgm.h:100
wchar_t author_en[256]
Definition vgm.h:101
wchar_t notes[256]
Definition vgm.h:102
wchar_t title_en[256]
Definition vgm.h:98