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"
|
2007-06-26 23:40:22 +00:00
|
|
|
#include "sound/mp3.h"
|
|
|
|
#include "sound/vorbis.h"
|
|
|
|
#include "sound/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
|
|
|
};
|
|
|
|
|
|
|
|
class MusicPlayer : public MidiDriver {
|
|
|
|
public:
|
|
|
|
MusicPlayer(MidiDriver *driver);
|
|
|
|
~MusicPlayer();
|
2005-01-17 14:19:17 +00:00
|
|
|
|
|
|
|
bool isPlaying() { return _isPlaying; }
|
2007-08-22 16:00:45 +00:00
|
|
|
void setPlaying(bool playing) { _isPlaying = playing; }
|
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; }
|
|
|
|
|
2004-11-19 07:41:59 +00:00
|
|
|
void setNativeMT32(bool b) { _nativeMT32 = b; }
|
|
|
|
bool hasNativeMT32() { return _nativeMT32; }
|
2004-04-29 03:54:03 +00:00
|
|
|
void playMusic();
|
|
|
|
void stopMusic();
|
2004-05-01 13:04:31 +00:00
|
|
|
void setLoop(bool loop) { _looping = loop; }
|
2005-01-17 14:19:17 +00:00
|
|
|
void setPassThrough(bool b) { _passThrough = b; }
|
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
|
|
|
|
int open();
|
|
|
|
void close();
|
|
|
|
void send(uint32 b);
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
void metaEvent(byte type, byte *data, uint16 length);
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
void setTimerCallback(void *timerParam, void (*timerProc)(void *)) { }
|
2009-11-02 21:54:57 +00:00
|
|
|
uint32 getBaseTempo() { return _driver ? _driver->getBaseTempo() : 0; }
|
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; }
|
|
|
|
|
|
|
|
MidiParser *_parser;
|
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;
|
|
|
|
byte _channelVolume[16];
|
|
|
|
bool _nativeMT32;
|
2004-04-30 07:13:26 +00:00
|
|
|
bool _isGM;
|
2004-10-21 22:40:06 +00:00
|
|
|
bool _passThrough;
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2004-04-29 03:54:03 +00:00
|
|
|
bool _isPlaying;
|
|
|
|
bool _looping;
|
|
|
|
bool _randomLoop;
|
|
|
|
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
|
|
|
|
2008-07-01 03:01:11 +00:00
|
|
|
Music(SagaEngine *vm, Audio::Mixer *mixer, MidiDriver *driver);
|
2009-11-02 21:54:57 +00:00
|
|
|
~Music();
|
2004-11-19 07:41:59 +00:00
|
|
|
void setNativeMT32(bool b) { _player->setNativeMT32(b); }
|
|
|
|
bool hasNativeMT32() { return _player->hasNativeMT32(); }
|
2004-11-20 17:19:15 +00:00
|
|
|
void setAdlib(bool b) { _adlib = b; }
|
|
|
|
bool hasAdlib() { return _adlib; }
|
2004-11-19 07:41:59 +00:00
|
|
|
void setPassThrough(bool b) { _player->setPassThrough(b); }
|
2009-11-02 21:54:57 +00:00
|
|
|
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
|
|
|
|
|
|
|
MusicPlayer *_player;
|
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
|
|
|
|
2004-11-20 17:19:15 +00:00
|
|
|
bool _adlib;
|
2004-11-15 03:03:48 +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
|
|
|
|
2007-07-12 08:52:07 +00:00
|
|
|
ResourceContext *_digitalMusicContext;
|
2005-07-19 19:05:52 +00:00
|
|
|
MidiParser *xmidiParser;
|
|
|
|
MidiParser *smfParser;
|
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);
|
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
|