Corrected formatting
This commit is contained in:
parent
dcc8a58377
commit
2e6402bae0
6 changed files with 61 additions and 58 deletions
|
|
@ -14,19 +14,20 @@
|
||||||
|
|
||||||
class MultiplyAddFixedGain : public benchmark::Fixture {
|
class MultiplyAddFixedGain : public benchmark::Fixture {
|
||||||
public:
|
public:
|
||||||
void SetUp(const ::benchmark::State& state) {
|
void SetUp(const ::benchmark::State& state)
|
||||||
std::random_device rd { };
|
{
|
||||||
|
std::random_device rd {};
|
||||||
std::mt19937 gen { rd() };
|
std::mt19937 gen { rd() };
|
||||||
std::uniform_real_distribution<float> dist { 0, 1 };
|
std::uniform_real_distribution<float> dist { 0, 1 };
|
||||||
input = std::vector<float>(state.range(0));
|
input = std::vector<float>(state.range(0));
|
||||||
output = std::vector<float>(state.range(0));
|
output = std::vector<float>(state.range(0));
|
||||||
gain = dist(gen);
|
gain = dist(gen);
|
||||||
std::fill(output.begin(), output.end(), 1.0f );
|
std::fill(output.begin(), output.end(), 1.0f);
|
||||||
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
std::generate(input.begin(), input.end(), [&]() { return dist(gen); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void TearDown(const ::benchmark::State& state [[maybe_unused]]) {
|
void TearDown(const ::benchmark::State& state [[maybe_unused]])
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float gain = {};
|
float gain = {};
|
||||||
|
|
@ -34,38 +35,43 @@ public:
|
||||||
std::vector<float> output;
|
std::vector<float> output;
|
||||||
};
|
};
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Straight)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Straight)
|
||||||
for (auto _ : state)
|
(benchmark::State& state)
|
||||||
{
|
{
|
||||||
|
for (auto _ : state) {
|
||||||
for (int i = 0; i < state.range(0); ++i)
|
for (int i = 0; i < state.range(0); ++i)
|
||||||
output[i] += gain * input[i];
|
output[i] += gain * input[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Scalar)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Scalar)
|
||||||
for (auto _ : state)
|
(benchmark::State& state)
|
||||||
{
|
{
|
||||||
|
for (auto _ : state) {
|
||||||
sfz::multiplyAdd<float, false>(gain, input, absl::MakeSpan(output));
|
sfz::multiplyAdd<float, false>(gain, input, absl::MakeSpan(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, SIMD)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, SIMD)
|
||||||
for (auto _ : state)
|
(benchmark::State& state)
|
||||||
{
|
{
|
||||||
|
for (auto _ : state) {
|
||||||
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(output));
|
sfz::multiplyAdd<float, true>(gain, input, absl::MakeSpan(output));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Scalar_Unaligned)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, Scalar_Unaligned)
|
||||||
for (auto _ : state)
|
(benchmark::State& state)
|
||||||
{
|
{
|
||||||
|
for (auto _ : state) {
|
||||||
sfz::multiplyAdd<float, false>(gain, absl::MakeSpan(input).subspan(1), absl::MakeSpan(output).subspan(1));
|
sfz::multiplyAdd<float, false>(gain, absl::MakeSpan(input).subspan(1), absl::MakeSpan(output).subspan(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, SIMD_Unaligned)(benchmark::State& state) {
|
BENCHMARK_DEFINE_F(MultiplyAddFixedGain, SIMD_Unaligned)
|
||||||
for (auto _ : state)
|
(benchmark::State& state)
|
||||||
{
|
{
|
||||||
|
for (auto _ : state) {
|
||||||
sfz::multiplyAdd<float, true>(gain, absl::MakeSpan(input).subspan(1), absl::MakeSpan(output).subspan(1));
|
sfz::multiplyAdd<float, true>(gain, absl::MakeSpan(input).subspan(1), absl::MakeSpan(output).subspan(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Convert implicitly to a pointer of channels
|
* @brief Convert implicitly to a pointer of channels
|
||||||
*/
|
*/
|
||||||
operator const float* const *() const noexcept
|
operator const float* const*() const noexcept
|
||||||
{
|
{
|
||||||
return spans.data();
|
return spans.data();
|
||||||
}
|
}
|
||||||
|
|
@ -220,7 +220,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief Convert implicitly to a pointer of channels
|
* @brief Convert implicitly to a pointer of channels
|
||||||
*/
|
*/
|
||||||
operator float* const *() noexcept
|
operator float* const*() noexcept
|
||||||
{
|
{
|
||||||
return spans.data();
|
return spans.data();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ void EffectBus::addToInputs(const float* const addInput[], float addGain, unsign
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned c = 0; c < EffectChannels; ++c) {
|
for (unsigned c = 0; c < EffectChannels; ++c) {
|
||||||
absl::Span<const float> addIn{ addInput[c], nframes };
|
absl::Span<const float> addIn { addInput[c], nframes };
|
||||||
sfz::multiplyAdd(addGain, addIn, _inputs.getSpan(c));
|
sfz::multiplyAdd(addGain, addIn, _inputs.getSpan(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public:
|
||||||
@brief Type of the factory function used to instantiate an effect given
|
@brief Type of the factory function used to instantiate an effect given
|
||||||
the contents of the <effect> block
|
the contents of the <effect> block
|
||||||
*/
|
*/
|
||||||
typedef std::unique_ptr<Effect> (MakeInstance)(absl::Span<const Opcode> members);
|
typedef std::unique_ptr<Effect>(MakeInstance)(absl::Span<const Opcode> members);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -738,7 +738,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||||
const auto effectNumber = opcode.backParameter();
|
const auto effectNumber = opcode.backParameter();
|
||||||
if (!effectNumber || *effectNumber < 1 || *effectNumber > config::maxEffectBuses)
|
if (!effectNumber || *effectNumber < 1 || *effectNumber > config::maxEffectBuses)
|
||||||
break;
|
break;
|
||||||
auto value = readOpcode<float>(opcode.value, {0, 100});
|
auto value = readOpcode<float>(opcode.value, { 0, 100 });
|
||||||
if (!value)
|
if (!value)
|
||||||
break;
|
break;
|
||||||
if (static_cast<size_t>(*effectNumber + 1) > gainToEffect.size())
|
if (static_cast<size_t>(*effectNumber + 1) > gainToEffect.size())
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
|
||||||
auto getOrCreateBus = [this](unsigned index) -> EffectBus& {
|
auto getOrCreateBus = [this](unsigned index) -> EffectBus& {
|
||||||
if (index + 1 > effectBuses.size())
|
if (index + 1 > effectBuses.size())
|
||||||
effectBuses.resize(index + 1);
|
effectBuses.resize(index + 1);
|
||||||
EffectBusPtr &slot = effectBuses[index];
|
EffectBusPtr& slot = effectBuses[index];
|
||||||
if (!slot)
|
if (!slot)
|
||||||
slot.reset(new EffectBus);
|
slot.reset(new EffectBus);
|
||||||
return *slot;
|
return *slot;
|
||||||
|
|
@ -216,7 +216,7 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
|
||||||
// note(jpc): gain opcodes are linear volumes in % units
|
// note(jpc): gain opcodes are linear volumes in % units
|
||||||
|
|
||||||
case hash("directtomain"):
|
case hash("directtomain"):
|
||||||
if (auto valueOpt = readOpcode<float>(opcode.value, {0, 100}))
|
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
|
||||||
getOrCreateBus(0).setGainToMain(*valueOpt / 100);
|
getOrCreateBus(0).setGainToMain(*valueOpt / 100);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
|
||||||
unsigned number = *numberOpt;
|
unsigned number = *numberOpt;
|
||||||
if (number < 1 || number > config::maxEffectBuses)
|
if (number < 1 || number > config::maxEffectBuses)
|
||||||
break;
|
break;
|
||||||
if (auto valueOpt = readOpcode<float>(opcode.value, {0, 100}))
|
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
|
||||||
getOrCreateBus(number).setGainToMain(*valueOpt / 100);
|
getOrCreateBus(number).setGainToMain(*valueOpt / 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -235,7 +235,7 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
|
||||||
unsigned number = *numberOpt;
|
unsigned number = *numberOpt;
|
||||||
if (number < 1 || number > config::maxEffectBuses)
|
if (number < 1 || number > config::maxEffectBuses)
|
||||||
break;
|
break;
|
||||||
if (auto valueOpt = readOpcode<float>(opcode.value, {0, 100}))
|
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
|
||||||
getOrCreateBus(number).setGainToMix(*valueOpt / 100);
|
getOrCreateBus(number).setGainToMix(*valueOpt / 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -245,12 +245,9 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
|
||||||
unsigned busIndex;
|
unsigned busIndex;
|
||||||
if (busName.empty() || busName == "main")
|
if (busName.empty() || busName == "main")
|
||||||
busIndex = 0;
|
busIndex = 0;
|
||||||
else if (busName.size() > 2 && busName.substr(0, 2) == "fx" &&
|
else if (busName.size() > 2 && busName.substr(0, 2) == "fx" && absl::SimpleAtoi(busName.substr(2), &busIndex) && busIndex >= 1 && busIndex <= config::maxEffectBuses) {
|
||||||
absl::SimpleAtoi(busName.substr(2), &busIndex) &&
|
|
||||||
busIndex >= 1 && busIndex <= config::maxEffectBuses) {
|
|
||||||
// an effect bus fxN, with N usually in [1,4]
|
// an effect bus fxN, with N usually in [1,4]
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DBG("Unsupported effect bus: " << busName);
|
DBG("Unsupported effect bus: " << busName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -465,7 +462,7 @@ void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
|
||||||
this->tempMixNodeBuffer.resize(samplesPerBlock);
|
this->tempMixNodeBuffer.resize(samplesPerBlock);
|
||||||
for (auto& voice : voices)
|
for (auto& voice : voices)
|
||||||
voice->setSamplesPerBlock(samplesPerBlock);
|
voice->setSamplesPerBlock(samplesPerBlock);
|
||||||
for (auto& bus: effectBuses)
|
for (auto& bus : effectBuses)
|
||||||
bus->setSamplesPerBlock(samplesPerBlock);
|
bus->setSamplesPerBlock(samplesPerBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue