From 6c0855f3d3efc52478ba9ce019fbd4c9287f4691 Mon Sep 17 00:00:00 2001 From: Neeraj Kumar Date: Thu, 5 Aug 2010 21:36:17 +0000 Subject: TESTBED: playing audio output with variable sample rates svn-id: r51766 --- engines/testbed/detection.cpp | 2 +- engines/testbed/sound.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++ engines/testbed/sound.h | 1 + 3 files changed, 47 insertions(+), 1 deletion(-) (limited to 'engines') diff --git a/engines/testbed/detection.cpp b/engines/testbed/detection.cpp index b0e3c4693b..6267be7f06 100644 --- a/engines/testbed/detection.cpp +++ b/engines/testbed/detection.cpp @@ -43,7 +43,7 @@ static const ADGameDescription testbedDescriptions[] = { "", AD_ENTRY1(NULL, 0), // No data files required Common::EN_ANY, - Common::kPlatformLinux, + Common::kPlatformPC, ADGF_NO_FLAGS, Common::GUIO_NONE }, diff --git a/engines/testbed/sound.cpp b/engines/testbed/sound.cpp index c2e0d434c0..89aede7ef8 100644 --- a/engines/testbed/sound.cpp +++ b/engines/testbed/sound.cpp @@ -210,10 +210,55 @@ bool SoundSubsystem::audiocdOutput() { return passed; } +bool SoundSubsystem::sampleRates() { + bool passed = true; + 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); + + s1->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1); + s2->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1); + s3->play(Audio::PCSpeaker::kWaveFormSine, 1000, -1); + + Audio::SoundHandle handle; + Common::Point pt(0, 100); + + mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, s1); + Testsuite::writeOnScreen(Common::String::printf("Playing at smaple rate: %d", s1->getRate()), pt); + g_system->delayMillis(1000); + mixer->stopHandle(handle); + g_system->delayMillis(1000); + + mixer->playStream(Audio::Mixer::kSpeechSoundType, &handle, s2); + Testsuite::writeOnScreen(Common::String::printf("Playing at sample rate : %d", s2->getRate()), pt); + g_system->delayMillis(1000); + mixer->stopHandle(handle); + g_system->delayMillis(1000); + + mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, s3); + Testsuite::writeOnScreen(Common::String::printf("Playing at sample rate : %d", s3->getRate()), pt); + g_system->delayMillis(1000); + mixer->stopHandle(handle); + g_system->delayMillis(1000); + + 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"); + passed = false; + } + + return passed; +} + SoundSubsystemTestSuite::SoundSubsystemTestSuite() { addTest("SimpleBeeps", &SoundSubsystem::playBeeps, true); addTest("MixSounds", &SoundSubsystem::mixSounds, true); addTest("AudiocdOutput", &SoundSubsystem::audiocdOutput, true); + addTest("SampleRates", &SoundSubsystem::sampleRates, true); } } // End of namespace Testbed diff --git a/engines/testbed/sound.h b/engines/testbed/sound.h index 1507c4543d..53ff96cedb 100644 --- a/engines/testbed/sound.h +++ b/engines/testbed/sound.h @@ -49,6 +49,7 @@ namespace SoundSubsystem { bool playBeeps(); bool mixSounds(); bool audiocdOutput(); +bool sampleRates(); } class SoundSubsystemTestSuite : public Testsuite { -- cgit v1.2.3