More accurate amplitude env (WIP)

pull/1/head
asb2m10 11 years ago
parent fbcc9267a3
commit bd6f556345
  1. BIN
      Builds/MacOSX/Dexed.xcodeproj/project.xcworkspace/xcuserdata/asb2m10.xcuserdatad/UserInterfaceState.xcuserstate
  2. 2
      README.md
  3. 71
      Source/DXComponents.cpp
  4. 3
      Source/DXComponents.h

@ -44,7 +44,7 @@ Warning: loading corrupt/random data can crash the plugin and ultimatly your DAW
best to filter out values that can crash the DX engine; but I keep it to the minimum to get the
digital circuit bending feel.
Saving those currupt/random sysex data will regenerate a 32 bulk program sysex dump with a
Saving those corrupt/random sysex data will regenerate a 32 bulk program sysex dump with a
valid checksum for your DX7 keyboard. I'm in now way responsible if this breaks your DX7 keyboard.
Credits & thanks

@ -135,35 +135,58 @@ EnvDisplay::EnvDisplay() {
}
void EnvDisplay::paint(Graphics &g) {
int rate[4];
int level[4];
g.setColour(Colours::black.withAlpha(0.1f));
g.setColour(Colours::black.withAlpha(0.5f));
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f);
g.setColour(Colours::white);
g.setColour(Colour(0xFF0FC00F).withAlpha(0.3f));
char *levels = pvalues + 4;
char *rates = pvalues;
float dist[4];
float total;
for (int i = 0; i < 4; i++) {
rate[i] = pvalues[i];
level[i] = pvalues[i+4];
int old = levels[3];
for(int i=0;i<4;i++) {
int nw = levels[i];
dist[i] = ((float)abs(nw - old)) / rates[i] == 0 ? 1 : rates[i];
total += dist[i];
old = nw;
}
env.init(rate, level, 99 << 5, 0);
env.keydown(true);
for (int i = 0; i < 72; i++) {
int32_t pos = env.getsample();
for (int j = 0; j < 16; j++) {
env.getsample();
}
g.setPixel(i, 32 - (sqrt(pos) / 512));
if ( total < 1 ) {
dist[0] = dist[1] = dist[2] = dist[3] = 1;
total = 4;
}
env.keydown(false);
for (int i = 0; i < 24; i++) {
int32_t pos = env.getsample();
for (int j = 0; j < 16; j++) {
env.getsample();
}
g.setPixel(i + 72, 32 - (sqrt(pos) / 512));
// TODO : this is WIP
float ratio = 96 / total;
int oldx = 0;
int oldy = 32 - ((float)levels[3] / 3.125);
Path p;
p.startNewSubPath(0, 32);
for(int i=0;i<4;i++) {
int newx = dist[i] * ratio + oldx;
int newy = 32 - ((float)levels[i] / 3.125);
p.lineTo(newx, newy);
//g.drawLine(oldx, oldy, newx, newy, 2);
oldx = newx;
oldy = newy;
}
p.lineTo(96,32);
p.lineTo(0, 32);
g.fillPath(p);
g.setColour(Colour(0xFFFFFFFF));
String len;
len << ((int) total);
g.drawText(len, 5, 1, 72, 14, Justification::left, true);
}
PitchEnvDisplay::PitchEnvDisplay() {
@ -200,7 +223,7 @@ void PitchEnvDisplay::paint(Graphics &g) {
float ratio = 96 / total;
int oldx = 0;
int oldy = (pitchenv_tab[levels[3]] + 128) / 10;
int oldy = (pitchenv_tab[levels[3]] + 128) / 5;
for(int i=0;i<4;i++) {
int newx = dist[i] * ratio + oldx;

@ -23,10 +23,7 @@
#include "../JuceLibraryCode/JuceHeader.h"
#include "msfa/env.h"
class EnvDisplay : public Component {
Env env;
public:
EnvDisplay();
char *pvalues;

Loading…
Cancel
Save