2 * Adplug - Replayer for many OPL2/OPL3 audio file formats.
3 * Copyright (C) 1999 - 2009 Simon Peter, <dn.tlp@gmx.net>, et al.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * cmf.h - CMF player by Adam Nielsen <malvineous@shikadi.net>
22 #include <stdint.h> // for uintxx_t
26 uint16_t iInstrumentBlockOffset;
27 uint16_t iMusicOffset;
28 uint16_t iTicksPerQuarterNote;
29 uint16_t iTicksPerSecond;
30 uint16_t iTagOffsetTitle;
31 uint16_t iTagOffsetComposer;
32 uint16_t iTagOffsetRemarks;
33 uint8_t iChannelsInUse[16];
34 uint16_t iNumInstruments;
40 uint8_t iScalingOutput;
42 uint8_t iSustainRelease;
47 OPERATOR op[2]; // 0 == modulator, 1 == carrier
52 int iPatch; // MIDI patch for this channel
53 int iPitchbend; // Current pitchbend amount for this channel
57 int iNoteStart; // When the note started playing (longest notes get cut first, 0 == channel free)
58 int iMIDINote; // MIDI note number currently being played on this OPL channel
59 int iMIDIChannel; // Source MIDI channel where this note came from
60 int iMIDIPatch; // Current MIDI patch set on this OPL channel
63 class CcmfPlayer: public CPlayer
66 uint8_t *data; // song data (CMF music block)
67 int iPlayPointer; // Current location of playback pointer
68 int iSongLen; // Max value for iPlayPointer
71 bool bPercussive; // are rhythm-mode instruments enabled?
72 uint8_t iCurrentRegs[256]; // Current values in the OPL chip
73 int iTranspose; // Transpose amount for entire song (between -128 and +128)
74 uint8_t iPrevCommand; // Previous command (used for repeated MIDI commands, as the seek and playback code need to share this)
76 int iNoteCount; // Used to count how long notes have been playing for
77 MIDICHANNEL chMIDI[16];
80 // Additions for AdPlug's design
83 std::string strTitle, strComposer, strRemarks;
86 static CPlayer *factory(Copl *newopl);
88 CcmfPlayer(Copl *newopl);
91 bool load(const std::string &filename, const CFileProvider &fp);
93 void rewind(int subsong);
97 { return std::string("Creative Music File (CMF)"); };
98 std::string gettitle();
99 std::string getauthor();
100 std::string getdesc();
103 uint32_t readMIDINumber();
104 void writeInstrumentSettings(uint8_t iChannel, uint8_t iOperatorSource, uint8_t iOperatorDest, uint8_t iInstrument);
105 void writeOPL(uint8_t iRegister, uint8_t iValue);
106 void cmfNoteOn(uint8_t iChannel, uint8_t iNote, uint8_t iVelocity);
107 void cmfNoteOff(uint8_t iChannel, uint8_t iNote, uint8_t iVelocity);
108 uint8_t getPercChannel(uint8_t iChannel);
109 void MIDIchangeInstrument(uint8_t iOPLChannel, uint8_t iMIDIChannel, uint8_t iNewInstrument);
110 void MIDIcontroller(uint8_t iChannel, uint8_t iController, uint8_t iValue);