diff options
author | rekado <rekado@elephly.net> | 2013-07-28 16:14:33 +0800 |
---|---|---|
committer | rekado <rekado@elephly.net> | 2013-07-28 16:14:33 +0800 |
commit | 61193b790f6595617546397a79ff2c1f46ef72ac (patch) | |
tree | 558cd2d75cdea84bc85bf132fbd87b3609e5307d | |
parent | 61f2f9b4af048ad6aea1318c525cdc288417001d (diff) |
pass sample pointer to tweak function
-rw-r--r-- | src/mdaPiano.cpp | 33 | ||||
-rw-r--r-- | src/mdaPiano.h | 4 |
2 files changed, 14 insertions, 23 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp index 419939a..7aa1242 100644 --- a/src/mdaPiano.cpp +++ b/src/mdaPiano.cpp @@ -47,14 +47,13 @@ mdaPiano::mdaPiano(double rate) }; #endif + load_kgrp(kgrp); for (unsigned char i=0; i<NSAMPLES; ++i) { load_sample(&samples[i], sample_names[i]); - } - - load_kgrp(kgrp); #ifdef EPIANO - tweak_samples(); + tweak_sample(&samples[i], kgrp[i].loop); #endif + } for(uint32_t i=0; i<NVOICES; ++i) { voices[i] = new mdaPianoVoice(rate, samples, kgrp); @@ -297,26 +296,20 @@ void mdaPiano::load_kgrp(KGRP *kgrp) { } -#ifdef EPIANO -void mdaPiano::tweak_samples() { +void mdaPiano::tweak_sample(Sample *s, long loop_offset) { //extra xfade looping... - for(uint32_t k=0; k<28; k++) - { - long p0 = samples[k].size; - long p1 = samples[k].size - kgrp[k].loop; + long p0 = s->size; + long p1 = s->size - loop_offset; - float xf = 1.0f; - float dxf = -0.02f; + float xf = 1.0f; + float dxf = -0.02f; - while(xf > 0.0f) - { - samples[k].buffer[p0] = (short)((1.0f - xf) * (float)samples[k].buffer[p0] + xf * (float)samples[k].buffer[p1]); - p0--; - p1--; - xf += dxf; - } + while(xf > 0.0f) { + s->buffer[p0] = (short)((1.0f - xf) * (float)s->buffer[p0] + xf * (float)s->buffer[p1]); + p0--; + p1--; + xf += dxf; } } -#endif static int _ = mdaPiano::register_class(p_uri); diff --git a/src/mdaPiano.h b/src/mdaPiano.h index 9f89307..ffb26c8 100644 --- a/src/mdaPiano.h +++ b/src/mdaPiano.h @@ -27,9 +27,7 @@ public: void load_kgrp(KGRP*); void load_sample(Sample*, const char*); -#ifdef EPIANO - void tweak_samples(void); -#endif + void tweak_sample(Sample*, long); unsigned find_free_voice(unsigned char, unsigned char); void handle_midi(uint32_t, unsigned char*); |