mirror of https://github.com/dcoredump/dexed.git
parent
166e39da57
commit
74395cd014
Binary file not shown.
@ -0,0 +1,246 @@ |
||||
/**
|
||||
* |
||||
* Copyright (c) 2014 Pascal Gauthier. |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation; either version 2 of |
||||
* the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be |
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied |
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
||||
* PURPOSE. See the GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public |
||||
* License along with this program; if not, write to the Free |
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
* Boston, MA 02110-1301 USA. |
||||
*/ |
||||
|
||||
#include "DXComponents.h" |
||||
#include "PluginProcessor.h" |
||||
#include "msfa/pitchenv.h" |
||||
|
||||
/**
|
||||
* Algorithm arrangements, based on the DX1 display. |
||||
*/ |
||||
static const char algoArr[][13] = { |
||||
// 1 2 3 4 5 6 7 8 9 A B C D
|
||||
{ 0, 0, 1, 3, 0, 0, 0, 2, 4, 0, 0, 5, -6 }, // 1
|
||||
{ 0, 0, 1, 3, 0, 0, 0, -2, 4, 0, 0, 5, 6 }, // 2
|
||||
{ 0, 0, 1, 4, 0, 0, 0, 2, 5, 0, 3, -6, 0 }, // 3
|
||||
{ 0, 0, 1, -4, 0, 0, 0, 2, -5, 0, 3, -6, 0 }, // 4
|
||||
{ 0, 1, 3, 5, 0, 0, 2, 4, -6, 0, 0, 0, 0 }, // 5
|
||||
{ 0, 1, 3, -5, 0, 0, 2, 4, -6, 0, 0, 0, 0 }, // 6
|
||||
{ 0, 1, 3, 0, 0, 0, -2, 4, 5, 0, 0, 6, 0 }, // 7
|
||||
{ 0, 1, 3, 0, 0, 0, 2, -4, 5, 0, 0, 6, 0 }, // 8
|
||||
{ 0, 1, 3, 0, 0, 0, -2, 4, 5, 0, 0, 6, 0 }, // 9
|
||||
{ 0, 0, 4, 1, 0, 0, 5, 6, 2, 0, 0, -3, 0 }, // 10
|
||||
{ 0, 0, 4, 1, 0, 0, 5, -6, 2, 0, 0, 3, 0 }, // 11
|
||||
{ 0, 0, 3, 0, 1, 0, 4, 5, 6, -2, 0, 0, 0 }, // 12
|
||||
{ 0, 0, 3, 0, 1, 0, 4, 5, -6, 2, 0, 0, 0 }, // 13
|
||||
// 1 2 3 4 5 6 7 8 9 A B C D
|
||||
{ 0, 0, 1, 3, 0, 0, 0, 2, 4, 0, 5, -6, 0 }, // 14
|
||||
{ 0, 0, 1, 3, 0, 0, 0, -2, 4, 0, 5, 6, 0 }, // 15
|
||||
{ 0, 0, 1, 0, 0, 0, 2, 3, 5, 0, 4, -6, 0 }, // 16
|
||||
{ 0, 0, 1, 0, 0, 0, -2, 3, 5, 0, 4, 6, 0 }, // 17
|
||||
{ 0, 0, 1, 0, 0, 0, 2, -3, 4, 0, 0, 5, 6 }, // 18
|
||||
{ 0, 0, 1, 4, 5, 0, 0, 2, -6, 0, 3, 0, 0 }, // 19
|
||||
{ 0, 1, 2, 0, 4, 0, -3, 0, 5, 6, 0, 0, 0 }, // 20
|
||||
{ 0, 1, 2, 4, 5, 0, -3, 0, 6, 0, 0, 0, 0 }, // 21
|
||||
{ 0, 1, 3, 4, 5, 0, 2, 0, -6, 0, 0, 0, 0 }, // 22
|
||||
{ 0, 1, 2, 4, 5, 0, 0, 3, -6, 0, 0, 0, 0 }, // 23
|
||||
{ 1, 2, 3, 4, 5, 0, 0, 0, -6, 0, 0, 0, 0 }, // 24
|
||||
{ 1, 2, 3, 4, 5, 0, 0, 0, -6, 0, 0, 0, 0 }, // 25
|
||||
{ 0, 1, 2, 0, 4, 0, 0, 3, 5, -6, 0, 0, 0 }, // 26
|
||||
// 1 2 3 4 5 6 7 8 9 A B C D
|
||||
{ 0, 1, 2, 0, 4, 0, 0, -3, 5, 6, 0, 0, 0 }, // 27
|
||||
{ 0, 1, 3, 6, 0, 0, 2, 4, 0, 0, -5, 0, 0 }, // 28
|
||||
{ 0, 1, 2, 3, 5, 0, 0, 0, 4, -6, 0, 0, 0 }, // 29
|
||||
{ 0, 1, 2, 3, 6, 0, 0, 0, 4, 0, 0, -5, 0 }, // 30
|
||||
{ 1, 2, 3, 4, 5, 0, 0, 0, 0, -6, 0, 0, 0 }, // 31
|
||||
{ 1, 2, 3, 4, 5, -6, 0, 0, 0, 0, 0, 0, 0 } // 32
|
||||
}; |
||||
|
||||
static char TMP_LEVEL_PTR[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; |
||||
|
||||
AlgoDisplay::AlgoDisplay() { |
||||
static char tmpAlgo = 0; |
||||
algo = &tmpAlgo; |
||||
} |
||||
|
||||
void AlgoDisplay::paint(Graphics &g) { |
||||
int alg; |
||||
|
||||
if ( *algo <= 31 ) { |
||||
alg = *algo; |
||||
} else { |
||||
alg = 31; |
||||
} |
||||
const char *arr = algoArr[alg]; |
||||
|
||||
g.setColour (Colours::black.withAlpha(0.1f)); |
||||
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f); |
||||
|
||||
for(int i=0;i<13;i++) { |
||||
int target = arr[i]; |
||||
if ( target == 0 ) |
||||
continue; |
||||
|
||||
if ( i < 6 ) { |
||||
drawOp(g, i, 3, target); |
||||
continue; |
||||
} |
||||
|
||||
if ( i < 10 ){ |
||||
drawOp(g, (i-6)+1, 2, target); |
||||
continue; |
||||
} |
||||
|
||||
if ( i < 12 ) { |
||||
drawOp(g, (i-10)+2, 1, target); |
||||
continue; |
||||
} |
||||
|
||||
// last one
|
||||
drawOp(g, (i-12)+3, 0, target); |
||||
} |
||||
|
||||
String algoTxt; |
||||
algoTxt << (alg+1); |
||||
g.drawText(algoTxt, 5, 1, 21, 14, Justification::left, true); |
||||
} |
||||
|
||||
void AlgoDisplay::drawOp(Graphics &g, int x, int y, int num) { |
||||
String txt; |
||||
txt << abs(num); |
||||
|
||||
int offx = 24; |
||||
int offy = 17; |
||||
|
||||
g.setColour(Colour(0xFF0FC00F)); |
||||
g.fillRect(x*offx+4, y*offy+3, offx-2, offy-1); |
||||
g.setColour(Colour(0xFFFFFFFF)); |
||||
g.drawText(txt, x*offx+3, y*offy+2, offx+2, offy+2, Justification::centred, true); |
||||
if ( num < 0 ) { |
||||
g.setColour(Colour(0xFFFFFFFF)); |
||||
int x1 = (x*offx) + 24; |
||||
g.drawLine(x1+1, y*offy+3, x1+1, y*offy+offy+2, 3); |
||||
} |
||||
} |
||||
|
||||
EnvDisplay::EnvDisplay() { |
||||
pvalues = (char *) &TMP_LEVEL_PTR;
|
||||
} |
||||
|
||||
void EnvDisplay::paint(Graphics &g) { |
||||
int rate[4]; |
||||
int level[4]; |
||||
|
||||
g.setColour(Colours::black.withAlpha(0.1f)); |
||||
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f); |
||||
g.setColour(Colours::white); |
||||
|
||||
for (int i = 0; i < 4; i++) { |
||||
rate[i] = pvalues[i]; |
||||
level[i] = pvalues[i+4]; |
||||
} |
||||
|
||||
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)); |
||||
} |
||||
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)); |
||||
} |
||||
} |
||||
|
||||
PitchEnvDisplay::PitchEnvDisplay() { |
||||
pvalues = (char *) &TMP_LEVEL_PTR; |
||||
} |
||||
|
||||
void PitchEnvDisplay::paint(Graphics &g) { |
||||
g.setColour(Colours::black.withAlpha(0.1f)); |
||||
g.fillRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 1.0f); |
||||
g.setColour(Colours::white); |
||||
|
||||
char *levels = pvalues + 4; |
||||
char *rates = pvalues; |
||||
|
||||
float dist[4]; |
||||
float total; |
||||
|
||||
int old = pitchenv_tab[levels[3]] + 128; |
||||
// find the scale
|
||||
|
||||
for(int i=0;i<4;i++) { |
||||
int nw = pitchenv_tab[levels[i]] + 128; |
||||
dist[i] = ((float)abs(nw - old)) / pitchenv_rate[rates[i]]; |
||||
total += dist[i]; |
||||
old = nw; |
||||
} |
||||
|
||||
if ( total < 0.00001 ) { |
||||
dist[0] = dist[1] = dist[2] = dist[3] = 1; |
||||
total = 4; |
||||
} |
||||
|
||||
TRACE("total %f", total); |
||||
TRACE("level %d %d %d %d", levels[0], levels[1], levels[2], levels[3]); |
||||
TRACE("dist %f %f %f %f", dist[0], dist[1], dist[2], dist[3]); |
||||
|
||||
// TODO : this is WIP
|
||||
float ratio = 96 / total; |
||||
|
||||
int oldx = 0; |
||||
int oldy = (pitchenv_tab[levels[3]] + 128) / 10; |
||||
|
||||
for(int i=0;i<4;i++) { |
||||
int newx = dist[i] * ratio + oldx; |
||||
int newy = (pitchenv_tab[levels[i]] + 128) / 10; |
||||
|
||||
g.drawLine(oldx, oldy, newx, newy, 2); |
||||
|
||||
oldx = newx; |
||||
oldy = newy; |
||||
} |
||||
} |
||||
|
||||
|
||||
void VuMeter::paint(Graphics &g) { |
||||
|
||||
// taken from the drawLevelMeter ;
|
||||
float width = getWidth(); |
||||
float height = getHeight(); |
||||
|
||||
g.setColour (Colours::black); |
||||
g.fillRoundedRectangle (0.0f, 0.0f, (float) width, (float) height, 0); |
||||
/*g.setColour (Colours::black.withAlpha (0.2f));
|
||||
g.drawRoundedRectangle (1.0f, 1.0f, width - 2.0f, height - 2.0f, 3.0f, 1.0f);*/ |
||||
|
||||
const int totalBlocks = 16; |
||||
const int numBlocks = roundToInt (totalBlocks * v); |
||||
const float h = (height - 6.0f) / (float) totalBlocks; |
||||
|
||||
for (int i = 0; i < totalBlocks; ++i) { |
||||
g.setColour (Colours::red); |
||||
if (i >= numBlocks) |
||||
g.setColour (Colours::red.withAlpha (0.2f)); |
||||
else |
||||
g.setColour (Colours::red); |
||||
//g.fillRoundedRectangle (3.0f + i * w + w * 0.1f, 3.0f, w * 0.8f, height - 6.0f, w * 0.4f);
|
||||
|
||||
g.fillRoundedRectangle (3.0f, (height-3.0f) - (3.0f + i * h + h * 0.1f) , width - 6.0f, h * 0.8f, 0); |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
/**
|
||||
* |
||||
* Copyright (c) 2014 Pascal Gauthier. |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation; either version 2 of |
||||
* the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be |
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied |
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
||||
* PURPOSE. See the GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public |
||||
* License along with this program; if not, write to the Free |
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
* Boston, MA 02110-1301 USA. |
||||
*/ |
||||
|
||||
#ifndef DXCOMPONENTS_H_INCLUDED |
||||
#define DXCOMPONENTS_H_INCLUDED |
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h" |
||||
|
||||
#include "msfa/env.h" |
||||
|
||||
class EnvDisplay : public Component { |
||||
Env env; |
||||
public: |
||||
EnvDisplay(); |
||||
char *pvalues; |
||||
void paint(Graphics &g); |
||||
}; |
||||
|
||||
class PitchEnvDisplay : public Component { |
||||
char rvalues[8]; |
||||
public: |
||||
PitchEnvDisplay(); |
||||
char *pvalues; |
||||
void paint(Graphics &g); |
||||
}; |
||||
|
||||
class AlgoDisplay : public Component { |
||||
void drawOp(Graphics &g, int x, int y, int num); |
||||
public: |
||||
AlgoDisplay(); |
||||
char *algo; |
||||
void paint(Graphics &g); |
||||
}; |
||||
|
||||
class VuMeter: public Component { |
||||
void paint(Graphics &g); |
||||
public : |
||||
float v; |
||||
}; |
||||
|
||||
#endif // DXCOMPONENTS_H_INCLUDED
|
@ -0,0 +1,293 @@ |
||||
/**
|
||||
* |
||||
* Copyright (c) 2014 Pascal Gauthier. |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation; either version 2 of |
||||
* the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be |
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied |
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
||||
* PURPOSE. See the GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public |
||||
* License along with this program; if not, write to the Free |
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
* Boston, MA 02110-1301 USA. |
||||
*/ |
||||
|
||||
#include <time.h> |
||||
|
||||
#include "PluginParam.h" |
||||
#include "PluginProcessor.h" |
||||
#include "PluginData.h" |
||||
|
||||
|
||||
uint8_t sysexChecksum(const char *sysex) { |
||||
uint8_t sum = 0; |
||||
for (int i=0; i<4096; i++) |
||||
sum = (sum + sysex[i]) % (1 << 8); |
||||
return ((1 << 8) - sum); |
||||
} |
||||
|
||||
|
||||
void extractProgramNames(const char *block, StringArray &dest) { |
||||
char programName[11]; |
||||
|
||||
dest.clear(); |
||||
|
||||
for (int i = 0; i < 32; i++) { |
||||
memcpy(programName, block + ((i * 128) + 118), 11); |
||||
|
||||
for (int j = 0; j < 10; j++) { |
||||
char c = (unsigned char) programName[j]; |
||||
switch (c) { |
||||
case 92: |
||||
c = 'Y'; |
||||
break; /* yen */ |
||||
case 126: |
||||
c = '>'; |
||||
break; /* >> */ |
||||
case 127: |
||||
c = '<'; |
||||
break; /* << */ |
||||
default: |
||||
if (c < 32 || c > 127) |
||||
c = 32; |
||||
break; |
||||
} |
||||
programName[j] = c; |
||||
} |
||||
programName[10] = 0; |
||||
|
||||
dest.add(String(programName)); |
||||
} |
||||
} |
||||
|
||||
int DexedAudioProcessor::importSysex(const char *imported) { |
||||
memcpy(sysex, imported + 6, 4096); |
||||
|
||||
uint8_t checksum = sysexChecksum(sysex); |
||||
extractProgramNames(sysex, programNames); |
||||
|
||||
if ( checksum != imported[4102] ) { |
||||
TRACE("sysex import checksum doesnt match"); |
||||
return 1; |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
void DexedAudioProcessor::exportSysex(char *dest) { |
||||
uint8_t header[] = { 0xF0, 0x43, 0x00, 0x09, 0x20, 0x00 }; |
||||
memcpy(dest, header, 6); |
||||
|
||||
// copy 32 voices
|
||||
memcpy(dest+6, sysex, 4096); |
||||
|
||||
// make checksum for dump
|
||||
uint8_t footer[] = { sysexChecksum(sysex), 0xF7 }; |
||||
|
||||
memcpy(dest+4102, footer, 2); |
||||
} |
||||
|
||||
/**
|
||||
* This function normalize data that comes from corrupted sysex data. |
||||
* It used to avoid engine crashing upon extrem values |
||||
*/ |
||||
char normparm(char value, char max) { |
||||
if ( value <= max ) |
||||
return value; |
||||
|
||||
// if this is beyond the max, we expect a 0-255 range, normalize this
|
||||
// to the expected return value; and this value as a random data.
|
||||
|
||||
return ((float)value)/255 * max; |
||||
} |
||||
|
||||
void DexedAudioProcessor::unpackProgram(int idx) { |
||||
char *bulk = sysex + (idx * 128); |
||||
|
||||
for (int op = 0; op < 6; op++) { |
||||
// eg rate and level, brk pt, depth, scaling
|
||||
memcpy(data + op * 21, bulk + op * 17, 11); |
||||
char leftrightcurves = bulk[op * 17 + 11]; |
||||
data[op * 21 + 11] = leftrightcurves & 3; |
||||
data[op * 21 + 12] = (leftrightcurves >> 2) & 3; |
||||
char detune_rs = bulk[op * 17 + 12]; |
||||
data[op * 21 + 13] = detune_rs & 7; |
||||
char kvs_ams = bulk[op * 17 + 13]; |
||||
data[op * 21 + 14] = kvs_ams & 3; |
||||
data[op * 21 + 15] = kvs_ams >> 2; |
||||
data[op * 21 + 16] = bulk[op * 17 + 14]; // output level
|
||||
char fcoarse_mode = bulk[op * 17 + 15]; |
||||
data[op * 21 + 17] = fcoarse_mode & 1; |
||||
data[op * 21 + 18] = fcoarse_mode >> 1; |
||||
data[op * 21 + 19] = bulk[op * 17 + 16]; // fine freq
|
||||
data[op * 21 + 20] = detune_rs >> 3; |
||||
} |
||||
memcpy(data + 126, bulk + 102, 9); // pitch env, algo
|
||||
char oks_fb = bulk[111]; |
||||
data[135] = oks_fb & 7; |
||||
data[136] = oks_fb >> 3; |
||||
memcpy(data + 137, bulk + 112, 4); // lfo
|
||||
char lpms_lfw_lks = bulk[116]; |
||||
data[141] = lpms_lfw_lks & 1; |
||||
data[142] = (lpms_lfw_lks >> 1) & 7; |
||||
data[143] = lpms_lfw_lks >> 4; |
||||
memcpy(data + 144, bulk + 117, 11); // transpose, name
|
||||
data[155] = 1; // operator on/off
|
||||
data[156] = 1; |
||||
data[157] = 1; |
||||
data[158] = 1; |
||||
data[159] = 1; |
||||
data[160] = 1; |
||||
} |
||||
|
||||
void DexedAudioProcessor::packProgram(int idx, const char *name) { |
||||
char *bulk = sysex + (idx * 128); |
||||
|
||||
for(int op = 0; op < 6; op++) { |
||||
// eg rate and level, brk pt, depth, scaling
|
||||
memcpy(bulk + op * 17, data + op * 21, 11); |
||||
int pp = op*17; |
||||
int up = op*21; |
||||
|
||||
// left curves
|
||||
bulk[pp+11] = (data[up+11]&0x03) | ((data[up+12]&0x03) << 2); |
||||
bulk[pp+12] = (data[up+13]&0x07) | ((data[up+20]&0x0f) << 3); |
||||
// kvs_ams
|
||||
bulk[pp+13] = (data[up+14]&0x03) | ((data[up+15]&0x07) << 2); |
||||
// output lvl
|
||||
bulk[pp+14] = data[up+16]; |
||||
// fcoarse_mode
|
||||
bulk[pp+15] = (data[up+17]&0x01) | ((data[up+18]&0x1f) << 1); |
||||
// fine freq
|
||||
bulk[pp+16] = data[up+19]; |
||||
} |
||||
memcpy(bulk + 102, data + 126, 9); // pitch env, algo
|
||||
bulk[111] = (data[135]&0x07) | ((data[136]&0x01) << 3); |
||||
memcpy(bulk + 112, data + 137, 4); // lfo
|
||||
bulk[116] = (data[141]&0x01) | (((data[142]&0x07) << 1) | ((data[143]&0x07) << 4)); |
||||
bulk[117] = data[144]; |
||||
int eos = 0; |
||||
for(int i=0; i < 10; i++) { |
||||
char c = name[i]; |
||||
if ( c == 0 ) |
||||
eos = 1; |
||||
if ( eos ) { |
||||
bulk[117+i] = ' '; |
||||
continue; |
||||
} |
||||
c = c < 32 ? ' ' : c; |
||||
c = c > 127 ? ' ' : c; |
||||
bulk[117+i] = c; |
||||
} |
||||
|
||||
char programName[11]; |
||||
memcpy(programName, bulk+117, 10); |
||||
programName[10] = 0; |
||||
programNames.set(idx, String(programName)); |
||||
} |
||||
|
||||
void DexedAudioProcessor::updateProgramFromSysex(const uint8 *rawdata) { |
||||
memcpy(data, rawdata, 160); |
||||
refreshUI = true; |
||||
} |
||||
|
||||
void DexedAudioProcessor::loadBuiltin(int idx) { |
||||
InputStream *is = builtin_pgm->createStreamForEntry(idx); |
||||
|
||||
if ( is == NULL ) { |
||||
TRACE("ENTRY IN ZIP NOT FOUND"); |
||||
return; |
||||
} |
||||
|
||||
uint8_t syx_data[4104]; |
||||
is->read(&syx_data, 4104); |
||||
delete is; |
||||
|
||||
importSysex((char *) &syx_data); |
||||
} |
||||
|
||||
#define CURRENT_PLUGINSTATE_VERSION 2 |
||||
struct PluginState { |
||||
int version; |
||||
uint8_t sysex[4104]; |
||||
uint8_t program[161]; |
||||
float cutoff; |
||||
float reso; |
||||
int programNum; |
||||
}; |
||||
|
||||
//==============================================================================
|
||||
void DexedAudioProcessor::getStateInformation(MemoryBlock& destData) { |
||||
// You should use this method to store your parameters in the memory block.
|
||||
// You could do that either as raw data, or use the XML or ValueTree classes
|
||||
// as intermediaries to make it easy to save and load complex data.
|
||||
|
||||
// used to SAVE plugin state
|
||||
|
||||
PluginState state; |
||||
|
||||
state.version = CURRENT_PLUGINSTATE_VERSION; |
||||
|
||||
exportSysex((char *)(&state.sysex)); |
||||
memcpy(state.program, data, 161); |
||||
state.cutoff = fx.uiCutoff; |
||||
state.reso = fx.uiReso; |
||||
state.programNum = currentProgram; |
||||
|
||||
destData.insert(&state, sizeof(PluginState), 0); |
||||
} |
||||
|
||||
void DexedAudioProcessor::setStateInformation(const void* source, int sizeInBytes) { |
||||
// You should use this method to restore your parameters from this memory block,
|
||||
// whose contents will have been created by the getStateInformation() call.
|
||||
|
||||
// used to LOAD plugin state
|
||||
|
||||
PluginState state; |
||||
|
||||
if ( sizeInBytes < sizeof(PluginState) ) { |
||||
TRACE("too small plugin state size %d", sizeInBytes); |
||||
return; |
||||
} |
||||
|
||||
if ( sizeInBytes > sizeof(PluginState) ) { |
||||
TRACE("too big plugin state size %d", sizeInBytes); |
||||
sizeInBytes = sizeof(PluginState); |
||||
} |
||||
|
||||
memcpy((void *) &state, source, sizeInBytes); |
||||
|
||||
if ( state.version != CURRENT_PLUGINSTATE_VERSION ) { |
||||
TRACE("version of VST chunk is not compatible, bailing out"); |
||||
return; |
||||
} |
||||
|
||||
importSysex((char *) state.sysex); |
||||
memcpy(data, state.program, 161); |
||||
|
||||
fx.uiCutoff = state.cutoff; |
||||
fx.uiReso = state.reso; |
||||
currentProgram = state.programNum; |
||||
|
||||
lastStateSave = (long) time(NULL); |
||||
TRACE("setting VST STATE"); |
||||
updateUI(); |
||||
} |
||||
|
||||
//==============================================================================
|
||||
/*void DexedAudioProcessor::getCurrentProgramStateInformation(
|
||||
MemoryBlock& destData) { |
||||
destData.insert(data, 161, 0); |
||||
} |
||||
|
||||
void DexedAudioProcessor::setCurrentProgramStateInformation(const void* source, |
||||
int sizeInBytes) { |
||||
memcpy((void *) data, source, sizeInBytes); |
||||
updateUI(); |
||||
}*/ |
@ -0,0 +1,27 @@ |
||||
/**
|
||||
* |
||||
* Copyright (c) 2014 Pascal Gauthier. |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation; either version 2 of |
||||
* the License, or (at your option) any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be |
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied |
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
||||
* PURPOSE. See the GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public |
||||
* License along with this program; if not, write to the Free |
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
||||
* Boston, MA 02110-1301 USA. |
||||
*/ |
||||
|
||||
#ifndef PLUGINDATA_H_INCLUDED |
||||
#define PLUGINDATA_H_INCLUDED |
||||
|
||||
#include "../JuceLibraryCode/JuceHeader.h" |
||||
|
||||
|
||||
#endif // PLUGINDATA_H_INCLUDED
|
Loading…
Reference in new issue