Skip to content

Commit

Permalink
Merge pull request #96 from BoysTownOrg/fixed-level-free-response-pre…
Browse files Browse the repository at this point in the history
…determined-stimuli-eye-tracking

Fixed level free response predetermined stimuli eye tracking
  • Loading branch information
sbashford authored Jan 17, 2023
2 parents 3b1045f + 9688a59 commit b184a8f
Show file tree
Hide file tree
Showing 11 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/core/include/av-speech-in-noise/core/IModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class RunningATestFacade {
const FixedLevelTest &) = 0;
virtual void initializeWithPredeterminedTargetsAndAudioRecording(
const FixedLevelTest &) = 0;
virtual void initializeWithPredeterminedTargetsAndEyeTracking(
const FixedLevelTest &) = 0;
virtual void playCalibration(const Calibration &) = 0;
virtual void playLeftSpeakerCalibration(const Calibration &) = 0;
virtual void playRightSpeakerCalibration(const Calibration &) = 0;
Expand Down
2 changes: 2 additions & 0 deletions lib/core/include/av-speech-in-noise/core/Model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class RunningATestFacadeImpl : public RunningATestFacade {
const FixedLevelTest &) override;
void initializeWithPredeterminedTargetsAndAudioRecording(
const FixedLevelTest &) override;
void initializeWithPredeterminedTargetsAndEyeTracking(
const FixedLevelTest &) override;
void initializeWithSingleSpeaker(const AdaptiveTest &) override;
void initializeWithDelayedMasker(const AdaptiveTest &) override;
void initializeWithTargetReplacementAndEyeTracking(
Expand Down
8 changes: 8 additions & 0 deletions lib/core/src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ void RunningATestFacadeImpl::
runningATest, fixedLevelMethod, test, &audioRecording);
}

void RunningATestFacadeImpl::initializeWithPredeterminedTargetsAndEyeTracking(
const FixedLevelTest &test) {
av_speech_in_noise::initialize(
fixedLevelMethod, test, predeterminedTargets);
av_speech_in_noise::initialize(
runningATest, fixedLevelMethod, test, &eyeTracking);
}

