[Scummvm-git-logs] scummvm master -> 29f913289cd059ecfc7bed61b6faa635c4ace3a9

dreammaster dreammaster at scummvm.org
Thu Feb 2 03:43:28 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
29f913289c TITANIC: Implemented CAudioBuffer class


Commit: 29f913289cd059ecfc7bed61b6faa635c4ace3a9
    https://github.com/scummvm/scummvm/commit/29f913289cd059ecfc7bed61b6faa635c4ace3a9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-01T21:43:10-05:00

Commit Message:
TITANIC: Implemented CAudioBuffer class

Changed paths:
  A engines/titanic/sound/audio_buffer.cpp
  A engines/titanic/sound/audio_buffer.h
    engines/titanic/module.mk
    engines/titanic/sound/music_room.cpp
    engines/titanic/sound/music_room_handler.cpp
    engines/titanic/sound/music_room_handler.h


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 51c77ba..d805f11 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -399,6 +399,7 @@ MODULE_OBJS := \
 	pet_control/pet_show_translation.o \
 	pet_control/pet_slider.o \
 	pet_control/pet_sound.o \
+	sound/audio_buffer.o \
 	sound/auto_music_player.o \
 	sound/auto_music_player_base.o \
 	sound/auto_sound_player.o \
diff --git a/engines/titanic/sound/audio_buffer.cpp b/engines/titanic/sound/audio_buffer.cpp
new file mode 100644
index 0000000..7de7c47
--- /dev/null
+++ b/engines/titanic/sound/audio_buffer.cpp
@@ -0,0 +1,90 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/sound/audio_buffer.h"
+
+namespace Titanic {
+
+CAudioBuffer::CAudioBuffer(int bufferSize) : _flag(true), _field18(0) {
+	_buffer.resize(bufferSize);
+	reset();
+}
+
+CAudioBuffer::~CAudioBuffer() {
+	_buffer.clear();
+}
+
+void CAudioBuffer::reset() {
+	_flag = true;
+	_fieldC = _field10 = _buffer.size() / 2;
+}
+
+const byte *CAudioBuffer::getDataPtr1() const {
+	return _flag ? &_buffer[_buffer.size() / 2] : &_buffer[0];
+}
+
+const byte *CAudioBuffer::getDataPtr2() const {
+	return _flag ? &_buffer[0] : &_buffer[_buffer.size() / 2];
+}
+
+const byte *CAudioBuffer::getPtr1() const {
+	const byte *ptr = getDataPtr1();
+	return ptr + (_buffer.size() / 2 - _fieldC);
+}
+
+const byte *CAudioBuffer::getPtr2() const {
+	const byte *ptr = getDataPtr2();
+	return ptr + (_buffer.size() / 2 - _field10);
+}
+
+void CAudioBuffer::setC(int val) {
+	_fieldC -= val;
+	if (_fieldC < 0) {
+		_fieldC = 0;
+	} else if (val && !_field10) {
+		update();
+	}
+}
+
+void CAudioBuffer::set10(int val) {
+	_field10 -= val;
+	if (_field10 < 0) {
+		_field10 = 0;
+	} else if (val && !_field10) {
+		update();
+	}
+}
+
+void CAudioBuffer::update() {
+	_flag = !_flag;
+	_fieldC = _field10 = _buffer.size() / 2;
+}
+
+void CAudioBuffer::enterCriticalSection() {
+	_mutex.lock();
+}
+
+void CAudioBuffer::leaveCriticalSection() {
+	_mutex.unlock();
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/sound/audio_buffer.h b/engines/titanic/sound/audio_buffer.h
new file mode 100644
index 0000000..77027ac
--- /dev/null
+++ b/engines/titanic/sound/audio_buffer.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_AUDIO_BUFFER_H
+#define TITANIC_AUDIO_BUFFER_H
+
+#include "common/array.h"
+#include "common/mutex.h"
+
+namespace Titanic {
+
+class CAudioBuffer {
+private:
+	Common::Mutex _mutex;
+public:
+	Common::Array<byte> _buffer;
+	int _fieldC;
+	int _field10;
+	bool _flag;
+	int _field18;
+public:
+	CAudioBuffer(int bufferSize);
+	~CAudioBuffer();
+
+	void reset();
+	const byte *getDataPtr1() const;
+	const byte *getDataPtr2() const;
+	const byte *getPtr1() const;
+	const byte *getPtr2() const;
+	int getC() const { return _fieldC; }
+	int get10() const { return _field10; }
+	void setC(int val);
+	void set10(int val);
+	void update();
+
+	/**
+	 * Enters a critical section
+	 */
+	void enterCriticalSection();
+
+	/**
+	 * Leave a critical section
+	 */
+	void leaveCriticalSection();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_AUDIO_BUFFER_H */
diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp
index 9db8900..4ef3b1d 100644
--- a/engines/titanic/sound/music_room.cpp
+++ b/engines/titanic/sound/music_room.cpp
@@ -85,7 +85,7 @@ void CMusicRoom::setupMusic(int volume) {
 			_musicHandler->setMuteControl(idx, instr._muteControl);
 		}
 
-		_musicHandler->createWaveFile(volume);
+		_musicHandler->setVolume(volume);
 	}
 }
 
diff --git a/engines/titanic/sound/music_room_handler.cpp b/engines/titanic/sound/music_room_handler.cpp
index c9e4d76..0b9c734 100644
--- a/engines/titanic/sound/music_room_handler.cpp
+++ b/engines/titanic/sound/music_room_handler.cpp
@@ -34,6 +34,7 @@ CMusicRoomHandler::CMusicRoomHandler(CProjectItem *project, CSoundManager *sound
 	_field108 = 0;
 	_field118 = 0;
 	_startTicks = _soundStartTicks = 0;
+	_audioBuffer = new CAudioBuffer(176400);
 }
 
 CMusicRoomHandler::~CMusicRoomHandler() {
@@ -64,8 +65,8 @@ CMusicWave *CMusicRoomHandler::createMusicWave(MusicInstrument instrument, int c
 	return _musicWaves[instrument];
 }
 
-void CMusicRoomHandler::createWaveFile(int musicVolume) {
-	_volume = musicVolume;
+void CMusicRoomHandler::setVolume(int volume) {
+	_volume = volume;
 	// TODO
 //	_waveFile = _soundManager->loadMusic()
 }
diff --git a/engines/titanic/sound/music_room_handler.h b/engines/titanic/sound/music_room_handler.h
index b8ab277..2240778 100644
--- a/engines/titanic/sound/music_room_handler.h
+++ b/engines/titanic/sound/music_room_handler.h
@@ -23,6 +23,7 @@
 #ifndef TITANIC_MUSIC_ROOM_HANDLER_H
 #define TITANIC_MUSIC_ROOM_HANDLER_H
 
+#include "titanic/sound/audio_buffer.h"
 #include "titanic/sound/music_wave.h"
 #include "titanic/sound/wave_file.h"
 
@@ -69,6 +70,7 @@ private:
 	CWaveFile *_waveFile;
 	int _soundHandle;
 	int _field108;
+	CAudioBuffer *_audioBuffer;
 	int _field118;
 	uint _soundStartTicks;
 	uint _startTicks;
@@ -90,7 +92,10 @@ public:
 	 */
 	CMusicWave *createMusicWave(MusicInstrument instrument, int count);
 
-	void createWaveFile(int musicVolume);
+	/**
+	 * Sets the volume and ??? other stuff
+	 */
+	void setVolume(int volume);
 
 	/**
 	 * Flags whether the music handler is active





More information about the Scummvm-git-logs mailing list