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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GROOVIE_MUSIC_H
|
|
|
|
#define GROOVIE_MUSIC_H
|
|
|
|
|
|
|
|
#include "groovie/groovie.h"
|
|
|
|
|
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/midiparser.h"
|
2008-11-18 19:29:51 +00:00
|
|
|
#include "common/mutex.h"
|
2008-11-14 21:32:20 +00:00
|
|
|
|
|
|
|
namespace Groovie {
|
|
|
|
|
|
|
|
class MusicPlayer : public MidiDriver {
|
|
|
|
public:
|
2009-01-01 22:49:44 +00:00
|
|
|
MusicPlayer(GroovieEngine *vm, const Common::String >lName);
|
2008-11-14 21:32:20 +00:00
|
|
|
~MusicPlayer();
|
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
|
|
|
|
|
|
|
// 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:
|
2008-11-24 21:53:23 +00:00
|
|
|
// User volume
|
2008-11-14 21:32:20 +00:00
|
|
|
uint16 _userVolume;
|
2008-11-24 21:53:23 +00:00
|
|
|
|
|
|
|
// Game volume
|
2008-11-14 21:32:20 +00:00
|
|
|
uint16 _gameVolume;
|
2008-11-24 21:53:23 +00:00
|
|
|
uint32 _fadingStartTime;
|
|
|
|
uint16 _fadingStartVolume;
|
|
|
|
uint16 _fadingEndVolume;
|
|
|
|
uint16 _fadingDuration;
|
2009-01-08 23:01:34 +00:00
|
|
|
void endTrack();
|
2008-11-24 21:53:23 +00:00
|
|
|
void applyFading();
|
|
|
|
|
|
|
|
// Song volumes
|
2008-11-14 21:32:20 +00:00
|
|
|
byte _chanVolumes[0x10];
|
|
|
|
void updateChanVolume(byte channel);
|
|
|
|
|
2008-12-19 16:55:54 +00:00
|
|
|
// Channel banks
|
|
|
|
byte _chanBanks[0x10];
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
2008-11-14 21:32:20 +00:00
|
|
|
public:
|
|
|
|
// MidiDriver interface
|
|
|
|
int open();
|
|
|
|
void close();
|
|
|
|
void send(uint32 b);
|
|
|
|
void metaEvent(byte type, byte *data, uint16 length);
|
|
|
|
void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc);
|
|
|
|
uint32 getBaseTempo(void);
|
|
|
|
MidiChannel *allocateChannel();
|
|
|
|
MidiChannel *getPercussionChannel();
|
|
|
|
|
|
|
|
private:
|
|
|
|
GroovieEngine *_vm;
|
2008-11-18 19:29:51 +00:00
|
|
|
Common::Mutex _mutex;
|
2008-11-14 21:32:20 +00:00
|
|
|
byte *_data;
|
|
|
|
MidiParser *_midiParser;
|
|
|
|
MidiDriver *_driver;
|
2008-12-19 16:55:54 +00:00
|
|
|
uint8 _musicType;
|
2009-01-28 23:29:19 +00:00
|
|
|
bool _isPlaying;
|
2008-11-14 21:32:20 +00:00
|
|
|
|
2009-03-10 21:54:45 +00:00
|
|
|
uint32 _backgroundFileRef;
|
2008-11-25 00:41:51 +00:00
|
|
|
uint8 _prevCDtrack;
|
2008-11-14 21:32:20 +00:00
|
|
|
|
2008-11-18 19:29:51 +00:00
|
|
|
static void onTimer(void *data);
|
|
|
|
|
2009-03-10 21:54:45 +00:00
|
|
|
bool play(uint32 fileref, bool loop);
|
|
|
|
bool load(uint32 fileref);
|
2008-11-14 21:32:20 +00:00
|
|
|
void unload();
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of Groovie namespace
|
|
|
|
|
|
|
|
#endif // GROOVIE_MUSIC_H
|