2010-08-17 09:28: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This code is based on original Hugo Trilogy source code
|
|
|
|
*
|
|
|
|
* Copyright (c) 1989-1995 David P. Gray
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HUGO_SOUND_H
|
|
|
|
#define HUGO_SOUND_H
|
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/mixer.h"
|
2011-03-24 16:39:08 +01:00
|
|
|
#include "audio/midiplayer.h"
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/softsynth/pcspk.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
namespace Hugo {
|
|
|
|
|
2011-03-24 16:39:08 +01:00
|
|
|
class MidiPlayer : public Audio::MidiPlayer {
|
2010-12-15 20:37:09 +00:00
|
|
|
public:
|
2011-03-25 11:13:43 +01:00
|
|
|
MidiPlayer();
|
2010-12-15 20:37:09 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
void pause(bool p);
|
|
|
|
void play(uint8 *stream, uint16 size);
|
2010-12-15 20:37:09 +00:00
|
|
|
|
2011-12-12 16:22:55 +01:00
|
|
|
// The following line prevents compiler warnings about hiding the pause()
|
|
|
|
// method from the parent class.
|
|
|
|
// FIXME: Maybe the pause(bool p) method should be removed and the
|
|
|
|
// pause/resume methods of the parent class be used instead?
|
|
|
|
virtual void pause() { Audio::MidiPlayer::pause(); }
|
|
|
|
|
2011-02-18 22:24:32 +01:00
|
|
|
uint32 getBaseTempo();
|
2010-12-15 20:37:09 +00:00
|
|
|
|
2011-03-24 16:39:08 +01:00
|
|
|
// Overload Audio::MidiPlayer method
|
|
|
|
virtual void sendToChannel(byte channel, uint32 b);
|
2011-03-25 14:10:02 +01:00
|
|
|
virtual void onTimer();
|
2011-03-24 16:39:08 +01:00
|
|
|
|
2010-12-15 20:37:09 +00:00
|
|
|
private:
|
|
|
|
bool _paused;
|
|
|
|
};
|
2010-10-25 13:31:01 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
class SoundHandler {
|
|
|
|
public:
|
2010-10-21 17:09:57 +00:00
|
|
|
SoundHandler(HugoEngine *vm);
|
2010-11-13 08:08:58 +00:00
|
|
|
~SoundHandler();
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
static const int kHugoCNT = 1190000;
|
|
|
|
|
2011-08-24 10:56:43 +02:00
|
|
|
int8 _pcspkrTimer; // Timer (ticks) for note being played
|
|
|
|
int8 _pcspkrOctave; // Current octave 1..7
|
|
|
|
int8 _pcspkrNoteDuration; // Current length of note (ticks)
|
2011-02-03 18:25:38 +00:00
|
|
|
|
2011-08-24 10:56:43 +02:00
|
|
|
const char *_DOSSongPtr;
|
|
|
|
const char *_DOSIntroSong;
|
2011-01-06 14:06:04 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
void toggleMusic();
|
|
|
|
void toggleSound();
|
|
|
|
void setMusicVolume();
|
2011-02-01 00:08:12 +00:00
|
|
|
static void loopPlayer(void *refCon);
|
2011-01-06 14:06:04 +00:00
|
|
|
void pcspkr_player();
|
2010-11-26 23:30:31 +00:00
|
|
|
void playMusic(int16 tune);
|
2011-02-02 21:12:51 +00:00
|
|
|
void playSound(int16 sound, const byte priority);
|
2010-08-26 23:13:17 +00:00
|
|
|
void initSound();
|
2010-12-22 22:25:52 +00:00
|
|
|
void syncVolume();
|
2011-01-01 10:51:57 +00:00
|
|
|
void checkMusic();
|
2011-02-12 16:20:57 +00:00
|
|
|
void loadIntroSong(Common::ReadStream &in);
|
2011-02-01 00:08:12 +00:00
|
|
|
void initPcspkrPlayer();
|
2011-02-03 18:25:38 +00:00
|
|
|
protected:
|
2011-08-24 10:56:43 +02:00
|
|
|
byte _curPriority; // Priority of currently playing sound
|
2011-02-03 18:25:38 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
private:
|
2010-10-21 17:09:57 +00:00
|
|
|
HugoEngine *_vm;
|
2010-08-17 09:28:20 +00:00
|
|
|
Audio::SoundHandle _soundHandle;
|
2010-08-26 23:13:17 +00:00
|
|
|
MidiPlayer *_midiPlayer;
|
2011-01-06 14:06:04 +00:00
|
|
|
Audio::PCSpeaker *_speakerStream;
|
|
|
|
Audio::SoundHandle _speakerHandle;
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
void stopSound();
|
|
|
|
void stopMusic();
|
2012-06-13 21:18:37 +02:00
|
|
|
void playMIDI(SoundPtr seqPtr, uint16 size);
|
2010-08-17 09:28:20 +00:00
|
|
|
};
|
|
|
|
|
2010-08-27 09:48:53 +00:00
|
|
|
} // End of namespace Hugo
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
#endif //HUGO_SOUND_H
|