diff options
author | Damien Zammit <damien@zamaudio.com> | 2015-01-22 12:16:30 +1100 |
---|---|---|
committer | Damien Zammit <damien@zamaudio.com> | 2015-01-22 12:17:48 +1100 |
commit | e25ac20029f8851586d3034ed9d5f1269b9c9a10 (patch) | |
tree | 06801188941fa2b0762c1db309b61a87d11a183c | |
parent | cddf33ec020dec5b545ae4026eb5ce36f233478f (diff) |
Improved triggering ZamPiano
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r-- | Makefile.mk | 3 | ||||
-rw-r--r-- | plugins/ZamPiano/ZamPianoPlugin.cpp | 25 | ||||
-rw-r--r-- | plugins/ZamPiano/ZamPianoPlugin.hpp | 5 |
3 files changed, 21 insertions, 12 deletions
diff --git a/Makefile.mk b/Makefile.mk index f1333e5..46a2fac 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -21,13 +21,12 @@ endif # -------------------------------------------------------------- # Common build and link flags -BASE_FLAGS = -Wall -Wextra -pipe -g +BASE_FLAGS = -Wall -Wextra -pipe BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections ifneq ($(NOOPT),true) BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse endif LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,--strip-all -LINK_OPTS += $(shell pkg-config --libs fftw3f) ifeq ($(MACOS),true) # MacOS linker flags diff --git a/plugins/ZamPiano/ZamPianoPlugin.cpp b/plugins/ZamPiano/ZamPianoPlugin.cpp index 0fba980..1d46c89 100644 --- a/plugins/ZamPiano/ZamPianoPlugin.cpp +++ b/plugins/ZamPiano/ZamPianoPlugin.cpp @@ -1540,8 +1540,10 @@ void ZamPianoPlugin::d_run(const float** inputs, float** outputs, uint32_t frame } else if (type == 0x80 && chan == 0x0) { // NOTE OFF - note[n].state = RELEASE; - gate = 1; + pgate = 1.; + if (note[n].state != SILENT) { + note[n].state = RELEASE; + } } } @@ -1563,21 +1565,28 @@ void ZamPianoPlugin::d_run(const float** inputs, float** outputs, uint32_t frame pgain = note[k].vel; pgate = 0.; ZamPianoPlugin::compute(1, inputs, outputs); - pgate = gate; + pgate = 1.; ZamPianoPlugin::compute(frames, inputs, outputs); - note[k].state = SUSTAIN; - } else if (note[k].state == SUSTAIN) { + note[k].state++; + } else if (note[k].state < RELEASE) { + printf("SUSTAIN: %d %d\n", k, note[k].state); pgate = gate; ZamPianoPlugin::compute(frames, inputs, outputs); - } else if (note[k].state == RELEASE) { - printf("RELEASE: %d\n", k); + note[k].state++; + } else if (note[k].state < DECAY) { + printf("RELEASE: %d %d\n", k, note[k].state); pfreq = 440. * powf(2., (k-69)/12.); - pgain = 0.001; + pgain = 0.; pgate = 0.; ZamPianoPlugin::compute(1, inputs, outputs); pgate = gate; ZamPianoPlugin::compute(frames, inputs, outputs); note[k].state++; + } else if (note[k].state < SILENT) { + printf("DECAY: %d %d\n", k, note[k].state); + pgate = gate; + ZamPianoPlugin::compute(frames, inputs, outputs); + note[k].state++; } } for (i = 0; i < frames; i++) { diff --git a/plugins/ZamPiano/ZamPianoPlugin.hpp b/plugins/ZamPiano/ZamPianoPlugin.hpp index 824eed6..63f7629 100644 --- a/plugins/ZamPiano/ZamPianoPlugin.hpp +++ b/plugins/ZamPiano/ZamPianoPlugin.hpp @@ -25,8 +25,9 @@ #define STRIKE 0 #define ATTACK 1 #define SUSTAIN 2 -#define RELEASE 3 -#define SILENT 200 +#define RELEASE 1000 +#define DECAY 1001 +#define SILENT 1011 START_NAMESPACE_DISTRHO |