Permalink
Browse files

STARTREK: Add debug channel for sound

  • Loading branch information...
Drenn1 authored and sev- committed May 7, 2018
1 parent f43c5d4 commit 69dac4d62d8179d0692476efe980934e51bda9ac
Showing with 15 additions and 2 deletions.
  1. +8 −2 engines/startrek/sound.cpp
  2. +3 −0 engines/startrek/startrek.cpp
  3. +4 −0 engines/startrek/startrek.h
@@ -88,6 +88,8 @@ void Sound::playMidiTrack(int track) {

assert(loadedSoundData != NULL);

debugC(6, kDebugSound, "Playing MIDI track %d", track);

// Check if a midi slot for this track exists already
for (int i=1; i<8; i++) {
if (_midiSlots[i].track == track) {
@@ -152,10 +154,13 @@ void Sound::playSoundEffect(const char *baseSoundName) {
if (readStream == nullptr)
error("Couldn't open '%s'", soundName.c_str());

debugC(5, kDebugSound, "Playing sound effect '%s'", baseSoundName);
Audio::AudioStream *audioStream = Audio::makeVOCStream(readStream, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
_vm->_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandles[i], audioStream);
return;
}

debugC(3, kDebugSound, "No sound slot to play '%s'", baseSoundName);
}

void Sound::playSpeech(const Common::String &basename) {
@@ -174,7 +179,7 @@ void Sound::playSpeech(const Common::String &basename) {
}

Common::String filename = "voc/" + Common::String(name.c_str(), name.c_str()+i) + ".voc";
debug("Playing speech '%s'", filename.c_str());
debugC(5, kDebugSound, "Playing speech '%s'", filename.c_str());
Common::SeekableReadStream *readStream = SearchMan.createReadStreamForMember(filename);
if (readStream == nullptr)
error("Couldn't open '%s'", filename.c_str());
@@ -197,6 +202,7 @@ void Sound::playSpeech(const Common::String &basename) {

void Sound::stopPlayingSpeech() {
if (_playingSpeech) {
debugC(5, kDebugSound, "Canceled speech playback");
_playingSpeech = false;
_vm->_system->getMixer()->stopHandle(_speechHandle);
}
@@ -230,7 +236,7 @@ void Sound::loadPCMusicFile(const char *baseSoundName) {
break;
}

debug(0, "Playing sound \'%s\'\n", soundName.c_str());
debugC(5, kDebugSound, "Loading midi \'%s\'\n", soundName.c_str());
SharedPtr<Common::SeekableReadStream> soundStream = _vm->openFile(soundName.c_str());

if (loadedSoundData != nullptr)
@@ -24,6 +24,7 @@
#include "base/version.h"
#include "common/archive.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/error.h"
#include "common/events.h"
#include "common/file.h"
@@ -39,6 +40,8 @@
namespace StarTrek {

StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) {
DebugMan.addDebugChannel(kDebugSound, "sound", "Sound");

_gfx = nullptr;
_sound = nullptr;
_macResFork = nullptr;
@@ -57,6 +57,10 @@ enum StarTrekGameFeatures {
GF_DEMO = (1 << 0)
};

enum kDebugLevels {
kDebugSound = 1 << 0
};


enum TrekEventType {
TREKEVENT_TICK = 0, // DOS clock changes (see updateClockTicks)

0 comments on commit 69dac4d

Please sign in to comment.