void RunningATestFacadeImpl::initializeWithSingleSpeaker(
const AdaptiveTest &test) {
av_speech_in_noise::initialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ enum class Method {
fixedLevelFreeResponseWithAllTargetsAndEyeTracking,
fixedLevelFreeResponseWithAllTargetsAndAudioRecording,
fixedLevelFreeResponseWithPredeterminedTargetsAndAudioRecording,
fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking,
fixedLevelCoordinateResponseMeasureWithTargetReplacement,
fixedLevelCoordinateResponseMeasureWithTargetReplacementAndEyeTracking,
fixedLevelCoordinateResponseMeasureWithSilentIntervalTargets,
Expand Down Expand Up @@ -74,6 +75,9 @@ constexpr auto name(Method c) -> const char * {
fixedLevelFreeResponseWithPredeterminedTargetsAndAudioRecording:
return "fixed-level free response predetermined stimuli audio "
"recording";
case Method::fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking:
return "fixed-level free response predetermined stimuli eye "
"tracking";
case Method::fixedLevelSyllablesWithAllTargets:
return "fixed-level syllables all stimuli";
case Method::unknown:
Expand Down
9 changes: 9 additions & 0 deletions lib/ui/src/TestSettingsInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ static auto method(const std::string &contents) -> Method {
fixedLevelCoordinateResponseMeasureWithSilentIntervalTargets),
Method::
fixedLevelCoordinateResponseMeasureWithSilentIntervalTargets},
{name(Method::
fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking),
Method::
fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking},
{name(Method::fixedLevelConsonants), Method::fixedLevelConsonants},
{name(Method::fixedLevelChooseKeywordsWithAllTargets),
Method::fixedLevelChooseKeywordsWithAllTargets},
Expand Down Expand Up @@ -355,6 +359,11 @@ static void initialize(RunningATestFacade &model, Method method,
startingSnr, [&](const FixedLevelTest &test) {
model.initializeWithPredeterminedTargetsAndAudioRecording(test);
});
case Method::fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking:
return av_speech_in_noise::initialize(method, contents, identity,
startingSnr, [&](const FixedLevelTest &test) {
model.initializeWithPredeterminedTargetsAndEyeTracking(test);
});
case Method::
fixedLevelCoordinateResponseMeasureWithTargetReplacementAndEyeTracking:
return av_speech_in_noise::initializeFixedLevelFixedTrialsTest(method,
Expand Down
3 changes: 3 additions & 0 deletions macos/run.mm
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ void initializeAppAndRunEventLoop(EyeTracker &eyeTracker,
{Method::
fixedLevelFreeResponseWithPredeterminedTargetsAndAudioRecording,
freeResponsePresenter},
{Method::
fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking,
freeResponsePresenter},
{Method::fixedLevelFreeResponseWithSilentIntervalTargets,
freeResponsePresenter},
{Method::fixedLevelFreeResponseWithTargetReplacement,
Expand Down
1 change: 1 addition & 0 deletions test/MaskerPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <mutex>
#include <atomic>
#include <condition_variable>
#include <thread>

namespace av_speech_in_noise {
constexpr auto operator==(const PlayerTime &a, const PlayerTime &b) -> bool {
Expand Down
47 changes: 47 additions & 0 deletions test/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,30 @@ class InitializingFixedLevelTestWithPredeterminedTargetsAndAudioRecording
auto testMethod() -> const TestMethod * override { return method; }
};

class InitializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking
: public InitializingFixedLevelTest {
FixedLevelTest test_;
FixedLevelMethodStub *method;

public:
explicit InitializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking(
FixedLevelMethodStub *method)
: method{method} {}

void run(RunningATestFacadeImpl &model) override {
model.initializeWithPredeterminedTargetsAndEyeTracking(test_);
}

void run(
RunningATestFacadeImpl &model, const FixedLevelTest &test) override {
model.initializeWithPredeterminedTargetsAndEyeTracking(test);
}

auto test() -> const Test & override { return test_; }

auto testMethod() -> const TestMethod * override { return method; }
};

auto initializedWithEyeTracking(
RecognitionTestModelStub &m, RunningATest::Observer *observer) -> bool {
return m.observer == observer;
Expand Down Expand Up @@ -881,6 +905,9 @@ class ModelTests : public ::testing::Test {
InitializingFixedLevelTestWithPredeterminedTargetsAndAudioRecording
initializingFixedLevelTestWithPredeterminedTargetsAndAudioRecording{
&fixedLevelMethod};
InitializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking
initializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking{
&fixedLevelMethod};

void run(InitializingTestUseCase &useCase) { useCase.run(model); }

Expand Down Expand Up @@ -1297,6 +1324,12 @@ MODEL_TEST(
initializingFixedLevelTestWithPredeterminedTargetsAndAudioRecording);
}

MODEL_TEST(
initializingFixedLevelTestWithPredeterminedTargetsAndEyeTrackingInitializesFixedLevelMethod) {
assertInitializesFixedLevelMethod(
initializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking);
}

MODEL_TEST(
initializeFixedLevelTestWithSilentIntervalTargetsAndEyeTrackingInitializesFixedLevelMethod) {
assertInitializesFixedLevelMethod(
Expand Down Expand Up @@ -1359,6 +1392,13 @@ MODEL_TEST(
predeterminedTargets);
}

MODEL_TEST(
initializeFixedLevelTestWithPredeterminedTargetsAndEyeTrackingInitializesWithPredeterminedTargets) {
assertInitializesFixedLevelTestWithTargetPlaylist(
initializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking,
predeterminedTargets);
}

MODEL_TEST(
initializeFixedLevelTestWithEachTargetNTimesInitializesWithEachTargetNTimes) {
assertInitializesFixedLevelTestWithTargetPlaylist(
Expand Down Expand Up @@ -1519,6 +1559,13 @@ MODEL_TEST(initializeAdaptiveTestWithEyeTrackingInitializesWithEyeTracking) {
initializedWithEyeTracking(internalModel, &eyeTracking));
}

MODEL_TEST(
initializeFixedLevelTestWithPredertiminedTargetsAndEyeTrackingInitializesWithEyeTracking) {
run(initializingFixedLevelTestWithPredeterminedTargetsAndEyeTracking);
AV_SPEECH_IN_NOISE_EXPECT_TRUE(
initializedWithEyeTracking(internalModel, &eyeTracking));
}

MODEL_TEST(
initializeAdaptiveTestWithCyclicTargetsAndEyeTrackingInitializesWithEyeTracking) {
run(initializingAdaptiveTestWithCyclicTargetsAndEyeTracking);
Expand Down
5 changes: 5 additions & 0 deletions test/ModelStub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ class ModelStub : public RunningATestFacade {
fixedLevelTest_ = p;
}

void initializeWithPredeterminedTargetsAndEyeTracking(
const FixedLevelTest &p) override {
fixedLevelTest_ = p;
}

void completeTrial() { listener_->trialComplete(); }

void setAudioDevices(std::vector<std::string> v) {
Expand Down
7 changes: 7 additions & 0 deletions test/TestSettingsInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,13 @@ TEST_SETTINGS_INTERPRETER_TEST(
fixedLevelTestIdentity);
}

TEST_SETTINGS_INTERPRETER_TEST(
fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTrackingPassesMethod) {
assertPassesTestMethod(interpreter, model, sessionController,
Method::fixedLevelFreeResponseWithPredeterminedTargetsAndEyeTracking,
fixedLevelTestIdentity);
}

TEST_SETTINGS_INTERPRETER_TEST(adaptivePassFailOverridesTestIdentity) {
assertOverridesTestIdentity(interpreter, model, sessionController,
Method::adaptivePassFail, adaptiveTestIdentity);
Expand Down
5 changes: 5 additions & 0 deletions test/TestSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ class RequestFailingModel : public RunningATestFacade {
throw RequestFailure{errorMessage};
}

void initializeWithPredeterminedTargetsAndEyeTracking(
const FixedLevelTest &) override {
throw RequestFailure{errorMessage};
}

void initializeWithSingleSpeaker(const AdaptiveTest &) override {
throw RequestFailure{errorMessage};
}
Expand Down

0 comments on commit b184a8f

Please sign in to comment.