Explicit float literals in tests

This commit is contained in:
Paul Ferrand 2020-01-05 00:19:08 +01:00
parent d33f5dae51
commit ffca05c9f3
6 changed files with 172 additions and 172 deletions

View file

@ -64,7 +64,7 @@ TEST_CASE("[ADSREnvelope] Attack")
sfz::ADSREnvelope<float> envelope;
envelope.reset(2, 0);
std::array<float, 5> output;
std::array<float, 5> expected { 0.5, 1.0, 1.0, 1.0, 1.0 };
std::array<float, 5> expected { 0.5f, 1.0f, 1.0f, 1.0f, 1.0f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
@ -80,13 +80,13 @@ TEST_CASE("[ADSREnvelope] Attack again")
sfz::ADSREnvelope<float> envelope;
envelope.reset(3, 0);
std::array<float, 5> output;
std::array<float, 5> expected { 0.33333, 0.66667, 1.0, 1.0, 1.0 };
std::array<float, 5> expected { 0.33333f, 0.66667f, 1.0f, 1.0f, 1.0f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(3, 0);
absl::c_fill(output, -1.0);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -97,14 +97,14 @@ TEST_CASE("[ADSREnvelope] Release")
envelope.reset(2, 4);
envelope.startRelease(2);
std::array<float, 8> output;
std::array<float, 8> expected { 0.5, 1.0, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
std::array<float, 8> expected { 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4);
envelope.startRelease(2);
absl::c_fill(output, -1.0);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -115,14 +115,14 @@ TEST_CASE("[ADSREnvelope] Delay")
envelope.reset(2, 4, 1.0f, 2);
std::array<float, 10> output;
envelope.startRelease(4);
std::array<float, 10> expected { 0.0, 0.0, 0.5, 1.0, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
std::array<float, 10> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4, 1.0f, 2);
envelope.startRelease(4);
absl::c_fill(output, -1.0);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -130,15 +130,15 @@ TEST_CASE("[ADSREnvelope] Delay")
TEST_CASE("[ADSREnvelope] Lower sustain")
{
sfz::ADSREnvelope<float> envelope;
envelope.reset(2, 4, 0.5, 2);
envelope.reset(2, 4, 0.5f, 2);
std::array<float, 10> output;
std::array<float, 10> expected { 0.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
std::array<float, 10> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4, 0.5, 2);
absl::c_fill(output, -1.0);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -146,15 +146,15 @@ TEST_CASE("[ADSREnvelope] Lower sustain")
TEST_CASE("[ADSREnvelope] Decay")
{
sfz::ADSREnvelope<float> envelope;
envelope.reset(2, 4, 0.5, 2, 2);
envelope.reset(2, 4, 0.5f, 2, 2);
std::array<float, 10> output;
std::array<float, 10> expected { 0.0, 0.0, 0.5, 1.0, 0.707107, 0.5, 0.5, 0.5, 0.5, 0.5 };
std::array<float, 10> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.707107f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5 };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4, 0.5, 2, 2);
absl::c_fill(output, -1.0);
envelope.reset(2, 4, 0.5f, 2, 2);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -162,15 +162,15 @@ TEST_CASE("[ADSREnvelope] Decay")
TEST_CASE("[ADSREnvelope] Hold")
{
sfz::ADSREnvelope<float> envelope;
envelope.reset(2, 4, 0.5, 2, 2, 2);
envelope.reset(2, 4, 0.5f, 2, 2, 2);
std::array<float, 12> output;
std::array<float, 12> expected { 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 0.707107, 0.5, 0.5, 0.5, 0.5, 0.5 };
std::array<float, 12> expected { 0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.707107f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4, 0.5, 2, 2, 2);
absl::c_fill(output, -1.0);
envelope.reset(2, 4, 0.5f, 2, 2, 2);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -178,17 +178,17 @@ TEST_CASE("[ADSREnvelope] Hold")
TEST_CASE("[ADSREnvelope] Hold with release")
{
sfz::ADSREnvelope<float> envelope;
envelope.reset(2, 4, 0.5, 2, 2, 2);
envelope.reset(2, 4, 0.5f, 2, 2, 2);
envelope.startRelease(8);
std::array<float, 14> output;
std::array<float, 14> expected { 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 0.707107, 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.0, 0.0 };
std::array<float, 14> expected { 0.0f, 0.0f, 0.5f, 1.0f, 1.0f, 1.0f, 0.707107f, 0.5f, 0.05f, 0.005f, 0.0005f, 0.00005f, 0.0f, 0.0f };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4, 0.5, 2, 2, 2);
envelope.reset(2, 4, 0.5f, 2, 2, 2);
envelope.startRelease(8);
absl::c_fill(output, -1.0);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -196,16 +196,16 @@ TEST_CASE("[ADSREnvelope] Hold with release")
TEST_CASE("[ADSREnvelope] Hold with release 2")
{
sfz::ADSREnvelope<float> envelope;
envelope.reset(2, 4, 0.5, 2, 2, 2);
envelope.reset(2, 4, 0.5f, 2, 2, 2);
envelope.startRelease(4);
std::array<float, 14> output;
std::array<float, 14> expected { 0.0, 0.0, 0.5, 1.0, 0.08409, 0.00707, 0.000594604, 0.00005, 0.0, 0.0, 0.0, 0.0 };
std::array<float, 14> expected { 0.0f, 0.0f, 0.5f, 1.0f, 0.08409f, 0.00707f, 0.000594604f, 0.00005f, 0.0f, 0.0f, 0.0f, 0.0 };
for (auto& out : output)
out = envelope.getNextValue();
REQUIRE(approxEqual<float>(output, expected));
envelope.reset(2, 4, 0.5, 2, 2, 2);
envelope.reset(2, 4, 0.5f, 2, 2, 2);
envelope.startRelease(4);
absl::c_fill(output, -1.0);
absl::c_fill(output, -1.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
}

View file

@ -61,15 +61,15 @@ TEST_CASE("[AudioBuffer] Access")
const int size { 5 };
sfz::AudioBuffer<float> buffer(2, size);
for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) {
buffer.getSample(0, frameIdx) = static_cast<double>(buffer.getNumFrames()) + frameIdx;
buffer.getSample(1, frameIdx) = static_cast<double>(buffer.getNumFrames()) - frameIdx;
buffer.getSample(0, frameIdx) = static_cast<float>(buffer.getNumFrames()) + frameIdx;
buffer.getSample(1, frameIdx) = static_cast<float>(buffer.getNumFrames()) - frameIdx;
}
for (size_t frameIdx = 0; frameIdx < buffer.getNumFrames(); ++frameIdx) {
REQUIRE(buffer.getSample(0, frameIdx) == static_cast<double>(buffer.getNumFrames()) + frameIdx);
REQUIRE(buffer(0, frameIdx) == static_cast<double>(buffer.getNumFrames()) + frameIdx);
REQUIRE(buffer.getSample(1, frameIdx) == static_cast<double>(buffer.getNumFrames()) - frameIdx);
REQUIRE(buffer(1, frameIdx) == static_cast<double>(buffer.getNumFrames()) - frameIdx);
REQUIRE(buffer.getSample(0, frameIdx) == static_cast<float>(buffer.getNumFrames()) + frameIdx);
REQUIRE(buffer(0, frameIdx) == static_cast<float>(buffer.getNumFrames()) + frameIdx);
REQUIRE(buffer.getSample(1, frameIdx) == static_cast<float>(buffer.getNumFrames()) - frameIdx);
REQUIRE(buffer(1, frameIdx) == static_cast<float>(buffer.getNumFrames()) - frameIdx);
}
}
@ -98,5 +98,5 @@ TEST_CASE("[AudioSpan] Constructions")
sfz::AudioSpan<float> manualSpan { { buffer.channelWriter(0), buffer.channelWriter(1) }, buffer.getNumFrames() };
sfz::AudioSpan<const float> manualConstSpan { { buffer.channelReader(0), buffer.channelReader(1) }, buffer.getNumFrames() };
sfz::AudioSpan<float> manualSpan2 { {buffer.getSpan(0), buffer.getSpan(1) } };
sfz::AudioSpan<const float> manualConstSpan2 { {buffer.getConstSpan(0), buffer.getConstSpan(1) } };
}
sfz::AudioSpan<const float> manualConstSpan2 { { buffer.getConstSpan(0), buffer.getConstSpan(1) } };
}

View file

@ -31,7 +31,7 @@ TEST_CASE("[EGDescription] Attack range")
sfz::EGDescription eg;
sfz::SfzCCArray ccArray { 0 };
eg.attack = 1;
eg.vel2attack = -1.27;
eg.vel2attack = -1.27f;
eg.ccAttack = { 63, 1.27f };
REQUIRE( eg.getAttack(ccArray, 0) == 1.0f );
REQUIRE( eg.getAttack(ccArray, 127) == 0.0f );
@ -47,7 +47,7 @@ TEST_CASE("[EGDescription] Delay range")
sfz::EGDescription eg;
sfz::SfzCCArray ccArray { 0 };
eg.delay = 1;
eg.vel2delay = -1.27;
eg.vel2delay = -1.27f;
eg.ccDelay = { 63, 1.27f };
REQUIRE( eg.getDelay(ccArray, 0) == 1.0f );
REQUIRE( eg.getDelay(ccArray, 127) == 0.0f );
@ -79,7 +79,7 @@ TEST_CASE("[EGDescription] Release range")
sfz::EGDescription eg;
sfz::SfzCCArray ccArray { 0 };
eg.release = 1;
eg.vel2release = -1.27;
eg.vel2release = -1.27f;
eg.ccRelease = { 63, 1.27f };
REQUIRE( eg.getRelease(ccArray, 0) == 1.0f );
REQUIRE( eg.getRelease(ccArray, 127) == 0.0f );
@ -95,7 +95,7 @@ TEST_CASE("[EGDescription] Hold range")
sfz::EGDescription eg;
sfz::SfzCCArray ccArray { 0 };
eg.hold = 1;
eg.vel2hold = -1.27;
eg.vel2hold = -1.27f;
eg.ccHold = { 63, 1.27f };
REQUIRE( eg.getHold(ccArray, 0) == 1.0f );
REQUIRE( eg.getHold(ccArray, 127) == 0.0f );

View file

@ -51,7 +51,7 @@ TEST_CASE("[LinearEnvelope] Basic state")
{
sfz::LinearEnvelope<float> envelope;
std::array<float, 5> output;
std::array<float, 5> expected { 0.0, 0.0, 0.0, 0.0, 0.0 };
std::array<float, 5> expected { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -59,9 +59,9 @@ TEST_CASE("[LinearEnvelope] Basic state")
TEST_CASE("[LinearEnvelope] Basic event")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(4, 1.0);
envelope.registerEvent(4, 1.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.25, 0.5, 0.75, 1.0, 1.0, 1.0, 1.0, 1.0 };
std::array<float, 8> expected { 0.25f, 0.5f, 0.75f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -69,10 +69,10 @@ TEST_CASE("[LinearEnvelope] Basic event")
TEST_CASE("[LinearEnvelope] 2 events, close")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(4, 1.0);
envelope.registerEvent(5, 2.0);
envelope.registerEvent(4, 1.0f);
envelope.registerEvent(5, 2.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.25, 0.5, 0.75, 1.0, 2.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 0.25f, 0.5f, 0.75f, 1.0f, 2.0f, 2.0f, 2.0f, 2.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -80,10 +80,10 @@ TEST_CASE("[LinearEnvelope] 2 events, close")
TEST_CASE("[LinearEnvelope] 2 events, far")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.0f, 2.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -91,10 +91,10 @@ TEST_CASE("[LinearEnvelope] 2 events, far")
TEST_CASE("[LinearEnvelope] 2 events, reversed")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(6, 2.0);
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0f);
envelope.registerEvent(2, 1.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.0f, 2.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -102,11 +102,11 @@ TEST_CASE("[LinearEnvelope] 2 events, reversed")
TEST_CASE("[LinearEnvelope] 3 events, overlapping")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(6, 3.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
envelope.registerEvent(6, 3.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 3.0, 3.0 };
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 3.0f, 3.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -114,11 +114,11 @@ TEST_CASE("[LinearEnvelope] 3 events, overlapping")
TEST_CASE("[LinearEnvelope] 3 events, out of block")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(10, 3.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
envelope.registerEvent(10, 3.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.5, 1, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0 };
std::array<float, 8> expected { 0.5f, 1.0f, 1.25f, 1.5f, 1.75f, 2.0f, 2.5f, 3.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -126,11 +126,11 @@ TEST_CASE("[LinearEnvelope] 3 events, out of block")
TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(10, 3.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
envelope.registerEvent(10, 3.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 };
std::array<float, 8> expected { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f };
envelope.getBlock(absl::MakeSpan(output));
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
@ -139,10 +139,10 @@ TEST_CASE("[LinearEnvelope] 3 events, out of block, with another block call")
TEST_CASE("[LinearEnvelope] 2 events, with another block call")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f };
envelope.getBlock(absl::MakeSpan(output));
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
@ -152,10 +152,10 @@ TEST_CASE("[LinearEnvelope] 2 events, function")
{
sfz::LinearEnvelope<float> envelope;
envelope.setFunction([](auto x) { return 2 * x; });
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 1, 2, 2.5, 3, 3.5, 4.0, 4.0, 4.0 };
std::array<float, 8> expected { 1.0f, 2.0f, 2.5f, 3.0f, 3.5f, 4.0f, 4.0f, 4.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -163,10 +163,10 @@ TEST_CASE("[LinearEnvelope] 2 events, function")
TEST_CASE("[LinearEnvelope] Get quantized")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -174,10 +174,10 @@ TEST_CASE("[LinearEnvelope] Get quantized")
TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.1);
envelope.registerEvent(6, 1.9);
envelope.registerEvent(2, 1.1f);
envelope.registerEvent(6, 1.9f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -185,10 +185,10 @@ TEST_CASE("[LinearEnvelope] Get quantized with unquantized targets")
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 3.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 3.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 };
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -196,12 +196,12 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps")
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of block step")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 3.0);
envelope.registerEvent(10, 4.2);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 3.0f);
envelope.registerEvent(10, 4.2f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 };
std::array<float, 8> expected2 { 4.0, 4.0, 4.0,4.0, 4.0, 4.0, 4.0, 4.0 };
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f };
std::array<float, 8> expected2 { 4.0f, 4.0f, 4.0f,4.0f, 4.0f, 4.0f, 4.0f, 4.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
@ -212,11 +212,11 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and an unquantized out of
TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps")
{
sfz::LinearEnvelope<float> envelope;
envelope.reset(3.0);
envelope.registerEvent(2, 2.0);
envelope.registerEvent(6, 0.0);
envelope.reset(3.0f);
envelope.registerEvent(2, 2.0f);
envelope.registerEvent(6, 0.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 3.0, 2.0, 2.0, 1.0, 1.0, 0.0, 0.0, 0.0 };
std::array<float, 8> expected { 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -224,11 +224,11 @@ TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps")
TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized")
{
sfz::LinearEnvelope<float> envelope;
envelope.reset(0.1);
envelope.registerEvent(3, 1.0);
envelope.registerEvent(7, 3.0);
envelope.reset(0.1f);
envelope.registerEvent(3, 1.0f);
envelope.registerEvent(7, 3.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.1, 0.1, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 };
std::array<float, 8> expected { 0.1f, 0.1f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -237,11 +237,11 @@ TEST_CASE("[LinearEnvelope] Get quantized with 2 steps and starting unquantized"
TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unquantized")
{
sfz::LinearEnvelope<float> envelope;
envelope.reset(3.6);
envelope.registerEvent(4, 1.0);
envelope.reset(3.6f);
envelope.registerEvent(4, 1.0f);
envelope.registerEvent(7, 0.0);
std::array<float, 8> output;
std::array<float, 8> expected { 3.6, 3.0, 2.0, 2.0, 1.0, 1.0, 0.0, 0.0 };
std::array<float, 8> expected { 3.6f, 3.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.0f, 0.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -249,10 +249,10 @@ TEST_CASE("[LinearEnvelope] Going down quantized with 2 steps and starting unqua
TEST_CASE("[LinearEnvelope] Get quantized with unclean events")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.2);
envelope.registerEvent(6, 2.5);
envelope.registerEvent(2, 1.2f);
envelope.registerEvent(6, 2.5f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 3.0 };
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 2.0f, 2.0f, 3.0f, 3.0f, 3.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
}
@ -260,12 +260,12 @@ TEST_CASE("[LinearEnvelope] Get quantized with unclean events")
TEST_CASE("[LinearEnvelope] Get quantized 3 events, one out of block")
{
sfz::LinearEnvelope<float> envelope;
envelope.registerEvent(2, 1.0);
envelope.registerEvent(6, 2.0);
envelope.registerEvent(10, 3.0);
envelope.registerEvent(2, 1.0f);
envelope.registerEvent(6, 2.0f);
envelope.registerEvent(10, 3.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected2 { 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0 };
std::array<float, 8> expected { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
std::array<float, 8> expected2 { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
REQUIRE(output == expected);
envelope.getQuantizedBlock(absl::MakeSpan(output), 1.0f);
@ -277,7 +277,7 @@ TEST_CASE("[MultiplicativeEnvelope] Basic state")
{
sfz::MultiplicativeEnvelope<float> envelope;
std::array<float, 5> output;
std::array<float, 5> expected { 1.0, 1.0, 1.0, 1.0, 1.0 };
std::array<float, 5> expected { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -285,9 +285,9 @@ TEST_CASE("[MultiplicativeEnvelope] Basic state")
TEST_CASE("[MultiplicativeEnvelope] Basic event")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.registerEvent(4, 2.0);
envelope.registerEvent(4, 2.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 1.1892, 1.4142, 1.68176, 2.0, 2.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 1.1892f, 1.4142f, 1.68176f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -295,10 +295,10 @@ TEST_CASE("[MultiplicativeEnvelope] Basic event")
TEST_CASE("[MultiplicativeEnvelope] 2 events")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.registerEvent(4, 2.0);
envelope.registerEvent(5, 4.0);
envelope.registerEvent(4, 2.0f);
envelope.registerEvent(5, 4.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 1.1892, 1.4142, 1.68176, 2.0, 4.0, 4.0, 4.0, 4.0 };
std::array<float, 8> expected { 1.1892f, 1.4142f, 1.68176f, 2.0f, 4.0f, 4.0f, 4.0f, 4.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -306,10 +306,10 @@ TEST_CASE("[MultiplicativeEnvelope] 2 events")
TEST_CASE("[MultiplicativeEnvelope] 2 events, far")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.registerEvent(2, 2.0);
envelope.registerEvent(6, 4.0);
envelope.registerEvent(2, 2.0f);
envelope.registerEvent(6, 4.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 1.4142, 2.0, 2.37841, 2.82843, 3.36358, 4.0, 4.0, 4.0 };
std::array<float, 8> expected { 1.4142f, 2.0f, 2.37841f, 2.82843f, 3.36358f, 4.0f, 4.0f, 4.0f };
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
}
@ -317,10 +317,10 @@ TEST_CASE("[MultiplicativeEnvelope] 2 events, far")
TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.registerEvent(2, 2.0);
envelope.registerEvent(6, 4.0);
envelope.registerEvent(2, 2.0f);
envelope.registerEvent(6, 4.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 };
std::array<float, 8> expected { 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 4.0f, 4.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
REQUIRE(output == expected);
}
@ -328,12 +328,12 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps")
TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of range step")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.registerEvent(2, 2.0);
envelope.registerEvent(6, 4.0);
envelope.registerEvent(10, 8.2);
envelope.registerEvent(2, 2.0f);
envelope.registerEvent(6, 4.0f);
envelope.registerEvent(10, 8.2f);
std::array<float, 8> output;
std::array<float, 8> expected { 1.0, 2.0, 2.0, 2.0, 2.0, 4.0, 4.0, 4.0 };
std::array<float, 8> expected2 { 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0, 8.0 };
std::array<float, 8> expected { 1.0f, 2.0f, 2.0f, 2.0f, 2.0f, 4.0f, 4.0f, 4.0f };
std::array<float, 8> expected2 { 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f, 8.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
REQUIRE(output == expected);
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
@ -343,11 +343,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with an unquantized out of ran
TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.reset(4.0);
envelope.registerEvent(2, 2.0);
envelope.registerEvent(6, 0.5);
envelope.reset(4.0f);
envelope.registerEvent(2, 2.0f);
envelope.registerEvent(6, 0.5f);
std::array<float, 8> output;
std::array<float, 8> expected { 4.0, 2.0, 2.0, 1.0, 1.0, 0.5, 0.5, 0.5 };
std::array<float, 8> expected { 4.0f, 2.0f, 2.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.5f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
REQUIRE(output == expected);
}
@ -355,10 +355,10 @@ TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps")
TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.registerEvent(2, 1.2);
envelope.registerEvent(6, 2.5);
envelope.registerEvent(2, 1.2f);
envelope.registerEvent(6, 2.5f);
std::array<float, 8> output;
std::array<float, 8> expected { 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0 };
std::array<float, 8> expected { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
REQUIRE(output == expected);
}
@ -366,11 +366,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with unclean events")
TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unquantized")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.reset(0.9);
envelope.registerEvent(3, 1.0);
envelope.registerEvent(7, 4.0);
envelope.reset(0.9f);
envelope.registerEvent(3, 1.0f);
envelope.registerEvent(7, 4.0f);
std::array<float, 8> output;
std::array<float, 8> expected { 0.9, 0.9, 1.0, 1.0, 2.0, 2.0, 4.0, 4.0 };
std::array<float, 8> expected { 0.9f, 0.9f, 1.0f, 1.0f, 2.0f, 2.0f, 4.0f, 4.0f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
REQUIRE(output == expected);
}
@ -379,11 +379,11 @@ TEST_CASE("[MultiplicativeEnvelope] Get quantized with 2 steps and starting unqu
TEST_CASE("[MultiplicativeEnvelope] Going down quantized with 2 steps and starting unquantized")
{
sfz::MultiplicativeEnvelope<float> envelope;
envelope.reset(4.6);
envelope.registerEvent(4, 1.0);
envelope.registerEvent(7, 0.25);
envelope.reset(4.6f);
envelope.registerEvent(4, 1.0f);
envelope.registerEvent(7, 0.25f);
std::array<float, 8> output;
std::array<float, 8> expected { 4.6, 2.0, 1.0, 1.0, 0.5, 0.5, 0.25, 0.25 };
std::array<float, 8> expected { 4.6f, 2.0f, 1.0f, 1.0f, 0.5f, 0.5f, 0.25f, 0.25f };
envelope.getQuantizedBlock(absl::MakeSpan(output), 2.0f);
REQUIRE(output == expected);
}
@ -394,13 +394,13 @@ TEST_CASE("[MultiplicativeEnvelope] Pitch envelope basic function")
sfz::MultiplicativeEnvelope<float> envelope;
envelope.setFunction([](float pitchValue){
const auto normalizedBend = sfz::normalizeBend(pitchValue);
const auto bendInCents = normalizedBend * 200;
const auto bendInCents = normalizedBend * 200.0f;
return sfz::centsFactor(bendInCents);
});
envelope.reset(0);
envelope.reset(0.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output[255] == 1.0_a);
envelope.registerEvent(252, -6020);
envelope.registerEvent(252, -6020.0f);
envelope.getBlock(absl::MakeSpan(output));
REQUIRE(output[255] == Approx(0.9168).epsilon(0.01));
}

View file

@ -73,7 +73,7 @@ void testLowpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFile
REQUIRE(approxEqual(outputData, expectedData));
filter.reset();
std::fill(outputData.begin(), outputData.end(), 0.0);
std::fill(outputData.begin(), outputData.end(), 0.0f);
std::vector<Type> gains(size);
std::fill(gains.begin(), gains.end(), gain);
filter.processLowpassVariableGain(inputData, absl::MakeSpan(outputData), gains);
@ -108,7 +108,7 @@ void testHighpass(const fs::path& inputNumpyFile, const fs::path& outputNumpyFil
REQUIRE(approxEqual(outputData, expectedData));
filter.reset();
std::fill(outputData.begin(), outputData.end(), 0.0);
std::fill(outputData.begin(), outputData.end(), 0.0f);
std::vector<Type> gains(size);
std::fill(gains.begin(), gains.end(), gain);
filter.processHighpassVariableGain(inputData, absl::MakeSpan(outputData), gains);

View file

@ -33,7 +33,7 @@ using namespace Catch::literals;
constexpr int smallBufferSize { 3 };
constexpr int bigBufferSize { 4095 };
constexpr int medBufferSize { 127 };
constexpr double fillValue { 1.3 };
constexpr float fillValue { 1.3f };
template <class Type>
inline bool approxEqualMargin(absl::Span<const Type> lhs, absl::Span<const Type> rhs, Type eps = 1e-3)
@ -334,7 +334,7 @@ TEST_CASE("[Helpers] Interleaved write SIMD vs Scalar")
std::array<float, medBufferSize * 2> outputScalar;
std::array<float, medBufferSize * 2> outputSIMD;
std::iota(leftInput.begin(), leftInput.end(), 0.0f);
std::iota(rightInput.begin(), rightInput.end(), medBufferSize);
std::iota(rightInput.begin(), rightInput.end(), static_cast<float>(medBufferSize));
sfz::writeInterleaved<float, false>(leftInput, rightInput, absl::MakeSpan(outputScalar));
sfz::writeInterleaved<float, true>(leftInput, rightInput, absl::MakeSpan(outputSIMD));
REQUIRE(outputScalar == outputSIMD);
@ -414,7 +414,7 @@ TEST_CASE("[Helpers] Gain, spans and inplace (SIMD)")
TEST_CASE("[Helpers] SFZ looping index")
{
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
std::array<int, 6> indices;
std::array<float, 6> leftCoeffs;
std::array<float, 6> rightCoeffs;
@ -429,7 +429,7 @@ TEST_CASE("[Helpers] SFZ looping index")
TEST_CASE("[Helpers] SFZ looping index (SIMD)")
{
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
std::array<int, 6> indices;
std::array<float, 6> leftCoeffs;
std::array<float, 6> rightCoeffs;
@ -458,13 +458,13 @@ TEST_CASE("[Helpers] SFZ looping index (SIMD)")
// sfz::loopingSFZIndex<float, false>(jumps, absl::MakeSpan(leftCoeffs), absl::MakeSpan(rightCoeffs), absl::MakeSpan(indices), 1.0f, medBufferSize, 1);
// sfz::loopingSFZIndex<float, true>(jumps, absl::MakeSpan(leftCoeffsSIMD), absl::MakeSpan(rightCoeffsSIMD), absl::MakeSpan(indicesSIMD), 1.0f, medBufferSize, 1);
// for (int i = 0; i < bigBufferSize; ++i)
// REQUIRE( ((static_cast<float>(indices[i]) + rightCoeffs[i] == Approx(static_cast<float>(indicesSIMD[i]) + rightCoeffsSIMD[i]).margin(1e-2))
// REQUIRE( ((static_cast<float>(indices[i]) + rightCoeffs[i] == Approx(static_cast<float>(indicesSIMD[i]) + rightCoeffsSIMD[i]).margin(1e-2))
// || (static_cast<float>(indices[i]) + rightCoeffs[i] == Approx(static_cast<float>(indicesSIMD[i]) + rightCoeffsSIMD[i] - static_cast<float>(medBufferSize)).margin(2e-2))) );
// }
TEST_CASE("[Helpers] SFZ saturating index")
{
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
std::array<int, 6> indices;
std::array<float, 6> leftCoeffs;
std::array<float, 6> rightCoeffs;
@ -479,7 +479,7 @@ TEST_CASE("[Helpers] SFZ saturating index")
TEST_CASE("[Helpers] SFZ saturating index (SIMD)")
{
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
std::array<float, 6> jumps { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
std::array<int, 6> indices;
std::array<float, 6> leftCoeffs;
std::array<float, 6> rightCoeffs;
@ -558,7 +558,7 @@ TEST_CASE("[Helpers] Multiplicative Ramp")
std::array<float, 6> output;
std::array<float, 6> expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v };
sfz::multiplicativeRamp<float, false>(absl::MakeSpan(output), start, v);
REQUIRE(output == expected);
REQUIRE(approxEqual<float>(output, expected));
}
TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)")
@ -568,7 +568,7 @@ TEST_CASE("[Helpers] Multiplicative Ramp (SIMD)")
std::array<float, 6> output;
std::array<float, 6> expected { v, v * v, v * v * v, v * v * v * v, v * v * v * v * v, v * v * v * v * v * v };
sfz::multiplicativeRamp<float, true>(absl::MakeSpan(output), start, v);
REQUIRE(output == expected);
REQUIRE(approxEqual<float>(output, expected));
}
TEST_CASE("[Helpers] Multiplicative Ramp (SIMD vs scalar)")
@ -595,7 +595,7 @@ TEST_CASE("[Helpers] Add")
{
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
std::array<float, 5> expected { 2.0, 3.0, 4.0, 5.0, 6.0 };
std::array<float, 5> expected { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
sfz::add<float, false>(input, absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -604,7 +604,7 @@ TEST_CASE("[Helpers] Add (SIMD)")
{
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
std::array<float, 5> expected { 2.0, 3.0, 4.0, 5.0, 6.0 };
std::array<float, 5> expected { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f };
sfz::add<float, true>(input, absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -614,9 +614,9 @@ TEST_CASE("[Helpers] Add (SIMD vs scalar)")
std::vector<float> input(bigBufferSize);
std::vector<float> outputScalar(bigBufferSize);
std::vector<float> outputSIMD(bigBufferSize);
absl::c_iota(input, 0.0);
absl::c_fill(outputScalar, 0.0);
absl::c_fill(outputSIMD, 0.0);
absl::c_iota(input, 0.0f);
absl::c_fill(outputScalar, 0.0f);
absl::c_fill(outputSIMD, 0.0f);
sfz::add<float, false>(input, absl::MakeSpan(outputScalar));
sfz::add<float, true>(input, absl::MakeSpan(outputSIMD));
@ -627,7 +627,7 @@ TEST_CASE("[Helpers] Subtract")
{
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
std::array<float, 5> expected { 0.0, -1.0, -2.0, -3.0, -4.0 };
std::array<float, 5> expected { 0.0f, -1.0f, -2.0f, -3.0f, -4.0f };
sfz::subtract<float, false>(input, absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -635,7 +635,7 @@ TEST_CASE("[Helpers] Subtract")
TEST_CASE("[Helpers] Subtract 2")
{
std::array<float, 5> output { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
std::array<float, 5> expected { 0.0, 1.0, 2.0, 3.0, 4.0 };
std::array<float, 5> expected { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f };
sfz::subtract<float, false>(1.0f, absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -645,7 +645,7 @@ TEST_CASE("[Helpers] Subtract (SIMD)")
{
std::array<float, 5> input { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };
std::array<float, 5> output { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f };
std::array<float, 5> expected { 0.0, -1.0, -2.0, -3.0, -4.0 };
std::array<float, 5> expected { 0.0f, -1.0f, -2.0f, -3.0f, -4.0f };
sfz::subtract<float, true>(input, absl::MakeSpan(output));
REQUIRE(output == expected);
}
@ -655,9 +655,9 @@ TEST_CASE("[Helpers] Subtract (SIMD vs scalar)")
std::vector<float> input(bigBufferSize);
std::vector<float> outputScalar(bigBufferSize);
std::vector<float> outputSIMD(bigBufferSize);
absl::c_iota(input, 0.0);
absl::c_fill(outputScalar, 0.0);
absl::c_fill(outputSIMD, 0.0);
absl::c_iota(input, 0.0f);
absl::c_fill(outputScalar, 0.0f);
absl::c_fill(outputSIMD, 0.0f);
sfz::subtract<float, false>(input, absl::MakeSpan(outputScalar));
sfz::subtract<float, true>(input, absl::MakeSpan(outputSIMD));
@ -668,8 +668,8 @@ TEST_CASE("[Helpers] Subtract 2 (SIMD vs scalar)")
{
std::vector<float> outputScalar(bigBufferSize);
std::vector<float> outputSIMD(bigBufferSize);
absl::c_iota(outputScalar, 0.0);
absl::c_iota(outputSIMD, 0.0);
absl::c_iota(outputScalar, 0.0f);
absl::c_iota(outputSIMD, 0.0f);
sfz::subtract<float, false>(1.2f, absl::MakeSpan(outputScalar));
sfz::subtract<float, true>(1.2f, absl::MakeSpan(outputSIMD));
@ -697,9 +697,9 @@ TEST_CASE("[Helpers] copy (SIMD vs scalar)")
std::vector<float> input(bigBufferSize);
std::vector<float> outputScalar(bigBufferSize);
std::vector<float> outputSIMD(bigBufferSize);
absl::c_iota(input, 0.0);
absl::c_fill(outputScalar, 0.0);
absl::c_fill(outputSIMD, 0.0);
absl::c_iota(input, 0.0f);
absl::c_fill(outputScalar, 0.0f);
absl::c_fill(outputSIMD, 0.0f);
sfz::add<float, false>(input, absl::MakeSpan(outputScalar));
sfz::add<float, true>(input, absl::MakeSpan(outputSIMD));
@ -716,7 +716,7 @@ TEST_CASE("[Helpers] Mean")
TEST_CASE("[Helpers] Mean (SIMD vs scalar)")
{
std::vector<float> input(bigBufferSize);
absl::c_iota(input, 0.0);
absl::c_iota(input, 0.0f);
REQUIRE(sfz::mean<float, false>(input) == Approx(sfz::mean<float, true>(input)).margin(0.001));
}
@ -730,14 +730,14 @@ TEST_CASE("[Helpers] Mean Squared")
TEST_CASE("[Helpers] Mean Squared (SIMD vs scalar)")
{
std::vector<float> input(medBufferSize);
absl::c_iota(input, 0.0);
absl::c_iota(input, 0.0f);
REQUIRE(sfz::meanSquared<float, false>(input) == sfz::meanSquared<float, true>(input));
}
TEST_CASE("[Helpers] Cumulative sum ")
{
std::array<float, 6> input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0 6.5 8.1
std::array<float, 6> output;
std::array<float, 6> input { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f }; // 1.1 2.3 3.6 5.0f 6.5 8.1
std::array<float, 6> output;
std::array<float, 6> expected { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f };
sfz::cumsum<float, false>(input, absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
@ -748,7 +748,7 @@ TEST_CASE("[Helpers] Cumulative sum (SIMD vs Scalar)")
std::vector<float> input(bigBufferSize);
std::vector<float> outputScalar(bigBufferSize);
std::vector<float> outputSIMD(bigBufferSize);
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0, 0.1);
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0f, 0.1f);
sfz::cumsum<float, false>(input, absl::MakeSpan(outputScalar));
sfz::cumsum<float, true>(input, absl::MakeSpan(outputSIMD));
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
@ -757,7 +757,7 @@ TEST_CASE("[Helpers] Cumulative sum (SIMD vs Scalar)")
TEST_CASE("[Helpers] Diff ")
{
std::array<float, 6> input { 1.1f, 2.3f, 3.6f, 5.0f, 6.5f, 8.1f };
std::array<float, 6> output;
std::array<float, 6> output;
std::array<float, 6> expected { 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f };
sfz::diff<float, false>(input, absl::MakeSpan(output));
REQUIRE(approxEqual<float>(output, expected));
@ -768,8 +768,8 @@ TEST_CASE("[Helpers] Diff (SIMD vs Scalar)")
std::vector<float> input(bigBufferSize);
std::vector<float> outputScalar(bigBufferSize);
std::vector<float> outputSIMD(bigBufferSize);
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0, 0.1);
sfz::linearRamp<float>(absl::MakeSpan(input), 0.0f, 0.1f);
sfz::diff<float, false>(input, absl::MakeSpan(outputScalar));
sfz::diff<float, true>(input, absl::MakeSpan(outputSIMD));
REQUIRE(approxEqual<float>(outputScalar, outputSIMD));
}
}