2008-11-14 21:32:20 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GROOVIE_MUSIC_H
|
|
|
|
#define GROOVIE_MUSIC_H
|
|
|
|
|
2010-06-07 17:14:42 +00:00
|
|
|
#include "common/array.h"
|
2008-11-18 19:29:51 +00:00
|
|
|
#include "common/mutex.h"
|
2010-06-07 17:14:42 +00:00
|
|
|
|
|
|
|
class MidiParser;
|
2008-11-14 21:32:20 +00:00
|
|
|
|
|
|
|
namespace Groovie {
|
|
|
|
|
2010-06-07 17:14:42 +00:00
|
|
|
class GroovieEngine;
|
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
class MusicPlayer {
|
2008-11-14 21:32:20 +00:00
|
|
|
public:
|
2009-07-05 09:34:54 +00:00
|
|
|
MusicPlayer(GroovieEngine *vm);
|
2009-08-18 15:31:26 +00:00
|
|
|
virtual ~MusicPlayer();
|
2009-07-05 09:34:54 +00:00
|
|
|
|
2009-03-10 21:54:45 +00:00
|
|
|
void playSong(uint32 fileref);
|
|
|
|
void setBackgroundSong(uint32 fileref);
|
2008-11-25 00:41:51 +00:00
|
|
|
void playCD(uint8 track);
|
2009-01-28 23:29:19 +00:00
|
|
|
void startBackground();
|
2008-11-14 21:32:20 +00:00
|
|
|
|
2009-08-05 13:57:40 +00:00
|
|
|
void frameTick();
|
|
|
|
void setBackgroundDelay(uint16 delay);
|
|
|
|
|
2008-11-14 21:32:20 +00:00
|
|
|
// Volume
|
|
|
|
void setUserVolume(uint16 volume);
|
|
|
|
void setGameVolume(uint16 volume, uint16 time);
|
2008-11-24 21:53:23 +00:00
|
|
|
|
2008-11-14 21:32:20 +00:00
|
|
|
private:
|
2009-07-05 09:34:54 +00:00
|
|
|
// Song playback
|
|
|
|
bool play(uint32 fileref, bool loop);
|
|
|
|
bool _isPlaying;
|
|
|
|
uint32 _backgroundFileRef;
|
|
|
|
uint8 _prevCDtrack;
|
2008-11-24 21:53:23 +00:00
|
|
|
|
2009-08-05 13:57:40 +00:00
|
|
|
uint16 _backgroundDelay;
|
|
|
|
|
2011-04-13 12:49:21 +00:00
|
|
|
// T7G iOS credits mp3 stream
|
|
|
|
void playCreditsIOS();
|
|
|
|
void stopCreditsIOS();
|
|
|
|
Audio::SoundHandle _handleCreditsIOS;
|
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
// Volume fading
|
2008-11-24 21:53:23 +00:00
|
|
|
uint32 _fadingStartTime;
|
|
|
|
uint16 _fadingStartVolume;
|
|
|
|
uint16 _fadingEndVolume;
|
|
|
|
uint16 _fadingDuration;
|
|
|
|
void applyFading();
|
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
protected:
|
|
|
|
GroovieEngine *_vm;
|
|
|
|
|
|
|
|
// Callback
|
|
|
|
static void onTimer(void *data);
|
|
|
|
virtual void onTimerInternal() {}
|
|
|
|
Common::Mutex _mutex;
|
|
|
|
|
|
|
|
// User volume
|
|
|
|
uint16 _userVolume;
|
|
|
|
// Game volume
|
|
|
|
uint16 _gameVolume;
|
|
|
|
|
|
|
|
// These are specific for each type of music
|
|
|
|
virtual void updateVolume() = 0;
|
|
|
|
virtual bool load(uint32 fileref, bool loop) = 0;
|
|
|
|
virtual void unload();
|
|
|
|
};
|
|
|
|
|
2011-03-23 14:23:26 +00:00
|
|
|
class MusicPlayerMidi : public MusicPlayer, public MidiDriver_BASE {
|
2009-07-05 09:34:54 +00:00
|
|
|
public:
|
|
|
|
MusicPlayerMidi(GroovieEngine *vm);
|
|
|
|
~MusicPlayerMidi();
|
|
|
|
|
2011-03-23 15:14:39 +00:00
|
|
|
// MidiDriver_BASE interface
|
2011-03-04 19:17:17 +00:00
|
|
|
virtual void send(uint32 b);
|
|
|
|
virtual void metaEvent(byte type, byte *data, uint16 length);
|
2009-07-05 09:34:54 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Channel volumes
|
2008-11-14 21:32:20 +00:00
|
|
|
byte _chanVolumes[0x10];
|
|
|
|
void updateChanVolume(byte channel);
|
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
void endTrack();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
byte *_data;
|
|
|
|
MidiParser *_midiParser;
|
|
|
|
MidiDriver *_driver;
|
|
|
|
|
2011-03-04 19:17:17 +00:00
|
|
|
virtual void onTimerInternal();
|
2009-07-05 09:34:54 +00:00
|
|
|
void updateVolume();
|
|
|
|
void unload();
|
|
|
|
|
|
|
|
bool loadParser(Common::SeekableReadStream *stream, bool loop);
|
|
|
|
};
|
|
|
|
|
|
|
|
class MusicPlayerXMI : public MusicPlayerMidi {
|
|
|
|
public:
|
|
|
|
MusicPlayerXMI(GroovieEngine *vm, const Common::String >lName);
|
|
|
|
~MusicPlayerXMI();
|
|
|
|
|
|
|
|
void send(uint32 b);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool load(uint32 fileref, bool loop);
|
|
|
|
|
|
|
|
private:
|
2008-12-19 16:55:54 +00:00
|
|
|
// Channel banks
|
|
|
|
byte _chanBanks[0x10];
|
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
// Output music type
|
|
|
|
uint8 _musicType;
|
|
|
|
|
2008-12-19 16:55:54 +00:00
|
|
|
// Timbres
|
|
|
|
class Timbre {
|
|
|
|
public:
|
|
|
|
Timbre() : data(NULL) {}
|
|
|
|
byte patch;
|
|
|
|
byte bank;
|
|
|
|
uint32 size;
|
|
|
|
byte *data;
|
|
|
|
};
|
|
|
|
Common::Array<Timbre> _timbres;
|
|
|
|
void loadTimbres(const Common::String &filename);
|
|
|
|
void clearTimbres();
|
|
|
|
void setTimbreAD(byte channel, const Timbre &timbre);
|
|
|
|
void setTimbreMT(byte channel, const Timbre &timbre);
|
2009-07-05 09:34:54 +00:00
|
|
|
};
|
2008-12-19 16:55:54 +00:00
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
class MusicPlayerMac : public MusicPlayerMidi {
|
2008-11-14 21:32:20 +00:00
|
|
|
public:
|
2009-07-05 09:34:54 +00:00
|
|
|
MusicPlayerMac(GroovieEngine *vm);
|
2008-11-14 21:32:20 +00:00
|
|
|
|
2009-07-05 09:34:54 +00:00
|
|
|
protected:
|
|
|
|
bool load(uint32 fileref, bool loop);
|
2010-06-22 19:21:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Common::SeekableReadStream *decompressMidi(Common::SeekableReadStream *stream);
|
2008-11-14 21:32:20 +00:00
|
|
|
};
|
|
|
|
|
2011-05-31 18:25:20 +00:00
|
|
|
class MusicPlayerIOS : public MusicPlayer {
|
2011-04-07 14:51:39 +00:00
|
|
|
public:
|
2011-05-31 18:25:20 +00:00
|
|
|
MusicPlayerIOS(GroovieEngine *vm);
|
|
|
|
~MusicPlayerIOS();
|
2011-04-07 14:51:39 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void updateVolume();
|
|
|
|
bool load(uint32 fileref, bool loop);
|
2011-04-13 12:52:19 +00:00
|
|
|
void unload();
|
2011-04-07 23:39:22 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Audio::SoundHandle _handle;
|
2011-04-07 14:51:39 +00:00
|
|
|
};
|
|
|
|
|
2008-11-14 21:32:20 +00:00
|
|
|
} // End of Groovie namespace
|
|
|
|
|
|
|
|
#endif // GROOVIE_MUSIC_H
|