mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-29 21:24:53 +00:00
DIRECTOR: Implement kTheVolume
This commit is contained in:
parent
8d50d855e6
commit
fef2d2f366
engines/director
@ -26,6 +26,7 @@
|
||||
#include "director/director.h"
|
||||
#include "director/cast.h"
|
||||
#include "director/frame.h"
|
||||
#include "director/sound.h"
|
||||
#include "director/sprite.h"
|
||||
#include "director/score.h"
|
||||
#include "director/lingo/lingo.h"
|
||||
@ -477,6 +478,24 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
|
||||
d.type = INT;
|
||||
d.u.i = 1;
|
||||
break;
|
||||
case kTheSoundEntity:
|
||||
{
|
||||
switch (field) {
|
||||
case kTheVolume:
|
||||
{
|
||||
SoundChannel *chan = _vm->getSoundManager()->getChannel(id.asInt());
|
||||
if (chan) {
|
||||
d.type = INT;
|
||||
d.u.i = (int)chan->volume;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warning("Lingo::getTheEntity(): Unprocessed getting field \"%s\" of entity %s", field2str(field), entity2str(entity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kTheSprite:
|
||||
d = getTheSprite(id, field);
|
||||
break;
|
||||
@ -506,7 +525,7 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
|
||||
break;
|
||||
default:
|
||||
warning("Lingo::getTheEntity(): Unprocessed getting field \"%s\" of entity %s", field2str(field), entity2str(entity));
|
||||
d.type = VOID;
|
||||
break;
|
||||
}
|
||||
|
||||
return d;
|
||||
@ -535,6 +554,23 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
|
||||
case kThePerFrameHook:
|
||||
warning("STUB: Lingo::setTheEntity(): setting the perframehook");
|
||||
break;
|
||||
case kTheSoundEntity:
|
||||
{
|
||||
switch (field) {
|
||||
case kTheVolume:
|
||||
{
|
||||
SoundChannel *chan = _vm->getSoundManager()->getChannel(id.asInt());
|
||||
if (chan) {
|
||||
chan->volume = (byte)d.asInt();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warning("Lingo::setTheEntity(): Unprocessed getting field \"%s\" of entity %s", field2str(field), entity2str(entity));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case kTheSprite:
|
||||
setTheSprite(id, field, d);
|
||||
break;
|
||||
|
@ -2213,7 +2213,7 @@ Sprite *Score::getSpriteById(uint16 id) {
|
||||
void Score::playSoundChannel(uint16 frameId) {
|
||||
Frame *frame = _frames[frameId];
|
||||
|
||||
debugC(5, kDebugLoading, "playSoundChannel(), Sound1 %d Sound2 %d", frame->_sound1, frame->_sound2);
|
||||
debugC(5, kDebugLoading, "playSoundChannel(): Sound1 %d Sound2 %d", frame->_sound1, frame->_sound2);
|
||||
DirectorSound *sound = _vm->getSoundManager();
|
||||
sound->playCastMember(frame->_sound1, 1, false);
|
||||
sound->playCastMember(frame->_sound2, 2, false);
|
||||
|
@ -42,8 +42,7 @@ DirectorSound::DirectorSound(DirectorEngine *vm) : _vm(vm) {
|
||||
}
|
||||
|
||||
for (uint i = 0; i < numChannels; i++) {
|
||||
_channels.push_back(new Audio::SoundHandle());
|
||||
_lastPlayingCasts.push_back(0);
|
||||
_channels.push_back(SoundChannel());
|
||||
}
|
||||
|
||||
_scriptSound = new Audio::SoundHandle();
|
||||
@ -56,12 +55,17 @@ DirectorSound::DirectorSound(DirectorEngine *vm) : _vm(vm) {
|
||||
}
|
||||
|
||||
DirectorSound::~DirectorSound() {
|
||||
for (uint i = 0; i < _channels.size(); i++) {
|
||||
delete _channels[i];
|
||||
}
|
||||
delete _scriptSound;
|
||||
}
|
||||
|
||||
SoundChannel *DirectorSound::getChannel(uint8 soundChannel) {
|
||||
if (soundChannel == 0 || soundChannel > _channels.size()) {
|
||||
warning("Invalid sound channel %d", soundChannel);
|
||||
return nullptr;
|
||||
}
|
||||
return &_channels[soundChannel - 1];
|
||||
}
|
||||
|
||||
void DirectorSound::playFile(Common::String filename, uint8 soundChannel) {
|
||||
if (debugChannelSet(-1, kDebugFast))
|
||||
return;
|
||||
@ -98,7 +102,7 @@ void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) {
|
||||
|
||||
return;
|
||||
}
|
||||
_lastPlayingCasts[soundChannel - 1] = 0;
|
||||
_channels[soundChannel - 1].lastPlayingCast = 0;
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
|
||||
@ -112,8 +116,8 @@ void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) {
|
||||
|
||||
Audio::RewindableAudioStream *sound = Audio::makeWAVStream(file, DisposeAfterUse::YES);
|
||||
|
||||
_mixer->stopHandle(*_channels[soundChannel - 1]);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, _channels[soundChannel - 1], sound);
|
||||
_mixer->stopHandle(_channels[soundChannel - 1].handle);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel - 1].handle, sound, -1, _channels[soundChannel - 1].volume);
|
||||
}
|
||||
|
||||
void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) {
|
||||
@ -121,7 +125,7 @@ void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) {
|
||||
warning("Invalid sound channel %d", soundChannel);
|
||||
return;
|
||||
}
|
||||
_lastPlayingCasts[soundChannel - 1] = 0;
|
||||
_channels[soundChannel - 1].lastPlayingCast = 0;
|
||||
|
||||
Common::File *file = new Common::File();
|
||||
|
||||
@ -133,8 +137,8 @@ void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) {
|
||||
|
||||
Audio::RewindableAudioStream *sound = Audio::makeAIFFStream(file, DisposeAfterUse::YES);
|
||||
|
||||
_mixer->stopHandle(*_channels[soundChannel - 1]);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, _channels[soundChannel - 1], sound);
|
||||
_mixer->stopHandle(_channels[soundChannel - 1].handle);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel - 1].handle, sound, -1, _channels[soundChannel - 1].volume);
|
||||
}
|
||||
|
||||
void DirectorSound::playMCI(Audio::AudioStream &stream, uint32 from, uint32 to) {
|
||||
@ -151,8 +155,8 @@ void DirectorSound::playStream(Audio::AudioStream &stream, uint8 soundChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
_mixer->stopHandle(*_channels[soundChannel - 1]);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, _channels[soundChannel - 1], &stream);
|
||||
_mixer->stopHandle(_channels[soundChannel - 1].handle);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel - 1].handle, &stream, -1, _channels[soundChannel - 1].volume);
|
||||
}
|
||||
|
||||
void DirectorSound::playCastMember(int castId, uint8 soundChannel, bool allowRepeat) {
|
||||
@ -176,7 +180,7 @@ void DirectorSound::playCastMember(int castId, uint8 soundChannel, bool allowRep
|
||||
playStream(*sd->getLoopingAudioStream(), soundChannel);
|
||||
else
|
||||
playStream(*sd->getAudioStream(), soundChannel);
|
||||
_lastPlayingCasts[soundChannel - 1] = castId;
|
||||
_channels[soundChannel - 1].lastPlayingCast = castId;
|
||||
}
|
||||
} else {
|
||||
warning("DirectorSound::playCastMember: couldn't find cast member %d", castId);
|
||||
@ -190,7 +194,7 @@ bool DirectorSound::isChannelActive(uint8 soundChannel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _mixer->isSoundHandleActive(*_channels[soundChannel - 1]);
|
||||
return _mixer->isSoundHandleActive(_channels[soundChannel - 1].handle);
|
||||
}
|
||||
|
||||
int DirectorSound::lastPlayingCast(uint8 soundChannel) {
|
||||
@ -199,7 +203,7 @@ int DirectorSound::lastPlayingCast(uint8 soundChannel) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _lastPlayingCasts[soundChannel - 1];
|
||||
return _channels[soundChannel - 1].lastPlayingCast;
|
||||
}
|
||||
|
||||
void DirectorSound::stopSound(uint8 soundChannel) {
|
||||
@ -208,15 +212,15 @@ void DirectorSound::stopSound(uint8 soundChannel) {
|
||||
return;
|
||||
}
|
||||
|
||||
_mixer->stopHandle(*_channels[soundChannel - 1]);
|
||||
_lastPlayingCasts[soundChannel - 1] = 0;
|
||||
_mixer->stopHandle(_channels[soundChannel - 1].handle);
|
||||
_channels[soundChannel - 1].lastPlayingCast = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
void DirectorSound::stopSound() {
|
||||
for (uint i = 0; i < _channels.size(); i++) {
|
||||
_mixer->stopHandle(*_channels[i]);
|
||||
_lastPlayingCasts[i] = 0;
|
||||
_mixer->stopHandle(_channels[i].handle);
|
||||
_channels[i].lastPlayingCast = 0;
|
||||
}
|
||||
_mixer->stopHandle(*_scriptSound);
|
||||
_mixer->stopHandle(*_pcSpeakerHandle);
|
||||
|
@ -23,6 +23,8 @@
|
||||
#ifndef DIRECTOR_SOUND_H
|
||||
#define DIRECTOR_SOUND_H
|
||||
|
||||
#include "audio/mixer.h"
|
||||
|
||||
namespace Audio {
|
||||
class AudioStream;
|
||||
class SoundHandle;
|
||||
@ -32,12 +34,19 @@ namespace Audio {
|
||||
|
||||
namespace Director {
|
||||
|
||||
struct SoundChannel {
|
||||
Audio::SoundHandle handle;
|
||||
int lastPlayingCast;
|
||||
byte volume;
|
||||
|
||||
SoundChannel(): handle(), lastPlayingCast(0), volume(255) {}
|
||||
};
|
||||
|
||||
class DirectorSound {
|
||||
|
||||
private:
|
||||
DirectorEngine *_vm;
|
||||
Common::Array<Audio::SoundHandle *> _channels;
|
||||
Common::Array<int> _lastPlayingCasts;
|
||||
Common::Array<SoundChannel> _channels;
|
||||
Audio::SoundHandle *_scriptSound;
|
||||
Audio::Mixer *_mixer;
|
||||
Audio::PCSpeaker *_speaker;
|
||||
@ -47,6 +56,7 @@ public:
|
||||
DirectorSound(DirectorEngine *vm);
|
||||
~DirectorSound();
|
||||
|
||||
SoundChannel *getChannel(uint8 soundChannel);
|
||||
void playWAV(Common::String filename, uint8 soundChannel);
|
||||
void playAIFF(Common::String filename, uint8 soundChannel);
|
||||
void playFile(Common::String filename, uint8 soundChannel);
|
||||
|
Loading…
Reference in New Issue
Block a user