LMMS
Loading...
Searching...
No Matches
cmf.h
Go to the documentation of this file.
1/*
2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2009 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 * cmf.h - CMF player by Adam Nielsen <malvineous@shikadi.net>
20 */
21
22#include <stdint.h> // for uintxx_t
23#include "player.h"
24
37
45
46typedef struct {
47 OPERATOR op[2]; // 0 == modulator, 1 == carrier
49} SBI;
50
51typedef struct {
52 int iPatch; // MIDI patch for this channel
53 int iPitchbend; // Current pitchbend amount for this channel
54 int iTranspose; // Transpose amount for this channel (between -128 and +128)
56
57typedef struct {
58 int iNoteStart; // When the note started playing (longest notes get cut first, 0 == channel free)
59 int iMIDINote; // MIDI note number currently being played on this OPL channel
60 int iMIDIChannel; // Source MIDI channel where this note came from
61 int iMIDIPatch; // Current MIDI patch set on this OPL channel
63
64class CcmfPlayer: public CPlayer
65{
66 private:
67 uint8_t *data; // song data (CMF music block)
68 int iPlayPointer; // Current location of playback pointer
69 int iSongLen; // Max value for iPlayPointer
72 bool bPercussive; // are rhythm-mode instruments enabled?
73 uint8_t iCurrentRegs[256]; // Current values in the OPL chip
74 uint8_t iPrevCommand; // Previous command (used for repeated MIDI commands, as the seek and playback code need to share this)
75 uint8_t iNotePlaying[16]; // Last note turned on, used for duplicate note check
76 bool bNoteFix[16]; // Fix duplicated Note On / Note Off
77
78 int iNoteCount; // Used to count how long notes have been playing for
81
82 // Additions for AdPlug's design
86
87 public:
88 static CPlayer *factory(Copl *newopl);
89
90 CcmfPlayer(Copl *newopl);
92
93 bool load(const std::string &filename, const CFileProvider &fp);
94 bool update();
95 void rewind(int subsong);
96 float getrefresh();
97
98 std::string gettype()
99 { return std::string("Creative Music File (CMF)"); };
100 std::string gettitle();
101 std::string getauthor();
102 std::string getdesc();
103
104 protected:
106 void writeInstrumentSettings(uint8_t iChannel, uint8_t iOperatorSource, uint8_t iOperatorDest, uint8_t iInstrument);
107 void writeOPL(uint8_t iRegister, uint8_t iValue);
108 void getFreq(uint8_t iChannel, uint8_t iNote, uint8_t * iBlock, uint16_t * iOPLFNum);
109 void cmfNoteOn(uint8_t iChannel, uint8_t iNote, uint8_t iVelocity);
110 void cmfNoteOff(uint8_t iChannel, uint8_t iNote, uint8_t iVelocity);
111 void cmfNoteUpdate(uint8_t iChannel);
113 void MIDIchangeInstrument(uint8_t iOPLChannel, uint8_t iMIDIChannel, uint8_t iNewInstrument);
114 void MIDIcontroller(uint8_t iChannel, uint8_t iController, uint8_t iValue);
115
116};
Definition fprovide.h:29
CPlayer(Copl *newopl)
Definition player.cpp:34
OPLCHANNEL chOPL[9]
Definition cmf.h:80
bool bPercussive
Definition cmf.h:72
bool bNoteFix[16]
Definition cmf.h:76
std::string strTitle
Definition cmf.h:85
void cmfNoteOn(uint8_t iChannel, uint8_t iNote, uint8_t iVelocity)
Definition cmf.cpp:546
void writeOPL(uint8_t iRegister, uint8_t iValue)
Definition cmf.cpp:523
bool update()
Definition cmf.cpp:221
SBI * pInstruments
Definition cmf.h:71
int iNoteCount
Definition cmf.h:78
uint8_t getPercChannel(uint8_t iChannel)
Definition cmf.cpp:756
int iDelayRemaining
Definition cmf.h:83
CcmfPlayer(Copl *newopl)
Definition cmf.cpp:91
bool bSongEnd
Definition cmf.h:84
static CPlayer * factory(Copl *newopl)
Definition cmf.cpp:86
uint32_t readMIDINumber()
Definition cmf.cpp:487
std::string gettype()
Definition cmf.h:98
void MIDIcontroller(uint8_t iChannel, uint8_t iController, uint8_t iValue)
Definition cmf.cpp:812
uint8_t iPrevCommand
Definition cmf.h:74
std::string strComposer
Definition cmf.h:85
float getrefresh()
Definition cmf.cpp:458
void cmfNoteOff(uint8_t iChannel, uint8_t iNote, uint8_t iVelocity)
Definition cmf.cpp:696
uint8_t iNotePlaying[16]
Definition cmf.h:75
bool load(const std::string &filename, const CFileProvider &fp)
Definition cmf.cpp:109
std::string getauthor()
Definition cmf.cpp:472
int iSongLen
Definition cmf.h:69
std::string getdesc()
Definition cmf.cpp:476
std::string gettitle()
Definition cmf.cpp:468
uint8_t * data
Definition cmf.h:67
int iPlayPointer
Definition cmf.h:68
CMFHEADER cmfHeader
Definition cmf.h:70
~CcmfPlayer()
Definition cmf.cpp:103
std::string strRemarks
Definition cmf.h:85
void writeInstrumentSettings(uint8_t iChannel, uint8_t iOperatorSource, uint8_t iOperatorDest, uint8_t iInstrument)
Definition cmf.cpp:504
uint8_t iCurrentRegs[256]
Definition cmf.h:73
MIDICHANNEL chMIDI[16]
Definition cmf.h:79
void getFreq(uint8_t iChannel, uint8_t iNote, uint8_t *iBlock, uint16_t *iOPLFNum)
Definition cmf.cpp:530
void cmfNoteUpdate(uint8_t iChannel)
Definition cmf.cpp:725
void MIDIchangeInstrument(uint8_t iOPLChannel, uint8_t iMIDIChannel, uint8_t iNewInstrument)
Definition cmf.cpp:770
void rewind(int subsong)
Definition cmf.cpp:386
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
Definition cmf.h:25
uint16_t iTagOffsetTitle
Definition cmf.h:30
uint16_t iNumInstruments
Definition cmf.h:34
uint8_t iChannelsInUse[16]
Definition cmf.h:33
uint16_t iTicksPerSecond
Definition cmf.h:29
uint16_t iTempo
Definition cmf.h:35
uint16_t iTagOffsetRemarks
Definition cmf.h:32
uint16_t iMusicOffset
Definition cmf.h:27
uint16_t iTicksPerQuarterNote
Definition cmf.h:28
uint16_t iInstrumentBlockOffset
Definition cmf.h:26
uint16_t iTagOffsetComposer
Definition cmf.h:31
Definition cmf.h:51
int iPatch
Definition cmf.h:52
int iTranspose
Definition cmf.h:54
int iPitchbend
Definition cmf.h:53
Definition cmf.h:38
uint8_t iScalingOutput
Definition cmf.h:40
uint8_t iCharMult
Definition cmf.h:39
uint8_t iSustainRelease
Definition cmf.h:42
uint8_t iWaveSel
Definition cmf.h:43
uint8_t iAttackDecay
Definition cmf.h:41
Definition cmf.h:57
int iMIDIPatch
Definition cmf.h:61
int iMIDIChannel
Definition cmf.h:60
int iMIDINote
Definition cmf.h:59
int iNoteStart
Definition cmf.h:58
Definition cmf.h:46
OPERATOR op[2]
Definition cmf.h:47
uint8_t iConnection
Definition cmf.h:48