2007-05-30 21:56:52 +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.
|
2002-08-18 16:21:34 +00:00
|
|
|
*
|
|
|
|
* 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.
|
2014-02-18 01:34:17 +00:00
|
|
|
*
|
2002-08-18 16:21:34 +00:00
|
|
|
* 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.
|
2014-02-18 01:34:17 +00:00
|
|
|
*
|
2002-08-18 16:21:34 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-08-18 16:21:34 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
#ifndef AGOS_MIDI_H
|
|
|
|
#define AGOS_MIDI_H
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mididrv.h"
|
|
|
|
#include "audio/midiparser.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/mutex.h"
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2005-05-10 22:56:25 +00:00
|
|
|
namespace Common {
|
2011-04-25 19:29:26 +00:00
|
|
|
class File;
|
2005-05-10 22:56:25 +00:00
|
|
|
}
|
2002-11-18 09:08:45 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
namespace AGOS {
|
2003-10-03 19:42:27 +00:00
|
|
|
|
2015-07-01 10:40:16 +00:00
|
|
|
enum kMusicMode {
|
|
|
|
kMusicModeDisabled = 0,
|
|
|
|
kMusicModeAccolade = 1,
|
2015-07-23 20:33:56 +00:00
|
|
|
kMusicModeMilesAudio = 2,
|
|
|
|
kMusicModeSimon1 = 3
|
2015-07-01 10:40:16 +00:00
|
|
|
};
|
|
|
|
|
2003-05-24 01:26:05 +00:00
|
|
|
struct MusicInfo {
|
|
|
|
MidiParser *parser;
|
2006-05-12 08:49:04 +00:00
|
|
|
byte *data;
|
|
|
|
byte num_songs; // For Type 1 SMF resources
|
|
|
|
byte *songs[16]; // For Type 1 SMF resources
|
2003-05-24 03:55:37 +00:00
|
|
|
uint32 song_sizes[16]; // For Type 1 SMF resources
|
2003-08-11 05:25:33 +00:00
|
|
|
|
2003-05-24 03:55:37 +00:00
|
|
|
MidiChannel *channel[16]; // Dynamic remapping of channels to resolve conflicts
|
2003-08-11 05:25:33 +00:00
|
|
|
byte volume[16]; // Current channel volume
|
2003-05-24 01:26:05 +00:00
|
|
|
|
|
|
|
MusicInfo() { clear(); }
|
|
|
|
void clear() {
|
|
|
|
parser = 0; data = 0; num_songs = 0;
|
2006-05-12 08:49:04 +00:00
|
|
|
memset(songs, 0, sizeof(songs));
|
|
|
|
memset(song_sizes, 0, sizeof(song_sizes));
|
|
|
|
memset(channel, 0, sizeof(channel));
|
2003-05-24 01:26:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-03-23 14:23:26 +00:00
|
|
|
class MidiPlayer : public MidiDriver_BASE {
|
2003-05-18 23:55:53 +00:00
|
|
|
protected:
|
2005-01-28 22:05:51 +00:00
|
|
|
Common::Mutex _mutex;
|
2003-05-18 23:55:53 +00:00
|
|
|
MidiDriver *_driver;
|
2003-07-14 08:29:17 +00:00
|
|
|
bool _map_mt32_to_gm;
|
MIDI: Send a reset MIDI device signal on startup.
This is currently done in the engine code. I adapted AGI, AGOS, DRACI,
GROOVIE, LURE, MADE, QUEEN, SAGA, SKY, TINSEL and TOUCHE to send a reset
device on startup. The sound output still works fine (started up a game
from every engine), so this should hopefully not introduce any regressions.
As far as I can tell it seems that SCUMM does send a proper device reset, so
I did not touch it. KYRA only sends a proper reset for MT-32 currently. I am
not sure about SCI though.
This fixes bug #3066826 "SIMON: MIDI notes off when using RTL after SCI".
svn-id: r52736
2010-09-15 22:00:20 +00:00
|
|
|
bool _nativeMT32;
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2003-05-24 01:26:05 +00:00
|
|
|
MusicInfo _music;
|
|
|
|
MusicInfo _sfx;
|
|
|
|
MusicInfo *_current; // Allows us to establish current context for operations.
|
|
|
|
|
|
|
|
// These are maintained for both music and SFX
|
2002-11-18 09:08:45 +00:00
|
|
|
byte _masterVolume; // 0-255
|
2008-07-14 22:10:04 +00:00
|
|
|
byte _musicVolume;
|
|
|
|
byte _sfxVolume;
|
2002-11-18 09:08:45 +00:00
|
|
|
bool _paused;
|
2003-05-24 01:26:05 +00:00
|
|
|
|
|
|
|
// These are only used for music.
|
2003-05-18 23:55:53 +00:00
|
|
|
byte _currentTrack;
|
2015-07-05 00:58:35 +00:00
|
|
|
bool _loopTrack;
|
2003-05-21 04:36:09 +00:00
|
|
|
byte _queuedTrack;
|
|
|
|
bool _loopQueuedTrack;
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2003-08-11 05:25:33 +00:00
|
|
|
protected:
|
2006-05-12 08:49:04 +00:00
|
|
|
static void onTimer(void *data);
|
2003-05-18 23:55:53 +00:00
|
|
|
void clearConstructs();
|
2006-05-12 08:49:04 +00:00
|
|
|
void clearConstructs(MusicInfo &info);
|
2003-08-11 05:25:33 +00:00
|
|
|
void resetVolumeTable();
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2003-05-18 23:55:53 +00:00
|
|
|
public:
|
2015-07-05 01:20:39 +00:00
|
|
|
bool _adLibMusic;
|
2003-05-24 01:26:05 +00:00
|
|
|
bool _enable_sfx;
|
2003-05-18 23:55:53 +00:00
|
|
|
|
2003-05-24 01:26:05 +00:00
|
|
|
public:
|
2007-02-16 13:41:38 +00:00
|
|
|
MidiPlayer();
|
2003-05-19 00:24:11 +00:00
|
|
|
virtual ~MidiPlayer();
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2006-05-12 08:49:04 +00:00
|
|
|
void loadSMF(Common::File *in, int song, bool sfx = false);
|
|
|
|
void loadMultipleSMF(Common::File *in, bool sfx = false);
|
|
|
|
void loadXMIDI(Common::File *in, bool sfx = false);
|
|
|
|
void loadS1D(Common::File *in, bool sfx = false);
|
2003-05-21 04:36:09 +00:00
|
|
|
|
2011-03-23 15:14:39 +00:00
|
|
|
bool hasNativeMT32() const { return _nativeMT32; }
|
2006-05-12 08:49:04 +00:00
|
|
|
void setLoop(bool loop);
|
2003-05-21 06:13:47 +00:00
|
|
|
void startTrack(int track);
|
2006-05-12 08:49:04 +00:00
|
|
|
void queueTrack(int track, bool loop);
|
|
|
|
bool isPlaying(bool check_queued = false) { return (_currentTrack != 255 && (_queuedTrack != 255 || !check_queued)); }
|
2003-05-21 04:36:09 +00:00
|
|
|
|
2003-05-18 23:55:53 +00:00
|
|
|
void stop();
|
2006-05-12 08:49:04 +00:00
|
|
|
void pause(bool b);
|
2002-08-18 16:21:34 +00:00
|
|
|
|
2011-03-23 16:07:48 +00:00
|
|
|
int getMusicVolume() const { return _musicVolume; }
|
|
|
|
int getSFXVolume() const { return _sfxVolume; }
|
2008-07-14 22:10:04 +00:00
|
|
|
void setVolume(int musicVol, int sfxVol);
|
2003-05-18 23:55:53 +00:00
|
|
|
|
|
|
|
public:
|
2015-06-20 22:45:45 +00:00
|
|
|
int open(int gameType, bool isDemo);
|
2011-03-23 15:14:39 +00:00
|
|
|
|
|
|
|
// MidiDriver_BASE interface implementation
|
|
|
|
virtual void send(uint32 b);
|
|
|
|
virtual void metaEvent(byte type, byte *data, uint16 length);
|
|
|
|
|
2015-06-20 22:45:45 +00:00
|
|
|
private:
|
2015-07-01 10:40:16 +00:00
|
|
|
kMusicMode _musicMode;
|
2019-05-02 17:24:41 +00:00
|
|
|
MusicType musicType;
|
|
|
|
|
2015-07-03 19:02:13 +00:00
|
|
|
private:
|
2015-07-04 10:55:49 +00:00
|
|
|
Common::SeekableReadStream *simon2SetupExtractFile(const Common::String &requestedFileName);
|
2002-08-18 16:21:34 +00:00
|
|
|
};
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
} // End of namespace AGOS
|
2003-10-03 19:42:27 +00:00
|
|
|
|
2002-08-18 16:21:34 +00:00
|
|
|
#endif
|