2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
2004-04-29 03:54:03 +00:00
|
|
|
*
|
2007-05-30 21:56:52 +00:00
|
|
|
* 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.
|
2004-04-29 03:54:03 +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.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2008-01-05 12:45:14 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-04-29 03:54:03 +00:00
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-29 03:54:03 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-29 03:54:03 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 13:04:31 +00:00
|
|
|
// Music class
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2007-02-19 17:30:43 +00:00
|
|
|
#ifndef SAGA_MUSIC_H
|
|
|
|
#define SAGA_MUSIC_H
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2005-09-20 18:04:26 +00:00
|
|
|
#include "sound/audiocd.h"
|
2004-04-29 03:54:03 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/midiparser.h"
|
2010-01-26 22:48:45 +00:00
|
|
|
#include "sound/decoders/mp3.h"
|
|
|
|
#include "sound/decoders/vorbis.h"
|
|
|
|
#include "sound/decoders/flac.h"
|
2007-08-22 15:28:31 +00:00
|
|
|
#include "common/mutex.h"
|
2004-04-29 03:54:03 +00:00
|
|
|
|
|
|
|
namespace Saga {
|
2005-07-19 19:05:52 +00:00
|
|
|
|
|
|
|
enum MusicFlags {
|
|
|
|
MUSIC_NORMAL = 0,
|
2004-10-27 21:32:28 +00:00
|
|
|
MUSIC_LOOP = 0x0001,
|
|
|
|
MUSIC_DEFAULT = 0xffff
|
2004-04-29 03:54:03 +00:00
|
|
|
};
|
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
class MusicDriver : public MidiDriver {
|
2004-04-29 03:54:03 +00:00
|
|
|
public:
|
2010-06-12 18:20:22 +00:00
|
|
|
MusicDriver();
|
|
|
|
~MusicDriver();
|
2005-01-17 14:19:17 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
void setVolume(int volume);
|
2004-05-01 13:04:31 +00:00
|
|
|
int getVolume() { return _masterVolume; }
|
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
bool isAdlib() { return _driverType == MD_ADLIB; }
|
|
|
|
bool isMT32() { return _driverType == MD_MT32 || _nativeMT32; }
|
2004-05-01 13:04:31 +00:00
|
|
|
void setGM(bool isGM) { _isGM = isGM; }
|
2004-04-30 07:13:26 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
//MidiDriver interface implementation
|
2010-06-12 18:20:22 +00:00
|
|
|
int open() { return _driver->open(); }
|
|
|
|
void close() { _driver->close(); }
|
2004-04-29 03:54:03 +00:00
|
|
|
void send(uint32 b);
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
void metaEvent(byte type, byte *data, uint16 length) {}
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
void setTimerCallback(void *timerParam, void (*timerProc)(void *)) { _driver->setTimerCallback(timerParam, timerProc); }
|
|
|
|
uint32 getBaseTempo() { return _driver->getBaseTempo(); }
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
//Channel allocation functions
|
|
|
|
MidiChannel *allocateChannel() { return 0; }
|
|
|
|
MidiChannel *getPercussionChannel() { return 0; }
|
|
|
|
|
2007-08-22 15:28:31 +00:00
|
|
|
Common::Mutex _mutex;
|
2004-04-29 03:54:03 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
static void onTimer(void *data);
|
|
|
|
|
|
|
|
MidiChannel *_channel[16];
|
|
|
|
MidiDriver *_driver;
|
2010-06-12 18:20:22 +00:00
|
|
|
MidiDriverType _driverType;
|
2004-04-29 03:54:03 +00:00
|
|
|
byte _channelVolume[16];
|
2004-04-30 07:13:26 +00:00
|
|
|
bool _isGM;
|
2010-06-12 18:20:22 +00:00
|
|
|
bool _nativeMT32;
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
byte _masterVolume;
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
byte *_musicData;
|
|
|
|
uint16 *_buf;
|
2006-03-02 18:25:56 +00:00
|
|
|
size_t _musicDataSize;
|
2004-04-29 03:54:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Music {
|
2004-05-01 13:04:31 +00:00
|
|
|
public:
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
Music(SagaEngine *vm, Audio::Mixer *mixer);
|
2009-11-02 21:54:57 +00:00
|
|
|
~Music();
|
|
|
|
bool isPlaying();
|
2008-11-11 17:34:52 +00:00
|
|
|
bool hasDigitalMusic() { return _digitalMusic; }
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
void play(uint32 resourceId, MusicFlags flags = MUSIC_DEFAULT);
|
2009-11-02 21:54:57 +00:00
|
|
|
void pause();
|
|
|
|
void resume();
|
|
|
|
void stop();
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2005-08-11 22:00:32 +00:00
|
|
|
void setVolume(int volume, int time = 1);
|
|
|
|
int getVolume() { return _currentVolume; }
|
2005-06-19 21:18:00 +00:00
|
|
|
|
2005-08-30 11:16:11 +00:00
|
|
|
int32 *_songTable;
|
|
|
|
int _songTableLen;
|
|
|
|
|
2004-05-01 13:04:31 +00:00
|
|
|
private:
|
2005-07-19 19:05:52 +00:00
|
|
|
SagaEngine *_vm;
|
2005-05-10 23:48:48 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
MusicDriver *_driver;
|
2005-05-11 00:01:44 +00:00
|
|
|
Audio::SoundHandle _musicHandle;
|
2005-01-17 14:19:17 +00:00
|
|
|
uint32 _trackNumber;
|
2004-04-29 03:54:03 +00:00
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
int _targetVolume;
|
|
|
|
int _currentVolume;
|
|
|
|
int _currentVolumePercent;
|
2008-11-11 17:34:52 +00:00
|
|
|
bool _digitalMusic;
|
2005-06-19 21:18:00 +00:00
|
|
|
|
2010-06-12 18:20:22 +00:00
|
|
|
ResourceContext *_musicContext;
|
2007-07-12 08:52:07 +00:00
|
|
|
ResourceContext *_digitalMusicContext;
|
2010-06-12 18:20:22 +00:00
|
|
|
MidiParser *_parser;
|
2005-06-19 21:18:00 +00:00
|
|
|
|
2006-03-02 18:25:56 +00:00
|
|
|
byte *_midiMusicData;
|
|
|
|
|
2005-06-19 21:18:00 +00:00
|
|
|
static void musicVolumeGaugeCallback(void *refCon);
|
2010-06-12 18:20:22 +00:00
|
|
|
static void onTimer(void *refCon);
|
2009-11-02 21:54:57 +00:00
|
|
|
void musicVolumeGauge();
|
2004-05-01 13:04:31 +00:00
|
|
|
};
|
2004-04-29 03:54:03 +00:00
|
|
|
|
|
|
|
} // End of namespace Saga
|
|
|
|
|
2004-05-01 13:04:31 +00:00
|
|
|
#endif
|