diff --git a/components/audio/test/mixer_unit.cpp b/components/audio/test/mixer_unit.cpp index b32b9cdb4cac7dbddf8f0124ee9eea2b040cc08b..dc98685be903634d20f570b2d48f43ea7bf90f49 100644 --- a/components/audio/test/mixer_unit.cpp +++ b/components/audio/test/mixer_unit.cpp @@ -5,10 +5,10 @@ using ftl::audio::StereoMixerF; TEST_CASE("Audio Mixer Stereo Float", "") { SECTION("Add two in sync tracks") { - StereoMixerF<100> mixer; + auto mixer = std::make_unique<StereoMixerF<100>>(); - mixer.add("Track1"); - mixer.add("Track2"); + mixer->add("Track1"); + mixer->add("Track2"); // Three 960 sample stereo frames std::vector<float> in1(960*2*3); @@ -17,16 +17,16 @@ TEST_CASE("Audio Mixer Stereo Float", "") { for (int i=0; i<960*2*3; ++i) in1[i] = float(i)+1.0f; for (int i=0; i<960*2*3; ++i) in2[i] = float(i)+2.0f; - mixer.write(0, in1); - mixer.write(1, in2); - mixer.mix(); + mixer->write(0, in1); + mixer->write(1, in2); + mixer->mix(); - REQUIRE( mixer.writePosition() == 3 ); - REQUIRE( mixer.readPosition() == 0 ); + REQUIRE( mixer->writePosition() == 3 ); + REQUIRE( mixer->readPosition() == 0 ); // Read one of the three valid frames std::vector<float> out; - mixer.read(out, 1); + mixer->read(out, 1); bool correct = true; // Check all values are correct @@ -39,10 +39,10 @@ TEST_CASE("Audio Mixer Stereo Float", "") { } SECTION("Add two out of sync tracks") { - StereoMixerF<100> mixer; + auto mixer = std::make_unique<StereoMixerF<100>>(); - mixer.add("Track1"); - mixer.add("Track2"); + mixer->add("Track1"); + mixer->add("Track2"); // Three 960 sample stereo frames std::vector<float> in1(960*2*3); @@ -51,16 +51,16 @@ TEST_CASE("Audio Mixer Stereo Float", "") { for (int i=0; i<960*2*3; ++i) in1[i] = float(i)+1.0f; for (int i=0; i<960*2*2; ++i) in2[i] = float(i)+2.0f; - mixer.write(0, in1); - mixer.write(1, in2); - mixer.mix(); + mixer->write(0, in1); + mixer->write(1, in2); + mixer->mix(); - REQUIRE( mixer.writePosition() == 2 ); - REQUIRE( mixer.readPosition() == 0 ); + REQUIRE( mixer->writePosition() == 2 ); + REQUIRE( mixer->readPosition() == 0 ); // Read one of the three valid frames std::vector<float> out; - mixer.read(out, 2); + mixer->read(out, 2); bool correct = true; // Check all values are correct @@ -75,13 +75,13 @@ TEST_CASE("Audio Mixer Stereo Float", "") { std::vector<float> in3(960*2*1); for (int i=0; i<960*2*1; ++i) in3[i] = float(i)+1.0f; - mixer.write(1, in3); - mixer.mix(); + mixer->write(1, in3); + mixer->mix(); - REQUIRE( mixer.writePosition() == 3 ); - REQUIRE( mixer.readPosition() == 2 ); + REQUIRE( mixer->writePosition() == 3 ); + REQUIRE( mixer->readPosition() == 2 ); - mixer.read(out, 1); + mixer->read(out, 1); // Check all values are correct for (int i=0; i<960*2*1; ++i) { @@ -95,35 +95,35 @@ TEST_CASE("Audio Mixer Stereo Float", "") { TEST_CASE("Audio Mixer Stereo Float Dynamic Tracks", "") { SECTION("Add one track after write") { - StereoMixerF<100> mixer; + auto mixer = std::make_unique<StereoMixerF<100>>(); - mixer.add("Track1"); + mixer->add("Track1"); // Three 960 sample stereo frames std::vector<float> in1(960*2*3); for (int i=0; i<960*2*3; ++i) in1[i] = float(i)+1.0f; - mixer.write(0, in1); - mixer.mix(); + mixer->write(0, in1); + mixer->mix(); - REQUIRE( mixer.writePosition() == 3 ); - REQUIRE( mixer.readPosition() == 0 ); + REQUIRE( mixer->writePosition() == 3 ); + REQUIRE( mixer->readPosition() == 0 ); std::vector<float> in2(960*2*3); for (int i=0; i<960*2*3; ++i) in2[i] = float(i)+2.0f; - mixer.add("Track2"); - mixer.write(0, in1); - mixer.write(1, in2); - mixer.mix(); + mixer->add("Track2"); + mixer->write(0, in1); + mixer->write(1, in2); + mixer->mix(); - REQUIRE( mixer.writePosition() == 6 ); - REQUIRE( mixer.readPosition() == 0 ); - REQUIRE( mixer.frames() == 6 ); + REQUIRE( mixer->writePosition() == 6 ); + REQUIRE( mixer->readPosition() == 0 ); + REQUIRE( mixer->frames() == 6 ); // Read one of the three valid frames std::vector<float> out; - mixer.read(out, mixer.frames()); + mixer->read(out, mixer->frames()); bool correct = true; // Check all values are correct