ref: 6da202f15fe72e56a509f617b1544b9b6cbe4864
parent: 924693c703c1372e3f60815c012b3cdcba417dd3
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed May 13 07:35:39 EDT 2020
add piano dsp
--- a/README.md
+++ b/README.md
@@ -1,11 +1,13 @@
# neindaw
-Some kind of DAW for 9front? An ongoing effort. Each instrument and filter is
-a filesystem. On top of that idea a DAW is supposed to be built, the UI is
-optional and based on the files exposed by each instrument or filter.
+Some kind of DAW for 9front? An ongoing effort. Each instrument and
+filter is a filesystem. On top of that idea a DAW is supposed to be
+built, the UI is optional and based on the files exposed by each
+instrument or filter.
-Besides the usual C interfaces, neindaw uses [Faust](https://faust.grame.fr)
-to build instruments. Here, watch this:
+Besides the usual C interfaces, neindaw uses
+[Faust](https://faust.grame.fr) to build instruments. Here, watch
+this:
![code](kick.jpg) → ![result](cfg.png)
@@ -17,13 +19,14 @@
## Testing
-One can use [ORCΛ](https://git.sr.ht/~ft/orca) coupled with neindaw as a
-live-coding environment under Plan 9, see [piper](piper/README.md).
+One can use [ORCΛ](https://git.sr.ht/~ft/orca) coupled with neindaw as
+a live-coding environment under Plan 9, see [piper](piper/README.md).
Here a basic example of using neindaw
manually is shown.
-So far two instruments are provided, which is a kick drum synth and AY-3-8910.
+So far three instruments are available: a simplified kick drum,
+AY-3-8910 and a piano.
```
daw/kick_drum -m /n/kick
@@ -37,8 +40,8 @@
cd K*
```
-Check the A oscillator frequency, the order is `type value initial min max step`.
-It's different for different UI elements.
+Check the A oscillator frequency, the order is `type value initial min
+max step`. It's different for different UI elements.
```
cat A/Frequency/ctl
--- a/dsp/mkfile
+++ b/dsp/mkfile
@@ -2,6 +2,7 @@
TARG=\
kick_drum\
+ piano\
BIN=/$objtype/bin/daw
--- /dev/null
+++ b/dsp/piano.c
@@ -1,0 +1,1542 @@
+/* ------------------------------------------------------------
+author: "Romain Michon (rmichon@ccrma.stanford.edu)"
+copyright: "Romain Michon"
+name: "Piano"
+version: "1.0"
+Code generated with Faust 2.23.10 (https://faust.grame.fr)
+Compilation options: -lang c -scal -ftz 0
+------------------------------------------------------------ */
+
+#ifndef __Piano_H__
+#define __Piano_H__
+
+/* Piano Plan 9 C architecture for Faust. */
+
+#include <u.h>
+#include <libc.h>
+#include "uiglue.h"
+
+#define max(x,y) (((x) > (y)) ? (x) : (y))
+#define min(x,y) (((x) < (y)) ? (x) : (y))
+
+#ifndef FAUSTFLOAT
+#define FAUSTFLOAT float
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* link with : "" */
+#include <math.h>
+#include <piano.h>
+#include <stdlib.h>
+
+static float Piano_faustpower2_f(float value) {
+ return (value * value);
+}
+
+#ifndef FAUSTCLASS
+#define FAUSTCLASS Piano
+#endif
+#ifdef __APPLE__
+#define exp10f __exp10f
+#define exp10 __exp10
+#endif
+
+typedef struct {
+ int fSampleRate;
+ float fConst0;
+ float fConst1;
+ float fConst2;
+ float fConst3;
+ float fConst4;
+ FAUSTFLOAT fHslider0;
+ float fConst5;
+ float fConst6;
+ float fConst7;
+ float fConst8;
+ float fRec11[2];
+ float fRec10[2];
+ int IOTA;
+ float fVec0[16384];
+ float fConst9;
+ int iConst10;
+ FAUSTFLOAT fHslider1;
+ FAUSTFLOAT fHslider2;
+ float fRec12[2];
+ FAUSTFLOAT fHslider3;
+ FAUSTFLOAT fHslider4;
+ int iRec23[2];
+ FAUSTFLOAT fButton0;
+ float fRec25[2];
+ float fConst11;
+ FAUSTFLOAT fHslider5;
+ float fRec24[2];
+ float fConst12;
+ float fConst13;
+ float fConst14;
+ FAUSTFLOAT fHslider6;
+ float fConst15;
+ float fRec26[2];
+ float fVec1[2];
+ float fVec2[2];
+ float fRec22[2];
+ float fRec21[2];
+ float fRec20[2];
+ float fRec19[2];
+ float fRec18[2];
+ float fConst16;
+ float fConst17;
+ float fRec17[3];
+ float fRec16[3];
+ float fRec15[3];
+ float fRec14[3];
+ float fRec13[2];
+ float fConst18;
+ FAUSTFLOAT fHslider7;
+ FAUSTFLOAT fHslider8;
+ float fRec33[2];
+ float fRec38[2];
+ float fRec37[2];
+ float fRec36[2];
+ float fRec35[2];
+ float fRec34[2];
+ float fVec3[2];
+ float fRec32[2];
+ float fRec31[2];
+ float fRec30[8192];
+ float fVec4[2];
+ float fRec42[2];
+ float fRec41[2];
+ float fRec40[8192];
+ float fVec5[2];
+ float fRec39[2];
+ float fRec27[2];
+ float fRec28[2];
+ float fConst19;
+ float fConst20;
+ float fRec43[3];
+ float fVec6[8192];
+ float fVec7[4096];
+ int iConst21;
+ float fVec8[4096];
+ int iConst22;
+ float fRec8[2];
+ float fConst23;
+ float fConst24;
+ float fConst25;
+ float fConst26;
+ float fRec47[2];
+ float fRec46[2];
+ float fVec9[16384];
+ float fConst27;
+ int iConst28;
+ float fVec10[4096];
+ int iConst29;
+ float fRec44[2];
+ float fConst30;
+ float fConst31;
+ float fConst32;
+ float fConst33;
+ float fRec51[2];
+ float fRec50[2];
+ float fVec11[16384];
+ float fConst34;
+ int iConst35;
+ float fVec12[2048];
+ int iConst36;
+ float fRec48[2];
+ float fConst37;
+ float fConst38;
+ float fConst39;
+ float fConst40;
+ float fRec55[2];
+ float fRec54[2];
+ float fVec13[32768];
+ float fConst41;
+ int iConst42;
+ float fConst43;
+ FAUSTFLOAT fHslider9;
+ float fVec14[4096];
+ float fVec15[4096];
+ int iConst44;
+ float fRec52[2];
+ float fConst45;
+ float fConst46;
+ float fConst47;
+ float fConst48;
+ float fRec59[2];
+ float fRec58[2];
+ float fVec16[32768];
+ float fConst49;
+ int iConst50;
+ float fVec17[2048];
+ int iConst51;
+ float fRec56[2];
+ float fConst52;
+ float fConst53;
+ float fConst54;
+ float fConst55;
+ float fRec63[2];
+ float fRec62[2];
+ float fVec18[16384];
+ float fConst56;
+ int iConst57;
+ float fVec19[2048];
+ int iConst58;
+ float fRec60[2];
+ float fConst59;
+ float fConst60;
+ float fConst61;
+ float fConst62;
+ float fRec67[2];
+ float fRec66[2];
+ float fVec20[32768];
+ float fConst63;
+ int iConst64;
+ float fVec21[4096];
+ int iConst65;
+ float fRec64[2];
+ float fConst66;
+ float fConst67;
+ float fConst68;
+ float fConst69;
+ float fRec71[2];
+ float fRec70[2];
+ float fVec22[16384];
+ float fConst70;
+ int iConst71;
+ float fVec23[4096];
+ int iConst72;
+ float fRec68[2];
+ float fRec0[3];
+ float fRec1[3];
+ float fRec2[3];
+ float fRec3[3];
+ float fRec4[3];
+ float fRec5[3];
+ float fRec6[3];
+ float fRec7[3];
+} Piano;
+
+Piano* newPiano(void) {
+ Piano* dsp = (Piano*)calloc(1, sizeof(Piano));
+ return dsp;
+}
+
+void deletePiano(Piano* dsp) {
+ USED(dsp);
+ free(dsp);
+}
+
+void metadataPiano(MetaGlue* m) {
+ m->declare(m->metaInterface, "author", "Romain Michon (rmichon@ccrma.stanford.edu)");
+ m->declare(m->metaInterface, "basics.lib/name", "Faust Basic Element Library");
+ m->declare(m->metaInterface, "basics.lib/version", "0.1");
+ m->declare(m->metaInterface, "copyright", "Romain Michon");
+ m->declare(m->metaInterface, "delays.lib/name", "Faust Delay Library");
+ m->declare(m->metaInterface, "delays.lib/version", "0.1");
+ m->declare(m->metaInterface, "description", "WaveGuide Commuted Piano");
+ m->declare(m->metaInterface, "filename", "piano.dsp");
+ m->declare(m->metaInterface, "filters.lib/allpass_comb:author", "Julius O. Smith III");
+ m->declare(m->metaInterface, "filters.lib/allpass_comb:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
+ m->declare(m->metaInterface, "filters.lib/allpass_comb:license", "MIT-style STK-4.3 license");
+ m->declare(m->metaInterface, "filters.lib/lowpass0_highpass1", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
+ m->declare(m->metaInterface, "filters.lib/lowpass0_highpass1:author", "Julius O. Smith III");
+ m->declare(m->metaInterface, "filters.lib/lowpass:author", "Julius O. Smith III");
+ m->declare(m->metaInterface, "filters.lib/lowpass:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
+ m->declare(m->metaInterface, "filters.lib/lowpass:license", "MIT-style STK-4.3 license");
+ m->declare(m->metaInterface, "filters.lib/name", "Faust Filters Library");
+ m->declare(m->metaInterface, "filters.lib/tf1:author", "Julius O. Smith III");
+ m->declare(m->metaInterface, "filters.lib/tf1:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
+ m->declare(m->metaInterface, "filters.lib/tf1:license", "MIT-style STK-4.3 license");
+ m->declare(m->metaInterface, "filters.lib/tf1s:author", "Julius O. Smith III");
+ m->declare(m->metaInterface, "filters.lib/tf1s:copyright", "Copyright (C) 2003-2019 by Julius O. Smith III <jos@ccrma.stanford.edu>");
+ m->declare(m->metaInterface, "filters.lib/tf1s:license", "MIT-style STK-4.3 license");
+ m->declare(m->metaInterface, "group", "Synthesis");
+ m->declare(m->metaInterface, "instruments.lib/author", "Romain Michon (rmichon@ccrma.stanford.edu)");
+ m->declare(m->metaInterface, "instruments.lib/copyright", "Romain Michon");
+ m->declare(m->metaInterface, "instruments.lib/licence", "STK-4.3");
+ m->declare(m->metaInterface, "instruments.lib/name", "Faust-STK Tools Library");
+ m->declare(m->metaInterface, "instruments.lib/version", "1.0");
+ m->declare(m->metaInterface, "licence", "STK-4.3");
+ m->declare(m->metaInterface, "maths.lib/author", "GRAME");
+ m->declare(m->metaInterface, "maths.lib/copyright", "GRAME");
+ m->declare(m->metaInterface, "maths.lib/license", "LGPL with exception");
+ m->declare(m->metaInterface, "maths.lib/name", "Faust Math Library");
+ m->declare(m->metaInterface, "maths.lib/version", "2.3");
+ m->declare(m->metaInterface, "name", "Piano");
+ m->declare(m->metaInterface, "noises.lib/name", "Faust Noise Generator Library");
+ m->declare(m->metaInterface, "noises.lib/version", "0.0");
+ m->declare(m->metaInterface, "platform.lib/name", "Generic Platform Library");
+ m->declare(m->metaInterface, "platform.lib/version", "0.1");
+ m->declare(m->metaInterface, "reverbs.lib/name", "Faust Reverb Library");
+ m->declare(m->metaInterface, "reverbs.lib/version", "0.0");
+ m->declare(m->metaInterface, "routes.lib/name", "Faust Signal Routing Library");
+ m->declare(m->metaInterface, "routes.lib/version", "0.2");
+ m->declare(m->metaInterface, "signals.lib/name", "Faust Signal Routing Library");
+ m->declare(m->metaInterface, "signals.lib/version", "0.0");
+ m->declare(m->metaInterface, "version", "1.0");
+}
+
+int getSampleRatePiano(Piano* dsp) {
+ USED(dsp);
+ return dsp->fSampleRate;
+}
+
+int getNumInputsPiano(Piano* dsp) {
+ USED(dsp);
+ return 0;
+}
+int getNumOutputsPiano(Piano* dsp) {
+ USED(dsp);
+ return 2;
+}
+int getInputRatePiano(Piano* dsp, int channel) {
+ USED(dsp);
+ int rate;
+ switch ((channel)) {
+ default: {
+ rate = -1;
+ break;
+ }
+ }
+ return rate;
+}
+int getOutputRatePiano(Piano* dsp, int channel) {
+ USED(dsp);
+ int rate;
+ switch ((channel)) {
+ case 0: {
+ rate = 1;
+ break;
+ }
+ case 1: {
+ rate = 1;
+ break;
+ }
+ default: {
+ rate = -1;
+ break;
+ }
+ }
+ return rate;
+}
+
+void classInitPiano(int sample_rate) {
+ USED(sample_rate);
+}
+
+void instanceResetUserInterfacePiano(Piano* dsp) {
+ USED(dsp);
+ dsp->fHslider0 = (FAUSTFLOAT)0.71999999999999997f;
+ dsp->fHslider1 = (FAUSTFLOAT)0.59999999999999998f;
+ dsp->fHslider2 = (FAUSTFLOAT)0.13700000000000001f;
+ dsp->fHslider3 = (FAUSTFLOAT)440.0f;
+ dsp->fHslider4 = (FAUSTFLOAT)0.0f;
+ dsp->fButton0 = (FAUSTFLOAT)0.0f;
+ dsp->fHslider5 = (FAUSTFLOAT)1.0f;
+ dsp->fHslider6 = (FAUSTFLOAT)0.10000000000000001f;
+ dsp->fHslider7 = (FAUSTFLOAT)0.28000000000000003f;
+ dsp->fHslider8 = (FAUSTFLOAT)0.10000000000000001f;
+ dsp->fHslider9 = (FAUSTFLOAT)0.5f;
+}
+
+void instanceClearPiano(Piano* dsp) {
+ USED(dsp);
+ /* C99 loop */
+ {
+ int l0;
+ for (l0 = 0; (l0 < 2); l0 = (l0 + 1)) {
+ dsp->fRec11[l0] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l1;
+ for (l1 = 0; (l1 < 2); l1 = (l1 + 1)) {
+ dsp->fRec10[l1] = 0.0f;
+ }
+ }
+ dsp->IOTA = 0;
+ /* C99 loop */
+ {
+ int l2;
+ for (l2 = 0; (l2 < 16384); l2 = (l2 + 1)) {
+ dsp->fVec0[l2] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l3;
+ for (l3 = 0; (l3 < 2); l3 = (l3 + 1)) {
+ dsp->fRec12[l3] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l4;
+ for (l4 = 0; (l4 < 2); l4 = (l4 + 1)) {
+ dsp->iRec23[l4] = 0;
+ }
+ }
+ /* C99 loop */
+ {
+ int l5;
+ for (l5 = 0; (l5 < 2); l5 = (l5 + 1)) {
+ dsp->fRec25[l5] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l6;
+ for (l6 = 0; (l6 < 2); l6 = (l6 + 1)) {
+ dsp->fRec24[l6] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l7;
+ for (l7 = 0; (l7 < 2); l7 = (l7 + 1)) {
+ dsp->fRec26[l7] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l8;
+ for (l8 = 0; (l8 < 2); l8 = (l8 + 1)) {
+ dsp->fVec1[l8] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l9;
+ for (l9 = 0; (l9 < 2); l9 = (l9 + 1)) {
+ dsp->fVec2[l9] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l10;
+ for (l10 = 0; (l10 < 2); l10 = (l10 + 1)) {
+ dsp->fRec22[l10] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l11;
+ for (l11 = 0; (l11 < 2); l11 = (l11 + 1)) {
+ dsp->fRec21[l11] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l12;
+ for (l12 = 0; (l12 < 2); l12 = (l12 + 1)) {
+ dsp->fRec20[l12] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l13;
+ for (l13 = 0; (l13 < 2); l13 = (l13 + 1)) {
+ dsp->fRec19[l13] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l14;
+ for (l14 = 0; (l14 < 2); l14 = (l14 + 1)) {
+ dsp->fRec18[l14] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l15;
+ for (l15 = 0; (l15 < 3); l15 = (l15 + 1)) {
+ dsp->fRec17[l15] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l16;
+ for (l16 = 0; (l16 < 3); l16 = (l16 + 1)) {
+ dsp->fRec16[l16] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l17;
+ for (l17 = 0; (l17 < 3); l17 = (l17 + 1)) {
+ dsp->fRec15[l17] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l18;
+ for (l18 = 0; (l18 < 3); l18 = (l18 + 1)) {
+ dsp->fRec14[l18] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l19;
+ for (l19 = 0; (l19 < 2); l19 = (l19 + 1)) {
+ dsp->fRec13[l19] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l20;
+ for (l20 = 0; (l20 < 2); l20 = (l20 + 1)) {
+ dsp->fRec33[l20] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l21;
+ for (l21 = 0; (l21 < 2); l21 = (l21 + 1)) {
+ dsp->fRec38[l21] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l22;
+ for (l22 = 0; (l22 < 2); l22 = (l22 + 1)) {
+ dsp->fRec37[l22] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l23;
+ for (l23 = 0; (l23 < 2); l23 = (l23 + 1)) {
+ dsp->fRec36[l23] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l24;
+ for (l24 = 0; (l24 < 2); l24 = (l24 + 1)) {
+ dsp->fRec35[l24] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l25;
+ for (l25 = 0; (l25 < 2); l25 = (l25 + 1)) {
+ dsp->fRec34[l25] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l26;
+ for (l26 = 0; (l26 < 2); l26 = (l26 + 1)) {
+ dsp->fVec3[l26] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l27;
+ for (l27 = 0; (l27 < 2); l27 = (l27 + 1)) {
+ dsp->fRec32[l27] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l28;
+ for (l28 = 0; (l28 < 2); l28 = (l28 + 1)) {
+ dsp->fRec31[l28] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l29;
+ for (l29 = 0; (l29 < 8192); l29 = (l29 + 1)) {
+ dsp->fRec30[l29] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l30;
+ for (l30 = 0; (l30 < 2); l30 = (l30 + 1)) {
+ dsp->fVec4[l30] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l31;
+ for (l31 = 0; (l31 < 2); l31 = (l31 + 1)) {
+ dsp->fRec42[l31] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l32;
+ for (l32 = 0; (l32 < 2); l32 = (l32 + 1)) {
+ dsp->fRec41[l32] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l33;
+ for (l33 = 0; (l33 < 8192); l33 = (l33 + 1)) {
+ dsp->fRec40[l33] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l34;
+ for (l34 = 0; (l34 < 2); l34 = (l34 + 1)) {
+ dsp->fVec5[l34] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l35;
+ for (l35 = 0; (l35 < 2); l35 = (l35 + 1)) {
+ dsp->fRec39[l35] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l36;
+ for (l36 = 0; (l36 < 2); l36 = (l36 + 1)) {
+ dsp->fRec27[l36] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l37;
+ for (l37 = 0; (l37 < 2); l37 = (l37 + 1)) {
+ dsp->fRec28[l37] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l38;
+ for (l38 = 0; (l38 < 3); l38 = (l38 + 1)) {
+ dsp->fRec43[l38] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l39;
+ for (l39 = 0; (l39 < 8192); l39 = (l39 + 1)) {
+ dsp->fVec6[l39] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l40;
+ for (l40 = 0; (l40 < 4096); l40 = (l40 + 1)) {
+ dsp->fVec7[l40] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l41;
+ for (l41 = 0; (l41 < 4096); l41 = (l41 + 1)) {
+ dsp->fVec8[l41] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l42;
+ for (l42 = 0; (l42 < 2); l42 = (l42 + 1)) {
+ dsp->fRec8[l42] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l43;
+ for (l43 = 0; (l43 < 2); l43 = (l43 + 1)) {
+ dsp->fRec47[l43] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l44;
+ for (l44 = 0; (l44 < 2); l44 = (l44 + 1)) {
+ dsp->fRec46[l44] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l45;
+ for (l45 = 0; (l45 < 16384); l45 = (l45 + 1)) {
+ dsp->fVec9[l45] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l46;
+ for (l46 = 0; (l46 < 4096); l46 = (l46 + 1)) {
+ dsp->fVec10[l46] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l47;
+ for (l47 = 0; (l47 < 2); l47 = (l47 + 1)) {
+ dsp->fRec44[l47] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l48;
+ for (l48 = 0; (l48 < 2); l48 = (l48 + 1)) {
+ dsp->fRec51[l48] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l49;
+ for (l49 = 0; (l49 < 2); l49 = (l49 + 1)) {
+ dsp->fRec50[l49] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l50;
+ for (l50 = 0; (l50 < 16384); l50 = (l50 + 1)) {
+ dsp->fVec11[l50] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l51;
+ for (l51 = 0; (l51 < 2048); l51 = (l51 + 1)) {
+ dsp->fVec12[l51] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l52;
+ for (l52 = 0; (l52 < 2); l52 = (l52 + 1)) {
+ dsp->fRec48[l52] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l53;
+ for (l53 = 0; (l53 < 2); l53 = (l53 + 1)) {
+ dsp->fRec55[l53] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l54;
+ for (l54 = 0; (l54 < 2); l54 = (l54 + 1)) {
+ dsp->fRec54[l54] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l55;
+ for (l55 = 0; (l55 < 32768); l55 = (l55 + 1)) {
+ dsp->fVec13[l55] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l56;
+ for (l56 = 0; (l56 < 4096); l56 = (l56 + 1)) {
+ dsp->fVec14[l56] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l57;
+ for (l57 = 0; (l57 < 4096); l57 = (l57 + 1)) {
+ dsp->fVec15[l57] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l58;
+ for (l58 = 0; (l58 < 2); l58 = (l58 + 1)) {
+ dsp->fRec52[l58] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l59;
+ for (l59 = 0; (l59 < 2); l59 = (l59 + 1)) {
+ dsp->fRec59[l59] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l60;
+ for (l60 = 0; (l60 < 2); l60 = (l60 + 1)) {
+ dsp->fRec58[l60] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l61;
+ for (l61 = 0; (l61 < 32768); l61 = (l61 + 1)) {
+ dsp->fVec16[l61] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l62;
+ for (l62 = 0; (l62 < 2048); l62 = (l62 + 1)) {
+ dsp->fVec17[l62] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l63;
+ for (l63 = 0; (l63 < 2); l63 = (l63 + 1)) {
+ dsp->fRec56[l63] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l64;
+ for (l64 = 0; (l64 < 2); l64 = (l64 + 1)) {
+ dsp->fRec63[l64] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l65;
+ for (l65 = 0; (l65 < 2); l65 = (l65 + 1)) {
+ dsp->fRec62[l65] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l66;
+ for (l66 = 0; (l66 < 16384); l66 = (l66 + 1)) {
+ dsp->fVec18[l66] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l67;
+ for (l67 = 0; (l67 < 2048); l67 = (l67 + 1)) {
+ dsp->fVec19[l67] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l68;
+ for (l68 = 0; (l68 < 2); l68 = (l68 + 1)) {
+ dsp->fRec60[l68] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l69;
+ for (l69 = 0; (l69 < 2); l69 = (l69 + 1)) {
+ dsp->fRec67[l69] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l70;
+ for (l70 = 0; (l70 < 2); l70 = (l70 + 1)) {
+ dsp->fRec66[l70] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l71;
+ for (l71 = 0; (l71 < 32768); l71 = (l71 + 1)) {
+ dsp->fVec20[l71] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l72;
+ for (l72 = 0; (l72 < 4096); l72 = (l72 + 1)) {
+ dsp->fVec21[l72] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l73;
+ for (l73 = 0; (l73 < 2); l73 = (l73 + 1)) {
+ dsp->fRec64[l73] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l74;
+ for (l74 = 0; (l74 < 2); l74 = (l74 + 1)) {
+ dsp->fRec71[l74] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l75;
+ for (l75 = 0; (l75 < 2); l75 = (l75 + 1)) {
+ dsp->fRec70[l75] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l76;
+ for (l76 = 0; (l76 < 16384); l76 = (l76 + 1)) {
+ dsp->fVec22[l76] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l77;
+ for (l77 = 0; (l77 < 4096); l77 = (l77 + 1)) {
+ dsp->fVec23[l77] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l78;
+ for (l78 = 0; (l78 < 2); l78 = (l78 + 1)) {
+ dsp->fRec68[l78] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l79;
+ for (l79 = 0; (l79 < 3); l79 = (l79 + 1)) {
+ dsp->fRec0[l79] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l80;
+ for (l80 = 0; (l80 < 3); l80 = (l80 + 1)) {
+ dsp->fRec1[l80] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l81;
+ for (l81 = 0; (l81 < 3); l81 = (l81 + 1)) {
+ dsp->fRec2[l81] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l82;
+ for (l82 = 0; (l82 < 3); l82 = (l82 + 1)) {
+ dsp->fRec3[l82] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l83;
+ for (l83 = 0; (l83 < 3); l83 = (l83 + 1)) {
+ dsp->fRec4[l83] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l84;
+ for (l84 = 0; (l84 < 3); l84 = (l84 + 1)) {
+ dsp->fRec5[l84] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l85;
+ for (l85 = 0; (l85 < 3); l85 = (l85 + 1)) {
+ dsp->fRec6[l85] = 0.0f;
+ }
+ }
+ /* C99 loop */
+ {
+ int l86;
+ for (l86 = 0; (l86 < 3); l86 = (l86 + 1)) {
+ dsp->fRec7[l86] = 0.0f;
+ }
+ }
+}
+
+void instanceConstantsPiano(Piano* dsp, int sample_rate) {
+ USED(sample_rate);
+ USED(dsp);
+ dsp->fSampleRate = sample_rate;
+ dsp->fConst0 = fminf(192000.0f, fmaxf(1.0f, (float)dsp->fSampleRate));
+ dsp->fConst1 = cosf((37699.1133f / dsp->fConst0));
+ dsp->fConst2 = floorf(((0.127837002f * dsp->fConst0) + 0.5f));
+ dsp->fConst3 = ((0.0f - (6.90775537f * dsp->fConst2)) / dsp->fConst0);
+ dsp->fConst4 = (0.5f * dsp->fConst3);
+ dsp->fConst5 = (0.333333343f * dsp->fConst3);
+ dsp->fConst6 = (1.0f / tanf((628.318542f / dsp->fConst0)));
+ dsp->fConst7 = (1.0f / (dsp->fConst6 + 1.0f));
+ dsp->fConst8 = (1.0f - dsp->fConst6);
+ dsp->fConst9 = floorf(((0.0316039994f * dsp->fConst0) + 0.5f));
+ dsp->iConst10 = (int)fminf(8192.0f, fmaxf(0.0f, (dsp->fConst2 - dsp->fConst9)));
+ dsp->fConst11 = (7.0f / dsp->fConst0);
+ dsp->fConst12 = expf((0.0f - (5.0f / dsp->fConst0)));
+ dsp->fConst13 = expf((0.0f - (0.5f / dsp->fConst0)));
+ dsp->fConst14 = (0.100000001f * dsp->fConst0);
+ dsp->fConst15 = (10.0f / dsp->fConst0);
+ dsp->fConst16 = (6.28318548f / dsp->fConst0);
+ dsp->fConst17 = (0.0500000007f / dsp->fConst0);
+ dsp->fConst18 = (0.159154937f * dsp->fConst0);
+ dsp->fConst19 = (1.0f / Piano_faustpower2_f(dsp->fConst0));
+ dsp->fConst20 = (2.0f / dsp->fConst0);
+ dsp->iConst21 = (int)fminf(8192.0f, fmaxf(0.0f, (0.0199999996f * dsp->fConst0)));
+ dsp->iConst22 = (int)fminf(2048.0f, fmaxf(0.0f, (dsp->fConst9 + -1.0f)));
+ dsp->fConst23 = floorf(((0.174713001f * dsp->fConst0) + 0.5f));
+ dsp->fConst24 = ((0.0f - (6.90775537f * dsp->fConst23)) / dsp->fConst0);
+ dsp->fConst25 = (0.5f * dsp->fConst24);
+ dsp->fConst26 = (0.333333343f * dsp->fConst24);
+ dsp->fConst27 = floorf(((0.0229039993f * dsp->fConst0) + 0.5f));
+ dsp->iConst28 = (int)fminf(8192.0f, fmaxf(0.0f, (dsp->fConst23 - dsp->fConst27)));
+ dsp->iConst29 = (int)fminf(2048.0f, fmaxf(0.0f, (dsp->fConst27 + -1.0f)));
+ dsp->fConst30 = floorf(((0.153128996f * dsp->fConst0) + 0.5f));
+ dsp->fConst31 = ((0.0f - (6.90775537f * dsp->fConst30)) / dsp->fConst0);
+ dsp->fConst32 = (0.5f * dsp->fConst31);
+ dsp->fConst33 = (0.333333343f * dsp->fConst31);
+ dsp->fConst34 = floorf(((0.0203460008f * dsp->fConst0) + 0.5f));
+ dsp->iConst35 = (int)fminf(8192.0f, fmaxf(0.0f, (dsp->fConst30 - dsp->fConst34)));
+ dsp->iConst36 = (int)fminf(1024.0f, fmaxf(0.0f, (dsp->fConst34 + -1.0f)));
+ dsp->fConst37 = floorf(((0.256891012f * dsp->fConst0) + 0.5f));
+ dsp->fConst38 = ((0.0f - (6.90775537f * dsp->fConst37)) / dsp->fConst0);
+ dsp->fConst39 = (0.5f * dsp->fConst38);
+ dsp->fConst40 = (0.333333343f * dsp->fConst38);
+ dsp->fConst41 = floorf(((0.0273330007f * dsp->fConst0) + 0.5f));
+ dsp->iConst42 = (int)fminf(16384.0f, fmaxf(0.0f, (dsp->fConst37 - dsp->fConst41)));
+ dsp->fConst43 = (0.5f * dsp->fConst0);
+ dsp->iConst44 = (int)fminf(2048.0f, fmaxf(0.0f, (dsp->fConst41 + -1.0f)));
+ dsp->fConst45 = floorf(((0.219990999f * dsp->fConst0) + 0.5f));
+ dsp->fConst46 = ((0.0f - (6.90775537f * dsp->fConst45)) / dsp->fConst0);
+ dsp->fConst47 = (0.5f * dsp->fConst46);
+ dsp->fConst48 = (0.333333343f * dsp->fConst46);
+ dsp->fConst49 = floorf(((0.0191229992f * dsp->fConst0) + 0.5f));
+ dsp->iConst50 = (int)fminf(16384.0f, fmaxf(0.0f, (dsp->fConst45 - dsp->fConst49)));
+ dsp->iConst51 = (int)fminf(1024.0f, fmaxf(0.0f, (dsp->fConst49 + -1.0f)));
+ dsp->fConst52 = floorf(((0.125f * dsp->fConst0) + 0.5f));
+ dsp->fConst53 = ((0.0f - (6.90775537f * dsp->fConst52)) / dsp->fConst0);
+ dsp->fConst54 = (0.5f * dsp->fConst53);
+ dsp->fConst55 = (0.333333343f * dsp->fConst53);
+ dsp->fConst56 = floorf(((0.0134579996f * dsp->fConst0) + 0.5f));
+ dsp->iConst57 = (int)fminf(8192.0f, fmaxf(0.0f, (dsp->fConst52 - dsp->fConst56)));
+ dsp->iConst58 = (int)fminf(1024.0f, fmaxf(0.0f, (dsp->fConst56 + -1.0f)));
+ dsp->fConst59 = floorf(((0.210389003f * dsp->fConst0) + 0.5f));
+ dsp->fConst60 = ((0.0f - (6.90775537f * dsp->fConst59)) / dsp->fConst0);
+ dsp->fConst61 = (0.5f * dsp->fConst60);
+ dsp->fConst62 = (0.333333343f * dsp->fConst60);
+ dsp->fConst63 = floorf(((0.0244210009f * dsp->fConst0) + 0.5f));
+ dsp->iConst64 = (int)fminf(16384.0f, fmaxf(0.0f, (dsp->fConst59 - dsp->fConst63)));
+ dsp->iConst65 = (int)fminf(2048.0f, fmaxf(0.0f, (dsp->fConst63 + -1.0f)));
+ dsp->fConst66 = floorf(((0.192303002f * dsp->fConst0) + 0.5f));
+ dsp->fConst67 = ((0.0f - (6.90775537f * dsp->fConst66)) / dsp->fConst0);
+ dsp->fConst68 = (0.5f * dsp->fConst67);
+ dsp->fConst69 = (0.333333343f * dsp->fConst67);
+ dsp->fConst70 = floorf(((0.0292910002f * dsp->fConst0) + 0.5f));
+ dsp->iConst71 = (int)fminf(8192.0f, fmaxf(0.0f, (dsp->fConst66 - dsp->fConst70)));
+ dsp->iConst72 = (int)fminf(2048.0f, fmaxf(0.0f, (dsp->fConst70 + -1.0f)));
+}
+
+void instanceInitPiano(Piano* dsp, int sample_rate) {
+ USED(sample_rate);
+ USED(dsp);
+ instanceConstantsPiano(dsp, sample_rate);
+ instanceResetUserInterfacePiano(dsp);
+ instanceClearPiano(dsp);
+}
+
+void initPiano(Piano* dsp, int sample_rate) {
+ USED(sample_rate);
+ USED(dsp);
+ classInitPiano(sample_rate);
+ instanceInitPiano(dsp, sample_rate);
+}
+
+void buildUserInterfacePiano(Piano* dsp, UIGlue* ui_interface) {
+ USED(dsp);
+ ui_interface->openVerticalBox(ui_interface->uiInterface, "Piano");
+ ui_interface->openHorizontalBox(ui_interface->uiInterface, "Basic_Parameters");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider3, "1", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider3, "tooltip", "Tone frequency");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider3, "unit", "Hz");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Freq", &dsp->fHslider3, 440.0f, 20.0f, 20000.0f, 1.0f);
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider5, "1", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider5, "tooltip", "Gain (value between 0 and 1)");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Gain", &dsp->fHslider5, 1.0f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fButton0, "1", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fButton0, "tooltip", "noteOn = 1, noteOff = 0");
+ ui_interface->addButton(ui_interface->uiInterface, "Gate", &dsp->fButton0);
+ ui_interface->closeBox(ui_interface->uiInterface);
+ ui_interface->openVerticalBox(ui_interface->uiInterface, "Physical_Parameters");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider4, "2", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider4, "tooltip", "A value between 0 and 1");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Brightness_Factor", &dsp->fHslider4, 0.0f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider8, "2", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider8, "tooltip", "A value between 0 and 1");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Detuning_Factor", &dsp->fHslider8, 0.100000001f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider6, "2", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider6, "tooltip", "A value between 0 and 1");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Hammer_Hardness", &dsp->fHslider6, 0.100000001f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider7, "2", "");
+ ui_interface->declare(ui_interface->uiInterface, &dsp->fHslider7, "tooltip", "A value between 0 and 1");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "Stiffness_Factor", &dsp->fHslider7, 0.280000001f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->closeBox(ui_interface->uiInterface);
+ ui_interface->openVerticalBox(ui_interface->uiInterface, "Reverb");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "reverbGain", &dsp->fHslider2, 0.136999995f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "roomSize", &dsp->fHslider0, 0.720000029f, 0.00999999978f, 2.0f, 0.00999999978f);
+ ui_interface->closeBox(ui_interface->uiInterface);
+ ui_interface->openVerticalBox(ui_interface->uiInterface, "Spat");
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "pan angle", &dsp->fHslider1, 0.600000024f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->addHorizontalSlider(ui_interface->uiInterface, "spatial width", &dsp->fHslider9, 0.5f, 0.0f, 1.0f, 0.00999999978f);
+ ui_interface->closeBox(ui_interface->uiInterface);
+ ui_interface->closeBox(ui_interface->uiInterface);
+}
+
+void computePiano(Piano* dsp, int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {
+ USED(inputs);
+ USED(dsp);
+ FAUSTFLOAT* output0 = outputs[0];
+ FAUSTFLOAT* output1 = outputs[1];
+ float fSlow0 = (float)dsp->fHslider0;
+ float fSlow1 = expf((dsp->fConst4 / fSlow0));
+ float fSlow2 = Piano_faustpower2_f(fSlow1);
+ float fSlow3 = (1.0f - (dsp->fConst1 * fSlow2));
+ float fSlow4 = (1.0f - fSlow2);
+ float fSlow5 = (fSlow3 / fSlow4);
+ float fSlow6 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow3) / Piano_faustpower2_f(fSlow4)) + -1.0f)));
+ float fSlow7 = (fSlow5 - fSlow6);
+ float fSlow8 = (fSlow1 * (fSlow6 + (1.0f - fSlow5)));
+ float fSlow9 = ((expf((dsp->fConst5 / fSlow0)) / fSlow1) + -1.0f);
+ float fSlow10 = (float)dsp->fHslider1;
+ float fSlow11 = (12.0f * (1.0f - fSlow10));
+ float fSlow12 = (0.00100000005f * (float)dsp->fHslider2);
+ float fSlow13 = (float)dsp->fHslider3;
+ int iSlow14 = (int)((17.3123398f * (logf(fSlow13) + -6.08677483f)) + 69.5f);
+ float fSlow15 = (float)getValueDCBa1((float)iSlow14);
+ float fSlow16 = (1.0f - fSlow15);
+ float fSlow17 = (float)getValueBq4_gEarBalled((float)iSlow14);
+ float fSlow18 = (2.0f * fSlow17);
+ float fSlow19 = (0.25f * (float)dsp->fHslider4);
+ float fSlow20 = (float)getValueLoudPole((float)iSlow14);
+ float fSlow21 = ((fSlow19 + (0.980000019f - fSlow20)) * (float)getValueLoudGain((float)iSlow14));
+ float fSlow22 = (0.5f * fSlow16);
+ float fSlow23 = (float)(iSlow14 >= 88);
+ float fSlow24 = (2.32830644e-10f * fSlow23);
+ float fSlow25 = (float)dsp->fButton0;
+ int iSlow26 = (fSlow25 > 0.0f);
+ float fSlow27 = expf((0.0f - (dsp->fConst11 / ((float)dsp->fHslider5 * (float)getValueDryTapAmpT60((float)iSlow14)))));
+ int iSlow28 = (fSlow25 < 1.0f);
+ float fSlow29 = (0.0f - (fSlow25 + -1.0f));
+ float fSlow30 = (dsp->fConst12 * fSlow29);
+ float fSlow31 = (float)dsp->fHslider6;
+ float fSlow32 = (dsp->fConst14 * fSlow31);
+ float fSlow33 = expf((0.0f - (dsp->fConst15 / fSlow31)));
+ float fSlow34 = (0.200000003f * (float)getValueSustainPedalLevel((float)iSlow14));
+ float fSlow35 = (1.16415322e-10f * fSlow23);
+ float fSlow36 = (0.0f - fSlow22);
+ float fSlow37 = (fSlow20 + (0.0199999996f - fSlow19));
+ float fSlow38 = powf(10.0f, (dsp->fConst17 * (float)getValuer3db((float)iSlow14)));
+ float fSlow39 = (cosf((dsp->fConst16 * (fSlow13 * (float)getValueThirdPartialFactor((float)iSlow14)))) * (0.0f - (2.0f * fSlow38)));
+ float fSlow40 = Piano_faustpower2_f(fSlow38);
+ float fSlow41 = powf(10.0f, (dsp->fConst17 * (float)getValuer2db((float)iSlow14)));
+ float fSlow42 = (cosf((dsp->fConst16 * (fSlow13 * (float)getValueSecondPartialFactor((float)iSlow14)))) * (0.0f - (2.0f * fSlow41)));
+ float fSlow43 = Piano_faustpower2_f(fSlow41);
+ float fSlow44 = cosf((dsp->fConst16 * fSlow13));
+ float fSlow45 = powf(10.0f, (dsp->fConst17 * (float)getValuer1_1db((float)iSlow14)));
+ float fSlow46 = (fSlow44 * (0.0f - (2.0f * fSlow45)));
+ float fSlow47 = Piano_faustpower2_f(fSlow45);
+ float fSlow48 = powf(10.0f, (0.0500000007f * (float)getValueSecondStageAmpRatio((float)iSlow14)));
+ float fSlow49 = powf(10.0f, (dsp->fConst17 * (float)getValuer1_2db((float)iSlow14)));
+ float fSlow50 = Piano_faustpower2_f(fSlow49);
+ float fSlow51 = (1.0f - fSlow48);
+ float fSlow52 = ((fSlow48 * fSlow47) + (fSlow50 * fSlow51));
+ float fSlow53 = (0.0f - (2.0f * ((fSlow48 * fSlow45) + (fSlow49 * fSlow51))));
+ float fSlow54 = (0.0f - (2.0f * fSlow49));
+ float fSlow55 = (float)dsp->fHslider7;
+ float fSlow56 = (float)getValueStiffnessCoefficient((float)iSlow14);
+ float fSlow57 = (13.6899996f * (Piano_faustpower2_f(fSlow55) * Piano_faustpower2_f(fSlow56)));
+ float fSlow58 = (fSlow57 + -1.0f);
+ float fSlow59 = (5.0f * ((float)dsp->fHslider8 * (float)getValueDetuningHz((float)iSlow14)));
+ float fSlow60 = (fSlow13 + fSlow59);
+ float fSlow61 = (dsp->fConst16 * fSlow60);
+ float fSlow62 = sinf(fSlow61);
+ float fSlow63 = (fSlow55 * fSlow56);
+ float fSlow64 = (7.4000001f * fSlow63);
+ float fSlow65 = (fSlow57 + 1.0f);
+ float fSlow66 = cosf(fSlow61);
+ float fSlow67 = (3.0f * atan2f((fSlow58 * fSlow62), (fSlow64 + (fSlow65 * fSlow66))));
+ float fSlow68 = powf(10.0f, (0.0500000007f * ((float)getValueSingleStringDecayRate((float)iSlow14) / fSlow13)));
+ float fSlow69 = (float)getValueSingleStringZero((float)iSlow14);
+ float fSlow70 = (float)getValueSingleStringPole((float)iSlow14);
+ float fSlow71 = (1.0f - fSlow70);
+ float fSlow72 = ((fSlow68 * fSlow69) * fSlow71);
+ float fSlow73 = (1.0f - fSlow69);
+ float fSlow74 = (fSlow70 * fSlow73);
+ float fSlow75 = (3.0f * fSlow74);
+ float fSlow76 = (fSlow72 - fSlow75);
+ float fSlow77 = (fSlow74 - fSlow72);
+ float fSlow78 = (4.0f * fSlow77);
+ float fSlow79 = (fSlow76 + fSlow78);
+ float fSlow80 = (fSlow68 * fSlow71);
+ float fSlow81 = ((3.0f * fSlow73) - fSlow80);
+ float fSlow82 = (((fSlow66 * fSlow76) / fSlow81) + 1.0f);
+ float fSlow83 = ((fSlow69 + fSlow80) + -1.0f);
+ float fSlow84 = (4.0f * fSlow83);
+ float fSlow85 = (((fSlow84 + (fSlow66 * fSlow79)) / fSlow81) + 1.0f);
+ float fSlow86 = (Piano_faustpower2_f(fSlow62) * fSlow76);
+ float fSlow87 = Piano_faustpower2_f(fSlow81);
+ float fSlow88 = (dsp->fConst18 * (((fSlow67 + atan2f((((0.0f - ((fSlow62 * fSlow79) / fSlow81)) * fSlow82) + (((fSlow62 * fSlow76) * fSlow85) / fSlow81)), ((fSlow82 * fSlow85) + ((fSlow86 * fSlow79) / fSlow87)))) + 6.28318548f) / fSlow60));
+ float fSlow89 = floorf(fSlow88);
+ float fSlow90 = (fSlow88 - fSlow89);
+ float fSlow91 = (0.00100000005f * ((0.999599993f * fSlow25) + (0.899999976f * (fSlow29 * (float)getValueReleaseLoopGain((float)iSlow14)))));
+ float fSlow92 = (1.39698386e-09f * (fSlow21 * (float)(iSlow14 < 88)));
+ float fSlow93 = (3.70000005f * fSlow63);
+ float fSlow94 = ((fSlow72 + fSlow78) - fSlow75);
+ float fSlow95 = (((fSlow84 + (fSlow66 * fSlow94)) / fSlow81) + 1.0f);
+ int iSlow96 = (int)(dsp->fConst18 * (((fSlow67 + atan2f((0.0f - ((fSlow62 * ((fSlow94 * fSlow82) - (fSlow76 * fSlow95))) / fSlow81)), ((fSlow82 * fSlow95) + ((fSlow86 * fSlow94) / fSlow87)))) + 6.28318548f) / fSlow60));
+ int iSlow97 = min(4097, max(0, (iSlow96 + 1)));
+ float fSlow98 = (1.0f / fSlow81);
+ float fSlow99 = (fSlow13 - fSlow59);
+ float fSlow100 = (dsp->fConst16 * fSlow99);
+ float fSlow101 = sinf(fSlow100);
+ float fSlow102 = cosf(fSlow100);
+ float fSlow103 = (3.0f * atan2f((fSlow58 * fSlow101), (fSlow64 + (fSlow65 * fSlow102))));
+ float fSlow104 = (((fSlow102 * fSlow76) / fSlow81) + 1.0f);
+ float fSlow105 = ((((fSlow102 * fSlow79) + fSlow84) / fSlow81) + 1.0f);
+ float fSlow106 = (Piano_faustpower2_f(fSlow101) * fSlow76);
+ float fSlow107 = (dsp->fConst18 * (((fSlow103 + atan2f((((0.0f - ((fSlow101 * fSlow79) / fSlow81)) * fSlow104) + (((fSlow101 * fSlow76) * fSlow105) / fSlow81)), ((fSlow104 * fSlow105) + ((fSlow106 * fSlow79) / fSlow87)))) + 6.28318548f) / fSlow99));
+ float fSlow108 = floorf(fSlow107);
+ float fSlow109 = (fSlow108 + (1.0f - fSlow107));
+ float fSlow110 = (((fSlow84 + (fSlow102 * fSlow94)) / fSlow81) + 1.0f);
+ int iSlow111 = (int)(dsp->fConst18 * (((fSlow103 + atan2f((0.0f - ((fSlow101 * ((fSlow104 * fSlow94) - (fSlow76 * fSlow110))) / fSlow81)), ((fSlow104 * fSlow110) + ((fSlow106 * fSlow94) / fSlow87)))) + 6.28318548f) / fSlow99));
+ int iSlow112 = min(4097, max(0, iSlow111));
+ float fSlow113 = (fSlow107 - fSlow108);
+ int iSlow114 = min(4097, max(0, (iSlow111 + 1)));
+ float fSlow115 = (fSlow89 + (1.0f - fSlow88));
+ int iSlow116 = min(4097, max(0, iSlow96));
+ float fSlow117 = (float)getValueEQBandWidthFactor((float)iSlow14);
+ float fSlow118 = (dsp->fConst19 * (Piano_faustpower2_f(fSlow13) * Piano_faustpower2_f(fSlow117)));
+ float fSlow119 = (0.5f * (1.0f - fSlow118));
+ float fSlow120 = (float)getValueEQGain((float)iSlow14);
+ float fSlow121 = ((0.0f - (dsp->fConst20 * (fSlow13 * fSlow117))) * cosf((dsp->fConst16 * (fSlow13 / (float)getValueStrikePosition((float)iSlow14)))));
+ float fSlow122 = expf((dsp->fConst25 / fSlow0));
+ float fSlow123 = Piano_faustpower2_f(fSlow122);
+ float fSlow124 = (1.0f - (dsp->fConst1 * fSlow123));
+ float fSlow125 = (1.0f - fSlow123);
+ float fSlow126 = (fSlow124 / fSlow125);
+ float fSlow127 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow124) / Piano_faustpower2_f(fSlow125)) + -1.0f)));
+ float fSlow128 = (fSlow126 - fSlow127);
+ float fSlow129 = (fSlow122 * (fSlow127 + (1.0f - fSlow126)));
+ float fSlow130 = ((expf((dsp->fConst26 / fSlow0)) / fSlow122) + -1.0f);
+ float fSlow131 = expf((dsp->fConst32 / fSlow0));
+ float fSlow132 = Piano_faustpower2_f(fSlow131);
+ float fSlow133 = (1.0f - (dsp->fConst1 * fSlow132));
+ float fSlow134 = (1.0f - fSlow132);
+ float fSlow135 = (fSlow133 / fSlow134);
+ float fSlow136 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow133) / Piano_faustpower2_f(fSlow134)) + -1.0f)));
+ float fSlow137 = (fSlow135 - fSlow136);
+ float fSlow138 = (fSlow131 * (fSlow136 + (1.0f - fSlow135)));
+ float fSlow139 = ((expf((dsp->fConst33 / fSlow0)) / fSlow131) + -1.0f);
+ float fSlow140 = expf((dsp->fConst39 / fSlow0));
+ float fSlow141 = Piano_faustpower2_f(fSlow140);
+ float fSlow142 = (1.0f - (dsp->fConst1 * fSlow141));
+ float fSlow143 = (1.0f - fSlow141);
+ float fSlow144 = (fSlow142 / fSlow143);
+ float fSlow145 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow142) / Piano_faustpower2_f(fSlow143)) + -1.0f)));
+ float fSlow146 = (fSlow144 - fSlow145);
+ float fSlow147 = (fSlow140 * (fSlow145 + (1.0f - fSlow144)));
+ float fSlow148 = ((expf((dsp->fConst40 / fSlow0)) / fSlow140) + -1.0f);
+ float fSlow149 = (12.0f * fSlow10);
+ int iSlow150 = (int)fminf(4096.0f, fmaxf(0.0f, (dsp->fConst43 * ((float)dsp->fHslider9 / fSlow13))));
+ float fSlow151 = expf((dsp->fConst47 / fSlow0));
+ float fSlow152 = Piano_faustpower2_f(fSlow151);
+ float fSlow153 = (1.0f - (dsp->fConst1 * fSlow152));
+ float fSlow154 = (1.0f - fSlow152);
+ float fSlow155 = (fSlow153 / fSlow154);
+ float fSlow156 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow153) / Piano_faustpower2_f(fSlow154)) + -1.0f)));
+ float fSlow157 = (fSlow155 - fSlow156);
+ float fSlow158 = (fSlow151 * (fSlow156 + (1.0f - fSlow155)));
+ float fSlow159 = ((expf((dsp->fConst48 / fSlow0)) / fSlow151) + -1.0f);
+ float fSlow160 = expf((dsp->fConst54 / fSlow0));
+ float fSlow161 = Piano_faustpower2_f(fSlow160);
+ float fSlow162 = (1.0f - (dsp->fConst1 * fSlow161));
+ float fSlow163 = (1.0f - fSlow161);
+ float fSlow164 = (fSlow162 / fSlow163);
+ float fSlow165 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow162) / Piano_faustpower2_f(fSlow163)) + -1.0f)));
+ float fSlow166 = (fSlow164 - fSlow165);
+ float fSlow167 = (fSlow160 * (fSlow165 + (1.0f - fSlow164)));
+ float fSlow168 = ((expf((dsp->fConst55 / fSlow0)) / fSlow160) + -1.0f);
+ float fSlow169 = expf((dsp->fConst61 / fSlow0));
+ float fSlow170 = Piano_faustpower2_f(fSlow169);
+ float fSlow171 = (1.0f - (dsp->fConst1 * fSlow170));
+ float fSlow172 = (1.0f - fSlow170);
+ float fSlow173 = (fSlow171 / fSlow172);
+ float fSlow174 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow171) / Piano_faustpower2_f(fSlow172)) + -1.0f)));
+ float fSlow175 = (fSlow173 - fSlow174);
+ float fSlow176 = (fSlow169 * (fSlow174 + (1.0f - fSlow173)));
+ float fSlow177 = ((expf((dsp->fConst62 / fSlow0)) / fSlow169) + -1.0f);
+ float fSlow178 = expf((dsp->fConst68 / fSlow0));
+ float fSlow179 = Piano_faustpower2_f(fSlow178);
+ float fSlow180 = (1.0f - (dsp->fConst1 * fSlow179));
+ float fSlow181 = (1.0f - fSlow179);
+ float fSlow182 = (fSlow180 / fSlow181);
+ float fSlow183 = sqrtf(fmaxf(0.0f, ((Piano_faustpower2_f(fSlow180) / Piano_faustpower2_f(fSlow181)) + -1.0f)));
+ float fSlow184 = (fSlow182 - fSlow183);
+ float fSlow185 = (fSlow178 * (fSlow183 + (1.0f - fSlow182)));
+ float fSlow186 = ((expf((dsp->fConst69 / fSlow0)) / fSlow178) + -1.0f);
+ /* C99 loop */
+ {
+ int i;
+ for (i = 0; (i < count); i = (i + 1)) {
+ dsp->fRec11[0] = (0.0f - (dsp->fConst7 * ((dsp->fConst8 * dsp->fRec11[1]) - (dsp->fRec2[1] + dsp->fRec2[2]))));
+ dsp->fRec10[0] = ((fSlow7 * dsp->fRec10[1]) + (fSlow8 * (dsp->fRec2[1] + (fSlow9 * dsp->fRec11[0]))));
+ dsp->fVec0[(dsp->IOTA & 16383)] = ((0.353553385f * dsp->fRec10[0]) + 9.99999968e-21f);
+ dsp->fRec12[0] = (fSlow12 + (0.999000013f * dsp->fRec12[1]));
+ dsp->iRec23[0] = ((1103515245 * dsp->iRec23[1]) + 12345);
+ dsp->fRec25[0] = ((fSlow25 * dsp->fRec25[1]) + 1.0f);
+ float fTemp0 = (dsp->fRec25[0] + -1.0f);
+ float fTemp1 = (float)((fTemp0 < 2.0f) & iSlow26);
+ float fTemp2 = ((0.0301973838f * fTemp1) + (fSlow27 * (float)((fTemp0 >= 2.0f) | iSlow28)));
+ dsp->fRec24[0] = ((dsp->fRec24[1] * fTemp2) + (0.150000006f * (fTemp1 * (1.0f - fTemp2))));
+ int iTemp3 = (fTemp0 < fSlow32);
+ float fTemp4 = (fSlow25 * ((dsp->fConst13 * (float)(fTemp0 >= fSlow32)) + (fSlow33 * (float)iTemp3)));
+ dsp->fRec26[0] = ((dsp->fRec26[1] * (fSlow30 + fTemp4)) + (fSlow34 * (((1.0f - fTemp4) - fSlow30) * (float)(iTemp3 & iSlow26))));
+ float fTemp5 = ((float)dsp->iRec23[0] * (dsp->fRec24[0] + dsp->fRec26[0]));
+ dsp->fVec1[0] = (fSlow24 * fTemp5);
+ float fTemp6 = (0.0f - ((0.5f * dsp->fVec1[1]) + (fSlow35 * fTemp5)));
+ dsp->fVec2[0] = fTemp6;
+ dsp->fRec22[0] = (((fSlow22 * fTemp6) + (fSlow36 * dsp->fVec2[1])) - (fSlow15 * dsp->fRec22[1]));
+ dsp->fRec21[0] = ((fSlow21 * dsp->fRec22[0]) + (fSlow37 * dsp->fRec21[1]));
+ dsp->fRec20[0] = ((fSlow21 * dsp->fRec21[0]) + (fSlow37 * dsp->fRec20[1]));
+ dsp->fRec19[0] = ((fSlow21 * dsp->fRec20[0]) + (fSlow37 * dsp->fRec19[1]));
+ dsp->fRec18[0] = ((fSlow21 * dsp->fRec19[0]) + (fSlow37 * dsp->fRec18[1]));
+ dsp->fRec17[0] = ((fSlow17 * (dsp->fRec18[0] - dsp->fRec18[1])) - ((fSlow39 * dsp->fRec17[1]) + (fSlow40 * dsp->fRec17[2])));
+ dsp->fRec16[0] = ((fSlow18 * dsp->fRec17[0]) - ((fSlow42 * dsp->fRec16[1]) + (fSlow43 * dsp->fRec16[2])));
+ dsp->fRec15[0] = (dsp->fRec16[0] - ((fSlow46 * dsp->fRec15[1]) + (fSlow47 * dsp->fRec15[2])));
+ dsp->fRec14[0] = ((dsp->fRec15[0] + ((fSlow52 * dsp->fRec15[2]) + (fSlow44 * ((fSlow53 * dsp->fRec15[1]) - (fSlow54 * dsp->fRec14[1]))))) - (fSlow50 * dsp->fRec14[2]));
+ dsp->fRec13[0] = ((fSlow16 * dsp->fRec14[0]) - (fSlow15 * dsp->fRec13[1]));
+ dsp->fRec33[0] = (fSlow91 + (0.999000013f * dsp->fRec33[1]));
+ dsp->fRec38[0] = ((fSlow92 * fTemp5) + (fSlow37 * dsp->fRec38[1]));
+ dsp->fRec37[0] = ((fSlow21 * dsp->fRec38[0]) + (fSlow37 * dsp->fRec37[1]));
+ dsp->fRec36[0] = ((fSlow21 * dsp->fRec37[0]) + (fSlow37 * dsp->fRec36[1]));
+ dsp->fRec35[0] = ((fSlow21 * dsp->fRec36[0]) + (fSlow37 * dsp->fRec35[1]));
+ dsp->fRec34[0] = (((fSlow22 * dsp->fRec35[0]) + (fSlow36 * dsp->fRec35[1])) - (fSlow15 * dsp->fRec34[1]));
+ float fTemp7 = (dsp->fRec33[0] * (dsp->fRec34[0] + dsp->fRec27[1]));
+ dsp->fVec3[0] = fTemp7;
+ dsp->fRec32[0] = (dsp->fVec3[1] - (fSlow93 * (dsp->fRec32[1] - fTemp7)));
+ dsp->fRec31[0] = (dsp->fRec32[1] - (fSlow93 * (dsp->fRec31[1] - dsp->fRec32[0])));
+ dsp->fRec30[(dsp->IOTA & 8191)] = (dsp->fRec31[1] + (fSlow93 * (dsp->fRec31[0] - dsp->fRec30[((dsp->IOTA - 1) & 8191)])));
+ float fTemp8 = (fSlow90 * dsp->fRec30[((dsp->IOTA - iSlow97) & 8191)]);
+ float fTemp9 = (dsp->fRec34[0] + (dsp->fRec33[0] * dsp->fRec28[1]));
+ dsp->fVec4[0] = fTemp9;
+ dsp->fRec42[0] = (dsp->fVec4[1] - (fSlow93 * (dsp->fRec42[1] - fTemp9)));
+ dsp->fRec41[0] = (dsp->fRec42[1] - (fSlow93 * (dsp->fRec41[1] - dsp->fRec42[0])));
+ dsp->fRec40[(dsp->IOTA & 8191)] = (dsp->fRec41[1] - (fSlow93 * (dsp->fRec40[((dsp->IOTA - 1) & 8191)] - dsp->fRec41[0])));
+ float fTemp10 = (fSlow109 * dsp->fRec40[((dsp->IOTA - iSlow112) & 8191)]);
+ float fTemp11 = (fSlow113 * dsp->fRec40[((dsp->IOTA - iSlow114) & 8191)]);
+ float fTemp12 = (fSlow115 * dsp->fRec30[((dsp->IOTA - iSlow116) & 8191)]);
+ float fTemp13 = (fTemp8 + (fTemp10 + (fTemp11 + fTemp12)));
+ dsp->fVec5[0] = fTemp13;
+ dsp->fRec39[0] = (fSlow98 * ((2.0f * ((fSlow83 * fTemp13) + (fSlow77 * dsp->fVec5[1]))) - (fSlow76 * dsp->fRec39[1])));
+ dsp->fRec27[0] = (fTemp8 + (dsp->fRec39[0] + fTemp12));
+ dsp->fRec28[0] = (fTemp10 + (dsp->fRec39[0] + fTemp11));
+ float fRec29 = fTemp13;
+ dsp->fRec43[0] = ((fSlow120 * fRec29) - ((fSlow121 * dsp->fRec43[1]) + (fSlow118 * dsp->fRec43[2])));
+ float fTemp14 = (dsp->fRec13[0] + (fRec29 + (fSlow119 * (dsp->fRec43[0] - dsp->fRec43[2]))));
+ dsp->fVec6[(dsp->IOTA & 8191)] = fTemp14;
+ dsp->fVec7[(dsp->IOTA & 4095)] = (fSlow11 * (dsp->fRec12[0] * fTemp14));
+ float fTemp15 = (0.300000012f * dsp->fVec7[((dsp->IOTA - dsp->iConst21) & 4095)]);
+ float fTemp16 = (dsp->fVec0[((dsp->IOTA - dsp->iConst10) & 16383)] - (fTemp15 + (0.600000024f * dsp->fRec8[1])));
+ dsp->fVec8[(dsp->IOTA & 4095)] = fTemp16;
+ dsp->fRec8[0] = dsp->fVec8[((dsp->IOTA - dsp->iConst22) & 4095)];
+ float fRec9 = (0.600000024f * fTemp16);
+ dsp->fRec47[0] = (dsp->fConst7 * ((dsp->fRec4[1] + dsp->fRec4[2]) - (dsp->fConst8 * dsp->fRec47[1])));
+ dsp->fRec46[0] = ((fSlow128 * dsp->fRec46[1]) + (fSlow129 * (dsp->fRec4[1] + (fSlow130 * dsp->fRec47[0]))));
+ dsp->fVec9[(dsp->IOTA & 16383)] = ((0.353553385f * dsp->fRec46[0]) + 9.99999968e-21f);
+ float fTemp17 = ((fTemp15 + dsp->fVec9[((dsp->IOTA - dsp->iConst28) & 16383)]) - (0.600000024f * dsp->fRec44[1]));
+ dsp->fVec10[(dsp->IOTA & 4095)] = fTemp17;
+ dsp->fRec44[0] = dsp->fVec10[((dsp->IOTA - dsp->iConst29) & 4095)];
+ float fRec45 = (0.600000024f * fTemp17);
+ dsp->fRec51[0] = (dsp->fConst7 * ((dsp->fRec0[1] + dsp->fRec0[2]) - (dsp->fConst8 * dsp->fRec51[1])));
+ dsp->fRec50[0] = ((fSlow137 * dsp->fRec50[1]) + (fSlow138 * (dsp->fRec0[1] + (fSlow139 * dsp->fRec51[0]))));
+ dsp->fVec11[(dsp->IOTA & 16383)] = ((0.353553385f * dsp->fRec50[0]) + 9.99999968e-21f);
+ float fTemp18 = ((dsp->fVec11[((dsp->IOTA - dsp->iConst35) & 16383)] + fTemp15) - (0.600000024f * dsp->fRec48[1]));
+ dsp->fVec12[(dsp->IOTA & 2047)] = fTemp18;
+ dsp->fRec48[0] = dsp->fVec12[((dsp->IOTA - dsp->iConst36) & 2047)];
+ float fRec49 = (0.600000024f * fTemp18);
+ dsp->fRec55[0] = (dsp->fConst7 * ((dsp->fRec3[1] + dsp->fRec3[2]) - (dsp->fConst8 * dsp->fRec55[1])));
+ dsp->fRec54[0] = ((fSlow146 * dsp->fRec54[1]) + (fSlow147 * (dsp->fRec3[1] + (fSlow148 * dsp->fRec55[0]))));
+ dsp->fVec13[(dsp->IOTA & 32767)] = ((0.353553385f * dsp->fRec54[0]) + 9.99999968e-21f);
+ float fTemp19 = dsp->fVec6[((dsp->IOTA - iSlow150) & 8191)];
+ dsp->fVec14[(dsp->IOTA & 4095)] = (fSlow149 * (dsp->fRec12[0] * fTemp19));
+ float fTemp20 = (0.300000012f * dsp->fVec14[((dsp->IOTA - dsp->iConst21) & 4095)]);
+ float fTemp21 = (((0.600000024f * dsp->fRec52[1]) + dsp->fVec13[((dsp->IOTA - dsp->iConst42) & 32767)]) - fTemp20);
+ dsp->fVec15[(dsp->IOTA & 4095)] = fTemp21;
+ dsp->fRec52[0] = dsp->fVec15[((dsp->IOTA - dsp->iConst44) & 4095)];
+ float fRec53 = (0.0f - (0.600000024f * fTemp21));
+ dsp->fRec59[0] = (dsp->fConst7 * ((dsp->fRec7[1] + dsp->fRec7[2]) - (dsp->fConst8 * dsp->fRec59[1])));
+ dsp->fRec58[0] = ((fSlow157 * dsp->fRec58[1]) + (fSlow158 * (dsp->fRec7[1] + (fSlow159 * dsp->fRec59[0]))));
+ dsp->fVec16[(dsp->IOTA & 32767)] = ((0.353553385f * dsp->fRec58[0]) + 9.99999968e-21f);
+ float fTemp22 = (((0.600000024f * dsp->fRec56[1]) + dsp->fVec16[((dsp->IOTA - dsp->iConst50) & 32767)]) - fTemp20);
+ dsp->fVec17[(dsp->IOTA & 2047)] = fTemp22;
+ dsp->fRec56[0] = dsp->fVec17[((dsp->IOTA - dsp->iConst51) & 2047)];
+ float fRec57 = (0.0f - (0.600000024f * fTemp22));
+ dsp->fRec63[0] = (0.0f - (dsp->fConst7 * ((dsp->fConst8 * dsp->fRec63[1]) - (dsp->fRec6[1] + dsp->fRec6[2]))));
+ dsp->fRec62[0] = ((fSlow166 * dsp->fRec62[1]) + (fSlow167 * (dsp->fRec6[1] + (fSlow168 * dsp->fRec63[0]))));
+ dsp->fVec18[(dsp->IOTA & 16383)] = ((0.353553385f * dsp->fRec62[0]) + 9.99999968e-21f);
+ float fTemp23 = (dsp->fVec18[((dsp->IOTA - dsp->iConst57) & 16383)] - (fTemp15 + (0.600000024f * dsp->fRec60[1])));
+ dsp->fVec19[(dsp->IOTA & 2047)] = fTemp23;
+ dsp->fRec60[0] = dsp->fVec19[((dsp->IOTA - dsp->iConst58) & 2047)];
+ float fRec61 = (0.600000024f * fTemp23);
+ dsp->fRec67[0] = (dsp->fConst7 * ((dsp->fRec1[1] + dsp->fRec1[2]) - (dsp->fConst8 * dsp->fRec67[1])));
+ dsp->fRec66[0] = ((fSlow175 * dsp->fRec66[1]) + (fSlow176 * (dsp->fRec1[1] + (fSlow177 * dsp->fRec67[0]))));
+ dsp->fVec20[(dsp->IOTA & 32767)] = ((0.353553385f * dsp->fRec66[0]) + 9.99999968e-21f);
+ float fTemp24 = (dsp->fVec20[((dsp->IOTA - dsp->iConst64) & 32767)] + ((0.600000024f * dsp->fRec64[1]) + fTemp20));
+ dsp->fVec21[(dsp->IOTA & 4095)] = fTemp24;
+ dsp->fRec64[0] = dsp->fVec21[((dsp->IOTA - dsp->iConst65) & 4095)];
+ float fRec65 = (0.0f - (0.600000024f * fTemp24));
+ dsp->fRec71[0] = (0.0f - (dsp->fConst7 * ((dsp->fConst8 * dsp->fRec71[1]) - (dsp->fRec5[1] + dsp->fRec5[2]))));
+ dsp->fRec70[0] = ((fSlow184 * dsp->fRec70[1]) + (fSlow185 * (dsp->fRec5[1] + (fSlow186 * dsp->fRec71[0]))));
+ dsp->fVec22[(dsp->IOTA & 16383)] = ((0.353553385f * dsp->fRec70[0]) + 9.99999968e-21f);
+ float fTemp25 = (dsp->fVec22[((dsp->IOTA - dsp->iConst71) & 16383)] + (fTemp20 + (0.600000024f * dsp->fRec68[1])));
+ dsp->fVec23[(dsp->IOTA & 4095)] = fTemp25;
+ dsp->fRec68[0] = dsp->fVec23[((dsp->IOTA - dsp->iConst72) & 4095)];
+ float fRec69 = (0.0f - (0.600000024f * fTemp25));
+ float fTemp26 = (fRec9 + dsp->fRec64[1]);
+ float fTemp27 = (dsp->fRec52[1] + fTemp26);
+ dsp->fRec0[0] = (dsp->fRec8[1] + (fRec45 + (fRec49 + (fRec53 + (dsp->fRec56[1] + (fRec57 + (fRec61 + (dsp->fRec44[1] + (dsp->fRec60[1] + (dsp->fRec48[1] + (fRec65 + (dsp->fRec68[1] + (fRec69 + fTemp27)))))))))))));
+ float fTemp28 = (dsp->fRec64[1] + dsp->fRec52[1]);
+ dsp->fRec1[0] = ((dsp->fRec8[1] + (fRec45 + (fRec49 + (fRec61 + (dsp->fRec44[1] + (dsp->fRec60[1] + (fRec9 + dsp->fRec48[1]))))))) - (fRec53 + (dsp->fRec56[1] + (fRec57 + (fRec65 + (dsp->fRec68[1] + (fRec69 + fTemp28)))))));
+ float fTemp29 = (fRec9 + dsp->fRec52[1]);
+ dsp->fRec2[0] = ((fRec45 + (fRec49 + (dsp->fRec44[1] + (dsp->fRec48[1] + (fRec65 + (dsp->fRec68[1] + (fRec69 + dsp->fRec64[1]))))))) - (dsp->fRec8[1] + (fRec53 + (dsp->fRec56[1] + (fRec57 + (fRec61 + (dsp->fRec60[1] + fTemp29)))))));
+ dsp->fRec3[0] = ((fRec45 + (fRec49 + (fRec53 + (dsp->fRec56[1] + (fRec57 + (dsp->fRec44[1] + (dsp->fRec48[1] + dsp->fRec52[1]))))))) - (dsp->fRec8[1] + (fRec61 + (dsp->fRec60[1] + (fRec65 + (dsp->fRec68[1] + (fRec69 + fTemp26)))))));
+ dsp->fRec4[0] = ((dsp->fRec8[1] + (fRec49 + (fRec53 + (dsp->fRec48[1] + (fRec65 + fTemp27))))) - (fRec45 + (dsp->fRec56[1] + (fRec57 + (fRec61 + (dsp->fRec44[1] + (dsp->fRec60[1] + (fRec69 + dsp->fRec68[1]))))))));
+ dsp->fRec5[0] = ((dsp->fRec8[1] + (fRec49 + (dsp->fRec56[1] + (fRec57 + (dsp->fRec48[1] + (dsp->fRec68[1] + (fRec9 + fRec69))))))) - (fRec45 + (fRec53 + (fRec61 + (dsp->fRec44[1] + (dsp->fRec60[1] + (fRec65 + fTemp28)))))));
+ dsp->fRec6[0] = ((fRec49 + (dsp->fRec56[1] + (fRec57 + (fRec61 + (dsp->fRec60[1] + (dsp->fRec48[1] + (fRec65 + dsp->fRec64[1]))))))) - (dsp->fRec8[1] + (fRec45 + (fRec53 + (dsp->fRec44[1] + (dsp->fRec68[1] + (fRec69 + fTemp29)))))));
+ dsp->fRec7[0] = ((fRec49 + (fRec53 + (fRec61 + (dsp->fRec60[1] + (dsp->fRec48[1] + (dsp->fRec68[1] + (fRec69 + dsp->fRec52[1]))))))) - (dsp->fRec8[1] + (fRec45 + (dsp->fRec56[1] + (fRec57 + (dsp->fRec44[1] + (fRec65 + fTemp26)))))));
+ float fTemp30 = (1.0f - dsp->fRec12[0]);
+ output0[i] = (FAUSTFLOAT)((0.370000005f * (dsp->fRec1[0] + dsp->fRec2[0])) + (fSlow11 * (fTemp30 * fTemp14)));
+ output1[i] = (FAUSTFLOAT)((0.370000005f * (dsp->fRec1[0] - dsp->fRec2[0])) + (fSlow149 * (fTemp30 * fTemp19)));
+ dsp->fRec11[1] = dsp->fRec11[0];
+ dsp->fRec10[1] = dsp->fRec10[0];
+ dsp->IOTA = (dsp->IOTA + 1);
+ dsp->fRec12[1] = dsp->fRec12[0];
+ dsp->iRec23[1] = dsp->iRec23[0];
+ dsp->fRec25[1] = dsp->fRec25[0];
+ dsp->fRec24[1] = dsp->fRec24[0];
+ dsp->fRec26[1] = dsp->fRec26[0];
+ dsp->fVec1[1] = dsp->fVec1[0];
+ dsp->fVec2[1] = dsp->fVec2[0];
+ dsp->fRec22[1] = dsp->fRec22[0];
+ dsp->fRec21[1] = dsp->fRec21[0];
+ dsp->fRec20[1] = dsp->fRec20[0];
+ dsp->fRec19[1] = dsp->fRec19[0];
+ dsp->fRec18[1] = dsp->fRec18[0];
+ dsp->fRec17[2] = dsp->fRec17[1];
+ dsp->fRec17[1] = dsp->fRec17[0];
+ dsp->fRec16[2] = dsp->fRec16[1];
+ dsp->fRec16[1] = dsp->fRec16[0];
+ dsp->fRec15[2] = dsp->fRec15[1];
+ dsp->fRec15[1] = dsp->fRec15[0];
+ dsp->fRec14[2] = dsp->fRec14[1];
+ dsp->fRec14[1] = dsp->fRec14[0];
+ dsp->fRec13[1] = dsp->fRec13[0];
+ dsp->fRec33[1] = dsp->fRec33[0];
+ dsp->fRec38[1] = dsp->fRec38[0];
+ dsp->fRec37[1] = dsp->fRec37[0];
+ dsp->fRec36[1] = dsp->fRec36[0];
+ dsp->fRec35[1] = dsp->fRec35[0];
+ dsp->fRec34[1] = dsp->fRec34[0];
+ dsp->fVec3[1] = dsp->fVec3[0];
+ dsp->fRec32[1] = dsp->fRec32[0];
+ dsp->fRec31[1] = dsp->fRec31[0];
+ dsp->fVec4[1] = dsp->fVec4[0];
+ dsp->fRec42[1] = dsp->fRec42[0];
+ dsp->fRec41[1] = dsp->fRec41[0];
+ dsp->fVec5[1] = dsp->fVec5[0];
+ dsp->fRec39[1] = dsp->fRec39[0];
+ dsp->fRec27[1] = dsp->fRec27[0];
+ dsp->fRec28[1] = dsp->fRec28[0];
+ dsp->fRec43[2] = dsp->fRec43[1];
+ dsp->fRec43[1] = dsp->fRec43[0];
+ dsp->fRec8[1] = dsp->fRec8[0];
+ dsp->fRec47[1] = dsp->fRec47[0];
+ dsp->fRec46[1] = dsp->fRec46[0];
+ dsp->fRec44[1] = dsp->fRec44[0];
+ dsp->fRec51[1] = dsp->fRec51[0];
+ dsp->fRec50[1] = dsp->fRec50[0];
+ dsp->fRec48[1] = dsp->fRec48[0];
+ dsp->fRec55[1] = dsp->fRec55[0];
+ dsp->fRec54[1] = dsp->fRec54[0];
+ dsp->fRec52[1] = dsp->fRec52[0];
+ dsp->fRec59[1] = dsp->fRec59[0];
+ dsp->fRec58[1] = dsp->fRec58[0];
+ dsp->fRec56[1] = dsp->fRec56[0];
+ dsp->fRec63[1] = dsp->fRec63[0];
+ dsp->fRec62[1] = dsp->fRec62[0];
+ dsp->fRec60[1] = dsp->fRec60[0];
+ dsp->fRec67[1] = dsp->fRec67[0];
+ dsp->fRec66[1] = dsp->fRec66[0];
+ dsp->fRec64[1] = dsp->fRec64[0];
+ dsp->fRec71[1] = dsp->fRec71[0];
+ dsp->fRec70[1] = dsp->fRec70[0];
+ dsp->fRec68[1] = dsp->fRec68[0];
+ dsp->fRec0[2] = dsp->fRec0[1];
+ dsp->fRec0[1] = dsp->fRec0[0];
+ dsp->fRec1[2] = dsp->fRec1[1];
+ dsp->fRec1[1] = dsp->fRec1[0];
+ dsp->fRec2[2] = dsp->fRec2[1];
+ dsp->fRec2[1] = dsp->fRec2[0];
+ dsp->fRec3[2] = dsp->fRec3[1];
+ dsp->fRec3[1] = dsp->fRec3[0];
+ dsp->fRec4[2] = dsp->fRec4[1];
+ dsp->fRec4[1] = dsp->fRec4[0];
+ dsp->fRec5[2] = dsp->fRec5[1];
+ dsp->fRec5[1] = dsp->fRec5[0];
+ dsp->fRec6[2] = dsp->fRec6[1];
+ dsp->fRec6[1] = dsp->fRec6[0];
+ dsp->fRec7[2] = dsp->fRec7[1];
+ dsp->fRec7[1] = dsp->fRec7[0];
+ }
+ }
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+static Piano *clonePiano(Piano *dsp) {
+ return memmove(newPiano(), dsp, sizeof(*dsp));
+}
+
+static void *statePiano(Piano *dsp, int *sz) {
+ *sz = sizeof(*dsp);
+ return dsp;
+}
+
+#define DSP Piano
+
+#include "dspf.h"
+
+static DSPf dspf = {
+ .new = newPiano,
+ .clone = clonePiano,
+ .state = statePiano,
+ .init = instanceInitPiano,
+ .delete = deletePiano,
+ .metadata = metadataPiano,
+ .num_in = getNumInputsPiano,
+ .num_out = getNumOutputsPiano,
+ .clear = instanceClearPiano,
+ .reset_ui = instanceResetUserInterfacePiano,
+ .build_ui = buildUserInterfacePiano,
+ .compute = computePiano,
+};
+
+void *
+class_init(int rate)
+{
+ classInitPiano(rate);
+ return &dspf;
+}
+
+#endif
--- /dev/null
+++ b/dsp/piano.dsp
@@ -1,0 +1,256 @@
+declare name "Piano";
+declare group "Synthesis";
+declare description "WaveGuide Commuted Piano";
+declare author "Romain Michon (rmichon@ccrma.stanford.edu)";
+declare copyright "Romain Michon";
+declare version "1.0";
+declare licence "STK-4.3"; // Synthesis Tool Kit 4.3 (MIT style license);
+declare description "A commuted WaveGuide piano.";
+
+import("instruments.lib");
+
+//==================== GUI SPECIFICATION ================
+
+freq = hslider("h:Basic_Parameters/Freq [1][unit:Hz] [tooltip:Tone frequency]",440,20,20000,1);
+gain = hslider("h:Basic_Parameters/Gain [1][tooltip:Gain (value between 0 and 1)]",1,0,1,0.01);
+gate = button("h:Basic_Parameters/Gate [1][tooltip:noteOn = 1, noteOff = 0]");
+
+brightnessFactor = hslider("v:Physical_Parameters/Brightness_Factor
+[2][tooltip:A value between 0 and 1]",0,0,1,0.01);
+detuningFactor = hslider("v:Physical_Parameters/Detuning_Factor
+[2][tooltip:A value between 0 and 1]",0.1,0,1,0.01)*10;
+stiffnessFactor = hslider("v:Physical_Parameters/Stiffness_Factor
+[2][tooltip:A value between 0 and 1]",0.28,0,1,0.01)*3.7;
+hammerHardness = hslider("v:Physical_Parameters/Hammer_Hardness
+[2][tooltip:A value between 0 and 1]",0.1,0,1,0.01)*0.1;
+
+//==================== COMMUTED PIANO PARAMETERS ================
+
+//variables to set keybord splitting zone
+DCB2_TURNOFF_KEYNUM = 92;
+FIRST_HIGH_NOTE = 88;
+PEDAL_ENVELOPE_T60 = 7;
+
+//convert an amplitude in db
+dbinv(x) = pow(10,0.05*x);
+
+//convert a frequency in a midi note number
+freqToNoteNumber = (log-log(440))/log(2)*12+69+0.5 : int;
+freqn = freq : freqToNoteNumber;
+
+//a counter that restart a every note-on
+cntSample = *(gate)+1~_ : -(1);
+
+//==================== PIANO SOUND BOARD ================
+
+//exponential envelope with 3 phases for the pedal excitation
+asympT60pedal(value,T60) = (*(factor) + constant)~_
+ with{
+ attDur = hammerHardness*float(ma.SR);
+ target = value*((cntSample < attDur) & (gate > 0));
+ factorAtt = exp (-1/(attDur));
+ factorG = exp(-1/(2*float(ma.SR)));
+ factorT60 = exp(-7/(T60*float(ma.SR)));
+ factor = factorAtt*gate*(cntSample < attDur) + (cntSample >= attDur)*gate*factorG + ((gate-1)*-1)*factorT60;
+ constant = (1 - factor)*target;
+ };
+
+//the sound of the piano sound board is generated by noise generator whose output gain is shaped by
+//an exponential envelope
+soundBoard = dryTapAmp*no.noise + pedalEnv*no.noise : *(0.5)
+ with{
+ //the values of the envelope cut-off time are stored in an external C++ function
+ dryTapAmpT60 = ffunction(float getValueDryTapAmpT60(float), <piano.h>,"");
+ sustainPedalLevel = ffunction(float getValueSustainPedalLevel(float), <piano.h>,"");
+
+ pedalEnvCutOffTime = 1.4;
+ noteCutOffTime = freqn : dryTapAmpT60*gain;
+ pedalEnvValue = freqn : sustainPedalLevel*0.2;
+ noteEnvValue = 0.15;
+ dryTapAmp = asympT60(noteEnvValue,0,noteCutOffTime,gate);
+ pedalEnv = asympT60pedal(pedalEnvValue,pedalEnvCutOffTime);
+ };
+
+//==================== HAMMER MODELING ================
+
+//To model the exitation hammer, we filter the sound from the soundboard with a serie of 4 one pole filters
+//connected in serie
+
+//onePole is declared in instruments.lib
+calcHammer = onePole((1-hammerPole)*hammerGain,-hammerPole)
+ with{
+ //filter gains and coefficients are stored in external C++ files
+ loudPole = ffunction(float getValueLoudPole(float), <piano.h>,"");
+ softPole = ffunction(float getValuePoleValue(float), <piano.h>,"");
+ loudGain = ffunction(float getValueLoudGain(float), <piano.h>,"");
+ softGain = ffunction(float getValueSoftGain(float), <piano.h>,"");
+
+ loudPoleValue = loudPole(freqn) + (brightnessFactor*-0.25) + 0.02;
+ softPoleValue = softPole(freqn);
+ normalizedVelocityValue = 1;
+ loudGainValue = loudGain(freqn);
+ softGainValue = softGain(freqn);
+ overallGain = 1;
+ hammerPole = softPoleValue + (loudPoleValue - softPoleValue)*normalizedVelocityValue;
+ hammerGain = overallGain*(softGainValue + (loudGainValue - softGainValue)*normalizedVelocityValue);
+ };
+
+hammer = seq(i,4,calcHammer);
+
+//==================== DC BLOCKERS ================
+
+//the values for the dcblockers a1 are stored in an external C++ file
+DCBa1 = ffunction(float getValueDCBa1(float), <piano.h>,"");
+dCBa1Value = freqn : DCBa1;
+dCBb0Value = 1 - dCBa1Value;
+
+dcBlock1 = poleZero((dCBb0Value*0.5),(dCBb0Value*-0.5),dCBa1Value);
+
+dcBlock2a = oneZero1(0.5,-0.5);
+
+dcBlock2b = onePole(dCBb0Value,dCBa1Value);
+
+//==================== HIGH TUNING CALCULATION ================
+
+//high tones are not generated with the waveguide technique but with a serie of biquad filters
+
+r1_1 = ffunction(float getValuer1_1db(float), <piano.h>,"");
+r1_2 = ffunction(float getValuer1_2db(float), <piano.h>,"");
+r2 = ffunction(float getValuer2db(float), <piano.h>,"");
+r3 = ffunction(float getValuer3db(float), <piano.h>,"");
+e = ffunction(float getValueSecondStageAmpRatio(float), <piano.h>,"");
+second_partial_factor = ffunction(float getValueSecondPartialFactor(float), <piano.h>,"");
+third_partial_factor = ffunction(float getValueThirdPartialFactor(float), <piano.h>,"");
+bq4_gEarBalled = ffunction(float getValueBq4_gEarBalled(float), <piano.h>,"");
+
+r1_1Value = r1_1(freqn)/ma.SR : dbinv;
+r1_2Value = r1_2(freqn)/ma.SR : dbinv;
+r2Value = r2(freqn)/ma.SR : dbinv;
+r3Value = r3(freqn)/ma.SR : dbinv;
+eValue = e(freqn) : dbinv;
+second_partial_factorValue = second_partial_factor(freqn);
+third_partial_factorValue = third_partial_factor(freqn);
+
+//set biquad gains and coeffs
+gainHighBq(0) = bq4_gEarBalled(freqn)/0.5;
+gainHighBq(1) = bq4_gEarBalled(freqn)/0.5;
+gainHighBq(2) = 1;
+gainHighBq(3) = 1;
+
+b0HighBq(0) = 1;
+b0HighBq(1) = 1;
+b0HighBq(2) = 1;
+b0HighBq(3) = 1;
+
+b1HighBq(0) = 0;
+b1HighBq(1) = 0;
+b1HighBq(2) = -2*(eValue*r1_1Value+(1-eValue)*r1_2Value)*cos(2*ma.PI*freq/ma.SR);
+b1HighBq(3) = 0;
+
+b2HighBq(0) = 0;
+b2HighBq(1) = 0;
+b2HighBq(2) = eValue*r1_1Value*r1_1Value+(1-eValue)*r1_2Value*r1_2Value;
+b2HighBq(3) = 0;
+
+a1HighBq(0) = -2*r3Value*cos(2*ma.PI*freq*third_partial_factorValue/ma.SR);
+a1HighBq(1) = -2*r2Value*cos(2*ma.PI*freq*second_partial_factorValue/ma.SR);
+a1HighBq(2) = -2*r1_1Value*cos(2*ma.PI*freq/ma.SR);
+a1HighBq(3) = -2*r1_2Value*cos(2*ma.PI*freq/ma.SR);
+
+a2HighBq(0) = r3Value*r3Value;
+a2HighBq(1) = r2Value*r2Value;
+a2HighBq(2) = r1_1Value*r1_1Value;
+a2HighBq(3) = r1_2Value*r1_2Value;
+
+highBqs = seq(i,4,*(gainHighBq(i)) : fi.TF2(b0HighBq(i),b1HighBq(i),b2HighBq(i),a1HighBq(i),a2HighBq(i)));
+
+hiPass = oneZero1(b0,b1)
+ with{
+ b0 = -0.5;
+ b1 = -0.5;
+ };
+
+//==================== STRIKE POSITION COMB FILTER EQ ================
+
+eq = _*filterGain : fi.TF2(b0,b1,b2,a1,a2)
+ with{
+ strikePosition = ffunction(float getValueStrikePosition(float), <piano.h>,"");
+ bandwidthFactors = ffunction(float getValueEQBandWidthFactor(float), <piano.h>,"");
+ eq_gain = ffunction(float getValueEQGain(float), <piano.h>,"");
+ eq_tuning = freq/strikePosition(freqn);
+ eq_bandwidth = bandwidthFactors(freqn)*freq;
+ filterGain = eq_gain(freqn);
+ a2 = (eq_bandwidth / ma.SR) * (eq_bandwidth / ma.SR);
+ a1 = -2*(eq_bandwidth / ma.SR)*cos(2*ma.PI*eq_tuning/ma.SR);
+ b0 = 0.5 - 0.5 * a2;
+ b1 = 0;
+ b2 = -b0;
+ };
+
+//==================== PIANO COUPLED STRINGS ================
+
+//values for the couple strings are stored in externals C++ functions
+singleStringDecRate = ffunction(float getValueSingleStringDecayRate(float), <piano.h>,"");
+singleStringZero = ffunction(float getValueSingleStringZero(float), <piano.h>,"");
+singleStringPole = ffunction(float getValueSingleStringPole(float), <piano.h>,"");
+stiffnessCoefficient = ffunction(float getValueStiffnessCoefficient(float), <piano.h>,"");
+
+//coupling filter parameters
+g = pow(10,((singleStringDecRate(freqn)/freq)/20)); //attenuation per period
+b = singleStringZero(freqn);
+a = singleStringPole(freqn);
+tempd = 3*(1-b)-g*(1-a);
+b0Coupling = 2*(g*(1-a)-(1-b))/tempd;
+b1Coupling = 2*(a*(1-b)-g*(1-a)*b)/tempd;
+a1Coupling = (g*(1-a)*b - 3*a*(1-b))/tempd;
+
+//string stiffness
+stiffness = stiffnessFactor*stiffnessCoefficient(freqn);
+
+stiffnessAP = poleZero(b0s,b1s,a1s)
+ with{
+ b0s = stiffness;
+ b1s = 1;
+ a1s = stiffness;
+ };
+
+delayG(frequency,stiffnessCoefficient) = de.fdelay(4096,delayLength)
+ with{
+ allPassPhase(a1,WT) = atan2((a1*a1-1.0)*sin(WT),(2.0*a1+(a1*a1+1.0)*cos(WT)));
+ poleZeroPhase(b0,b1,a1,WT) = atan2(-b1*sin(WT)*(1 + a1*cos(WT)) + a1*sin(WT)*(b0 + b1*cos(WT)),
+ (b0 + b1*cos(WT))*(1 + a1*cos(WT)) + b1*sin(WT)*a1*sin(WT));
+ wT = frequency*2*ma.PI/ma.SR;
+ delayLength = (2*ma.PI + 3*allPassPhase(stiffnessCoefficient, wT) +
+ poleZeroPhase((1+2*b0Coupling),
+ a1Coupling + 2*b1Coupling, a1Coupling, wT)) / wT;
+ };
+
+coupledStrings = (parallelStrings <: (_,(_+_ <: _,_),_ : _,_,(_ : couplingFilter),_ : adder))~(_,_) : !,!,_
+ with{
+ releaseLoopGain = ffunction(float getValueReleaseLoopGain(float), <piano.h>,"");
+ hz = ffunction(float getValueDetuningHz(float), <piano.h>,"");
+ coupledStringLoopGain = gate*0.9996 + ((gate-1)*-1)*releaseLoopGain(freqn)*0.9 : si.smoo;
+ couplingFilter = poleZero(b0Coupling,b1Coupling,a1Coupling);
+ hzValue = hz(freqn);
+ freq1 = freq + 0.5*hzValue*detuningFactor;
+ freq2 = freq - 0.5*hzValue*detuningFactor;
+ delay1 = delayG(freq1,stiffness);
+ delay2 = delayG(freq2,stiffness);
+ parallelStrings(x,y) = _ <: (+(x)*coupledStringLoopGain : seq(i,3,stiffnessAP) : delay1),
+ (_+y*coupledStringLoopGain : seq(i,3,stiffnessAP) : delay2);
+ adder(w,x,y,z) = (y <: +(w),+(z)),x ;
+ };
+
+//stereoizer is declared in instruments.lib and implement a stereo spacialisation in function of
+//the frequency period in number of samples
+stereo = stereoizer(ma.SR/freq);
+
+//==================== PROCESSING ================
+
+conditionLowNote = freqn < FIRST_HIGH_NOTE;
+conditionHighNote = freqn >= FIRST_HIGH_NOTE;
+
+process = soundBoard <: (*(conditionLowNote)*6 : hammer : dcBlock1 : coupledStrings <: +(eq)),
+(*(conditionHighNote) : hiPass : dcBlock1 : hammer : dcBlock2a : highBqs : dcBlock2b) :> + : *(12) :
+stereo : instrReverb;
+
--- /dev/null
+++ b/dsp/piano.h
@@ -1,0 +1,609 @@
+//Parameters for piano.dsp
+//©Romain Michon (rmichon@ccrma.stanford.edu), 2011
+//licence: FAUST-STK
+
+// translated to C
+
+static double lookupValue(double *points, int numpoints, double x)
+{
+ // Note: Assumes points are monotonically increasing in X!
+
+ int i=0;
+ while (x>points[i*2] && i<numpoints)
+ i++;
+
+ if (i==0)
+ return points[1];
+
+ if (i>=numpoints)
+ return points[(numpoints-1)*2+1];
+
+ double ratio = (x - points[(i-1)*2]) / (points[i*2] - points[(i-1)*2]);
+
+ return points[(i-1)*2+1]*(1-ratio) + points[i*2+1]*(ratio);
+}
+
+#define lookup(t,x) lookupValue(t, nelem(t)/2, x)
+
+/* PianoDriver.sb */
+static double noteOffDelayTime[] = {
+ 89.000,3.000,
+ 93.000,2.000,
+ 95.000,1.500,
+ 99.782,1.020,
+ 108.000,0.300,
+};
+
+/* pianoDriverC.sb */
+/* Coupling Filter */
+
+static double singleStringDecayRate[] = {
+ 21.000,-1.500,
+ 24.000,-1.500,
+ 28.000,-1.500,
+ 29.000,-6.000,
+ 36.000,-6.000,
+ 42.000,-6.100,
+ 48.000,-7.000,
+ 52.836,-7.000,
+ 60.000,-7.300,
+ 66.000,-7.700,
+ 72.000,-8.000,
+ 78.000,-8.800,
+ 84.000,-10.000,
+ 88.619,-11.215,
+ 92.368,-12.348,
+ 95.684,-13.934,
+ 99.000,-15.000
+};
+
+static double singleStringZero[] = {
+ 21.000,-1.000,
+ 24.000,-1.000,
+ 28.000,-1.000,
+ 29.000,-1.000,
+ 32.534,-1.000,
+ 36.000,-0.700,
+ 42.000,-0.400,
+ 48.000,-0.200,
+ 54.000,-0.120,
+ 60.000,-0.080,
+ 66.000,-0.070,
+ 72.000,-0.070,
+ 79.000,-0.065,
+ 84.000,-0.063,
+ 88.000,-0.060,
+ 96.000,-0.050,
+ 99.000,-0.050
+};
+
+static double singleStringPole[] = {
+ 21.000,0.350,
+ 24.604,0.318,
+ 26.335,0.279,
+ 28.000,0.250,
+ 32.000,0.150,
+ 36.000,0.000,
+ 42.000,0.000,
+ 48.000,0.000,
+ 54.000,0.000,
+ 60.000,0.000,
+ 66.000,0.000,
+ 72.000,0.000,
+ 76.000,0.000,
+ 84.000,0.000,
+ 88.000,0.000,
+ 96.000,0.000,
+ 99.000,0.000
+};
+
+static double releaseLoopGain[] = {
+ 21.000,0.865,
+ 24.000,0.880,
+ 29.000,0.896,
+ 36.000,0.910,
+ 48.000,0.920,
+ 60.000,0.950,
+ 72.000,0.965,
+ 84.000,0.988,
+ 88.000,0.997,
+ 99.000,0.988
+};
+
+static double detuningHz[] = {
+ 21.000,0.003,
+ 24.000,0.003,
+ 28.000,0.003,
+ 29.000,0.060,
+ 31.000,0.100,
+ 36.000,0.110,
+ 42.000,0.120,
+ 48.000,0.200,
+ 54.000,0.200,
+ 60.000,0.250,
+ 66.000,0.270,
+ 72.232,0.300,
+ 78.000,0.350,
+ 84.000,0.500,
+ 88.531,0.582,
+ 92.116,0.664,
+ 95.844,0.793,
+ 99.000,1.000
+};
+
+static double stiffnessCoefficient[] = {
+ 21.000,-0.850,
+ 23.595,-0.850,
+ 27.055,-0.830,
+ 29.000,-0.700,
+ 37.725,-0.516,
+ 46.952,-0.352,
+ 60.000,-0.250,
+ 73.625,-0.036,
+ 93.810,-0.006,
+ 99.000,1.011
+};
+
+static double strikePosition[] = {
+ 21.000,0.050,
+ 24.000,0.050,
+ 28.000,0.050,
+ 35.000,0.050,
+ 41.000,0.050,
+ 42.000,0.125,
+ 48.000,0.125,
+ 60.000,0.125,
+ 72.000,0.125,
+ 84.000,0.125,
+ 96.000,0.125,
+ 99.000,0.125
+};
+
+static double EQGain[] = {
+ 21.000,2.000,
+ 24.000,2.000,
+ 28.000,2.000,
+ 30.000,2.000,
+ 35.562,1.882,
+ 41.000,1.200,
+ 42.000,0.600,
+ 48.000,0.500,
+ 54.000,0.500,
+ 59.928,0.502,
+ 66.704,0.489,
+ 74.201,0.477,
+ 91.791,1.000,
+ 99.000,1.000
+};
+
+static double EQBandwidthFactor[] = {
+ 21.000,5.000,
+ 24.112,5.000,
+ 28.000,5.000,
+ 35.000,4.956,
+ 41.000,6.000,
+ 42.000,2.000,
+ 48.773,1.072,
+ 57.558,1.001,
+ 63.226,1.048,
+ 69.178,1.120,
+ 72.862,1.525,
+ 80.404,2.788,
+ 97.659,1.739
+};
+
+/* PianoDriverA */
+/* HammerFilter */
+
+static double loudPole[] = {
+ 21.000,0.875,
+ 23.719,0.871,
+ 27.237,0.836,
+ 28.996,0.828,
+ 32.355,0.820,
+ 36.672,0.816,
+ 40.671,0.820,
+ 45.788,0.812,
+ 47.867,0.812,
+ 54.000,0.810,
+ 60.000,0.800,
+ 66.000,0.800,
+ 72.000,0.810,
+ 78.839,0.824,
+ 84.446,0.844,
+ 89.894,0.844,
+ 96.463,0.848,
+ 103.512,0.840,
+ 107.678,0.840
+};
+
+static double softPole[] = {
+ 21.000,0.990,
+ 24.000,0.990,
+ 28.000,0.990,
+ 29.000,0.990,
+ 36.000,0.990,
+ 42.000,0.990,
+ 48.000,0.985,
+ 54.000,0.970,
+ 60.000,0.960,
+ 66.000,0.960,
+ 72.000,0.960,
+ 78.000,0.970,
+ 84.673,0.975,
+ 91.157,0.990,
+ 100.982,0.970,
+ 104.205,0.950
+};
+
+static double normalizedVelocity[] = {
+ 0.000,0.000,
+ 0.170,0.318,
+ 0.316,0.546,
+ 0.460,0.709,
+ 0.599,0.825,
+ 0.717,0.894,
+ 0.841,0.945,
+ 1.000,1.000
+};
+
+static double loudGain[] = {
+ 21.873,0.891,
+ 25.194,0.870,
+ 30.538,0.848,
+ 35.448,0.853,
+ 41.513,0.842,
+ 47.434,0.826,
+ 53.644,0.820,
+ 60.720,0.815,
+ 65.630,0.820,
+ 72.995,0.853,
+ 79.060,0.920,
+ 85.270,1.028,
+ 91.624,1.247,
+ 95.668,1.296,
+ 99.000,1.300,
+ 100.000,1.100
+};
+
+static double softGain[] = {
+ 20.865,0.400,
+ 22.705,0.400,
+ 25.960,0.400,
+ 28.224,0.400,
+ 31.196,0.400,
+ 36.715,0.400,
+ 44.499,0.400,
+ 53.981,0.400,
+ 60.000,0.350,
+ 66.000,0.350,
+ 72.661,0.350,
+ 81.435,0.430,
+ 88.311,0.450,
+ 93.040,0.500,
+ 96.434,0.500
+};
+
+/* Soundboard */
+
+static double sustainPedalLevel[] = {
+ 21.000,0.050,
+ 24.000,0.050,
+ 31.000,0.030,
+ 36.000,0.025,
+ 48.000,0.010,
+ 60.000,0.005,
+ 66.000,0.003,
+ 72.000,0.002,
+ 78.000,0.002,
+ 84.000,0.003,
+ 90.000,0.003,
+ 96.000,0.003,
+ 108.000,0.002
+};
+
+static double DryTapAmpT60[] = {
+ 21.001,0.491,
+ 26.587,0.498,
+ 34.249,0.470,
+ 40.794,0.441,
+ 47.977,0.392,
+ 55.000,0.370,
+ 60.000,0.370,
+ 66.000,0.370,
+ 71.934,0.370,
+ 78.000,0.370,
+ 83.936,0.390,
+ 88.557,0.387,
+ 92.858,0.400,
+ 97.319,0.469,
+ 102.400,0.500,
+ 107.198,0.494
+};
+
+static double DryTapAmpCurrent = 0.15;
+
+static double DCBa1[] = {
+ 21.000,-0.999,
+ 24.000,-0.999,
+ 30.000,-0.999,
+ 36.000,-0.999,
+ 42.000,-0.999,
+ 48.027,-0.993,
+ 60.000,-0.995,
+ 72.335,-0.960,
+ 78.412,-0.924,
+ 84.329,-0.850,
+ 87.688,-0.770,
+ 91.000,-0.700,
+ 92.000,-0.910,
+ 96.783,-0.850,
+ 99.000,-0.800,
+ 100.000,-0.850,
+ 104.634,-0.700,
+ 107.518,-0.500
+};
+
+/* pianoDriverB */
+/* High Notes */
+
+static double secondStageAmpRatio[] = {
+ 82.277,-18.508,
+ 88.000,-30.000,
+ 90.000,-30.000,
+ 93.451,-30.488,
+ 98.891,-30.633,
+ 107.573,-30.633
+};
+
+static double r1_1db[] = {
+ 100.000,-75.000,
+ 103.802,-237.513,
+ 108.000,-400.000
+};
+
+static double r1_2db[] = {
+ 98.388,-16.562,
+ 100.743,-75.531,
+ 103.242,-154.156,
+ 108.000,-300.000
+};
+
+double r2db[2*2] = {
+ 100.000,-115.898,
+ 107.858,-250.000
+};
+
+double r3db[2*2] = {
+ 100.000,-150.000,
+ 108.000,-400.000
+};
+
+double secondPartialFactor[2*2] = {
+ 88.000,2.000,
+ 108.000,2.100
+};
+
+double thirdPartialFactor[2*2] = {
+ 88.000,3.100,
+ 108.000,3.100
+};
+
+double bq4_gEarBalled[6*2] = {
+ 100.000,0.040,
+ 102.477,0.100,
+ 104.518,0.300,
+ 106.000,0.500,
+ 107.000,1.000,
+ 108.000,1.500
+};
+
+#define getValueDryTapAmpT60(x) lookup(DryTapAmpT60, x)
+#define getValueSustainPedalLevel(x) lookup(sustainPedalLevel, x)
+#define getValueLoudPole(x) lookup(loudPole, x)
+#define getValuePoleValue(x) lookup(poleValue, x)
+#define getValueLoudGain(x) lookup(loudGain, x)
+#define getValueSoftGain(x) lookup(softGain, x)
+#define getValueDCBa1(x) lookup(DCBa1, x)
+#define getValuer1_1db(x) lookup(r1_1db, x)
+#define getValuer1_2db(x) lookup(r1_2db, x)
+#define getValuer2db(x) lookup(r2db, x)
+#define getValuer3db(x) lookup(r3db, x)
+#define getValueSecondStageAmpRatio(x) lookup(secondStageAmpRatio, x)
+#define getValueSecondPartialFactor(x) lookup(secondPartialFactor, x)
+#define getValueThirdPartialFactor(x) lookup(thirdPartialFactor, x)
+#define getValueBq4_gEarBalled(x) lookup(bq4_gEarBalled, x)
+#define getValueStrikePosition(x) lookup(strikePosition, x)
+#define getValueEQBandWidthFactor(x) lookup(EQBandwidthFactor, x)
+#define getValueEQGain(x) lookup(EQGain, x)
+#define getValueDetuningHz(x) lookup(detuningHz, x)
+#define getValueSingleStringDecayRate(x) lookup(singleStringDecayRate, x)
+#define getValueSingleStringZero(x) lookup(singleStringZero, x)
+#define getValueSingleStringPole(x) lookup(singleStringPole, x)
+#define getValueStiffnessCoefficient(x) lookup(stiffnessCoefficient, x)
+#define getValueReleaseLoopGain(x) lookup(releaseLoopGain, x)
+
+//Harpsichord
+
+static double loopFilterb0[] = {
+ 35.000,0.94373,
+ 36.000,0.94731,
+ 46.000,0.94731,
+ 47.000,0.96202,
+ 52.000,0.96202,
+ 53.000,0.97477,
+ 58.000,0.97477,
+ 59.000,0.97733,
+ 64.000,0.97733,
+ 65.000,0.97971,
+ 70.000,0.97971,
+ 71.000,0.97971,
+ 76.000,0.97971,
+ 77.000,0.98698,
+ 82.000,0.98698,
+ 83.000,0.98462,
+ 86.000,0.98462,
+ 87.000,0.98611,
+};
+
+static double loopFilterb1[] = {
+ 35.000,0.60010,
+ 36.000,-0.59124,
+ 46.000,-0.59124,
+ 47.000,-0.21243,
+ 52.000,-0.21243,
+ 53.000,-0.39280,
+ 58.000,-0.39280,
+ 59.000,-0.48307,
+ 64.000,-0.48307,
+ 65.000,0.51965,
+ 70.000,0.51965,
+ 71.000,0.51965,
+ 76.000,0.51965,
+ 77.000,-0.42463,
+ 82.000,-0.42463,
+ 83.000,0.85655,
+ 86.000,0.85655,
+ 87.000,0.68851,
+};
+
+static double loopFilterb2[] = {
+ 35.000,-0.00360,
+ 36.000,-0.12249,
+ 46.000,-0.12249,
+ 47.000,-0.16044,
+ 52.000,-0.16044,
+ 53.000,-0.21680,
+ 58.000,-0.21680,
+ 59.000,-0.16346,
+ 64.000,-0.16346,
+ 65.000,0.22162,
+ 70.000,0.22162,
+ 71.000,0.22162,
+ 76.000,0.22162,
+ 77.000,-0.14973,
+ 82.000,-0.14973,
+ 83.000,0.24937,
+ 86.000,0.24937,
+ 87.000,0.14838,
+};
+
+static double loopFiltera1[] = {
+ 35.000,0.5941,
+ 36.000,-0.65928,
+ 46.000,-0.65928,
+ 47.000,-0.24222,
+ 52.000,-0.24222,
+ 53.000,-0.41402,
+ 58.000,-0.41402,
+ 59.000,-0.50837,
+ 64.000,-0.50837,
+ 65.000,0.51263,
+ 70.000,0.51263,
+ 71.000,0.51263,
+ 76.000,0.51263,
+ 77.000,-0.43976,
+ 82.000,-0.43976,
+ 83.000,0.85396,
+ 86.000,0.85396,
+ 87.000,0.68332,
+};
+
+static double loopFiltera2[] = {
+ 35.000,-0.02641,
+ 36.000,-0.10275,
+ 46.000,-0.10275,
+ 47.000,-0.15842,
+ 52.000,-0.15842,
+ 53.000,-0.21653,
+ 58.000,-0.21653,
+ 59.000,-0.15833,
+ 64.000,-0.15833,
+ 65.000,0.22025,
+ 70.000,0.22025,
+ 71.000,0.22025,
+ 76.000,0.22025,
+ 77.000,-0.14583,
+ 82.000,-0.14583,
+ 83.000,0.24405,
+ 86.000,0.24405,
+ 87.000,0.14370,
+};
+
+#define getValueLoopFilterb0(x) lookup(LoopFilterb0, x)
+#define getValueLoopFilterb1(x) lookup(LoopFilterb1, x)
+#define getValueLoopFilterb2(x) lookup(LoopFilterb2, x)
+#define getValueLoopFiltera1(x) lookup(LoopFiltera1, x)
+#define getValueLoopFiltera2(x) lookup(LoopFiltera2, x)
+
+//bass
+
+static double bassLoopFilterb0[] = {
+ 24.000,0.54355,
+ 26.000,0.54355,
+ 27.000,0.55677,
+ 29.000,0.55677,
+ 32.000,0.55677,
+ 33.000,0.83598,
+ 36.000,0.83598,
+ 43.000,0.83598,
+ 44.000,0.88292,
+ 48.000,0.88292,
+ 51.000,0.88292,
+ 52.000,0.77805,
+ 54.000,0.77805,
+ 57.000,0.77805,
+ 58.000,0.91820,
+ 60.000,0.91820,
+ 61.000,0.91820,
+ 63.000,0.94594,
+ 65.000,0.91820,
+};
+
+static double bassLoopFilterb1[] = {
+ 24.000,-0.36586,
+ 26.000,-0.36586,
+ 27.000,-0.37628,
+ 29.000,-0.37628,
+ 32.000,-0.37628,
+ 33.000,-0.60228,
+ 36.000,-0.60228,
+ 43.000,-0.60228,
+ 44.000,-0.65721,
+ 48.000,-0.65721,
+ 51.000,-0.65721,
+ 52.000,-0.51902,
+ 54.000,-0.51902,
+ 57.000,-0.51902,
+ 58.000,-0.80765,
+ 60.000,-0.80765,
+ 61.000,-0.80765,
+ 63.000,-0.83230,
+ 65.000,-0.83230,
+};
+
+static double bassLoopFiltera1[] = {
+ 24.000,-0.81486,
+ 26.000,-0.81486,
+ 27.000,-0.81147,
+ 29.000,-0.81147,
+ 32.000,-0.81147,
+ 33.000,-0.76078,
+ 36.000,-0.76078,
+ 43.000,-0.76078,
+ 44.000,-0.77075,
+ 48.000,-0.77075,
+ 51.000,-0.77075,
+ 52.000,-0.73548,
+ 54.000,-0.73548,
+ 57.000,-0.73548,
+ 58.000,-0.88810,
+ 60.000,-0.88810,
+ 61.000,-0.88810,
+ 63.000,-0.88537,
+ 65.000,-0.88537,
+};
+
+#define getValueBassLoopFilterb0(x) lookup(BassLoopFilterb0, x)
+#define getValueBassLoopFilterb1(x) lookup(BassLoopFilterb1, x)
+#define getValueBassLoopFiltera1(x) lookup(BassLoopFiltera1, x)