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