summaryrefslogtreecommitdiff
path: root/src/mdaPiano.cpp
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-07-28 16:14:33 +0800
committerrekado <rekado@elephly.net>2013-07-28 16:14:33 +0800
commit61193b790f6595617546397a79ff2c1f46ef72ac (patch)
tree558cd2d75cdea84bc85bf132fbd87b3609e5307d /src/mdaPiano.cpp
parent61f2f9b4af048ad6aea1318c525cdc288417001d (diff)
pass sample pointer to tweak function
Diffstat (limited to 'src/mdaPiano.cpp')
-rw-r--r--src/mdaPiano.cpp33
1 files changed, 13 insertions, 20 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);