diff options
author | rekado <rekado@elephly.net> | 2013-07-28 12:41:28 +0800 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2013-07-28 12:41:28 +0800 |
commit | de1a6a2b750a518bf96da919447943fd4eb2eceb (patch) | |
tree | 76c6affa795ce03f607409299601ad8b5c44d81b /src | |
parent | f9020a788fb384a3f095977aa629a31db9d43962 (diff) |
[piano] fix: hardness offset may result in negative values
Diffstat (limited to 'src')
-rw-r--r-- | src/mdaPianoVoice.cpp | 15 | ||||
-rw-r--r-- | src/mdaPianoVoice.h | 4 |
2 files changed, 5 insertions, 14 deletions
diff --git a/src/mdaPianoVoice.cpp b/src/mdaPianoVoice.cpp index 4551c6b..7d9e366 100644 --- a/src/mdaPianoVoice.cpp +++ b/src/mdaPianoVoice.cpp @@ -56,11 +56,7 @@ void mdaPianoVoice::on(unsigned char key, unsigned char velocity) { update(Current); float l=99.0f; -#ifdef PIANO - uint32_t k, s; -#elif defined EPIANO long k, s; -#endif if(velocity > 0) { @@ -72,7 +68,7 @@ void mdaPianoVoice::on(unsigned char key, unsigned char velocity) { s = size; #ifdef PIANO - if(velocity > 40) s += (uint32_t)(sizevel * (float)(velocity - 40)); + if(velocity > 40) s += (long)(sizevel * (float)(velocity - 40)); #endif k = 0; @@ -82,11 +78,10 @@ void mdaPianoVoice::on(unsigned char key, unsigned char velocity) { l += (float)(key - kgrp[k].root); // pitch #ifdef PIANO l = 22050.0f * iFs * (float)exp(0.05776226505 * l); - delta = (uint32_t)(65536.0f * l); #elif defined EPIANO l = 32000.0f * iFs * (float)exp(0.05776226505 * l); - delta = (long)(65536.0f * l); #endif + delta = (long)(65536.0f * l); frac = 0; pos = 0; @@ -191,11 +186,7 @@ void mdaPianoVoice::render(uint32_t from, uint32_t to) { return; float x, l, r; -#ifdef PIANO - uint32_t i; -#elif defined EPIANO long i; -#endif update(Current); for (uint32_t frame = from; frame < to; ++frame) { @@ -276,7 +267,7 @@ void mdaPianoVoice::render(uint32_t from, uint32_t to) { void mdaPianoVoice::update(Param par) { #ifdef PIANO - size = (uint32_t)(12.0f * p_helper(p_hardness_offset, par) - 6.0f); + size = (long)(12.0f * p_helper(p_hardness_offset, par) - 6.0f); sizevel = 0.12f * p_helper(p_velocity_to_hardness, par); muffvel = p_helper(p_velocity_to_muffling, par) * p_helper(p_velocity_to_muffling, par) * 5.0f; diff --git a/src/mdaPianoVoice.h b/src/mdaPianoVoice.h index e7d9601..9de7cac 100644 --- a/src/mdaPianoVoice.h +++ b/src/mdaPianoVoice.h @@ -24,16 +24,16 @@ class mdaPianoVoice : public lvtk::Voice { float width; float fine, random; float sizevel, velsens, volume; + long size; #ifdef PIANO float comb[256]; float cdep, trim; float stretch; float muff, muffvel; - uint32_t cpos, size; + uint32_t cpos; #endif #ifdef EPIANO - long size; float overdrive; float lfo0, lfo1, dlfo, lmod, rmod; float treb, tfrq, tl, tr; |