summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrekado <rekado@elephly.net>2013-01-25 18:29:11 +0800
committerrekado <rekado@elephly.net>2013-01-25 18:29:11 +0800
commita4bf64eb72d145366874a85444e27e67a8df2349 (patch)
treea5872853c97e217b53773337e62be6d97f314f51
parent665a36b5e110d28d43f4579fc6fcc84d67e01ccc (diff)
cosmetic changes
-rw-r--r--src/mdaPiano.cpp10
-rw-r--r--src/mdaPianoVoice.cpp23
2 files changed, 15 insertions, 18 deletions
diff --git a/src/mdaPiano.cpp b/src/mdaPiano.cpp
index ae463f4..1b153c8 100644
--- a/src/mdaPiano.cpp
+++ b/src/mdaPiano.cpp
@@ -79,8 +79,7 @@ unsigned mdaPiano::find_free_voice(unsigned char key, unsigned char velocity) {
}
-void mdaPiano::setVolume(float value)
-{
+void mdaPiano::setVolume(float value) {
for (uint32_t v=0; v<NVOICES; ++v)
voices[v]->set_volume(value);
}
@@ -165,8 +164,7 @@ void mdaPiano::handle_midi(uint32_t size, unsigned char* data) {
// TODO: load keymapping from a file
-void mdaPiano::load_kgrp(KGRP *kgrp)
-{
+void mdaPiano::load_kgrp(KGRP *kgrp) {
kgrp[ 0].root = 36; kgrp[ 0].high = 37; kgrp[ 0].loop = 14774;
kgrp[ 1].root = 40; kgrp[ 1].high = 41; kgrp[ 1].loop = 16268;
kgrp[ 2].root = 43; kgrp[ 2].high = 45; kgrp[ 2].loop = 33541;
@@ -185,8 +183,7 @@ void mdaPiano::load_kgrp(KGRP *kgrp)
}
-void mdaPiano::load_sample(Sample *s, const char* name)
-{
+void mdaPiano::load_sample(Sample *s, const char* name) {
FILE *f;
long num, size;
char filepath[STRING_BUF];
@@ -227,4 +224,5 @@ void mdaPiano::load_sample(Sample *s, const char* name)
return;
}
+
static int _ = mdaPiano::register_class(p_uri);
diff --git a/src/mdaPianoVoice.cpp b/src/mdaPianoVoice.cpp
index 80f55da..8eba4e3 100644
--- a/src/mdaPianoVoice.cpp
+++ b/src/mdaPianoVoice.cpp
@@ -45,8 +45,7 @@ float mdaPianoVoice::p_helper(unsigned short id, Param d) {
}
-void mdaPianoVoice::on(unsigned char note, unsigned char velocity)
-{
+void mdaPianoVoice::on(unsigned char note, unsigned char velocity) {
// store key that turned this voice on (used in 'get_key')
m_key = note;
update(Current);
@@ -54,7 +53,7 @@ void mdaPianoVoice::on(unsigned char note, unsigned char velocity)
float l=99.0f;
uint32_t k, s;
- if(velocity>0)
+ if(velocity > 0)
{
k = (note - 60) * (note - 60);
l = fine + random * ((float)(k % 13) - 6.5f); //random & fine tune
@@ -93,9 +92,8 @@ void mdaPianoVoice::on(unsigned char note, unsigned char velocity)
l = 2.0f * *p(p_envelope_decay);
if(l < 1.0f) l += 0.25f - 0.5f * *p(p_envelope_decay);
dec = (float)exp(-iFs * exp(-0.6 + 0.033 * (double)note - l));
- }
- else //note off
- {
+ } else {
+ // some keyboards send note off events as 'note on' with velocity 0
release(0);
}
}
@@ -120,8 +118,7 @@ void mdaPianoVoice::release(unsigned char velocity)
}
-void mdaPianoVoice::render(uint32_t from, uint32_t to)
-{
+void mdaPianoVoice::render(uint32_t from, uint32_t to) {
// abort if no key is pressed
// initially m_key is INVALID_KEY, so no sound will be rendered
if (m_key == LV2::INVALID_KEY)
@@ -131,9 +128,10 @@ void mdaPianoVoice::render(uint32_t from, uint32_t to)
uint32_t i;
for (uint32_t frame = from; frame < to; ++frame) {
+ // initialize left and right output
l = r = 0.0f;
- frac += delta; //integer-based linear interpolation
+ frac += delta; // integer-based linear interpolation
pos += frac >> 16;
frac &= 0xFFFF;
if(pos > end) pos -= loop;
@@ -165,14 +163,15 @@ void mdaPianoVoice::render(uint32_t from, uint32_t to)
}
-void mdaPianoVoice::update(Param par)
-{
+void mdaPianoVoice::update(Param par) {
size = (uint32_t)(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;
velsens = 1.0f + p_helper(p_velocity_sensitivity, par) + p_helper(p_velocity_sensitivity, par);
- if(p_helper(p_velocity_sensitivity, par) < 0.25f) velsens -= 0.75f - 3.0f * p_helper(p_velocity_sensitivity, par);
+ if(p_helper(p_velocity_sensitivity, par) < 0.25f) {
+ velsens -= 0.75f - 3.0f * p_helper(p_velocity_sensitivity, par);
+ }
fine = p_helper(p_fine_tuning, par) - 0.5f;
random = 0.077f * p_helper(p_random_detuning, par) * p_helper(p_random_detuning, par);