Add some functions to lookup filter type. Add the bpk_2p alias.
This commit is contained in:
parent
21ed6f9ed3
commit
344e318b19
3 changed files with 73 additions and 33 deletions
|
|
@ -498,32 +498,13 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||||
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
if (!extendIfNecessary(filters, filterIndex + 1, Default::numFilters))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (hash(opcode.value)) {
|
absl::optional<FilterType> ftype = Filter::typeFromName(opcode.value);
|
||||||
case hash("lpf_1p"): filters[filterIndex].type = FilterType::kFilterLpf1p; break;
|
|
||||||
case hash("hpf_1p"): filters[filterIndex].type = FilterType::kFilterHpf1p; break;
|
if (ftype)
|
||||||
case hash("lpf_2p"): filters[filterIndex].type = FilterType::kFilterLpf2p; break;
|
filters[filterIndex].type = *ftype;
|
||||||
case hash("hpf_2p"): filters[filterIndex].type = FilterType::kFilterHpf2p; break;
|
else {
|
||||||
case hash("bpf_2p"): filters[filterIndex].type = FilterType::kFilterBpf2p; break;
|
filters[filterIndex].type = FilterType::kFilterNone;
|
||||||
case hash("brf_2p"): filters[filterIndex].type = FilterType::kFilterBrf2p; break;
|
DBG("Unknown filter type: " << std::string(opcode.value));
|
||||||
case hash("bpf_1p"): filters[filterIndex].type = FilterType::kFilterBpf1p; break;
|
|
||||||
case hash("brf_1p"): filters[filterIndex].type = FilterType::kFilterBrf1p; break;
|
|
||||||
case hash("apf_1p"): filters[filterIndex].type = FilterType::kFilterApf1p; break;
|
|
||||||
case hash("lpf_2p_sv"): filters[filterIndex].type = FilterType::kFilterLpf2pSv; break;
|
|
||||||
case hash("hpf_2p_sv"): filters[filterIndex].type = FilterType::kFilterHpf2pSv; break;
|
|
||||||
case hash("bpf_2p_sv"): filters[filterIndex].type = FilterType::kFilterBpf2pSv; break;
|
|
||||||
case hash("brf_2p_sv"): filters[filterIndex].type = FilterType::kFilterBrf2pSv; break;
|
|
||||||
case hash("lpf_4p"): filters[filterIndex].type = FilterType::kFilterLpf4p; break;
|
|
||||||
case hash("hpf_4p"): filters[filterIndex].type = FilterType::kFilterHpf4p; break;
|
|
||||||
case hash("lpf_6p"): filters[filterIndex].type = FilterType::kFilterLpf6p; break;
|
|
||||||
case hash("hpf_6p"): filters[filterIndex].type = FilterType::kFilterHpf6p; break;
|
|
||||||
case hash("pink"): filters[filterIndex].type = FilterType::kFilterPink; break;
|
|
||||||
case hash("lsh"): filters[filterIndex].type = FilterType::kFilterLsh; break;
|
|
||||||
case hash("hsh"): filters[filterIndex].type = FilterType::kFilterHsh; break;
|
|
||||||
case hash("pkf_2p"): [[fallthrough]];
|
|
||||||
case hash("peq"): filters[filterIndex].type = FilterType::kFilterPeq; break;
|
|
||||||
default:
|
|
||||||
filters[filterIndex].type = FilterType::kFilterNone;
|
|
||||||
DBG("Unknown filter type: " << std::string(opcode.value));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -629,13 +610,13 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||||
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
if (!extendIfNecessary(equalizers, eqNumber, Default::numEQs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (hash(opcode.value)) {
|
absl::optional<EqType> ftype = FilterEq::typeFromName(opcode.value);
|
||||||
case hash("peak"): equalizers[eqNumber - 1].type = EqType::kEqPeak; break;
|
|
||||||
case hash("lshelf"): equalizers[eqNumber - 1].type = EqType::kEqLowShelf; break;
|
if (ftype)
|
||||||
case hash("hshelf"): equalizers[eqNumber - 1].type = EqType::kEqHighShelf; break;
|
equalizers[eqNumber - 1].type = *ftype;
|
||||||
default:
|
else {
|
||||||
equalizers[eqNumber - 1].type = EqType::kEqNone;
|
equalizers[eqNumber - 1].type = EqType::kEqNone;
|
||||||
DBG("Unknown EQ type: " << std::string(opcode.value));
|
DBG("Unknown EQ type: " << std::string(opcode.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "SfzFilter.h"
|
#include "SfzFilter.h"
|
||||||
#include "SfzFilterImpls.cxx"
|
#include "SfzFilterImpls.cxx"
|
||||||
|
#include "StringViewHelpers.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "SIMDHelpers.h"
|
#include "SIMDHelpers.h"
|
||||||
#include "Debug.h"
|
#include "Debug.h"
|
||||||
|
|
@ -203,6 +204,39 @@ void Filter::setType(FilterType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absl::optional<FilterType> Filter::typeFromName(absl::string_view name)
|
||||||
|
{
|
||||||
|
absl::optional<FilterType> ftype;
|
||||||
|
|
||||||
|
switch (hash(name)) {
|
||||||
|
case hash("lpf_1p"): ftype = kFilterLpf1p; break;
|
||||||
|
case hash("hpf_1p"): ftype = kFilterHpf1p; break;
|
||||||
|
case hash("lpf_2p"): ftype = kFilterLpf2p; break;
|
||||||
|
case hash("hpf_2p"): ftype = kFilterHpf2p; break;
|
||||||
|
case hash("bpf_2p"): ftype = kFilterBpf2p; break;
|
||||||
|
case hash("brf_2p"): ftype = kFilterBrf2p; break;
|
||||||
|
case hash("bpf_1p"): ftype = kFilterBpf1p; break;
|
||||||
|
case hash("brf_1p"): ftype = kFilterBrf1p; break;
|
||||||
|
case hash("apf_1p"): ftype = kFilterApf1p; break;
|
||||||
|
case hash("lpf_2p_sv"): ftype = kFilterLpf2pSv; break;
|
||||||
|
case hash("hpf_2p_sv"): ftype = kFilterHpf2pSv; break;
|
||||||
|
case hash("bpf_2p_sv"): ftype = kFilterBpf2pSv; break;
|
||||||
|
case hash("brf_2p_sv"): ftype = kFilterBrf2pSv; break;
|
||||||
|
case hash("lpf_4p"): ftype = kFilterLpf4p; break;
|
||||||
|
case hash("hpf_4p"): ftype = kFilterHpf4p; break;
|
||||||
|
case hash("lpf_6p"): ftype = kFilterLpf6p; break;
|
||||||
|
case hash("hpf_6p"): ftype = kFilterHpf6p; break;
|
||||||
|
case hash("pink"): ftype = kFilterPink; break;
|
||||||
|
case hash("lsh"): ftype = kFilterLsh; break;
|
||||||
|
case hash("hsh"): ftype = kFilterHsh; break;
|
||||||
|
case hash("bpk_2p"): [[fallthrough]];
|
||||||
|
case hash("pkf_2p"): [[fallthrough]];
|
||||||
|
case hash("peq"): ftype = kFilterPeq; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ftype;
|
||||||
|
}
|
||||||
|
|
||||||
sfzFilterDsp *Filter::Impl::getDsp(unsigned channels, FilterType type)
|
sfzFilterDsp *Filter::Impl::getDsp(unsigned channels, FilterType type)
|
||||||
{
|
{
|
||||||
switch (idDsp(channels, type)) {
|
switch (idDsp(channels, type)) {
|
||||||
|
|
@ -410,6 +444,19 @@ void FilterEq::setType(EqType type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absl::optional<EqType> FilterEq::typeFromName(absl::string_view name)
|
||||||
|
{
|
||||||
|
absl::optional<EqType> ftype;
|
||||||
|
|
||||||
|
switch (hash(name)) {
|
||||||
|
case hash("peak"): ftype = kEqPeak; break;
|
||||||
|
case hash("lshelf"): ftype = kEqLowShelf; break;
|
||||||
|
case hash("hshelf"): ftype = kEqHighShelf; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ftype;
|
||||||
|
}
|
||||||
|
|
||||||
sfzFilterDsp *FilterEq::Impl::getDsp(unsigned channels, EqType type)
|
sfzFilterDsp *FilterEq::Impl::getDsp(unsigned channels, EqType type)
|
||||||
{
|
{
|
||||||
switch (idDsp(channels, type)) {
|
switch (idDsp(channels, type)) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "absl/types/optional.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace sfz {
|
namespace sfz {
|
||||||
|
|
@ -82,6 +84,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setType(FilterType type);
|
void setType(FilterType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the filter type associated with the given name.
|
||||||
|
*/
|
||||||
|
static absl::optional<FilterType> typeFromName(absl::string_view name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
std::unique_ptr<Impl> P;
|
std::unique_ptr<Impl> P;
|
||||||
|
|
@ -187,6 +194,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void setType(EqType type);
|
void setType(EqType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get the filter type associated with the given name.
|
||||||
|
*/
|
||||||
|
static absl::optional<EqType> typeFromName(absl::string_view name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Impl;
|
struct Impl;
|
||||||
std::unique_ptr<Impl> P;
|
std::unique_ptr<Impl> P;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue