2007-05-30 21:56:52 +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.
|
2003-12-16 02:10:15 +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
|
2003-12-16 02:10:15 +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.
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
2006-02-11 10:01:01 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-12-16 02:10:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-20 18:04:13 +00:00
|
|
|
#ifndef SWORD1_MUSIC_H
|
|
|
|
#define SWORD1_MUSIC_H
|
2003-12-16 02:10:15 +00:00
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/scummsys.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/mutex.h"
|
2003-12-16 02:10:15 +00:00
|
|
|
#include "common/file.h"
|
2004-01-01 15:22:15 +00:00
|
|
|
#include "sound/audiostream.h"
|
2007-02-20 18:50:17 +00:00
|
|
|
#include "sound/mixer.h"
|
2004-01-01 15:22:15 +00:00
|
|
|
#include "sound/rate.h"
|
|
|
|
|
2004-01-11 15:47:41 +00:00
|
|
|
namespace Sword1 {
|
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#define TOTAL_TUNES 270
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
class MusicHandle : public Audio::AudioStream {
|
2004-01-01 15:22:15 +00:00
|
|
|
private:
|
2005-05-10 22:56:25 +00:00
|
|
|
Common::File _file;
|
2004-01-01 15:22:15 +00:00
|
|
|
int32 _fading;
|
2004-01-01 16:56:00 +00:00
|
|
|
int32 _fadeSamples;
|
2006-04-29 22:33:31 +00:00
|
|
|
Audio::AudioStream *_audioSource;
|
2004-01-01 15:22:15 +00:00
|
|
|
public:
|
2007-03-02 23:53:20 +00:00
|
|
|
MusicHandle() : _fading(0), _audioSource(NULL) {}
|
2004-01-01 15:22:15 +00:00
|
|
|
virtual int readBuffer(int16 *buffer, const int numSamples);
|
|
|
|
bool play(const char *filename, bool loop);
|
|
|
|
void stop();
|
|
|
|
void fadeUp();
|
|
|
|
void fadeDown();
|
2004-10-12 15:50:00 +00:00
|
|
|
bool streaming() const;
|
2004-01-01 15:22:15 +00:00
|
|
|
int32 fading() { return _fading; }
|
|
|
|
bool endOfData() const;
|
|
|
|
bool endOfStream() const { return false; }
|
2004-10-12 15:50:00 +00:00
|
|
|
bool isStereo() const;
|
|
|
|
int getRate() const;
|
2004-01-01 15:22:15 +00:00
|
|
|
};
|
|
|
|
|
2006-04-29 22:33:31 +00:00
|
|
|
class Music : public Audio::AudioStream {
|
2003-12-16 02:10:15 +00:00
|
|
|
public:
|
2005-05-10 23:48:48 +00:00
|
|
|
Music(Audio::Mixer *pMixer);
|
2004-01-11 15:47:41 +00:00
|
|
|
~Music();
|
2003-12-16 02:10:15 +00:00
|
|
|
void startMusic(int32 tuneId, int32 loopFlag);
|
2004-01-01 15:22:15 +00:00
|
|
|
void fadeDown();
|
2004-01-07 17:47:46 +00:00
|
|
|
void setVolume(uint8 volL, uint8 volR);
|
|
|
|
void giveVolume(uint8 *volL, uint8 *volR);
|
2004-11-27 16:18:25 +00:00
|
|
|
|
|
|
|
// AudioStream API
|
|
|
|
int readBuffer(int16 *buffer, const int numSamples) {
|
|
|
|
mixer(buffer, numSamples / 2);
|
|
|
|
return numSamples;
|
|
|
|
}
|
|
|
|
bool isStereo() const { return true; }
|
|
|
|
bool endOfData() const { return false; }
|
|
|
|
int getRate() const { return _sampleRate; }
|
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
private:
|
2005-05-11 00:01:44 +00:00
|
|
|
Audio::st_volume_t _volumeL, _volumeR;
|
2004-01-11 15:47:41 +00:00
|
|
|
MusicHandle _handles[2];
|
2005-05-11 00:01:44 +00:00
|
|
|
Audio::RateConverter *_converter[2];
|
2005-05-10 23:48:48 +00:00
|
|
|
Audio::Mixer *_mixer;
|
2007-02-20 18:50:17 +00:00
|
|
|
Audio::SoundHandle _soundHandle;
|
2004-11-27 16:18:25 +00:00
|
|
|
uint32 _sampleRate;
|
2005-01-28 22:05:51 +00:00
|
|
|
Common::Mutex _mutex;
|
2004-11-27 16:18:25 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
static void passMixerFunc(void *param, int16 *buf, uint len);
|
2003-12-22 02:47:43 +00:00
|
|
|
void mixer(int16 *buf, uint32 len);
|
2004-11-27 16:18:25 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
static const char _tuneList[TOTAL_TUNES][8]; // in staticres.cpp
|
|
|
|
};
|
|
|
|
|
2005-07-30 21:11:48 +00:00
|
|
|
} // End of namespace Sword1
|
2004-01-11 15:47:41 +00:00
|
|
|
|
2003-12-16 02:10:15 +00:00
|
|
|
#endif // BSMUSIC_H
|