2010-07-26 20:59:50 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2011-02-09 01:09:01 +00:00
|
|
|
#include "audio/softsynth/pcspk.h"
|
2010-07-26 20:59:50 +00:00
|
|
|
|
2010-11-08 23:07:42 +00:00
|
|
|
#include "backends/audiocd/audiocd.h"
|
|
|
|
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/config-manager.h"
|
|
|
|
|
2010-07-30 20:10:30 +00:00
|
|
|
#include "testbed/sound.h"
|
|
|
|
|
2010-07-26 20:59:50 +00:00
|
|
|
namespace Testbed {
|
|
|
|
|
2010-07-29 13:09:14 +00:00
|
|
|
enum {
|
|
|
|
kPlayChannel1 = 'pch1',
|
|
|
|
kPlayChannel2 = 'pch2',
|
|
|
|
kPlayChannel3 = 'pch3',
|
|
|
|
kPauseChannel1 = 'pac1',
|
|
|
|
kPauseChannel2 = 'pac2',
|
|
|
|
kPauseChannel3 = 'pac3'
|
|
|
|
};
|
|
|
|
|
2010-07-30 13:54:25 +00:00
|
|
|
SoundSubsystemDialog::SoundSubsystemDialog() : TestbedInteractionDialog(80, 60, 400, 170) {
|
2010-07-29 13:09:14 +00:00
|
|
|
_xOffset = 25;
|
|
|
|
_yOffset = 0;
|
|
|
|
Common::String text = "Sound Subsystem Tests: Test Mixing of Audio Streams.";
|
|
|
|
addText(350, 20, text, Graphics::kTextAlignCenter, _xOffset, 15);
|
|
|
|
addButton(200, 20, "Play Channel #1", kPlayChannel1);
|
|
|
|
addButton(200, 20, "Play Channel #2", kPlayChannel2);
|
|
|
|
addButton(200, 20, "Play Channel #3", kPlayChannel3);
|
|
|
|
addButton(50, 20, "Close", GUI::kCloseCmd, 160, 15);
|
2010-07-30 20:10:30 +00:00
|
|
|
|
|
|
|
_mixer = g_system->getMixer();
|
|
|
|
|
2010-08-14 08:32:39 +00:00
|
|
|
// the three streams to be mixed
|
2010-07-30 20:10:30 +00:00
|
|
|
Audio::PCSpeaker *s1 = new Audio::PCSpeaker();
|
|
|
|
Audio::PCSpeaker *s2 = new Audio::PCSpeaker();
|
|
|
|
Audio::PCSpeaker *s3 = new Audio::PCSpeaker();
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-30 20:10:30 +00:00
|
|
|
s1->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
2010-08-03 19:24:09 +00:00
|
|
|
s2->play(Audio::PCSpeaker::kWaveFormSine, 1200, -1);
|
|
|
|
s3->play(Audio::PCSpeaker::kWaveFormSine, 1400, -1);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->playStream(Audio::Mixer::kPlainSoundType, &_h1, s1);
|
|
|
|
_mixer->pauseHandle(_h1, true);
|
|
|
|
|
|
|
|
_mixer->playStream(Audio::Mixer::kSpeechSoundType, &_h2, s2);
|
|
|
|
_mixer->pauseHandle(_h2, true);
|
|
|
|
|
|
|
|
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_h3, s3);
|
|
|
|
_mixer->pauseHandle(_h3, true);
|
|
|
|
|
2010-07-29 13:09:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SoundSubsystemDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-29 13:09:14 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case kPlayChannel1:
|
|
|
|
_buttonArray[0]->setLabel("Pause Channel #1");
|
|
|
|
_buttonArray[0]->setCmd(kPauseChannel1);
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->pauseHandle(_h1, false);
|
2010-07-29 13:09:14 +00:00
|
|
|
break;
|
|
|
|
case kPlayChannel2:
|
|
|
|
_buttonArray[1]->setLabel("Pause Channel #2");
|
|
|
|
_buttonArray[1]->setCmd(kPauseChannel2);
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->pauseHandle(_h2, false);
|
2010-07-29 13:09:14 +00:00
|
|
|
break;
|
|
|
|
case kPlayChannel3:
|
|
|
|
_buttonArray[2]->setLabel("Pause Channel #3");
|
|
|
|
_buttonArray[2]->setCmd(kPauseChannel3);
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->pauseHandle(_h3, false);
|
2010-07-29 13:09:14 +00:00
|
|
|
break;
|
|
|
|
case kPauseChannel1:
|
|
|
|
_buttonArray[0]->setLabel("Play Channel #1");
|
|
|
|
_buttonArray[0]->setCmd(kPlayChannel1);
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->pauseHandle(_h1, true);
|
2010-07-29 13:09:14 +00:00
|
|
|
break;
|
|
|
|
case kPauseChannel2:
|
|
|
|
_buttonArray[1]->setLabel("Play Channel #2");
|
|
|
|
_buttonArray[1]->setCmd(kPlayChannel2);
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->pauseHandle(_h2, true);
|
2010-07-29 13:09:14 +00:00
|
|
|
break;
|
|
|
|
case kPauseChannel3:
|
|
|
|
_buttonArray[2]->setLabel("Play Channel #3");
|
|
|
|
_buttonArray[2]->setCmd(kPlayChannel3);
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->pauseHandle(_h3, true);
|
2010-07-29 13:09:14 +00:00
|
|
|
break;
|
|
|
|
default:
|
2010-07-30 20:10:30 +00:00
|
|
|
_mixer->stopAll();
|
2010-07-29 13:09:14 +00:00
|
|
|
GUI::Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
TestExitStatus SoundSubsystem::playBeeps() {
|
2010-07-30 20:10:30 +00:00
|
|
|
Testsuite::clearScreen();
|
2010-08-14 08:32:39 +00:00
|
|
|
TestExitStatus passed = kTestPassed;
|
2010-07-30 20:10:30 +00:00
|
|
|
Common::String info = "Testing Sound Output by generating beeps\n"
|
|
|
|
"You should hear a left beep followed by a right beep\n";
|
|
|
|
|
|
|
|
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
|
|
Testsuite::logPrintf("Info! Skipping test : Play Beeps\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
return kTestSkipped;
|
2010-07-30 20:10:30 +00:00
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-26 20:59:50 +00:00
|
|
|
Audio::PCSpeaker *speaker = new Audio::PCSpeaker();
|
|
|
|
Audio::Mixer *mixer = g_system->getMixer();
|
|
|
|
Audio::SoundHandle handle;
|
|
|
|
mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, speaker);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-30 20:10:30 +00:00
|
|
|
// Left Beep
|
|
|
|
Testsuite::writeOnScreen("Left Beep", Common::Point(0, 100));
|
2010-07-26 20:59:50 +00:00
|
|
|
mixer->setChannelBalance(handle, -127);
|
2010-07-30 20:10:30 +00:00
|
|
|
speaker->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
|
|
|
g_system->delayMillis(500);
|
|
|
|
mixer->pauseHandle(handle, true);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-09 21:18:27 +00:00
|
|
|
if (Testsuite::handleInteractiveInput(" Were you able to hear the left beep? ", "Yes", "No", kOptionRight)) {
|
2010-07-30 20:10:30 +00:00
|
|
|
Testsuite::logDetailedPrintf("Error! Left Beep couldn't be detected : Error with Mixer::setChannelBalance()\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
passed = kTestFailed;
|
2010-07-30 20:10:30 +00:00
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-30 20:10:30 +00:00
|
|
|
// Right Beep
|
|
|
|
Testsuite::writeOnScreen("Right Beep", Common::Point(0, 100));
|
2010-07-26 20:59:50 +00:00
|
|
|
mixer->setChannelBalance(handle, 127);
|
2010-07-30 20:10:30 +00:00
|
|
|
mixer->pauseHandle(handle, false);
|
|
|
|
g_system->delayMillis(500);
|
2010-07-26 20:59:50 +00:00
|
|
|
mixer->stopAll();
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-07-30 20:10:30 +00:00
|
|
|
if (Testsuite::handleInteractiveInput("Were you able to hear the right beep?", "Yes", "No", kOptionRight)) {
|
|
|
|
Testsuite::logDetailedPrintf("Error! Right Beep couldn't be detected : Error with Mixer::setChannelBalance()\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
passed = kTestFailed;
|
2010-07-30 20:10:30 +00:00
|
|
|
}
|
|
|
|
return passed;
|
2010-07-26 20:59:50 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
TestExitStatus SoundSubsystem::mixSounds() {
|
2010-08-03 19:24:09 +00:00
|
|
|
Testsuite::clearScreen();
|
2010-08-14 08:32:39 +00:00
|
|
|
TestExitStatus passed = kTestPassed;
|
2010-08-03 19:24:09 +00:00
|
|
|
Common::String info = "Testing Mixer Output by generating multichannel sound output using PC speaker emulator.\n"
|
|
|
|
"The mixer should be able to play them simultaneously\n";
|
|
|
|
|
|
|
|
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
|
|
Testsuite::logPrintf("Info! Skipping test : Mix Sounds\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
return kTestSkipped;
|
2010-08-03 19:24:09 +00:00
|
|
|
}
|
|
|
|
|
2010-07-29 13:09:14 +00:00
|
|
|
SoundSubsystemDialog sDialog;
|
|
|
|
sDialog.runModal();
|
2010-08-03 19:24:09 +00:00
|
|
|
if (Testsuite::handleInteractiveInput("Was the mixer able to simultaneously play multiple channels?", "Yes", "No", kOptionRight)) {
|
|
|
|
Testsuite::logDetailedPrintf("Error! Multiple channels couldn't be played : Error with Mixer Class\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
passed = kTestFailed;
|
2010-08-03 19:24:09 +00:00
|
|
|
}
|
|
|
|
return passed;
|
|
|
|
}
|
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
TestExitStatus SoundSubsystem::audiocdOutput() {
|
2010-08-03 19:24:09 +00:00
|
|
|
Testsuite::clearScreen();
|
2010-08-14 08:32:39 +00:00
|
|
|
TestExitStatus passed = kTestPassed;
|
2010-08-03 19:24:09 +00:00
|
|
|
Common::String info = "Testing AudioCD API implementation.\n"
|
|
|
|
"Here we have four tracks, we play them in order i.e 1-2-3-last.\n"
|
|
|
|
"The user should verify if the tracks were run in correct order or not.";
|
|
|
|
|
|
|
|
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
|
|
Testsuite::logPrintf("Info! Skipping test : AudioCD API\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
return kTestSkipped;
|
2010-08-03 19:24:09 +00:00
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-03 19:24:09 +00:00
|
|
|
Common::Point pt(0, 100);
|
|
|
|
Testsuite::writeOnScreen("Playing the tracks of testCD in order i.e 1-2-3-last", pt);
|
|
|
|
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-03 19:24:09 +00:00
|
|
|
// Play all tracks
|
2010-08-14 08:32:39 +00:00
|
|
|
for (int i = 1; i < 5; i++) {
|
2010-11-08 22:53:36 +00:00
|
|
|
g_system->getAudioCDManager()->play(i, 1, 0, 0);
|
|
|
|
while (g_system->getAudioCDManager()->isPlaying()) {
|
2010-08-03 19:24:09 +00:00
|
|
|
g_system->delayMillis(500);
|
2010-11-01 16:02:28 +00:00
|
|
|
Testsuite::writeOnScreen(Common::String::format("Playing Now: track%02d", i), pt);
|
2010-08-03 19:24:09 +00:00
|
|
|
}
|
|
|
|
g_system->delayMillis(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
Testsuite::clearScreen();
|
|
|
|
if (Testsuite::handleInteractiveInput("Were all the tracks played in order i.e 1-2-3-last ?", "Yes", "No", kOptionRight)) {
|
2010-11-08 22:53:36 +00:00
|
|
|
Testsuite::logPrintf("Error! Error in _system->getAudioCDManager()->play() or probably sound files were not detected, try -d1 (debuglevel 1)\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
passed = kTestFailed;
|
2010-08-03 19:24:09 +00:00
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-03 19:24:09 +00:00
|
|
|
return passed;
|
2010-07-29 13:09:14 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
TestExitStatus SoundSubsystem::sampleRates() {
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
Common::String info = "Testing Multiple Sample Rates.\n"
|
|
|
|
"Here we try to play sounds at three different sample rates.";
|
|
|
|
|
|
|
|
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
|
|
Testsuite::logPrintf("Info! Skipping test : Sample Rates\n");
|
|
|
|
return kTestSkipped;
|
|
|
|
}
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-09 20:10:53 +00:00
|
|
|
TestExitStatus passed = kTestPassed;
|
2010-08-05 21:36:17 +00:00
|
|
|
Audio::Mixer *mixer = g_system->getMixer();
|
|
|
|
|
|
|
|
Audio::PCSpeaker *s1 = new Audio::PCSpeaker();
|
|
|
|
// Stream at half sampling rate
|
|
|
|
Audio::PCSpeaker *s2 = new Audio::PCSpeaker(s1->getRate() - 10000);
|
|
|
|
// Stream at twice sampling rate
|
|
|
|
Audio::PCSpeaker *s3 = new Audio::PCSpeaker(s1->getRate() + 10000);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-05 21:36:17 +00:00
|
|
|
s1->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
|
|
|
s2->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
|
|
|
s3->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-05 21:36:17 +00:00
|
|
|
Audio::SoundHandle handle;
|
|
|
|
Common::Point pt(0, 100);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-05 21:36:17 +00:00
|
|
|
mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, s1);
|
2010-11-01 16:02:28 +00:00
|
|
|
Testsuite::writeOnScreen(Common::String::format("Playing at smaple rate: %d", s1->getRate()), pt);
|
2010-08-05 21:36:17 +00:00
|
|
|
g_system->delayMillis(1000);
|
|
|
|
mixer->stopHandle(handle);
|
|
|
|
g_system->delayMillis(1000);
|
|
|
|
|
|
|
|
mixer->playStream(Audio::Mixer::kSpeechSoundType, &handle, s2);
|
2010-11-01 16:02:28 +00:00
|
|
|
Testsuite::writeOnScreen(Common::String::format("Playing at sample rate : %d", s2->getRate()), pt);
|
2010-08-05 21:36:17 +00:00
|
|
|
g_system->delayMillis(1000);
|
|
|
|
mixer->stopHandle(handle);
|
|
|
|
g_system->delayMillis(1000);
|
|
|
|
|
|
|
|
mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, s3);
|
2010-11-01 16:02:28 +00:00
|
|
|
Testsuite::writeOnScreen(Common::String::format("Playing at sample rate : %d", s3->getRate()), pt);
|
2010-08-05 21:36:17 +00:00
|
|
|
g_system->delayMillis(1000);
|
|
|
|
mixer->stopHandle(handle);
|
|
|
|
g_system->delayMillis(1000);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-05 21:36:17 +00:00
|
|
|
Testsuite::clearScreen();
|
|
|
|
if (Testsuite::handleInteractiveInput("Was the mixer able to play beeps with variable sample rates?", "Yes", "No", kOptionRight)) {
|
|
|
|
Testsuite::logDetailedPrintf("Error! Error with variable sample rates\n");
|
2010-08-09 20:10:53 +00:00
|
|
|
passed = kTestFailed;
|
2010-08-05 21:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return passed;
|
|
|
|
}
|
|
|
|
|
2010-07-26 20:59:50 +00:00
|
|
|
SoundSubsystemTestSuite::SoundSubsystemTestSuite() {
|
2010-07-30 20:10:30 +00:00
|
|
|
addTest("SimpleBeeps", &SoundSubsystem::playBeeps, true);
|
2010-07-29 13:09:14 +00:00
|
|
|
addTest("MixSounds", &SoundSubsystem::mixSounds, true);
|
2010-08-14 08:32:39 +00:00
|
|
|
|
2010-08-12 14:47:25 +00:00
|
|
|
// Make audio-files discoverable
|
|
|
|
Common::FSNode gameRoot(ConfMan.get("path"));
|
|
|
|
if (gameRoot.exists()) {
|
|
|
|
SearchMan.addSubDirectoryMatching(gameRoot, "audiocd-files");
|
|
|
|
if (SearchMan.hasFile("track01.mp3") && SearchMan.hasFile("track02.mp3") && SearchMan.hasFile("track03.mp3") && SearchMan.hasFile("track04.mp3")) {
|
|
|
|
addTest("AudiocdOutput", &SoundSubsystem::audiocdOutput, true);
|
|
|
|
} else {
|
|
|
|
Testsuite::logPrintf("Warning! Skipping test AudioCD: Required data files missing, check game-dir/audiocd-files\n");
|
|
|
|
}
|
|
|
|
}
|
2010-08-05 21:36:17 +00:00
|
|
|
addTest("SampleRates", &SoundSubsystem::sampleRates, true);
|
2010-07-26 20:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Testbed
|