Skip to content

Commit

Permalink
Make it compile on Emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
clo-yunhee committed Dec 20, 2022
1 parent 7c6a164 commit 46127d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions src/app/FormantGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ using nativeformat::param::createParam;

FormantGenerator::FormantGenerator(const AudioTime& time,
const std::vector<double>& 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();
Expand Down
2 changes: 1 addition & 1 deletion src/app/OneFormantFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 46127d2

Please sign in to comment.