TESTBED: implemented some sample beeps using PCSpeaker emulator for testing sound subsystem

svn-id: r51333
This commit is contained in:
Neeraj Kumar 2010-07-26 20:59:50 +00:00
parent a9941138da
commit 39780f4a68
5 changed files with 127 additions and 1 deletions

View File

@ -8,6 +8,7 @@ MODULE_OBJS := \
graphics.o \
misc.o \
savegame.o \
sound.o \
testbed.o \
testsuite.o

50
engines/testbed/sound.cpp Normal file
View File

@ -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

65
engines/testbed/sound.h Normal file
View File

@ -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

View File

@ -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";
}
};

View File

@ -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() {