From 46127d27c3ab8331df23a200c0c2f62a59799cf6 Mon Sep 17 00:00:00 2001 From: Clo Yun-Hee Dufour Date: Tue, 20 Dec 2022 07:29:03 +0100 Subject: [PATCH] Make it compile on Emscripten --- src/app/FormantGenerator.cpp | 24 +++++++++++++++++------- src/app/OneFormantFilter.h | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/FormantGenerator.cpp b/src/app/FormantGenerator.cpp index e51dddf..51c2fb4 100644 --- a/src/app/FormantGenerator.cpp +++ b/src/app/FormantGenerator.cpp @@ -4,14 +4,24 @@ using nativeformat::param::createParam; FormantGenerator::FormantGenerator(const AudioTime& time, const std::vector& input) - : BufferedGenerator(time), - m_filters({{800, 0, 80}, - {1150, -6, 90}, - {2900, -32, 120}, - {3900, -20, 130}, - {4650, -50, 140}}), - m_input(input) { + : BufferedGenerator(time), m_input(input) { + // Initializing it manually instead of an initializer list constructor because + // for some reason Emscripten doesn't like it + double initial[][3] = {{800, 0, 80}, + {1150, -6, 90}, + {2900, -32, 120}, + {3900, -20, 130}, + {4650, -50, 140}}; + for (int k = 0; k < kNumFormants; ++k) { + const double fk = initial[k][0]; + const double gk = initial[k][1]; + const double bk = initial[k][2]; + + m_filters[k].setFrequency(fk); + m_filters[k].setGain(gk); + m_filters[k].setBandwidth(bk); + m_targetF[k] = m_filters[k].frequency(); m_targetB[k] = m_filters[k].bandwidth(); m_targetG[k] = m_filters[k].gain(); diff --git a/src/app/OneFormantFilter.h b/src/app/OneFormantFilter.h index 314e25a..7691dd7 100644 --- a/src/app/OneFormantFilter.h +++ b/src/app/OneFormantFilter.h @@ -5,7 +5,7 @@ class OneFormantFilter { public: - OneFormantFilter(double fc, double gain, double bw, double fs = 48000); + OneFormantFilter(double fc = 100, double gain = 0, double bw = 50, double fs = 48000); double sampleRate() const; void setSampleRate(double fs);