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.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2004-04-29 03:54:03 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:24 +01:00
|
|
|
*
|
2004-04-29 03:54:03 +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.
|
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
|
|
|
|
2011-03-25 16:59:54 +01:00
|
|
|
#include "audio/midiplayer.h"
|
2011-03-25 18:10:40 +01:00
|
|
|
#include "audio/midiparser.h"
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mixer.h"
|
|
|
|
#include "audio/decoders/mp3.h"
|
|
|
|
#include "audio/decoders/vorbis.h"
|
|
|
|
#include "audio/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,
|
2014-07-20 16:04:43 +03:00
|
|
|
MUSIC_LOOP = 0x0001
|
2004-04-29 03:54:03 +00:00
|
|
|
};
|
|
|
|
|
2011-03-25 16:59:54 +01:00
|
|
|
class MusicDriver : public Audio::MidiPlayer {
|
2004-04-29 03:54:03 +00:00
|
|
|
public:
|
2010-06-12 18:20:22 +00:00
|
|
|
MusicDriver();
|
2005-01-17 14:19:17 +00:00
|
|
|
|
2011-03-25 16:59:54 +01:00
|
|
|
void play(SagaEngine *vm, ByteArray *buffer, bool loop);
|
2012-09-12 19:31:29 -04:00
|
|
|
void playQuickTime(const Common::String &musicName, bool loop);
|
2011-03-25 16:59:54 +01:00
|
|
|
virtual void pause();
|
|
|
|
virtual void resume();
|
2004-05-01 13:04:31 +00:00
|
|
|
|
2011-03-28 18:06:24 +02:00
|
|
|
bool isAdlib() const { return _driverType == MT_ADLIB; }
|
2011-03-25 16:59:54 +01:00
|
|
|
|
|
|
|
// FIXME
|
|
|
|
bool isPlaying() const { return _parser && _parser->isPlaying(); }
|
2004-04-30 07:13:26 +00:00
|
|
|
|
2011-03-23 16:14:39 +01:00
|
|
|
// MidiDriver_BASE interface implementation
|
|
|
|
virtual void send(uint32 b);
|
2011-03-25 16:59:54 +01:00
|
|
|
virtual void metaEvent(byte type, byte *data, uint16 length);
|
2004-04-29 03:54:03 +00:00
|
|
|
|
|
|
|
protected:
|
2010-06-21 21:36:36 +00:00
|
|
|
MusicType _driverType;
|
2004-04-30 07:13:26 +00:00
|
|
|
bool _isGM;
|
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
|
|
|
|
2014-07-20 16:04:43 +03:00
|
|
|
void play(uint32 resourceId, MusicFlags flags = MUSIC_NORMAL);
|
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
|
|
|
|
2010-10-22 23:13:17 +00:00
|
|
|
Common::Array<int32> _songTable;
|
2005-08-30 11:16:11 +00:00
|
|
|
|
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
|
|
|
|
2011-03-25 16:59:54 +01:00
|
|
|
MusicDriver *_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
|
|
|
|
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;
|
2005-06-19 21:18:00 +00:00
|
|
|
|
2006-03-02 18:25:56 +00:00
|
|
|
|
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();
|
2010-10-24 22:17:44 +00:00
|
|
|
ByteArray *_currentMusicBuffer;
|
|
|
|
ByteArray _musicBuffer[2];
|
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
|