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