Skip to content

Commit

Permalink
ACCESS: Implement loadSounds
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 29, 2014
1 parent e57d7e8 commit 1d8f239
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
31 changes: 18 additions & 13 deletions engines/access/sound.cpp
Expand Up @@ -29,36 +29,36 @@ namespace Access {

SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) :
_vm(vm), _mixer(mixer) {
Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0);
for (int i = 0; i < MAX_SOUNDS; ++i)
_soundTable[i] = nullptr;

_music = nullptr;
_musicRepeat = false;
}

SoundManager::~SoundManager() {
for (int i = 0; i < MAX_SOUNDS; ++i)
clearSounds();
}

void SoundManager::clearSounds() {
for (int i = 0; i < _soundTable.size(); ++i)
delete _soundTable[i];
_soundTable.clear();
_soundPriority.clear();
}

void SoundManager::queueSound(int idx, int fileNum, int subfile) {
/*
_soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile);
_soundTable[idx]._size = _vm->_files->_filesize;
*/
delete _soundTable[idx];
_soundTable[idx] = _vm->_files->loadFile(fileNum, subfile);
}

Resource *SoundManager::loadSound(int fileNum, int subfile) {
return _vm->_files->loadFile(fileNum, subfile);
}

void SoundManager::playSound(int soundIndex) {
int idx = _soundPriority[soundIndex - 1] - 1;
playSound(_soundTable[idx]->data(), _soundTable[idx]->_size);
int idx = _soundPriority[soundIndex];
playSound(_soundTable[idx]);
}

void SoundManager::playSound(byte *data, uint32 size) {
void SoundManager::playSound(Resource *res) {
/*
Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false);
audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0);
Expand All @@ -68,7 +68,12 @@ void SoundManager::playSound(byte *data, uint32 size) {
}

void SoundManager::loadSounds(Common::Array<RoomInfo::SoundIdent> &sounds) {
// TODO
clearSounds();

for (uint i = 0; i < sounds.size(); ++i) {
_soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile));
_soundPriority.push_back(sounds[i]._priority);
}
}

void SoundManager::midiPlay() {
Expand Down
8 changes: 5 additions & 3 deletions engines/access/sound.h
Expand Up @@ -39,10 +39,12 @@ class SoundManager {
Audio::Mixer *_mixer;
Audio::SoundHandle _soundHandle;

void playSound(byte *data, uint32 size);
void clearSounds();

void playSound(Resource *res);
public:
Resource *_soundTable[MAX_SOUNDS];
int _soundPriority[MAX_SOUNDS];
Common::Array<Resource *> _soundTable;
Common::Array<int> _soundPriority;
Resource *_music;
bool _musicRepeat;
public:
Expand Down
1 change: 1 addition & 0 deletions engines/access/video.cpp
Expand Up @@ -30,6 +30,7 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) {
_videoFrame = 0;
_soundFlag = false;
_soundFrame = 0;
_videoData = nullptr;
}

VideoPlayer::~VideoPlayer() {
Expand Down

0 comments on commit 1d8f239

Please sign in to comment.