2009-12-27 02:46:00 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program 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; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program 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 this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SCI_MIDIPARSER_H
|
|
|
|
#define SCI_MIDIPARSER_H
|
|
|
|
|
|
|
|
#include "sci/resource.h"
|
2010-01-05 01:22:16 +00:00
|
|
|
#include "sci/sound/music.h"
|
2009-12-27 02:46:00 +00:00
|
|
|
#include "sound/midiparser.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Sound drivers info: (from driver cmd0)
|
2010-01-12 21:07:56 +00:00
|
|
|
AdLib/SB : track 0 , voices 9 , patch 3 ah=1
|
2009-12-27 02:46:00 +00:00
|
|
|
ProAudioSp: track 0 , voices 9 , patch 3 ah=17
|
|
|
|
GenerlMIDI: track 7 , voices 32, patch 4 ah=1 SCI1.1
|
|
|
|
Game Blast: track 9 , voices 12, patch 101 ah=1
|
|
|
|
MT-32 : track 12, voices 32, patch 1 ah=1
|
|
|
|
PC Speaker: track 18, voices 1 , patch 0xFF ah=1
|
|
|
|
Tandy : track 19, voices 3 , patch 101 ah=1
|
|
|
|
IBM PS/1 : track 19, voices 3 , patch 101 ah=1
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Sci {
|
|
|
|
|
2010-01-13 08:14:16 +00:00
|
|
|
/**
|
|
|
|
* An extended standard MIDI (SMF) parser. Sierra used an extra channel
|
|
|
|
* with special commands for extended functionality and animation syncing.
|
|
|
|
* Refer to MidiParser_SMF() in /sound/midiparser_smf.cpp for the standard
|
|
|
|
* MIDI (SMF) parser functionality that the SCI MIDI parser is based on
|
|
|
|
*/
|
2009-12-27 02:46:00 +00:00
|
|
|
class MidiParser_SCI : public MidiParser {
|
|
|
|
public:
|
2010-06-16 21:02:58 +00:00
|
|
|
MidiParser_SCI(SciVersion soundVersion, SciMusic *music);
|
2009-12-27 02:46:00 +00:00
|
|
|
~MidiParser_SCI();
|
2010-06-21 22:07:03 +00:00
|
|
|
|
|
|
|
void mainThreadBegin();
|
|
|
|
void mainThreadEnd();
|
|
|
|
|
2009-12-27 02:46:00 +00:00
|
|
|
bool loadMusic(SoundResource::Track *track, MusicEntry *psnd, int channelFilterMask, SciVersion soundVersion);
|
|
|
|
bool loadMusic(byte *, uint32) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-19 20:23:55 +00:00
|
|
|
void sendInitCommands();
|
2009-12-27 02:46:00 +00:00
|
|
|
void unloadMusic();
|
2010-09-01 19:20:17 +00:00
|
|
|
void setMasterVolume(byte masterVolume);
|
2010-01-05 10:28:09 +00:00
|
|
|
void setVolume(byte volume);
|
2009-12-27 02:46:00 +00:00
|
|
|
void stop() {
|
2009-12-28 10:42:14 +00:00
|
|
|
_abort_parse = true;
|
|
|
|
allNotesOff();
|
2009-12-27 02:46:00 +00:00
|
|
|
}
|
|
|
|
void pause() {
|
2009-12-28 10:42:14 +00:00
|
|
|
allNotesOff();
|
2010-01-22 12:26:12 +00:00
|
|
|
if (_resetOnPause)
|
|
|
|
jumpToTick(0);
|
2009-12-27 02:46:00 +00:00
|
|
|
}
|
|
|
|
|
2010-06-14 22:35:49 +00:00
|
|
|
void allNotesOff();
|
|
|
|
|
2010-06-11 14:47:13 +00:00
|
|
|
const byte *getMixedData() const { return _mixedData; }
|
2010-11-25 16:09:45 +00:00
|
|
|
byte getSongReverb();
|
2010-06-11 14:47:13 +00:00
|
|
|
|
2010-06-16 21:02:58 +00:00
|
|
|
void tryToOwnChannels();
|
2010-06-27 21:41:30 +00:00
|
|
|
void lostChannels();
|
2010-06-21 22:07:03 +00:00
|
|
|
void sendFromScriptToDriver(uint32 midi);
|
|
|
|
void sendToDriver(uint32 midi);
|
2010-06-18 13:36:29 +00:00
|
|
|
void sendToDriver(byte status, byte firstOp, byte secondOp) {
|
|
|
|
sendToDriver(status | ((uint32)firstOp << 8) | ((uint32)secondOp << 16));
|
|
|
|
}
|
2010-06-03 21:57:49 +00:00
|
|
|
|
2010-06-16 21:02:58 +00:00
|
|
|
protected:
|
2009-12-27 02:46:00 +00:00
|
|
|
void parseNextEvent(EventInfo &info);
|
|
|
|
byte *midiMixChannels();
|
|
|
|
byte *midiFilterChannels(int channelMask);
|
|
|
|
byte midiGetNextChannel(long ticker);
|
|
|
|
|
2010-06-16 21:02:58 +00:00
|
|
|
SciMusic *_music;
|
|
|
|
|
2010-06-21 22:07:03 +00:00
|
|
|
// this is set, when main thread calls us -> we send commands to queue instead to driver
|
|
|
|
bool _mainThreadCalled;
|
|
|
|
|
2009-12-27 02:46:00 +00:00
|
|
|
SciVersion _soundVersion;
|
|
|
|
byte *_mixedData;
|
|
|
|
SoundResource::Track *_track;
|
|
|
|
MusicEntry *_pSnd;
|
|
|
|
uint32 _loopTick;
|
2010-09-01 19:20:17 +00:00
|
|
|
byte _masterVolume; // the overall master volume (same for all tracks)
|
|
|
|
byte _volume; // the global volume of the current track
|
2009-12-27 02:46:00 +00:00
|
|
|
|
|
|
|
bool _signalSet;
|
|
|
|
int16 _signalToSet;
|
2010-01-21 22:33:35 +00:00
|
|
|
bool _dataincAdd;
|
|
|
|
int16 _dataincToAdd;
|
2010-01-22 12:26:12 +00:00
|
|
|
bool _resetOnPause;
|
2010-01-15 07:40:07 +00:00
|
|
|
|
2010-06-16 21:02:58 +00:00
|
|
|
bool _channelUsed[16];
|
|
|
|
int16 _channelRemap[16];
|
2010-06-17 11:54:54 +00:00
|
|
|
bool _channelMuted[16];
|
2010-06-28 09:22:57 +00:00
|
|
|
byte _channelVolume[16];
|
2009-12-27 02:46:00 +00:00
|
|
|
};
|
|
|
|
|
2009-12-28 21:00:59 +00:00
|
|
|
} // End of namespace Sci
|
2009-12-27 02:46:00 +00:00
|
|
|
|
|
|
|
#endif
|