From 39780f4a6801091fc680c7d55d2a1f7a0a4356be Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Mon, 26 Jul 2010 20:59:50 +0000 Subject: [PATCH] TESTBED: implemented some sample beeps using PCSpeaker emulator for testing sound subsystem svn-id: r51333 --- engines/testbed/module.mk | 1 + engines/testbed/sound.cpp | 50 ++++++++++++++++++++++++++++ engines/testbed/sound.h | 65 +++++++++++++++++++++++++++++++++++++ engines/testbed/template.h | 8 ++++- engines/testbed/testbed.cpp | 4 +++ 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 engines/testbed/sound.cpp create mode 100644 engines/testbed/sound.h diff --git a/engines/testbed/module.mk b/engines/testbed/module.mk index d66242d37a6..4c530e412a5 100644 --- a/engines/testbed/module.mk +++ b/engines/testbed/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \ graphics.o \ misc.o \ savegame.o \ + sound.o \ testbed.o \ testsuite.o diff --git a/engines/testbed/sound.cpp b/engines/testbed/sound.cpp new file mode 100644 index 00000000000..671f720be50 --- /dev/null +++ b/engines/testbed/sound.cpp @@ -0,0 +1,50 @@ +/* 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. + * + * $URL$ + * $Id$ + */ + +#include "sound/mixer.h" +#include "testbed/sound.h" +#include "sound/softsynth/pcspk.h" + +namespace Testbed { + +bool SoundSubsystem::playPCSpkSound() { + Audio::PCSpeaker *speaker = new Audio::PCSpeaker(); + Audio::Mixer *mixer = g_system->getMixer(); + Audio::SoundHandle handle; + mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, speaker); + speaker->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1); + g_system->delayMillis(1000); + mixer->setChannelBalance(handle, -127); + g_system->delayMillis(1000); + mixer->setChannelBalance(handle, 127); + g_system->delayMillis(1000); + mixer->stopAll(); + return true; +} + +SoundSubsystemTestSuite::SoundSubsystemTestSuite() { + addTest("PCSpkrSound", &SoundSubsystem::playPCSpkSound, true); +} + +} // End of namespace Testbed diff --git a/engines/testbed/sound.h b/engines/testbed/sound.h new file mode 100644 index 00000000000..4078bbcac39 --- /dev/null +++ b/engines/testbed/sound.h @@ -0,0 +1,65 @@ +/* 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. + * + * $URL$ + * $Id$ + */ + +#ifndef TESTBED_SOUND_H +#define TESTBED_SOUND_H + +#include "testbed/testsuite.h" + +namespace Testbed { + +namespace SoundSubsystem { + +// Helper functions for SoundSubsystem tests + +// will contain function declarations for SoundSubsystem tests +bool playPCSpkSound(); +} + +class SoundSubsystemTestSuite : public Testsuite { +public: + /** + * The constructor for the SoundSubsystemTestSuite + * For every test to be executed one must: + * 1) Create a function that would invoke the test + * 2) Add that test to list by executing addTest() + * + * @see addTest() + */ + SoundSubsystemTestSuite(); + ~SoundSubsystemTestSuite() {} + + const char *getName() const { + return "SoundSubsystem"; + } + + const char *getDescription() const { + return "Sound Subsystem"; + } + +}; + +} // End of namespace Testbed + +#endif // TESTBED_SOUND_H diff --git a/engines/testbed/template.h b/engines/testbed/template.h index 6ce5c783441..a2efca1157c 100644 --- a/engines/testbed/template.h +++ b/engines/testbed/template.h @@ -52,7 +52,13 @@ public: */ XXXTestSuite(); ~XXXTestSuite() {} - const char *getName() const; + const char *getName() const { + return "Dummy Template"; + } + + const char *getDescription() const { + return "Some Arbit description"; + } }; diff --git a/engines/testbed/testbed.cpp b/engines/testbed/testbed.cpp index bdf8badaa5b..7eeb33a70d0 100644 --- a/engines/testbed/testbed.cpp +++ b/engines/testbed/testbed.cpp @@ -34,6 +34,7 @@ #include "testbed/graphics.h" #include "testbed/misc.h" #include "testbed/savegame.h" +#include "testbed/sound.h" #include "testbed/testbed.h" namespace Testbed { @@ -72,6 +73,9 @@ TestbedEngine::TestbedEngine(OSystem *syst) // Events ts = new EventTestSuite(); _testsuiteList.push_back(ts); + // Sound + ts = new SoundSubsystemTestSuite(); + _testsuiteList.push_back(ts); } TestbedEngine::~TestbedEngine() {