summaryrefslogtreecommitdiff
path: root/muse2/synti/vam
diff options
context:
space:
mode:
Diffstat (limited to 'muse2/synti/vam')
-rw-r--r--muse2/synti/vam/common_defs.h8
-rw-r--r--muse2/synti/vam/vam.cpp169
-rw-r--r--muse2/synti/vam/vam.h12
-rw-r--r--muse2/synti/vam/vamgui.cpp137
4 files changed, 226 insertions, 100 deletions
diff --git a/muse2/synti/vam/common_defs.h b/muse2/synti/vam/common_defs.h
new file mode 100644
index 00000000..59821a70
--- /dev/null
+++ b/muse2/synti/vam/common_defs.h
@@ -0,0 +1,8 @@
+#ifndef __VAM_UNIQUE_ID_H
+#define __VAM_UNIQUE_ID_H
+
+// Make sure this number is unique among all the MESS synths.
+#define VAM_UNIQUE_ID 2
+
+#endif
+
diff --git a/muse2/synti/vam/vam.cpp b/muse2/synti/vam/vam.cpp
index fd71d9ea..14280651 100644
--- a/muse2/synti/vam/vam.cpp
+++ b/muse2/synti/vam/vam.cpp
@@ -35,6 +35,7 @@
#include "muse/midi.h"
#include "muse/midictrl.h"
+#include "common_defs.h"
#include "vam.h"
#include "vamgui.h"
#include "libsynti/mono.h"
@@ -165,7 +166,8 @@ class VAM : public MessMono {
float velocity;
//int idata[NUM_CONTROLLER]; // buffer for init data
- int *idata;
+ //int *idata;
+ unsigned char* idata;
EnvelopeGenerator dco1_env;
EnvelopeGenerator dco2_env;
@@ -192,7 +194,10 @@ class VAM : public MessMono {
public:
virtual int getControllerInfo(int, const char**, int*, int*, int*, int*) const;
- virtual void getInitData(int* n, const unsigned char**p) const;
+ //virtual void getInitData(int* n, const unsigned char**p) const;
+ virtual void getInitData(int* n, const unsigned char**p);
+ // This is only a kludge required to support old songs' midistates. Do not use in any new synth.
+ virtual int oldMidiStateHeader(const unsigned char** data) const;
//virtual bool guiVisible() const;
//virtual void showGui(bool);
//virtual bool hasGui() const { return true; }
@@ -207,7 +212,7 @@ class VAM : public MessMono {
virtual bool setController(int channel, int ctrl, int val);
virtual bool sysex(int, const unsigned char*);
VAM(int sr);
- ~VAM();
+ virtual ~VAM();
bool init(const char* name);
};
@@ -227,7 +232,7 @@ float VAM::lin2exp[VAM::LIN2EXP_SIZE];
VAM::VAM(int sr)
: MessMono()
{
- idata = new int[NUM_CONTROLLER];
+ idata = new unsigned char[3 + NUM_CONTROLLER * sizeof(int)];
setSampleRate(sr);
gui = 0;
}
@@ -238,6 +243,10 @@ VAM::VAM(int sr)
VAM::~VAM()
{
+ if (gui)
+ delete gui;
+ //delete idata;
+ delete [] idata; // p4.0.27
--useCount;
if (useCount == 0) {
delete[] sin_tbl;
@@ -247,6 +256,13 @@ VAM::~VAM()
}
}
+int VAM::oldMidiStateHeader(const unsigned char** data) const
+{
+ unsigned char const d[3] = {MUSE_SYNTH_SYSEX_MFG_ID, VAM_UNIQUE_ID, INIT_DATA_CMD};
+ *data = &d[0];
+ return 3;
+}
+
//---------------------------------------------------------
// curTime
//---------------------------------------------------------
@@ -438,11 +454,16 @@ void VAM::processMessages()
if (ev.type() == ME_CONTROLLER)
{
// process local?
- setController(ev.dataA() & 0xfff, ev.dataB());
+ //setController(ev.dataA() & 0xfff, ev.dataB());
+ setController(ev.dataA(), ev.dataB());
sendEvent(ev);
}
else
+ {
+ #ifdef VAM_DEBUG
printf("VAM::process(): unknown event\n");
+ #endif
+ }
}
}
@@ -604,7 +625,17 @@ int VAM::getControllerInfo(int id, const char** name, int* controller,
bool VAM::setController(int /*channel*/, int ctrl, int data)
{
- setController(ctrl & 0xfff, data);
+ //setController(ctrl & 0xfff, data);
+ // p4.0.27
+ if(ctrl < VAM_FIRST_CTRL || ctrl > VAM_LAST_CTRL)
+ {
+ #ifdef VAM_DEBUG
+ printf("VAM::setController Invalid controller number 0x%x\n", ctrl);
+ #endif
+ return false;
+ }
+ setController(ctrl, data);
+
MidiPlayEvent ev(0, 0, channel, ME_CONTROLLER, ctrl, data);
gui->writeEvent(ev);
return false;
@@ -612,6 +643,15 @@ bool VAM::setController(int /*channel*/, int ctrl, int data)
void VAM::setController(int ctrl, int data)
{
+ // p4.0.27
+ if(ctrl < VAM_FIRST_CTRL || ctrl > VAM_LAST_CTRL)
+ {
+ #ifdef VAM_DEBUG
+ printf("VAM: Invalid controller number 0x%x\n", ctrl);
+ #endif
+ return;
+ }
+
// fprintf(stderr, "ctrl: %d data: %d\n", ctrl, data);
int maxval = 128*128-1;
double normval = double(data) / double(maxval);
@@ -723,22 +763,34 @@ void VAM::setController(int ctrl, int data)
if(dco2.pw == 1.0) dco2.pw = 0.99;
break;
default:
- printf("VAM: set unknown Ctrl 0x%x to 0x%x\n", ctrl, data);
- break;
+ //#ifdef VAM_DEBUG
+ //printf("VAM: set unknown Ctrl 0x%x to 0x%x\n", ctrl, data);
+ //#endif
+ //break;
+ return; // p4.0.27
}
- controller[ctrl] = data;
+ //controller[ctrl] = data;
+ controller[ctrl - VAM_FIRST_CTRL] = data; // p4.0.27
}
//---------------------------------------------------------
// getInitData
//---------------------------------------------------------
-void VAM::getInitData(int* n, const unsigned char**p) const
- {
+//void VAM::getInitData(int* n, const unsigned char**p) const
+void VAM::getInitData(int* n, const unsigned char**p)
+{
+ // p4.0.27
+ *n = 3 + NUM_CONTROLLER * sizeof(int);
+ idata[0] = MUSE_SYNTH_SYSEX_MFG_ID; // Global MusE Soft Synth Manufacturer ID
+ idata[1] = VAM_UNIQUE_ID; // VAM
+ idata[2] = INIT_DATA_CMD; // Initialization command
+ int* d = (int*)&idata[3];
+
//int i;//prevent of compiler warning: unused variable
- int* d = idata;
+ //int* d = idata;
//int maxval = 128*128-1; //prevent of compiler warning: unused variable
- *n = NUM_CONTROLLER * sizeof(int);
+ // *n = NUM_CONTROLLER * sizeof(int);
// // setController(0, DCO1_PITCHMOD, p++);
// *d++ = int(dco1.pitchmod+8191*341.333);
@@ -935,51 +987,68 @@ void VAM::getInitData(int* n, const unsigned char**p) const
*d++ = gui->getController(DCO2_PW);
*p = (unsigned char*)idata;
- }
+}
//---------------------------------------------------------
// sysex
//---------------------------------------------------------
bool VAM::sysex(int n, const unsigned char* data)
+{
+ // p4.0.27
+ if(unsigned(n) == (3 + NUM_CONTROLLER * sizeof(int)))
{
- n=n; // remove warning of unused variable
- int *p= (int*)data;
- setController(0, DCO1_PITCHMOD, *p++);
- setController(0, DCO2_PITCHMOD, *p++);
- setController(0, DCO1_WAVEFORM, *p++);
- setController(0, DCO2_WAVEFORM, *p++);
- setController(0, DCO1_FM, *p++);
- setController(0, DCO2_FM, *p++);
- setController(0, DCO1_PWM, *p++);
- setController(0, DCO2_PWM, *p++);
- setController(0, DCO1_ATTACK, *p++);
- setController(0, DCO2_ATTACK, *p++);
- setController(0, DCO1_DECAY, *p++);
- setController(0, DCO2_DECAY, *p++);
- setController(0, DCO1_SUSTAIN, *p++ );
- setController(0, DCO2_SUSTAIN, *p++ );
- setController(0, DCO1_RELEASE, *p++);
- setController(0, DCO2_RELEASE, *p++);
- setController(0, LFO_FREQ, *p++);
- setController(0, LFO_WAVEFORM, *p++);
- setController(0, FILT_ENV_MOD, *p++);
- setController(0, FILT_KEYTRACK, *p++);
- setController(0, FILT_RES, *p++);
- setController(0, FILT_ATTACK, *p++);
- setController(0, FILT_DECAY, *p++);
- setController(0, FILT_SUSTAIN, *p++);
- setController(0, FILT_RELEASE, *p++);
- setController(0, DCO2ON, *p++);
- setController(0, FILT_INVERT, *p++);
- setController(0, FILT_CUTOFF, *p++);
- setController(0, DCO1_DETUNE, *p++);
- setController(0, DCO2_DETUNE, *p++);
- setController(0, DCO1_PW, *p++);
- setController(0, DCO2_PW, *p++);
-
- return false;
+ if (data[0] == MUSE_SYNTH_SYSEX_MFG_ID) // Global MusE Soft Synth Manufacturer ID
+ {
+ if (data[1] == VAM_UNIQUE_ID) // VAM
+ {
+ if (data[2] == INIT_DATA_CMD) // Initialization command
+ {
+ int *p= (int*)(data + 3);
+ setController(0, DCO1_PITCHMOD, *p++);
+ setController(0, DCO2_PITCHMOD, *p++);
+ setController(0, DCO1_WAVEFORM, *p++);
+ setController(0, DCO2_WAVEFORM, *p++);
+ setController(0, DCO1_FM, *p++);
+ setController(0, DCO2_FM, *p++);
+ setController(0, DCO1_PWM, *p++);
+ setController(0, DCO2_PWM, *p++);
+ setController(0, DCO1_ATTACK, *p++);
+ setController(0, DCO2_ATTACK, *p++);
+ setController(0, DCO1_DECAY, *p++);
+ setController(0, DCO2_DECAY, *p++);
+ setController(0, DCO1_SUSTAIN, *p++ );
+ setController(0, DCO2_SUSTAIN, *p++ );
+ setController(0, DCO1_RELEASE, *p++);
+ setController(0, DCO2_RELEASE, *p++);
+ setController(0, LFO_FREQ, *p++);
+ setController(0, LFO_WAVEFORM, *p++);
+ setController(0, FILT_ENV_MOD, *p++);
+ setController(0, FILT_KEYTRACK, *p++);
+ setController(0, FILT_RES, *p++);
+ setController(0, FILT_ATTACK, *p++);
+ setController(0, FILT_DECAY, *p++);
+ setController(0, FILT_SUSTAIN, *p++);
+ setController(0, FILT_RELEASE, *p++);
+ setController(0, DCO2ON, *p++);
+ setController(0, FILT_INVERT, *p++);
+ setController(0, FILT_CUTOFF, *p++);
+ setController(0, DCO1_DETUNE, *p++);
+ setController(0, DCO2_DETUNE, *p++);
+ setController(0, DCO1_PW, *p++);
+ setController(0, DCO2_PW, *p++);
+ return false;
+ }
+ }
+ }
}
+
+ #ifdef VAM_DEBUG
+ printf("VAM: unknown sysex\n");
+ #endif
+
+ return false;
+}
//---------------------------------------------------------
// nativeGuiVisible
diff --git a/muse2/synti/vam/vam.h b/muse2/synti/vam/vam.h
index 3da27e79..72edd9f8 100644
--- a/muse2/synti/vam/vam.h
+++ b/muse2/synti/vam/vam.h
@@ -21,8 +21,12 @@
#ifndef __VAM_H
#define __VAM_H
+#include "muse/midictrl.h"
+
enum {
- DCO1_PITCHMOD, DCO1_WAVEFORM, DCO1_FM, DCO1_PWM,
+ //DCO1_PITCHMOD,
+ DCO1_PITCHMOD = CTRL_RPN14_OFFSET, // p4.0.27
+ DCO1_WAVEFORM, DCO1_FM, DCO1_PWM,
DCO1_ATTACK, DCO1_DECAY, DCO1_SUSTAIN, DCO1_RELEASE,
DCO2_PITCHMOD, DCO2_WAVEFORM, DCO2_FM, DCO2_PWM,
DCO2_ATTACK, DCO2_DECAY, DCO2_SUSTAIN, DCO2_RELEASE,
@@ -32,7 +36,11 @@ enum {
DCO1_DETUNE, DCO2_DETUNE, DCO1_PW, DCO2_PW
};
+#define VAM_FIRST_CTRL DCO1_PITCHMOD
+#define VAM_LAST_CTRL DCO2_PW
+#define NUM_CONTROLLER 32
+#define INIT_DATA_CMD 1
-#define NUM_CONTROLLER 32
+//#define VAM_DEBUG
#endif /* __VAM_H */
diff --git a/muse2/synti/vam/vamgui.cpp b/muse2/synti/vam/vamgui.cpp
index 50b6552c..34f8636c 100644
--- a/muse2/synti/vam/vamgui.cpp
+++ b/muse2/synti/vam/vamgui.cpp
@@ -32,6 +32,7 @@
#include <list>
+#include "common_defs.h"
#include "vamgui.h"
#include "vam.h"
@@ -187,38 +188,39 @@ VAMGui::VAMGui()
savePresetsToFile->setIcon(QIcon(*saveasIcon));
deletePreset->setIcon(QIcon(*deleteIcon));
- dctrl[DCO1_PITCHMOD] = SynthGuiCtrl(PitchModS, LCDNumber1, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_WAVEFORM] = SynthGuiCtrl(Waveform, 0, SynthGuiCtrl::COMBOBOX);
- dctrl[DCO1_FM] = SynthGuiCtrl(FMS, LCDNumber1_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_PWM] = SynthGuiCtrl(PWMS, LCDNumber1_3, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_ATTACK] = SynthGuiCtrl(AttackS, LCDNumber1_3_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_DECAY] = SynthGuiCtrl(DecayS, LCDNumber1_3_2_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_SUSTAIN] = SynthGuiCtrl(SustainS, LCDNumber1_3_2_3, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_RELEASE] = SynthGuiCtrl(ReleaseS, LCDNumber1_3_2_4, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_PITCHMOD] = SynthGuiCtrl(PitchModS2, LCDNumber1_4, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_WAVEFORM] = SynthGuiCtrl(Waveform2, 0, SynthGuiCtrl::COMBOBOX);
- dctrl[DCO2_FM] = SynthGuiCtrl(FMS2, LCDNumber1_2_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_PWM] = SynthGuiCtrl(PWMS2, LCDNumber1_3_3, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_ATTACK] = SynthGuiCtrl(AttackS2, LCDNumber1_3_2_5, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_DECAY] = SynthGuiCtrl(DecayS2, LCDNumber1_3_2_2_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_SUSTAIN] = SynthGuiCtrl(SustainS2, LCDNumber1_3_2_3_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_RELEASE] = SynthGuiCtrl(ReleaseS2, LCDNumber1_3_2_4_2, SynthGuiCtrl::SLIDER);
- dctrl[LFO_FREQ] = SynthGuiCtrl(FreqS, LCDNumber1_5, SynthGuiCtrl::SLIDER);
- dctrl[LFO_WAVEFORM] = SynthGuiCtrl(Waveform2_2, 0, SynthGuiCtrl::COMBOBOX);
- dctrl[FILT_ENV_MOD] = SynthGuiCtrl(EnvModS, LCDNumber1_5_3, SynthGuiCtrl::SLIDER);
- dctrl[FILT_KEYTRACK] = SynthGuiCtrl(KeyTrack, 0, SynthGuiCtrl::SWITCH);
- dctrl[FILT_RES] = SynthGuiCtrl(ResS, LCDNumber1_5_5, SynthGuiCtrl::SLIDER);
- dctrl[FILT_ATTACK] = SynthGuiCtrl(AttackS3, LCDNumber1_3_2_5_2, SynthGuiCtrl::SLIDER);
- dctrl[FILT_DECAY] = SynthGuiCtrl(DecayS3, LCDNumber1_3_2_2_2_2, SynthGuiCtrl::SLIDER);
- dctrl[FILT_SUSTAIN] = SynthGuiCtrl(SustainS3, LCDNumber1_3_2_3_2_2, SynthGuiCtrl::SLIDER);
- dctrl[FILT_RELEASE] = SynthGuiCtrl(ReleaseS3, LCDNumber1_3_2_4_2_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO2ON] = SynthGuiCtrl(DCO2On, 0, SynthGuiCtrl::SWITCH);
- dctrl[FILT_INVERT] = SynthGuiCtrl(FilterInvert, 0, SynthGuiCtrl::SWITCH);
- dctrl[FILT_CUTOFF] = SynthGuiCtrl(CutoffS, LCDNumber1_5_5_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_DETUNE] = SynthGuiCtrl(DetuneS, LCDNumber1_6, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_DETUNE] = SynthGuiCtrl(DetuneS2, LCDNumber1_6_2, SynthGuiCtrl::SLIDER);
- dctrl[DCO1_PW] = SynthGuiCtrl(PWS, LCDNumber1_2_3, SynthGuiCtrl::SLIDER);
- dctrl[DCO2_PW] = SynthGuiCtrl(PWS2, LCDNumber1_2_4, SynthGuiCtrl::SLIDER);
+ // p4.0.27 First ctrl offset.
+ dctrl[DCO1_PITCHMOD - VAM_FIRST_CTRL] = SynthGuiCtrl(PitchModS, LCDNumber1, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_WAVEFORM - VAM_FIRST_CTRL] = SynthGuiCtrl(Waveform, 0, SynthGuiCtrl::COMBOBOX);
+ dctrl[DCO1_FM - VAM_FIRST_CTRL] = SynthGuiCtrl(FMS, LCDNumber1_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_PWM - VAM_FIRST_CTRL] = SynthGuiCtrl(PWMS, LCDNumber1_3, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_ATTACK - VAM_FIRST_CTRL] = SynthGuiCtrl(AttackS, LCDNumber1_3_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_DECAY - VAM_FIRST_CTRL] = SynthGuiCtrl(DecayS, LCDNumber1_3_2_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_SUSTAIN - VAM_FIRST_CTRL] = SynthGuiCtrl(SustainS, LCDNumber1_3_2_3, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_RELEASE - VAM_FIRST_CTRL] = SynthGuiCtrl(ReleaseS, LCDNumber1_3_2_4, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_PITCHMOD - VAM_FIRST_CTRL] = SynthGuiCtrl(PitchModS2, LCDNumber1_4, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_WAVEFORM - VAM_FIRST_CTRL] = SynthGuiCtrl(Waveform2, 0, SynthGuiCtrl::COMBOBOX);
+ dctrl[DCO2_FM - VAM_FIRST_CTRL] = SynthGuiCtrl(FMS2, LCDNumber1_2_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_PWM - VAM_FIRST_CTRL] = SynthGuiCtrl(PWMS2, LCDNumber1_3_3, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_ATTACK - VAM_FIRST_CTRL] = SynthGuiCtrl(AttackS2, LCDNumber1_3_2_5, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_DECAY - VAM_FIRST_CTRL] = SynthGuiCtrl(DecayS2, LCDNumber1_3_2_2_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_SUSTAIN - VAM_FIRST_CTRL] = SynthGuiCtrl(SustainS2, LCDNumber1_3_2_3_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_RELEASE - VAM_FIRST_CTRL] = SynthGuiCtrl(ReleaseS2, LCDNumber1_3_2_4_2, SynthGuiCtrl::SLIDER);
+ dctrl[LFO_FREQ - VAM_FIRST_CTRL] = SynthGuiCtrl(FreqS, LCDNumber1_5, SynthGuiCtrl::SLIDER);
+ dctrl[LFO_WAVEFORM - VAM_FIRST_CTRL] = SynthGuiCtrl(Waveform2_2, 0, SynthGuiCtrl::COMBOBOX);
+ dctrl[FILT_ENV_MOD - VAM_FIRST_CTRL] = SynthGuiCtrl(EnvModS, LCDNumber1_5_3, SynthGuiCtrl::SLIDER);
+ dctrl[FILT_KEYTRACK - VAM_FIRST_CTRL] = SynthGuiCtrl(KeyTrack, 0, SynthGuiCtrl::SWITCH);
+ dctrl[FILT_RES - VAM_FIRST_CTRL] = SynthGuiCtrl(ResS, LCDNumber1_5_5, SynthGuiCtrl::SLIDER);
+ dctrl[FILT_ATTACK - VAM_FIRST_CTRL] = SynthGuiCtrl(AttackS3, LCDNumber1_3_2_5_2, SynthGuiCtrl::SLIDER);
+ dctrl[FILT_DECAY - VAM_FIRST_CTRL] = SynthGuiCtrl(DecayS3, LCDNumber1_3_2_2_2_2, SynthGuiCtrl::SLIDER);
+ dctrl[FILT_SUSTAIN - VAM_FIRST_CTRL] = SynthGuiCtrl(SustainS3, LCDNumber1_3_2_3_2_2, SynthGuiCtrl::SLIDER);
+ dctrl[FILT_RELEASE - VAM_FIRST_CTRL] = SynthGuiCtrl(ReleaseS3, LCDNumber1_3_2_4_2_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2ON - VAM_FIRST_CTRL] = SynthGuiCtrl(DCO2On, 0, SynthGuiCtrl::SWITCH);
+ dctrl[FILT_INVERT - VAM_FIRST_CTRL] = SynthGuiCtrl(FilterInvert, 0, SynthGuiCtrl::SWITCH);
+ dctrl[FILT_CUTOFF - VAM_FIRST_CTRL] = SynthGuiCtrl(CutoffS, LCDNumber1_5_5_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_DETUNE - VAM_FIRST_CTRL] = SynthGuiCtrl(DetuneS, LCDNumber1_6, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_DETUNE - VAM_FIRST_CTRL] = SynthGuiCtrl(DetuneS2, LCDNumber1_6_2, SynthGuiCtrl::SLIDER);
+ dctrl[DCO1_PW - VAM_FIRST_CTRL] = SynthGuiCtrl(PWS, LCDNumber1_2_3, SynthGuiCtrl::SLIDER);
+ dctrl[DCO2_PW - VAM_FIRST_CTRL] = SynthGuiCtrl(PWS2, LCDNumber1_2_4, SynthGuiCtrl::SLIDER);
map = new QSignalMapper(this);
@@ -275,11 +277,22 @@ void VAMGui::ctrlChanged(int idx)
else if (ctrl->type == SynthGuiCtrl::SWITCH) {
val = ((QCheckBox*)(ctrl->editor))->isChecked();
}
- sendController(0, idx + CTRL_RPN14_OFFSET, val);
+ //sendController(0, idx + CTRL_RPN14_OFFSET, val);
+ sendController(0, idx + VAM_FIRST_CTRL, val); // p4.0.27
}
int VAMGui::getController(int idx)
{
+ // p4.0.27
+ if(idx < VAM_FIRST_CTRL || idx > VAM_LAST_CTRL)
+ {
+ //#ifdef VAM_DEBUG
+ printf("VAMGui:: invalid controller number %d\n", idx);
+ //#endif
+ return 0;
+ }
+ idx -= VAM_FIRST_CTRL;
+
SynthGuiCtrl* ctrl = &dctrl[idx];
int val = 0;
if (ctrl->type == SynthGuiCtrl::SLIDER) {
@@ -302,8 +315,9 @@ int VAMGui::getControllerInfo(int id, const char** name, int* controller,
if (id >= NUM_CONTROLLER)
return 0;
+ //*controller = id;
+ *controller = id + VAM_FIRST_CTRL; // p4.0.27
- *controller = id;
*name = vam_ctrl_names[id];
const SynthGuiCtrl* ctrl = (const SynthGuiCtrl*)&dctrl[id];
//int val = 0;
@@ -357,8 +371,9 @@ void VAMGui::activatePreset(Preset* preset)
fprintf(stderr, "internal error 1\n");
exit(-1);
}
- for (unsigned int i = 0; i < sizeof(dctrl)/sizeof(*dctrl); ++i) {
- setParam(i, preset->ctrl[i]);
+ //for (unsigned int i = 0; i < sizeof(dctrl)/sizeof(*dctrl); ++i) {
+ for (unsigned int i = 0; i < NUM_CONTROLLER; ++i) { // p4.0.27
+ setParam(i, preset->ctrl[i]);
ctrlChanged(i);
}
}
@@ -443,9 +458,9 @@ void VAMGui::setPreset(Preset* preset)
//
#if 0
putchar(0xf0);
- putchar(0x7c); // mess
- putchar(0x2); // vam
- putchar(0x3); // setPreset
+ putchar(MUSE_SYNTH_SYSEX_MFG_ID); // mess
+ putchar(VAM_UNIQUE_ID); // vam
+ putchar(0x3); // setPreset
QByteArray ba = preset->name.toLatin1();
const char* name = ba.constData();
while (*name)
@@ -467,8 +482,11 @@ void VAMGui::setPreset(Preset* preset)
void VAMGui::setParam(int param, int val)
{
- if (param >= int(sizeof(dctrl)/sizeof(*dctrl))) {
+ //if (param >= int(sizeof(dctrl)/sizeof(*dctrl))) {
+ if (param >= NUM_CONTROLLER) { // p4.0.27
+ #ifdef VAM_DEBUG
fprintf(stderr, "vam: set unknown parameter 0x%x to 0x%x\n", param, val);
+ #endif
return;
}
SynthGuiCtrl* ctrl = &dctrl[param];
@@ -496,15 +514,17 @@ void VAMGui::setParam(int param, int val)
// sysexReceived
//---------------------------------------------------------
-void VAMGui::sysexReceived(const unsigned char* data, int len)
+void VAMGui::sysexReceived(const unsigned char* /*data*/, int /*len*/)
{
- if (len >= 4) {
+ // Removed, this is not used. p4.0.27
+ /*
+ if (len >= 4) {
//---------------------------------------------
// MusE Soft Synth
//---------------------------------------------
- if (data[0] == 0x7c) {
- if (data[1] == 2) { // vam
+ if (data[0] == MUSE_SYNTH_SYSEX_MFG_ID) {
+ if (data[1] == VAM_UNIQUE_ID) { // vam
if (data[2] == 2) { // parameter response
if (len != 6) {
fprintf(stderr, "vam gui: bad sysEx len\n");
@@ -531,10 +551,15 @@ void VAMGui::sysexReceived(const unsigned char* data, int len)
}
}
}
- fprintf(stderr, "vam gui: unknown sysex received, len %d:\n", len);
+
+ #ifdef VAM_DEBUG
+ fprintf(stderr, "vam gui: unknown sysex received, len %d:\n", len);
for (int i = 0; i < len; ++i)
fprintf(stderr, "%02x ", data[i]);
fprintf(stderr, "\n");
+ #endif
+ */
+
}
//---------------------------------------------------------
@@ -544,12 +569,28 @@ void VAMGui::sysexReceived(const unsigned char* data, int len)
void VAMGui::processEvent(const MidiPlayEvent& ev)
{
if (ev.type() == ME_CONTROLLER)
- setParam(ev.dataA() & 0xfff, ev.dataB());
+ {
+ //setParam(ev.dataA() & 0xfff, ev.dataB());
+ // p4.0.27
+ int ctl = ev.dataA();
+ if(ctl < VAM_FIRST_CTRL || ctl > VAM_LAST_CTRL)
+ {
+ //#ifdef VAM_DEBUG
+ printf("VAMGui:: invalid controller number %d\n", ctl);
+ //#endif
+ return;
+ }
+ setParam(ctl - VAM_FIRST_CTRL, ev.dataB());
+
+ }
else if (ev.type() == ME_SYSEX)
- sysexReceived(ev.data(), ev.len())
- ;
+ sysexReceived(ev.data(), ev.len());
else
+ {
+ #ifdef VAM_DEBUG
printf("VAMGui::illegal event type received\n");
+ #endif
+ }
}
//---------------------------------------------------------