scummvm/engines/access/sound.h

124 lines
2.8 KiB
C
Raw Normal View History

2014-08-02 19:14:42 +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 3 of the License, or
* (at your option) any later version.
*
2014-08-02 19:14:42 +00:00
* 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.
*
2014-08-02 19:14:42 +00:00
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2014-08-02 19:14:42 +00:00
*
*/
#ifndef ACCESS_SOUND_H
#define ACCESS_SOUND_H
#include "common/scummsys.h"
#include "access/files.h"
2014-12-01 13:07:09 +00:00
#include "audio/midiplayer.h"
#define MAX_SOUNDS 20
namespace Audio {
class AudioStream;
class SoundHandle;
}
2014-08-02 19:14:42 +00:00
namespace Access {
class AccessEngine;
struct SoundEntry {
Resource *_res;
int _priority;
SoundEntry() { _res = nullptr; _priority = 0; }
SoundEntry(Resource *res, int priority) { _res = res; _priority = priority; }
};
2014-08-02 19:14:42 +00:00
class SoundManager {
struct QueuedSound {
Audio::AudioStream *_stream;
int _soundId;
QueuedSound() : _stream(nullptr), _soundId(-1) {}
QueuedSound(Audio::AudioStream *stream, int soundId) : _stream(stream), _soundId(soundId) {}
};
2014-08-02 19:14:42 +00:00
private:
AccessEngine *_vm;
Audio::Mixer *_mixer;
Audio::SoundHandle *_effectsHandle;
Common::Array<QueuedSound> _queue;
2014-08-29 00:24:25 +00:00
void clearSounds();
void playSound(Resource *res, int priority, bool loop, int soundIndex = -1);
bool isSoundQueued(int soundId) const;
2014-08-02 19:14:42 +00:00
public:
Common::Array<SoundEntry> _soundTable;
2014-08-29 02:15:39 +00:00
bool _playingSound;
2014-08-02 19:14:42 +00:00
public:
SoundManager(AccessEngine *vm, Audio::Mixer *mixer);
~SoundManager();
2014-08-02 19:14:42 +00:00
void loadSoundTable(int idx, int fileNum, int subfile, int priority = 1);
void playSound(int soundIndex, bool loop = false);
2014-12-27 14:31:43 +00:00
void checkSoundQueue();
2014-12-27 15:05:23 +00:00
bool isSFXPlaying();
2014-08-06 02:17:30 +00:00
Resource *loadSound(int fileNum, int subfile);
2014-08-08 00:31:42 +00:00
void loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds);
2014-08-07 02:43:40 +00:00
void stopSound();
void freeSounds();
};
2014-12-01 13:07:09 +00:00
class MusicManager : public Audio::MidiPlayer {
private:
AccessEngine *_vm;
2014-12-01 07:46:32 +00:00
Resource *_tempMusic;
2014-12-01 13:07:09 +00:00
// MidiDriver_BASE interface implementation
2020-02-09 11:05:26 +00:00
void send(uint32 b) override;
2014-12-01 07:46:32 +00:00
2014-12-01 13:07:09 +00:00
public:
2014-12-01 07:46:32 +00:00
Resource *_music;
bool _byte1F781;
2014-12-01 07:46:32 +00:00
public:
MusicManager(AccessEngine *vm);
2020-02-09 11:05:26 +00:00
~MusicManager() override;
2014-08-07 02:43:40 +00:00
void midiPlay();
2014-11-20 12:28:31 +00:00
bool checkMidiDone();
2014-08-06 02:17:30 +00:00
void midiRepeat();
2014-08-06 12:28:20 +00:00
void stopSong();
2014-08-30 21:17:19 +00:00
void newMusic(int musicId, int mode);
2014-08-07 02:43:40 +00:00
void freeMusic();
2014-12-01 07:46:32 +00:00
void loadMusic(int fileNum, int subfile);
void loadMusic(FileIdent file);
2014-12-01 13:07:09 +00:00
void setLoop(bool loop);
2014-08-02 19:14:42 +00:00
};
} // End of namespace Access
#endif /* ACCESS_SOUND_H*/