zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 44cade5459110d0083e4bc598c501d66188f33cf
parent 5d80ba8e3b775dce3f368302bb764b72822e6e14
Author: Hans Petter Selasky <hps@selasky.org>
Date:   Thu,  2 Apr 2020 18:16:42 +0200

Implement API for per-note pitch.

Signed-off-by: Hans Petter Selasky <hps@selasky.org>

Diffstat:
Msrc/Synth/SynthNote.cpp | 12++++++++++++
Msrc/Synth/SynthNote.h | 3+++
2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/Synth/SynthNote.cpp b/src/Synth/SynthNote.cpp @@ -163,6 +163,18 @@ void SynthNote::setVelocity(float velocity_) { legato.setDecounter(0); //avoid chopping sound due fade-in } +void SynthNote::setPitch(float freq_, float log2_freq_) { + legato.setSilent(true); //Let legato.update(...) return 0. + LegatoParams pars{freq_, legato.getVelocity(), + legato.getPortamento(), log2_freq_, true, legato.getSeed()}; + try { + legatonote(pars); + } catch (std::bad_alloc &ba) { + std::cerr << "failed to set velocity to legato note: " << ba.what() << std::endl; + } + legato.setDecounter(0); //avoid chopping sound due fade-in +} + float SynthNote::getRandomFloat() { return (getRandomUint() / (INT32_MAX * 1.0f)); } diff --git a/src/Synth/SynthNote.h b/src/Synth/SynthNote.h @@ -72,6 +72,9 @@ class SynthNote /* For polyphonic aftertouch needed */ void setVelocity(float velocity_); + /* For per-note pitch */ + void setPitch(float freq_, float log2_freq_); + /* Random numbers with own seed */ float getRandomFloat(); prng_t getRandomUint();