enabled MIDI volume changes
svn-id: r24627
This commit is contained in:
parent
05dcf9c11d
commit
424e9e362e
7 changed files with 25 additions and 48 deletions
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/stdafx.h"
|
#include "common/stdafx.h"
|
||||||
#include "common/mutex.h"
|
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
|
|
||||||
#include "sound/midiparser.h"
|
#include "sound/midiparser.h"
|
||||||
|
@ -31,7 +30,7 @@
|
||||||
namespace Touche {
|
namespace Touche {
|
||||||
|
|
||||||
MidiPlayer::MidiPlayer(MidiDriver *driver)
|
MidiPlayer::MidiPlayer(MidiDriver *driver)
|
||||||
: _masterVolume(255), _isPlaying(false), _driver(driver), _parser(0), _midiData(0) {
|
: _driver(driver), _parser(0), _midiData(0), _isLooping(false), _isPlaying(false), _masterVolume(0) {
|
||||||
assert(_driver);
|
assert(_driver);
|
||||||
memset(_channelsTable, 0, sizeof(_channelsTable));
|
memset(_channelsTable, 0, sizeof(_channelsTable));
|
||||||
memset(_channelsVolume, 0, sizeof(_channelsVolume));
|
memset(_channelsVolume, 0, sizeof(_channelsVolume));
|
||||||
|
@ -75,12 +74,12 @@ void MidiPlayer::updateTimer() {
|
||||||
_mutex.unlock();
|
_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MidiPlayer::adjustVolume(int diff) {
|
||||||
|
setVolume(_masterVolume + diff);
|
||||||
|
}
|
||||||
|
|
||||||
void MidiPlayer::setVolume(int volume) {
|
void MidiPlayer::setVolume(int volume) {
|
||||||
if (volume < 0) {
|
_masterVolume = CLIP(volume, 0, 255);
|
||||||
volume = 0;
|
|
||||||
} else if (volume > 255) {
|
|
||||||
volume = 255;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < NUM_CHANNELS; ++i) {
|
for (int i = 0; i < NUM_CHANNELS; ++i) {
|
||||||
if (_channelsTable[i]) {
|
if (_channelsTable[i]) {
|
||||||
_channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255);
|
_channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255);
|
||||||
|
|
|
@ -24,13 +24,14 @@
|
||||||
#define TOUCHE_MIDI_H
|
#define TOUCHE_MIDI_H
|
||||||
|
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
#include "common/mutex.h"
|
||||||
|
|
||||||
#include "sound/mididrv.h"
|
#include "sound/mididrv.h"
|
||||||
|
|
||||||
class MidiParser;
|
class MidiParser;
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class ReadStream;
|
class ReadStream;
|
||||||
class Mutex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Touche {
|
namespace Touche {
|
||||||
|
@ -48,7 +49,9 @@ public:
|
||||||
void play(Common::ReadStream &stream, int size, bool loop = false);
|
void play(Common::ReadStream &stream, int size, bool loop = false);
|
||||||
void stop();
|
void stop();
|
||||||
void updateTimer();
|
void updateTimer();
|
||||||
|
void adjustVolume(int diff);
|
||||||
void setVolume(int volume);
|
void setVolume(int volume);
|
||||||
|
int getVolume() const { return _masterVolume; }
|
||||||
|
|
||||||
// MidiDriver interface
|
// MidiDriver interface
|
||||||
int open();
|
int open();
|
||||||
|
@ -64,14 +67,14 @@ private:
|
||||||
|
|
||||||
static void timerCallback(void *p);
|
static void timerCallback(void *p);
|
||||||
|
|
||||||
int _masterVolume;
|
|
||||||
bool _isLooping;
|
|
||||||
bool _isPlaying;
|
|
||||||
MidiDriver *_driver;
|
MidiDriver *_driver;
|
||||||
MidiParser *_parser;
|
MidiParser *_parser;
|
||||||
MidiChannel *_channelsTable[NUM_CHANNELS];
|
|
||||||
byte _channelsVolume[NUM_CHANNELS];
|
|
||||||
uint8 *_midiData;
|
uint8 *_midiData;
|
||||||
|
bool _isLooping;
|
||||||
|
bool _isPlaying;
|
||||||
|
int _masterVolume;
|
||||||
|
MidiChannel *_channelsTable[NUM_CHANNELS];
|
||||||
|
uint8 _channelsVolume[NUM_CHANNELS];
|
||||||
Common::Mutex _mutex;
|
Common::Mutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -561,7 +561,6 @@ void ToucheEngine::res_loadSound(int priority, int num) {
|
||||||
|
|
||||||
void ToucheEngine::res_loadMusic(int num) {
|
void ToucheEngine::res_loadMusic(int num) {
|
||||||
debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num);
|
debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num);
|
||||||
warning("UNIMPLEMENTED ToucheEngine::res_loadMusic() num=%d", num);
|
|
||||||
uint32 size;
|
uint32 size;
|
||||||
const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
|
const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
|
||||||
_fData.seek(offs);
|
_fData.seek(offs);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*
|
*
|
||||||
* $URL$
|
* $URL$
|
||||||
* $Id: $
|
* $Id$
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ void ToucheEngine::loadGameStateData(Common::ReadStream *stream) {
|
||||||
clearRoomArea();
|
clearRoomArea();
|
||||||
int16 room_offs_x, room_offs_y;
|
int16 room_offs_x, room_offs_y;
|
||||||
_currentEpisodeNum = stream->readUint16LE();
|
_currentEpisodeNum = stream->readUint16LE();
|
||||||
_currentMusicNum = stream->readUint16LE();
|
_newMusicNum = stream->readUint16LE();
|
||||||
_currentRoomNum = stream->readUint16LE();
|
_currentRoomNum = stream->readUint16LE();
|
||||||
res_loadRoom(_currentRoomNum);
|
res_loadRoom(_currentRoomNum);
|
||||||
room_offs_x = stream->readUint16LE();
|
room_offs_x = stream->readUint16LE();
|
||||||
|
|
|
@ -46,12 +46,7 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
|
||||||
clearDirtyRects();
|
clearDirtyRects();
|
||||||
|
|
||||||
_defaultSoundPriority = 0;
|
_defaultSoundPriority = 0;
|
||||||
_snd_midiContext.unk2 = 0;
|
|
||||||
_snd_midiContext.unkA = 1;
|
|
||||||
_snd_midiContext.unkB = 0;
|
|
||||||
_snd_midiContext.volume = 0;
|
|
||||||
_snd_midiContext.unkF = 0;
|
|
||||||
_snd_midiContext.currentVolume = 175;
|
|
||||||
_playSoundCounter = 0;
|
_playSoundCounter = 0;
|
||||||
|
|
||||||
_processRandomPaletteCounter = 0;
|
_processRandomPaletteCounter = 0;
|
||||||
|
@ -1711,15 +1706,10 @@ void ToucheEngine::clearRoomArea() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToucheEngine::startNewMusic() {
|
void ToucheEngine::startNewMusic() {
|
||||||
_snd_midiContext.unkA = _flagsTable[619] & 0xFF;
|
// bool unkMidiFlag = _flagsTable[619] != 0;
|
||||||
if (_newMusicNum != 0 && _newMusicNum != _currentMusicNum) {
|
if (_newMusicNum != 0 && _newMusicNum != _currentMusicNum) {
|
||||||
_snd_midiContext.unkB = 3;
|
|
||||||
if (_snd_midiContext.unkF != 0 && _snd_midiContext.unk2 != 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_snd_midiContext.unkB = 0;
|
|
||||||
res_loadMusic(_newMusicNum);
|
res_loadMusic(_newMusicNum);
|
||||||
_snd_midiContext.unk2 = 0;
|
_currentMusicNum = _newMusicNum;
|
||||||
_newMusicNum = 0;
|
_newMusicNum = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,15 +197,6 @@ struct SpriteData {
|
||||||
uint16 h;
|
uint16 h;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MidiContext {
|
|
||||||
uint8 unk2;
|
|
||||||
uint8 unkA;
|
|
||||||
uint8 unkB;
|
|
||||||
uint16 volume;
|
|
||||||
uint8 unkF;
|
|
||||||
uint16 currentVolume;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ProgramPointData {
|
struct ProgramPointData {
|
||||||
int16 x, y, z;
|
int16 x, y, z;
|
||||||
int16 priority;
|
int16 priority;
|
||||||
|
@ -617,7 +608,6 @@ protected:
|
||||||
int _playSoundCounter;
|
int _playSoundCounter;
|
||||||
Audio::SoundHandle _sfxHandle;
|
Audio::SoundHandle _sfxHandle;
|
||||||
Audio::SoundHandle _speechHandle;
|
Audio::SoundHandle _speechHandle;
|
||||||
MidiContext _snd_midiContext;
|
|
||||||
|
|
||||||
int16 _inventoryList1[101];
|
int16 _inventoryList1[101];
|
||||||
int16 _inventoryList2[101];
|
int16 _inventoryList2[101];
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "common/savefile.h"
|
#include "common/savefile.h"
|
||||||
|
|
||||||
#include "touche/graphics.h"
|
#include "touche/graphics.h"
|
||||||
|
#include "touche/midi.h"
|
||||||
#include "touche/touche.h"
|
#include "touche/touche.h"
|
||||||
|
|
||||||
namespace Touche {
|
namespace Touche {
|
||||||
|
@ -63,7 +64,7 @@ void ToucheEngine::setupUIRect() {
|
||||||
Common::Rect(154, 256, 392, 268),
|
Common::Rect(154, 256, 392, 268),
|
||||||
Common::Rect(126, 222, 420, 242)
|
Common::Rect(126, 222, 420, 242)
|
||||||
};
|
};
|
||||||
|
|
||||||
buttonsRectTable1 = inButtonsRectTable1;
|
buttonsRectTable1 = inButtonsRectTable1;
|
||||||
buttonsRectTable2 = inButtonsRectTable2;
|
buttonsRectTable2 = inButtonsRectTable2;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +131,7 @@ void ToucheEngine::ui_drawButtonBorders(const Common::Rect *r, int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToucheEngine::ui_drawMusicVolumeBar() {
|
void ToucheEngine::ui_drawMusicVolumeBar() {
|
||||||
int volume = _snd_midiContext.volume * 232 / 256;
|
int volume = _midiPlayer->getVolume() * 232 / 255;
|
||||||
if (volume != 0) {
|
if (volume != 0) {
|
||||||
Graphics::fillRect(_offscreenBuffer, 640, 157, 259, volume, 6, 0xF0);
|
Graphics::fillRect(_offscreenBuffer, 640, 157, 259, volume, 6, 0xF0);
|
||||||
}
|
}
|
||||||
|
@ -394,14 +395,10 @@ void ToucheEngine::ui_handleOptions(int forceDisplay) {
|
||||||
_talkTextMode = kTalkModeVoiceAndText;
|
_talkTextMode = kTalkModeVoiceAndText;
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 26:
|
||||||
if (_snd_midiContext.volume > 0) {
|
_midiPlayer->adjustVolume(-16);
|
||||||
_snd_midiContext.volume -= 16;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
if (_snd_midiContext.volume < 256) {
|
_midiPlayer->adjustVolume(+16);
|
||||||
_snd_midiContext.volume += 16;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +407,6 @@ void ToucheEngine::ui_handleOptions(int forceDisplay) {
|
||||||
if (_flagsTable[611] != 0) {
|
if (_flagsTable[611] != 0) {
|
||||||
_flagsTable[611] = ui_displayQuitDialog();
|
_flagsTable[611] = ui_displayQuitDialog();
|
||||||
}
|
}
|
||||||
_snd_midiContext.currentVolume = _snd_midiContext.volume;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue