diff options
author | Christopher Arndt | 2024-04-11 23:39:31 +0200 |
---|---|---|
committer | Christopher Arndt | 2024-04-11 23:39:31 +0200 |
commit | 37b7da42da5d4b663bb80c92ee8667c36bd006e3 (patch) | |
tree | 650e7a39e3a4aa8db8bd442bf2173e268657bb12 | |
parent | b6142258cafb5b78d185ca18b3a28059069d870a (diff) | |
download | aur-37b7da42da5d4b663bb80c92ee8667c36bd006e3.tar.gz |
Fix polyphony calculation for Piano in LVZ wrapper
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 4 | ||||
-rw-r--r-- | polyphony-param.patch | 83 |
3 files changed, 6 insertions, 85 deletions
@@ -1,7 +1,7 @@ pkgbase = mod-mda-lv2-git pkgdesc = MOD fork of the LV2 port of the MDA plugins (git version) pkgver = 1.1.0.r217.b2df88c - pkgrel = 2 + pkgrel = 3 url = https://github.com/moddevices/mda-lv2 arch = x86_64 groups = lv2-plugins @@ -22,6 +22,6 @@ pkgbase = mod-mda-lv2-git source = polyphony-param.patch sha256sums = SKIP sha256sums = d65b3202225da4bb57611ec0f53b038386ae3f58d91fdbc7502c1ab032e62e80 - sha256sums = b8a262b83c9b2f89b9ceac336ee93868974a1e0ab435b864e9bfb9c36a9417bc + sha256sums = 8f7f61df6823d9f501d098acad4987b632d8ef2cfd9f4c819e0b548025dfbe04 pkgname = mod-mda-lv2-git @@ -3,7 +3,7 @@ _pkgname=mod-mda-lv2 pkgname=$_pkgname-git pkgver=1.1.0.r217.b2df88c -pkgrel=2 +pkgrel=3 pkgdesc='MOD fork of the LV2 port of the MDA plugins (git version)' arch=(x86_64) url='https://github.com/moddevices/mda-lv2' @@ -20,7 +20,7 @@ source=("$_pkgname::git+https://github.com/moddevices/mda-lv2.git" 'polyphony-param.patch') sha256sums=('SKIP' 'd65b3202225da4bb57611ec0f53b038386ae3f58d91fdbc7502c1ab032e62e80' - 'b8a262b83c9b2f89b9ceac336ee93868974a1e0ab435b864e9bfb9c36a9417bc') + '8f7f61df6823d9f501d098acad4987b632d8ef2cfd9f4c819e0b548025dfbe04') pkgver() { cd $_pkgname diff --git a/polyphony-param.patch b/polyphony-param.patch index 69a356fa6679..07f5e060bce5 100644 --- a/polyphony-param.patch +++ b/polyphony-param.patch @@ -207,61 +207,9 @@ index 10163c2..84cedc9 100644 lv2:port [
lv2:symbol "fine_tuning" ;
diff --git a/lvz/wrapper.cpp b/lvz/wrapper.cpp -index 34bd836..ac13f8d 100644 +index 34bd836..3db5b34 100644 --- a/lvz/wrapper.cpp +++ b/lvz/wrapper.cpp -@@ -49,7 +49,7 @@ - // para valores de 0 a 1, pois o código do mda foi projetado para trabalhar com esses valores - - --float translateParameter(PLUGIN_CLASS* effect,int port,float value,bool inverted) { -+float translateParameter(PLUGIN_CLASS* effect,int port,float value,bool inverted) { - if(strcmp(effect->getUniqueID(), "mdaAmb") == 0) { - switch(port) { - case 0: -@@ -224,17 +224,17 @@ float translateParameter(PLUGIN_CLASS* effect,int port,float value,bool inverted - } - } - else if(strcmp(effect->getUniqueID(), "mdaDX10") == 0) { -- /* -- Scaling process is convoluted but here is an explanation, -+ /* -+ Scaling process is convoluted but here is an explanation, - but just plugging through a bunch of values would make the presets not work: -- -+ - All envelope time based parameters are implemented as a recursive equation within the synth. - This means that at each sample it calculated something along the lines of: env_volume = env_volume * 0.999... - Here the 0.999... parameter is a decayparameter which will be explained later, for now let's call it dec. - The volume over time can then be found as: amp = dec^[n_samples]. - Thus the decay time can be found when subsituting a "silence ratio" for amp, in this case -60db -> 0.001. -- This gives n_samples = log_{dec}(amp) or in c++ terms: log(0.001)/log(dec). (as log_a(b) = log(b)/log(a)) -- -+ This gives n_samples = log_{dec}(amp) or in c++ terms: log(0.001)/log(dec). (as log_a(b) = log(b)/log(a)) -+ - Now the host provides the value as a linear interpolation from min to max, no matter if you specify it as logarithmic. - F.Y.I. the scaling they use for logarithmic is min*e^(x * ln(max/min)) where x = [0,1]. - The different time parameters have different equations for how they calculate the parameters: -@@ -245,7 +245,7 @@ float translateParameter(PLUGIN_CLASS* effect,int port,float value,bool inverted - - Modulator Release = exp( -(1/samplerate) * exp(5-8x) ) - However these map exactly to the way the logarithmic parameter mapping in the host works. - Given that the output needs to be scaled the same way we can solve the equation for x given a value between min and max: -- value = min*e^(x * ln(max/min)) -> x = ln(value/min)/ln(max/min). -+ value = min*e^(x * ln(max/min)) -> x = ln(value/min)/ln(max/min). - Put this value in the equation and it should return the correct value for x for the time parameter. - However some parameters have insanely long times so there is some additional stretching going on for the last ten percent of the range. - */ -@@ -254,8 +254,8 @@ float translateParameter(PLUGIN_CLASS* effect,int port,float value,bool inverted - return inverted ? 2.5*expf(value * logf(4000.f/2.5)) : logf(value/2.5)/logf(4000.f/2.5); - //return inverted ? value*100 : value/(100); - case(1): -- /* -- carrier decay times range from ~45ms to ~135 seconds -+ /* -+ carrier decay times range from ~45ms to ~135 seconds - so in order to make it useful some stretching is applied to the value input for 6s to 7s to make it stretch - stretching should happen from 6000ms to 7000ms value input - log(6000/46.5)/log(7000/46.5) = ~0.97 @@ -412,7 +412,7 @@ float translateParameter(PLUGIN_CLASS* effect,int port,float value,bool inverted case(7): return inverted ? value*200 : value/(200); @@ -276,7 +224,7 @@ index 34bd836..ac13f8d 100644 return inverted ? value*200 : value/(200); case(8): - return inverted ? value : value; -+ return inverted ? 8 + (int32_t)(31.9f * value) : (value - 8) / 31.9f; ++ return inverted ? 8 + (int32_t)(24.9f * value) : (value - 8) / 24.9f; case(9): return inverted ? value*100-50 : (value + 50)/(100); case(10): @@ -301,15 +249,6 @@ index 6684e98..79a6b9a 100644 setProgram(0); } -@@ -127,7 +127,7 @@ mdaEPiano::mdaEPiano(audioMasterCallback audioMaster) : AudioEffectX(audioMaster - - //initialise... - memset(voice, 0, sizeof(voice)); -- for(int32_t v=0; v<NVOICES; v++) -+ for(int32_t v=0; v<NVOICES; v++) - { - voice[v].env = 0.0f; - voice[v].dec = 0.99f; //all notes off @@ -163,7 +163,7 @@ void mdaEPiano::update() //parameter change if(param[6] < 0.25f) velsens -= 0.75f - 3.0f * param[6]; @@ -328,21 +267,3 @@ index 6684e98..79a6b9a 100644 case 9: strcpy(label, "Fine Tuning"); break; case 10: strcpy(label, "Random Tuning"); break; -@@ -408,7 +408,7 @@ void mdaEPiano::processReplacing(float **inputs, float **outputs, int32_t sample - - if(frame<sampleFrames) - { -- if(activevoices == 0 && programs[curProgram].param[4] > 0.5f) -+ if(activevoices == 0 && programs[curProgram].param[4] > 0.5f) - { lfo0 = -0.7071f; lfo1 = 0.7071f; } //reset LFO phase - good idea? - - if (!end) { -@@ -541,7 +541,7 @@ int32_t mdaEPiano::processEvent(const LV2_Atom_Event* ev) - sustain = midiData[2] & 0x40; - if(sustain==0) - { -- noteOn(SUSTAIN, 0); //end all sustained notes -+ noteOn(SUSTAIN, 0); //end all sustained notes - } - break; - |