aboutsummaryrefslogtreecommitdiffstats
path: root/src/MemlessPoly.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-18 13:51:37 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-18 13:51:37 +0200
commit20f50f4cbf225f014466963abf576a2a65976063 (patch)
tree29995c2824fd7257eafaadc9cd2415584de26443 /src/MemlessPoly.cpp
parenta8b1aa0b60a1f5bf884069091d0f43b12c521bb8 (diff)
downloaddabmod-20f50f4cbf225f014466963abf576a2a65976063.tar.gz
dabmod-20f50f4cbf225f014466963abf576a2a65976063.tar.bz2
dabmod-20f50f4cbf225f014466963abf576a2a65976063.zip
Remove default coefs from MemlessPoly
Diffstat (limited to 'src/MemlessPoly.cpp')
-rw-r--r--src/MemlessPoly.cpp61
1 files changed, 24 insertions, 37 deletions
diff --git a/src/MemlessPoly.cpp b/src/MemlessPoly.cpp
index b0d950c..0cc04f2 100644
--- a/src/MemlessPoly.cpp
+++ b/src/MemlessPoly.cpp
@@ -46,13 +46,6 @@ using namespace std;
#define NUM_COEFS 5
-// By default the signal is unchanged
-static const std::array<complexf, 8> default_coefficients({{
- 1, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0
- }});
-
-
MemlessPoly::MemlessPoly(const std::string& coefs_file, unsigned int num_threads) :
PipelinedModCodec(),
RemoteControllable("memlesspoly"),
@@ -85,42 +78,36 @@ MemlessPoly::MemlessPoly(const std::string& coefs_file, unsigned int num_threads
void MemlessPoly::load_coefficients(const std::string &coefFile)
{
std::vector<complexf> coefs;
- if (coefFile == "default") {
- std::copy(default_coefficients.begin(), default_coefficients.end(),
- std::back_inserter(coefs));
+ std::ifstream coef_fstream(coefFile.c_str());
+ if (!coef_fstream) {
+ throw std::runtime_error("MemlessPoly: Could not open file with coefs!");
}
- else {
- std::ifstream coef_fstream(coefFile.c_str());
- if (!coef_fstream) {
- throw std::runtime_error("MemlessPoly: Could not open file with coefs!");
- }
- int n_coefs;
- coef_fstream >> n_coefs;
+ int n_coefs;
+ coef_fstream >> n_coefs;
- if (n_coefs <= 0) {
- throw std::runtime_error("MemlessPoly: coefs file has invalid format.");
- }
- else if (n_coefs != NUM_COEFS) {
- throw std::runtime_error("MemlessPoly: invalid number of coefs: " +
- std::to_string(coefs.size()));
- }
+ if (n_coefs <= 0) {
+ throw std::runtime_error("MemlessPoly: coefs file has invalid format.");
+ }
+ else if (n_coefs != NUM_COEFS) {
+ throw std::runtime_error("MemlessPoly: invalid number of coefs: " +
+ std::to_string(coefs.size()));
+ }
- etiLog.log(debug, "MemlessPoly: Reading %d coefs...", n_coefs);
+ etiLog.log(debug, "MemlessPoly: Reading %d coefs...", n_coefs);
- coefs.resize(n_coefs);
+ coefs.resize(n_coefs);
- for (int n = 0; n < n_coefs; n++) {
- float a, b;
- coef_fstream >> a;
- coef_fstream >> b;
- coefs[n] = complexf(a, b);
+ for (int n = 0; n < n_coefs; n++) {
+ float a, b;
+ coef_fstream >> a;
+ coef_fstream >> b;
+ coefs[n] = complexf(a, b);
- if (coef_fstream.eof()) {
- etiLog.log(error, "MemlessPoly: file %s should contains %d coefs, "
- "but EOF reached after %d coefs !",
- coefFile.c_str(), n_coefs, n);
- throw std::runtime_error("MemlessPoly: coefs file invalid !");
- }
+ if (coef_fstream.eof()) {
+ etiLog.log(error, "MemlessPoly: file %s should contains %d coefs, "
+ "but EOF reached after %d coefs !",
+ coefFile.c_str(), n_coefs, n);
+ throw std::runtime_error("MemlessPoly: coefs file invalid !");
}
}