summaryrefslogtreecommitdiff
path: root/muse2/synti/simpledrums2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-06-28 12:38:56 +0000
committerFlorian Jung <flo@windfisch.org>2011-06-28 12:38:56 +0000
commit1ee2c8cb621fdc9b165b891f6d8d4607dadabf9b (patch)
tree27174350316c57d48f8ecaad54f7919f0ba106e1 /muse2/synti/simpledrums2
parent2f4a98c62adf7241944ea7949d4b6a50d4b4af36 (diff)
parent933aeb536f3d90eb38bc96308de628eeedd81755 (diff)
merged with current trunk. i hope this works...
Diffstat (limited to 'muse2/synti/simpledrums2')
-rw-r--r--muse2/synti/simpledrums2/common.h5
-rw-r--r--muse2/synti/simpledrums2/common_defs.h8
-rw-r--r--muse2/synti/simpledrums2/simpledrums.cpp319
-rw-r--r--muse2/synti/simpledrums2/simpledrums.h12
-rw-r--r--muse2/synti/simpledrums2/simpledrumsgui.cpp202
-rw-r--r--muse2/synti/simpledrums2/simpledrumsgui.h43
-rw-r--r--muse2/synti/simpledrums2/ssplugin.cpp1
-rw-r--r--muse2/synti/simpledrums2/ssplugin.h1
-rw-r--r--muse2/synti/simpledrums2/ssplugingui.cpp33
-rw-r--r--muse2/synti/simpledrums2/ssplugingui.h19
10 files changed, 495 insertions, 148 deletions
diff --git a/muse2/synti/simpledrums2/common.h b/muse2/synti/simpledrums2/common.h
index e4763540..f31ca7ce 100644
--- a/muse2/synti/simpledrums2/common.h
+++ b/muse2/synti/simpledrums2/common.h
@@ -16,11 +16,11 @@
#define SS_VERSIONSTRING "1.0"
-#define SS_DEBUG 0
+#define SS_DEBUG 0
#define SS_DEBUG_INIT 0
#define SS_TRACE_FUNC 0
#define SS_DEBUG_MIDI 0
-#define SS_DEBUG_LADSPA 0
+#define SS_DEBUG_LADSPA 0
#define SS_DEBUG_STATE 0
#define SS_DBG(string) if (SS_DEBUG) fprintf(stderr, "%s:%d:%s: %s\n", __FILE__ , __LINE__ , __PRETTY_FUNCTION__, string);
@@ -34,6 +34,7 @@
#define SS_DBG_LADSPA2(string1, string2) if (SS_DEBUG_LADSPA) fprintf(stderr, "%s:%d:%s: %s: %s\n", __FILE__ , __LINE__ , __PRETTY_FUNCTION__, string1, string2);
#define SS_SYSEX_INIT_DATA_VERSION 1
+#define SS_SYSEX_EFFECT_INIT_DATA_VERSION 2 // Added Jun 15 2011. Original value was SS_SYSEX_INIT_DATA_VERSION (1). p4.0.27 Tim.
#define SS_NR_OF_CHANNELS 16
#define SS_AUDIO_CHANNELS 2
diff --git a/muse2/synti/simpledrums2/common_defs.h b/muse2/synti/simpledrums2/common_defs.h
new file mode 100644
index 00000000..b3745a1d
--- /dev/null
+++ b/muse2/synti/simpledrums2/common_defs.h
@@ -0,0 +1,8 @@
+#ifndef __SIMPLEDRUMS_UNIQUE_ID_H
+#define __SIMPLEDRUMS_UNIQUE_ID_H
+
+// Make sure this number is unique among all the MESS synths.
+#define SIMPLEDRUMS_UNIQUE_ID 4
+
+#endif
+
diff --git a/muse2/synti/simpledrums2/simpledrums.cpp b/muse2/synti/simpledrums2/simpledrums.cpp
index f14a0627..80f61102 100644
--- a/muse2/synti/simpledrums2/simpledrums.cpp
+++ b/muse2/synti/simpledrums2/simpledrums.cpp
@@ -5,6 +5,7 @@
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// Contributer: (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -14,6 +15,7 @@
#include "muse/midi.h"
//#include "libsynti/mpevent.h"
#include "muse/mpevent.h"
+//#include "common_defs.h"
#include "simpledrums.h"
#include <samplerate.h>
@@ -82,6 +84,9 @@ SimpleSynth::SimpleSynth(int sr)
SS_samplerate = sr;
SS_initPlugins();
+ initBuffer = 0;
+ initLen = 0;
+
simplesynth_ptr = this;
master_vol = 100.0 / SS_MASTER_VOLUME_QUOT;
master_vol_ctrlval = 100;
@@ -203,6 +208,9 @@ SimpleSynth::~SimpleSynth()
{
SS_TRACE_IN
+ if(gui)
+ delete gui; // p4.0.27
+
// Cleanup channels and samples:
SS_DBG("Cleaning up sample data");
for (int i=0; i<SS_NR_OF_CHANNELS; i++) {
@@ -233,9 +241,21 @@ SimpleSynth::~SimpleSynth()
SS_DBG("Deleting process buffer");
delete[] processBuffer[0];
delete[] processBuffer[1];
+ if (initBuffer)
+ {
+ SS_DBG("Deleting init buffer");
+ delete [] initBuffer;
+ }
SS_TRACE_OUT
}
+int SimpleSynth::oldMidiStateHeader(const unsigned char** data) const
+{
+ unsigned char const d[2] = {MUSE_SYNTH_SYSEX_MFG_ID, SIMPLEDRUMS_UNIQUE_ID};
+ *data = &d[0];
+ return 2;
+}
+
//---------------------------------------------------------
// nativeGuiVisible
/*!
@@ -299,7 +319,8 @@ bool SimpleSynth::playNote(int /*channel*/, int pitch, int velo)
}
else {
//Note off:
- if (channels[ch].noteoff_ignore) {
+ ///if (channels[ch].noteoff_ignore) {
+ if (!channels[ch].noteoff_ignore) { // p4.0.27
if (SS_DEBUG_MIDI) {
printf("Note off on channel %d\n", ch);
}
@@ -497,8 +518,17 @@ bool SimpleSynth::setController(int channel, int id, int val, bool /*fromGui*/)
\return false for ok, true for not ok
*/
//---------------------------------------------------------
-bool SimpleSynth::sysex(int /*len*/, const unsigned char* data)
+bool SimpleSynth::sysex(int len, const unsigned char* d)
+ {
+ if(len < 3 || d[0] != MUSE_SYNTH_SYSEX_MFG_ID
+ || d[1] != SIMPLEDRUMS_UNIQUE_ID)
{
+ if (SS_DEBUG_MIDI)
+ printf("MusE SimpleDrums: Unknown sysex header\n");
+ return false;
+ }
+
+ const unsigned char* data = d + 2;
SS_TRACE_IN
int cmd = data[0];
switch (cmd) {
@@ -565,20 +595,23 @@ bool SimpleSynth::sysex(int /*len*/, const unsigned char* data)
{
int initdata_len = 0;
const byte* tmp_initdata = NULL;
- byte* event_data = NULL;
+ ///byte* event_data = NULL;
getInitData(&initdata_len, &tmp_initdata);
- int totlen = initdata_len + 1;
-
- event_data = new byte[initdata_len + 1];
- event_data[0] = SS_SYSEX_SEND_INIT_DATA;
- memcpy(event_data + 1, tmp_initdata, initdata_len);
- delete[] tmp_initdata;
- tmp_initdata = NULL;
-
- MidiPlayEvent ev(0, 0, ME_SYSEX, event_data, totlen);
+ ///int totlen = initdata_len + 1;
+
+ ///event_data = new byte[initdata_len + 1];
+ ///event_data[0] = SS_SYSEX_SEND_INIT_DATA;
+ *((byte*)(tmp_initdata) + 1) = SS_SYSEX_SEND_INIT_DATA; // Re-use the synth ID byte as the command byte.
+
+ ///memcpy(event_data + 1, tmp_initdata, initdata_len);
+ ///delete[] tmp_initdata;
+ ///tmp_initdata = NULL;
+
+ ///MidiPlayEvent ev(0, 0, ME_SYSEX, event_data, totlen);
+ MidiPlayEvent ev(0, 0, ME_SYSEX, tmp_initdata + 1, initdata_len - 1); // Strip MFG ID.
gui->writeEvent(ev);
- delete[] event_data;
+ ///delete[] event_data;
break;
}
@@ -639,7 +672,7 @@ const MidiPatch* SimpleSynth::getPatchInfo(int index, const MidiPatch* patch) co
\return 0 when done, otherwise return next desired controller index
*/
//---------------------------------------------------------
-int SimpleSynth::getControllerInfo(int index, const char** name, int* controller, int* min, int* max)
+int SimpleSynth::getControllerInfo(int index, const char** name, int* controller, int* min, int* max, int* initval) const
{
SS_TRACE_IN
if (index >= SS_NR_OF_CONTROLLERS) {
@@ -652,7 +685,9 @@ int SimpleSynth::getControllerInfo(int index, const char** name, int* controller
*min = controllers[index].min;
*max = controllers[index].max;
- if (SS_DEBUG_MIDI) {
+ *initval = 0; // p4.0.27 FIXME NOTE TODO
+
+ if (SS_DEBUG_MIDI) {
printf("setting controller info: index %d name %s controller %d min %d max %d\n", index, *name, *controller, *min, *max);
}
SS_TRACE_OUT
@@ -660,6 +695,31 @@ int SimpleSynth::getControllerInfo(int index, const char** name, int* controller
}
//---------------------------------------------------------
+// processMessages
+// Called from host always, even if output path is unconnected.
+//---------------------------------------------------------
+
+void SimpleSynth::processMessages()
+{
+ //Process messages from the gui
+ while (gui->fifoSize()) {
+ MidiPlayEvent ev = gui->readEvent();
+ if (ev.type() == ME_SYSEX) {
+ sysex(ev.len(), ev.data());
+ sendEvent(ev);
+ }
+ else if (ev.type() == ME_CONTROLLER) {
+ setController(ev.channel(), ev.dataA(), ev.dataB(), true);
+ sendEvent(ev);
+ }
+ else {
+ if (SS_DEBUG)
+ printf("SimpleSynth::process(): unknown event, type: %d\n", ev.type());
+ }
+ }
+}
+
+//---------------------------------------------------------
// process
/*!
\fn SimpleSynth::process
@@ -671,6 +731,7 @@ int SimpleSynth::getControllerInfo(int index, const char** name, int* controller
//---------------------------------------------------------
void SimpleSynth::process(float** out, int offset, int len)
{
+ /*
//Process messages from the gui
while (gui->fifoSize()) {
MidiPlayEvent ev = gui->readEvent();
@@ -687,7 +748,8 @@ void SimpleSynth::process(float** out, int offset, int len)
printf("SimpleSynth::process(): unknown event, type: %d\n", ev.type());
}
}
-
+ */
+
if (synth_state == SS_RUNNING) {
//Temporary mix-doubles
@@ -843,6 +905,19 @@ bool SimpleSynth::init(const char* name)
}
//---------------------------------------------------------
+// getInitBuffer
+//---------------------------------------------------------
+void SimpleSynth::setupInitBuffer(int len)
+{
+ if (len > initLen) {
+ if (initBuffer)
+ delete [] initBuffer;
+ initBuffer = new byte[len];
+ initLen = len;
+ }
+}
+
+//---------------------------------------------------------
/*!
\fn SimpleSynth::getInitData
\brief Data for reinitialization of SimpleSynth when loading project
@@ -850,7 +925,8 @@ bool SimpleSynth::init(const char* name)
\param data - data that is sent as a sysex to the synth on reload of project
*/
//---------------------------------------------------------
-void SimpleSynth::getInitData(int* n, const unsigned char** data)
+//void SimpleSynth::getInitData(int* n, const unsigned char** data) const
+void SimpleSynth::getInitData(int* n, const unsigned char** data)
{
SS_TRACE_IN
// Calculate length of data
@@ -877,7 +953,10 @@ void SimpleSynth::getInitData(int* n, const unsigned char** data)
int labelnamelen = plugin->label().size() + 2;
len+=(namelen + labelnamelen);
- len+=3; //1 byte for nr of parameters, 1 byte for return gain, 1 byte for effect on/off
+ ///len+=3; //1 byte for nr of parameters, 1 byte for return gain, 1 byte for effect on/off
+ // p4.0.27 Tim.
+ len+=6; //4 bytes for nr of parameters, 1 byte for return gain, 1 byte for effect on/off
+
len+=sendEffects[i].nrofparameters; // 1 byte for each parameter value
}
else {
@@ -885,17 +964,29 @@ void SimpleSynth::getInitData(int* n, const unsigned char** data)
}
}
+ len += 2; // For header.
+
// First, SS_SYSEX_INIT_DATA
- byte* buffer = new byte[len];
- memset(buffer, 0, len);
- buffer[0] = SS_SYSEX_INIT_DATA;
- buffer[1] = SS_SYSEX_INIT_DATA_VERSION;
+
+ ///byte* buffer = new byte[len];
+ setupInitBuffer(len);
+
+ memset(initBuffer, 0, len);
+ //initBuffer[0] = SS_SYSEX_INIT_DATA;
+ //initBuffer[1] = SS_SYSEX_INIT_DATA_VERSION;
+ initBuffer[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ initBuffer[1] = SIMPLEDRUMS_UNIQUE_ID;
+ initBuffer[2] = SS_SYSEX_INIT_DATA;
+ initBuffer[3] = SS_SYSEX_INIT_DATA_VERSION;
if (SS_DEBUG_INIT) {
printf("Length of init data: %d\n", len);
- printf("buffer[0] - SS_SYSEX_INIT_DATA: %d\n", SS_SYSEX_INIT_DATA);
- printf("buffer[1] - SS_SYSEX_INIT_DATA_VERSION: %d\n", SS_SYSEX_INIT_DATA_VERSION);
+ //printf("initBuffer[0] - SS_SYSEX_INIT_DATA: %d\n", SS_SYSEX_INIT_DATA);
+ //printf("initBuffer[1] - SS_SYSEX_INIT_DATA_VERSION: %d\n", SS_SYSEX_INIT_DATA_VERSION);
+ printf("initBuffer[2] - SS_SYSEX_INIT_DATA: %d\n", SS_SYSEX_INIT_DATA);
+ printf("initBuffer[3] - SS_SYSEX_INIT_DATA_VERSION: %d\n", SS_SYSEX_INIT_DATA_VERSION);
}
- int i = 2;
+ //int i = 2;
+ int i = 4;
// All channels:
// 0 - volume ctrlval (0-127)
// 1 - pan (0-127)
@@ -905,71 +996,75 @@ void SimpleSynth::getInitData(int* n, const unsigned char** data)
// 8 - len of filename, n
// 9 - 9+n - filename
for (int ch=0; ch<SS_NR_OF_CHANNELS; ch++) {
- buffer[i] = (byte) channels[ch].volume_ctrlval;
- buffer[i+1] = (byte) channels[ch].pan;
- buffer[i+2] = (byte) channels[ch].noteoff_ignore;
- buffer[i+3] = (byte) channels[ch].channel_on;
- buffer[i+4] = (byte) round(channels[ch].sendfxlevel[0] * 127.0);
- buffer[i+5] = (byte) round(channels[ch].sendfxlevel[1] * 127.0);
- buffer[i+6] = (byte) round(channels[ch].sendfxlevel[2] * 127.0);
- buffer[i+7] = (byte) round(channels[ch].sendfxlevel[3] * 127.0);
+ initBuffer[i] = (byte) channels[ch].volume_ctrlval;
+ initBuffer[i+1] = (byte) channels[ch].pan;
+ initBuffer[i+2] = (byte) channels[ch].noteoff_ignore;
+ initBuffer[i+3] = (byte) channels[ch].channel_on;
+ initBuffer[i+4] = (byte) round(channels[ch].sendfxlevel[0] * 127.0);
+ initBuffer[i+5] = (byte) round(channels[ch].sendfxlevel[1] * 127.0);
+ initBuffer[i+6] = (byte) round(channels[ch].sendfxlevel[2] * 127.0);
+ initBuffer[i+7] = (byte) round(channels[ch].sendfxlevel[3] * 127.0);
if (SS_DEBUG_INIT) {
printf("Channel %d:\n", ch);
- printf("buffer[%d] - channels[ch].volume_ctrlval = \t%d\n", i, channels[ch].volume_ctrlval);
- printf("buffer[%d] - channels[ch].pan = \t\t%d\n", i+1, channels[ch].pan);
- printf("buffer[%d] - channels[ch].noteoff_ignore = \t%d\n", i+2, channels[ch].noteoff_ignore );
- printf("buffer[%d] - channels[ch].channel_on = \t%d\n", i+3, channels[ch].channel_on);
+ printf("initBuffer[%d] - channels[ch].volume_ctrlval = \t%d\n", i, channels[ch].volume_ctrlval);
+ printf("initBuffer[%d] - channels[ch].pan = \t\t%d\n", i+1, channels[ch].pan);
+ printf("initBuffer[%d] - channels[ch].noteoff_ignore = \t%d\n", i+2, channels[ch].noteoff_ignore );
+ printf("initBuffer[%d] - channels[ch].channel_on = \t%d\n", i+3, channels[ch].channel_on);
for (int j= i+4; j < i+8; j++) {
- printf("buffer[%d] - channels[ch].sendfxlevel[%d]= \t%d\n", j, j-i-4, (int)round(channels[ch].sendfxlevel[j-i-4] * 127.0));
+ printf("initBuffer[%d] - channels[ch].sendfxlevel[%d]= \t%d\n", j, j-i-4, (int)round(channels[ch].sendfxlevel[j-i-4] * 127.0));
}
}
if (channels[ch].sample) {
int filenamelen = strlen(channels[ch].sample->filename.c_str()) + 1;
- buffer[i+8] = (byte) filenamelen;
- memcpy((buffer+(i+9)), channels[ch].sample->filename.c_str(), filenamelen);
+ initBuffer[i+8] = (byte) filenamelen;
+ memcpy((initBuffer+(i+9)), channels[ch].sample->filename.c_str(), filenamelen);
if (SS_DEBUG_INIT) {
- printf("buffer[%d] - filenamelen: %d\n", i+8, filenamelen);
- printf("buffer[%d] - buffer[%d] - filename: ", (i+9), (i+9) + filenamelen - 1);
+ printf("initBuffer[%d] - filenamelen: %d\n", i+8, filenamelen);
+ printf("initBuffer[%d] - initBuffer[%d] - filename: ", (i+9), (i+9) + filenamelen - 1);
for (int j = i+9; j< i+9+filenamelen; j++) {
- printf("%c",buffer[j]);
+ printf("%c",initBuffer[j]);
}
printf("\n");
}
i+= (SS_NR_OF_CHANNEL_CONTROLLERS + 1 + filenamelen);
}
else {
- buffer[i+8] = SS_NO_SAMPLE;
+ initBuffer[i+8] = SS_NO_SAMPLE;
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: SS_NO_SAMPLE: - %d\n", i+8, SS_NO_SAMPLE);
+ printf("initBuffer[%d]: SS_NO_SAMPLE: - %d\n", i+8, SS_NO_SAMPLE);
}
i+= (SS_NR_OF_CHANNEL_CONTROLLERS + 1);
}
}
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: Master vol: - %d\n", i, master_vol_ctrlval);
+ printf("initBuffer[%d]: Master vol: - %d\n", i, master_vol_ctrlval);
}
- buffer[i] = master_vol_ctrlval;
- *(data) = buffer; *n = len;
+ initBuffer[i] = master_vol_ctrlval;
+ *(data) = initBuffer; *n = len;
i++;
//Send effects:
- buffer[i] = SS_SYSEX_INIT_DATA_VERSION; //Just for check
+
+ ///initBuffer[i] = SS_SYSEX_INIT_DATA_VERSION; //Just for check
+ // Jun 10 2011. Bumped version up from 1 (with its own ID). p4.0.27 Tim
+ initBuffer[i] = SS_SYSEX_EFFECT_INIT_DATA_VERSION; //Just for check
+
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: Control value, SS_SYSEX_INIT_DATA_VERSION\n", i);
+ printf("initBuffer[%d]: Control value, SS_SYSEX_EFFECT_INIT_DATA_VERSION = %d\n", i, SS_SYSEX_EFFECT_INIT_DATA_VERSION);
}
i++;
for (int j=0; j<SS_NR_OF_SENDEFFECTS; j++) {
if (sendEffects[j].plugin) {
int labelnamelen = sendEffects[j].plugin->label().size() + 1;
- buffer[i] = labelnamelen;
- memcpy((buffer+i+1), sendEffects[j].plugin->label().toLatin1().constData(), labelnamelen);
+ initBuffer[i] = labelnamelen;
+ memcpy((initBuffer+i+1), sendEffects[j].plugin->label().toLatin1().constData(), labelnamelen);
if (SS_DEBUG_INIT) {
- printf("buffer[%d] - labelnamelen: %d\n", i, labelnamelen);
- printf("buffer[%d] - buffer[%d] - filename: ", (i+1), (i+1) + labelnamelen - 1);
+ printf("initBuffer[%d] - labelnamelen: %d\n", i, labelnamelen);
+ printf("initBuffer[%d] - initBuffer[%d] - filename: ", (i+1), (i+1) + labelnamelen - 1);
for (int k = i+1; k < i+1+labelnamelen; k++) {
- printf("%c",buffer[k]);
+ printf("%c",initBuffer[k]);
}
printf("\n");
}
@@ -977,45 +1072,55 @@ void SimpleSynth::getInitData(int* n, const unsigned char** data)
i+=(labelnamelen + 1);
int namelen = sendEffects[j].plugin->lib().size() + 1;
- buffer[i] = namelen;
- memcpy((buffer+i+1), sendEffects[j].plugin->lib().toLatin1().constData(), namelen);
+ initBuffer[i] = namelen;
+ memcpy((initBuffer+i+1), sendEffects[j].plugin->lib().toLatin1().constData(), namelen);
if (SS_DEBUG_INIT) {
- printf("buffer[%d] - libnamelen : %d\n", i, namelen);
- printf("buffer[%d] - buffer[%d] - filename: ", (i+1), (i+1) + namelen - 1);
+ printf("initBuffer[%d] - libnamelen : %d\n", i, namelen);
+ printf("initBuffer[%d] - initBuffer[%d] - filename: ", (i+1), (i+1) + namelen - 1);
for (int k = i+1; k < i+1+namelen; k++) {
- printf("%c",buffer[k]);
+ printf("%c",initBuffer[k]);
}
printf("\n");
}
i+=(namelen + 1);
- buffer[i]=sendEffects[j].nrofparameters;
+ ///initBuffer[i]=sendEffects[j].nrofparameters;
+ // Jun 10 2011. Changed to 32 bit. p4.0.27 Tim.
+ *((unsigned*)&initBuffer[i]) = sendEffects[j].nrofparameters;
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: sendEffects[%d].nrofparameters=%d\n", i, j, buffer[i]);
+ printf("initBuffer[%d]: sendEffects[%d].nrofparameters=%d\n", i, j, *((unsigned*)&initBuffer[i]));
+ }
+ ///i++;
+ i+=4;
+
+ initBuffer[i]=sendEffects[j].retgain_ctrlval;
+ if (SS_DEBUG_INIT) {
+ printf("initBuffer[%d]: sendEffects[%d].retgain_ctrlval=%d\n", i, j, initBuffer[i]);
}
i++;
- buffer[i]=sendEffects[j].retgain_ctrlval;
+ // Jun 10 2011. This one was missing. p4.0.27 Tim.
+ initBuffer[i] = sendEffects[j].state;
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: sendEffects[%d].retgain_ctrlval=%d\n", i, j, buffer[i]);
+ printf("initBuffer[%d]: sendEffects[%d].state=%d\n", i, j, initBuffer[i]);
}
i++;
for (int k=0; k<sendEffects[j].nrofparameters; k++) {
//TODO: Convert to 127-scale
- buffer[i] = sendEffects[j].plugin->getGuiControlValue(k);
+ initBuffer[i] = sendEffects[j].plugin->getGuiControlValue(k);
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: sendEffects[%d].parameterval[%d]=%d\n", i, j, k, buffer[i]);
+ printf("initBuffer[%d]: sendEffects[%d].parameterval[%d]=%d\n", i, j, k, initBuffer[i]);
}
i++;
}
}
// No plugin loaded:
else {
- buffer[i] = SS_NO_PLUGIN;
+ initBuffer[i] = SS_NO_PLUGIN;
if (SS_DEBUG_INIT) {
- printf("buffer[%d]: SS_NO_PLUGIN\n", i);
+ printf("initBuffer[%d]: SS_NO_PLUGIN\n", i);
}
i++;
}
@@ -1118,11 +1223,15 @@ void SimpleSynth::parseInitData(const unsigned char* data)
ptr++;
// Effects:
- if (*(ptr) != SS_SYSEX_INIT_DATA_VERSION) {
- fprintf(stderr, "Error loading init data - control byte not found. Skipping...\n");
+ ///if (*(ptr) != SS_SYSEX_INIT_DATA_VERSION) {
+ int effver = *(ptr);
+ if (effver < 1 || effver > SS_SYSEX_EFFECT_INIT_DATA_VERSION) {
+ //if (SS_DEBUG_INIT)
+ fprintf(stderr, "Error loading init data - effect init version is from future or too old. Skipping...\n");
SS_TRACE_OUT
return;
}
+
ptr++;
for (int i=0; i<SS_NR_OF_SENDEFFECTS; i++) {
@@ -1149,9 +1258,14 @@ void SimpleSynth::parseInitData(const unsigned char* data)
initSendEffect(i, libnametmp.c_str(), labelnametmp.c_str());
//initSendEffect(0, "cmt", "freeverb3");
- byte params = *(ptr);
- byte retgain = *(ptr+1);
- ptr+=2;
+ ///byte params = *(ptr);
+ unsigned params = (effver < 2) ? *(ptr) : *((unsigned*)ptr); // p4.0.27
+ ptr+= (effver < 2) ? 1 : 4;
+
+ ///byte retgain = *(ptr+1);
+ ///ptr+=2;
+ byte retgain = *(ptr); // p4.0.27
+ ptr++;
sendEffects[i].nrofparameters = params;
@@ -1161,7 +1275,19 @@ void SimpleSynth::parseInitData(const unsigned char* data)
MidiPlayEvent ev(0, 0, 0, ME_CONTROLLER, SS_PLUGIN_RETURNLEVEL_CONTROLLER(i), retgain);
gui->writeEvent(ev);
- for (int j=0; j<params; j++) {
+ // Jun 10 2011. This one was missing. p4.0.27 Tim.
+ if(effver >= 2)
+ {
+ if (SS_DEBUG_INIT)
+ printf("buffer[%ld] - sendeffect[%d] state=%d\n", long(ptr-data), i, *(ptr));
+ sendEffects[i].state = (SS_SendFXState) *(ptr);
+ MidiPlayEvent ev(0, 0, 0, ME_CONTROLLER, SS_PLUGIN_ONOFF_CONTROLLER(i), sendEffects[i].state);
+ gui->writeEvent(ev);
+ ptr++;
+ }
+
+ ///for (int j=0; j<params; j++) {
+ for (unsigned j=0; j<params; j++) {
if (SS_DEBUG_INIT){
//wilyfoobar-2011-02-13
// arg2 :pointer diifference might be 64 bit (long long) on 64 bit machine, this requires cast to long
@@ -1481,16 +1607,23 @@ void SimpleSynth::guiSendSampleLoaded(bool success, int ch, const char* filename
{
SS_TRACE_IN
int len = strlen(filename) + 3; //2 + filenamelen + 1;
+ //int len = strlen(filename) + 3 + 2; //2 + filenamelen + 1, + 2 for header;
byte out[len];
+ //out[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ //out[1] = SIMPLEDRUMS_UNIQUE_ID;
if (success) {
out[0] = SS_SYSEX_LOAD_SAMPLE_OK;
+ //out[2] = SS_SYSEX_LOAD_SAMPLE_OK;
}
else {
out[0] = SS_SYSEX_LOAD_SAMPLE_ERROR;
+ //out[2] = SS_SYSEX_LOAD_SAMPLE_ERROR;
}
out[1] = ch;
+ //out[3] = ch;
memcpy(out+2, filename, strlen(filename)+1);
+ //memcpy(out+4, filename, strlen(filename)+1);
MidiPlayEvent ev(0, 0, ME_SYSEX, out, len);
gui->writeEvent(ev);
SS_TRACE_OUT
@@ -1504,8 +1637,13 @@ void SimpleSynth::guiSendError(const char* errorstring)
{
SS_TRACE_IN
byte out[strlen(errorstring)+2];
+ //byte out[strlen(errorstring)+4];
+ //out[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ //out[1] = SIMPLEDRUMS_UNIQUE_ID;
out[0] = SS_SYSEX_ERRORMSG;
+ //out[2] = SS_SYSEX_ERRORMSG;
memcpy(out+1, errorstring, strlen(errorstring) +1);
+ //memcpy(out+3, errorstring, strlen(errorstring) +1);
SS_TRACE_OUT
}
@@ -1590,15 +1728,24 @@ bool SimpleSynth::initSendEffect(int id, QString lib, QString name)
//TODO: cleanup if failed
}
}
+
//Notify gui
- int len = 3;
+ ///int len = 3;
+ int len = 2 + 4; // Char is not enough for many plugins. Was causing crash. Changed to 32 bits. p4.0.27 Tim.
+ //int len = 5;
byte out[len];
out[0] = SS_SYSEX_LOAD_SENDEFFECT_OK;
out[1] = id;
+ //out[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ //out[1] = SIMPLEDRUMS_UNIQUE_ID;
+ //out[2] = SS_SYSEX_LOAD_SENDEFFECT_OK;
+ //out[3] = id;
int j=0;
for (iPlugin i = plugins.begin(); i!=plugins.end(); i++, j++) {
if ((*i)->lib() == plugin->lib() && (*i)->label() == plugin->label()) {
- out[2] = j;
+ ///out[2] = j;
+ //out[4] = j;
+ *((unsigned*)(out + 2)) = j;
MidiPlayEvent ev(0, 0, ME_SYSEX, out, len);
gui->writeEvent(ev);
}
@@ -1638,9 +1785,15 @@ void SimpleSynth::cleanupPlugin(int id)
sendEffects[id].plugin = 0;
byte d[2];
+ //byte d[4];
d[0] = SS_SYSEX_CLEAR_SENDEFFECT_OK;
d[1] = id;
+ //d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ //d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ //d[2] = SS_SYSEX_CLEAR_SENDEFFECT_OK;
+ //d[3] = id;
MidiPlayEvent ev(0, 0, ME_SYSEX, d, 2);
+ //MidiPlayEvent ev(0, 0, ME_SYSEX, d, 4);
gui->writeEvent(ev);
SS_TRACE_OUT
}
@@ -1694,11 +1847,19 @@ void SimpleSynth::guiUpdateFxParameter(int fxid, int param, float val)
}
byte d[4];
+ //byte d[6];
d[0] = SS_SYSEX_SET_PLUGIN_PARAMETER_OK;
d[1] = fxid;
d[2] = param;
d[3] = intval;
+ //d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ //d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ //d[2] = SS_SYSEX_SET_PLUGIN_PARAMETER_OK;
+ //d[3] = fxid;
+ //d[4] = param;
+ //d[5] = intval;
MidiPlayEvent ev(0, 0, ME_SYSEX, d, 4);
+ //MidiPlayEvent ev(0, 0, ME_SYSEX, d, 6);
gui->writeEvent(ev);
SS_TRACE_OUT
}
@@ -1742,9 +1903,15 @@ void SimpleSynth::guiNotifySampleCleared(int ch)
{
SS_TRACE_IN
byte d[2];
+ //byte d[4];
d[0] = SS_SYSEX_CLEAR_SAMPLE_OK;
d[1] = (byte) ch;
+ //d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ //d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ //d[2] = SS_SYSEX_CLEAR_SAMPLE_OK;
+ //d[3] = (byte) ch;
MidiPlayEvent ev(0, 0, ME_SYSEX, d, 2);
+ //MidiPlayEvent ev(0, 0, ME_SYSEX, d, 4);
gui->writeEvent(ev);
SS_TRACE_OUT
}
diff --git a/muse2/synti/simpledrums2/simpledrums.h b/muse2/synti/simpledrums2/simpledrums.h
index 58a5945e..f0339d6a 100644
--- a/muse2/synti/simpledrums2/simpledrums.h
+++ b/muse2/synti/simpledrums2/simpledrums.h
@@ -5,6 +5,7 @@
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// Contributer: (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -15,6 +16,7 @@
#include <sndfile.h>
#include "libsynti/mess.h"
#include "common.h"
+#include "common_defs.h"
//#include "libsynti/mpevent.h"
#include "muse/mpevent.h"
#include "simpledrumsgui.h"
@@ -124,11 +126,15 @@ class SimpleSynth : public Mess
virtual bool sysex(int arg1, const unsigned char* arg2);
virtual const char* getPatchName(int arg1, int arg2, int arg3) const;
virtual const MidiPatch* getPatchInfo(int arg1, const MidiPatch* arg2) const;
- virtual int getControllerInfo(int arg1, const char** arg2, int* arg3, int* arg4, int* arg5);
+ virtual int getControllerInfo(int arg1, const char** arg2, int* arg3, int* arg4, int* arg5, int* arg6) const;
+ virtual void processMessages();
virtual void process(float** data, int offset, int len);
//virtual void showGui(bool arg1);
virtual void showNativeGui(bool arg1);
+ ///virtual void getInitData(int*, const unsigned char**) const;
virtual void getInitData(int*, const unsigned char**);
+ // 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;
bool init(const char* name);
void guiSendSampleLoaded(bool success, int ch, const char* filename);
void guiSendError(const char* errorstring);
@@ -139,6 +145,10 @@ class SimpleSynth : public Mess
private:
SimpleSynthGui* gui;
+ byte* initBuffer;
+ int initLen;
+ void setupInitBuffer(int len);
+
SS_Channel channels[SS_NR_OF_CHANNELS];
SS_Controller controllers[SS_NR_OF_CONTROLLERS];
bool setController(int channel, int id, int val, bool fromGui);
diff --git a/muse2/synti/simpledrums2/simpledrumsgui.cpp b/muse2/synti/simpledrums2/simpledrumsgui.cpp
index f90c1da8..7d314565 100644
--- a/muse2/synti/simpledrums2/simpledrumsgui.cpp
+++ b/muse2/synti/simpledrums2/simpledrumsgui.cpp
@@ -5,6 +5,7 @@
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// Contributer: (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -19,6 +20,7 @@
#include <QLineEdit>
#include <QMessageBox>
+#include "common_defs.h"
#include "simpledrumsgui.h"
//#include "libsynti/mpevent.h"
#include "muse/mpevent.h"
@@ -85,10 +87,16 @@ SimpleSynthGui* simplesynthgui_ptr;
*/
QChannelSlider::QChannelSlider(Qt::Orientation orientation, int ch, QWidget* parent)
: QSlider(orientation, parent)
- {
- channel = ch;
- }
+{
+ channel = ch;
+}
+void QChannelSlider::sliderChange(SliderChange change)
+{
+ QSlider::sliderChange(change);
+ if(change == QAbstractSlider::SliderValueChange)
+ emit valueChanged(channel, value());
+}
/*!
\fn QChannelSlider::getChannel()
@@ -110,6 +118,7 @@ void QChannelSlider::setChannel(int ch)
/*!
\fn QChannelSlider::setValue(int val)
*/
+/*
void QChannelSlider::setValue(int val)
{
val = (val > 127 ? 127 : val);
@@ -117,10 +126,32 @@ void QChannelSlider::setValue(int val)
QSlider::setValue(val);
emit valueChanged(channel, val);
}
+*/
+
+QInvertedSlider::QInvertedSlider(Qt::Orientation o, QWidget* parent)
+ : QSlider(o, parent)
+{
+ setInvertedAppearance(true); // p4.0.27
+}
+
+void QInvertedSlider::sliderChange(SliderChange change)
+{
+ QSlider::sliderChange(change);
+ if(change == QAbstractSlider::SliderValueChange)
+ emit invertedValueChanged(value());
+}
+
+QInvertedChannelSlider::QInvertedChannelSlider(Qt::Orientation o, int channel, QWidget* parent)
+ : QChannelSlider(o, channel, parent)
+{
+ setInvertedAppearance(true); // p4.0.27
+ //setInvertedControls(true);
+}
/*!
\fn QInvertedChannelSlider::setValue(int val)
*/
+/*
void QInvertedChannelSlider::setValue(int val)
{
int inverted = this->maximum() - val;
@@ -129,10 +160,12 @@ void QInvertedChannelSlider::setValue(int val)
QSlider::setValue(val);
emit valueChanged(channel, inverted);
}
+*/
/*!
\fn QInvertedSlider::setValue(int val)
*/
+/*
void QInvertedSlider::setValue(int val)
{
int inverted = this->maximum() - val;
@@ -141,7 +174,7 @@ void QInvertedSlider::setValue(int val)
emit invertedValueChanged(inverted);
QSlider::setValue(val);
}
-
+*/
/*!
\fn QChannelCheckbox::QChannelCheckbox(QWidget* parent, int ch)
@@ -194,11 +227,20 @@ QChannelDial::QChannelDial(QWidget* parent, int ch, int fxid)
/*!
\fn QChannelSlider::setValue(int val)
*/
+/*
void QChannelDial::setValue(int val)
{
QDial::setValue(val);
emit valueChanged(channel, sendfxid, val);
}
+*/
+
+void QChannelDial::sliderChange(SliderChange change)
+{
+ QDial::sliderChange(change);
+ if(change == QAbstractSlider::SliderValueChange)
+ emit valueChanged(channel, sendfxid, value());
+}
/*!
\fn SimpleSynthGui::SimpleSynthGui()
@@ -236,10 +278,16 @@ SimpleSynthGui::SimpleSynthGui()
inchnlLayout->addWidget(onOff[i]);
connect(onOff[i], SIGNAL(channelState(int, bool)), SLOT(channelOnOff(int, bool)));
- volumeSliders[i] = new QInvertedChannelSlider(Qt::Vertical, i, channelButtonGroups[i]);
+ ///volumeSliders[i] = new QInvertedChannelSlider(Qt::Vertical, i, channelButtonGroups[i]);
+ // By Tim. p4.0.27 Inverted was not correct type. Maybe was work in progress, rest of code was not converted yet?
+ volumeSliders[i] = new QChannelSlider(Qt::Vertical, i, channelButtonGroups[i]);
+
volumeSliders[i]->setMinimum(SS_VOLUME_MIN_VALUE);
volumeSliders[i]->setMaximum(SS_VOLUME_MAX_VALUE);
- volumeSliders[i]->setValue(SS_VOLUME_MAX_VALUE - SS_VOLUME_DEFAULT_VALUE);
+
+ ///volumeSliders[i]->setValue(SS_VOLUME_MAX_VALUE - SS_VOLUME_DEFAULT_VALUE);
+ volumeSliders[i]->setValue(SS_VOLUME_DEFAULT_VALUE); // p4.0.27
+
// volumeSliders[i]->setMinimumSize(SS_VOLSLDR_WIDTH, SS_VOLSLDR_LENGTH);
volumeSliders[i]->setToolTip("Volume, channel " + QString::number(i + 1));
// setMinimumSize(SS_VOLSLDR_WIDTH, SS_VOLSLDR_LENGTH);
@@ -310,13 +358,22 @@ SimpleSynthGui::SimpleSynthGui()
QVBoxLayout* mbgLayout = new QVBoxLayout(masterButtonGroup);
mbgLayout->setAlignment(Qt::AlignCenter);
// masterButtonGroup->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
- masterSlider = new QInvertedSlider(Qt::Vertical, masterButtonGroup);
+
+ ///masterSlider = new QInvertedSlider(Qt::Vertical, masterButtonGroup);
+ // By Tim. p4.0.27 Inverted was not correct type. Maybe was work in progress, rest of code was not converted yet?
+ masterSlider = new QSlider(Qt::Vertical, masterButtonGroup);
+
masterSlider->setToolTip("Master volume");
mbgLayout->addWidget(masterSlider);
masterSlider->setRange(0, 127);
- masterSlider->setValue(SS_VOLUME_MAX_VALUE - (int)(SS_MASTERVOL_DEFAULT_VALUE*SS_VOLUME_MAX_VALUE));
+
+ ///masterSlider->setValue(SS_VOLUME_MAX_VALUE - (int)(SS_MASTERVOL_DEFAULT_VALUE*SS_VOLUME_MAX_VALUE));
+ masterSlider->setValue((int)(SS_MASTERVOL_DEFAULT_VALUE*SS_VOLUME_MAX_VALUE)); // p4.0.27
+
// masterSlider->setMinimumSize(SS_MASTERSLDR_WIDTH, SS_MASTERSLDR_HEIGHT);
- connect(masterSlider, SIGNAL(invertedValueChanged(int)), SLOT(masterVolChanged(int)));
+
+ ///connect(masterSlider, SIGNAL(invertedValueChanged(int)), SLOT(masterVolChanged(int)));
+ connect(masterSlider, SIGNAL(valueChanged(int)), SLOT(masterVolChanged(int))); // p4.0.27
//Main groupbox
mainGroupBox = new QGroupBox(this);
@@ -435,7 +492,10 @@ void SimpleSynthGui::processEvent(const MidiPlayEvent& ev)
switch(id) {
case SS_CHANNEL_CTRL_VOLUME:
volumeSliders[ch]->blockSignals(true);
- volumeSliders[ch]->setValue(SS_VOLUME_MAX_VALUE - val);
+
+ ///volumeSliders[ch]->setValue(SS_VOLUME_MAX_VALUE - val);
+ volumeSliders[ch]->setValue(val); // p4.0.27
+
volumeSliders[ch]->blockSignals(false);
break;
@@ -479,7 +539,10 @@ void SimpleSynthGui::processEvent(const MidiPlayEvent& ev)
else if (id >= SS_FIRST_MASTER_CONTROLLER && id <= SS_LAST_MASTER_CONTROLLER) {
if (id == SS_MASTER_CTRL_VOLUME) {
masterSlider->blockSignals(true);
- masterSlider->setValue(SS_MASTERVOL_MAX_VALUE - val);
+
+ ///masterSlider->setValue(SS_MASTERVOL_MAX_VALUE - val);
+ masterSlider->setValue(val); // p4.0.27
+
masterSlider->blockSignals(false);
}
}
@@ -495,6 +558,13 @@ void SimpleSynthGui::processEvent(const MidiPlayEvent& ev)
SS_PluginFront* pf = pluginGui->getPluginFront((unsigned)fxid);
pf->setRetGain(val);
}
+ // Plugin on/off:
+ else if (cmd == SS_PLUGIN_ONOFF) { // p4.0.27
+ if (SS_DEBUG_MIDI)
+ printf("SimpleSynthGui::processEvent - fx onoff received: fxid: %d val: %d\n", fxid, val);
+ SS_PluginFront* pf = pluginGui->getPluginFront((unsigned)fxid);
+ pf->setOnOff(val);
+ }
}
}
//
@@ -502,6 +572,7 @@ void SimpleSynthGui::processEvent(const MidiPlayEvent& ev)
//
else if (ev.type() == ME_SYSEX) {
byte* data = ev.data();
+ //byte* data = d + 2;
int cmd = *data;
switch (cmd) {
case SS_SYSEX_LOAD_SAMPLE_OK: {
@@ -549,7 +620,8 @@ void SimpleSynthGui::processEvent(const MidiPlayEvent& ev)
}
int fxid = *(data+1);
SS_PluginFront* pf = pluginGui->getPluginFront((unsigned)fxid);
- pf->updatePluginValue(*(data+2));
+ ///pf->updatePluginValue(*(data+2));
+ pf->updatePluginValue( *((unsigned*)(data+2)) ); // p4.0.27
break;
}
@@ -711,13 +783,20 @@ void SimpleSynthGui::loadSampleDialogue(int channel)
if (SS_DEBUG)
printf("lastDir = %s\n", lastDir.toLatin1().constData());
- int l = filename.length() + 4;
+ //int l = filename.length() + 4;
+ int l = filename.length() + 6;
byte d[l];
- d[0] = SS_SYSEX_LOAD_SAMPLE;
- d[1] = (byte) channel;
- d[2] = (byte) filename.length();
- memcpy(d+3, filename.toLatin1().constData(), filename.length()+1);
+ //d[0] = SS_SYSEX_LOAD_SAMPLE;
+ //d[1] = (byte) channel;
+ //d[2] = (byte) filename.length();
+ d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ d[2] = SS_SYSEX_LOAD_SAMPLE;
+ d[3] = (byte) channel;
+ d[4] = (byte) filename.length();
+ //memcpy(d+3, filename.toLatin1().constData(), filename.length()+1);
+ memcpy(d+5, filename.toLatin1().constData(), filename.length()+1);
sendSysex(d, l);
}
}
@@ -730,10 +809,16 @@ void SimpleSynthGui::loadSampleDialogue(int channel)
void SimpleSynthGui::clearSample(int ch)
{
if (sampleNameLineEdit[ch]->text().length() > 0) { //OK, we've got a live one here
- byte d[2];
- d[0] = SS_SYSEX_CLEAR_SAMPLE;
- d[1] = (byte) ch;
- sendSysex(d, 2);
+ //byte d[2];
+ byte d[4];
+ //d[0] = SS_SYSEX_CLEAR_SAMPLE;
+ //d[1] = (byte) ch;
+ d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ d[2] = SS_SYSEX_CLEAR_SAMPLE;
+ d[3] = (byte) ch;
+ //sendSysex(d, 2);
+ sendSysex(d, 4);
sampleNameLineEdit[ch]->setText("");
}
}
@@ -751,12 +836,19 @@ void SimpleSynthGui::displayPluginGui()
*/
void SimpleSynthGui::loadEffectInvoked(int fxid, QString lib, QString label)
{
- int l = 4 + lib.length() + label.length();
+ //int l = 4 + lib.length() + label.length();
+ int l = 6 + lib.length() + label.length();
byte d[l];
- d[0] = SS_SYSEX_LOAD_SENDEFFECT;
- d[1] = (byte) fxid;
- memcpy (d+2, lib.toLatin1().constData(), lib.length()+1);
- memcpy (d+3+lib.length(), label.toLatin1().constData(), label.length()+1);
+ //d[0] = SS_SYSEX_LOAD_SENDEFFECT;
+ //d[1] = (byte) fxid;
+ d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ d[2] = SS_SYSEX_LOAD_SENDEFFECT;
+ d[3] = (byte) fxid;
+ //memcpy (d+2, lib.toLatin1().constData(), lib.length()+1);
+ //memcpy (d+3+lib.length(), label.toLatin1().constData(), label.length()+1);
+ memcpy (d+4, lib.toLatin1().constData(), lib.length()+1);
+ memcpy (d+5+lib.length(), label.toLatin1().constData(), label.length()+1);
sendSysex(d, l);
}
@@ -784,10 +876,16 @@ void SimpleSynthGui::toggleEffectOnOff(int fxid, int state)
*/
void SimpleSynthGui::clearPlugin(int fxid)
{
- byte d[2];
- d[0] = SS_SYSEX_CLEAR_SENDEFFECT;
- d[1] = fxid;
- sendSysex(d, 2);
+ //byte d[2];
+ byte d[4];
+ //d[0] = SS_SYSEX_CLEAR_SENDEFFECT;
+ //d[1] = fxid;
+ d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ d[2] = SS_SYSEX_CLEAR_SENDEFFECT;
+ d[3] = fxid;
+ //sendSysex(d, 2);
+ sendSysex(d, 4);
}
@@ -796,13 +894,19 @@ void SimpleSynthGui::clearPlugin(int fxid)
*/
void SimpleSynthGui::effectParameterChanged(int fxid, int parameter, int val)
{
- //printf("Gui: effectParameterChanged: %d %d %d\n", fxid, parameter, val);
- int len = 4;
+ //int len = 4;
+ int len = 6;
byte d[len];
- d[0] = SS_SYSEX_SET_PLUGIN_PARAMETER;
- d[1] = (byte) fxid;
- d[2] = (byte) parameter;
- d[3] = (byte) val;
+ //d[0] = SS_SYSEX_SET_PLUGIN_PARAMETER;
+ //d[1] = (byte) fxid;
+ //d[2] = (byte) parameter;
+ //d[3] = (byte) val;
+ d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ d[2] = SS_SYSEX_SET_PLUGIN_PARAMETER;
+ d[3] = (byte) fxid;
+ d[4] = (byte) parameter;
+ d[5] = (byte) val;
sendSysex(d, len);
}
@@ -826,7 +930,9 @@ void SimpleSynthGui::aboutButtonClicked()
{
QString caption = "SimpleDrums ver";
caption+= SS_VERSIONSTRING;
- QString text = caption + "\n\n(C) Copyright 2000-2004 Mathias Lundgren (lunar_shuttle@users.sf.net), Werner Schweer\nPublished under the GNU Public License";
+ ///QString text = caption + "\n\n(C) Copyright 2000-2004 Mathias Lundgren (lunar_shuttle@users.sf.net), Werner Schweer\nPublished under the GNU Public License";
+ QString text = caption + "\n\n(C) Copyright 2000-2004 Mathias Lundgren (lunar_shuttle@users.sf.net), Werner Schweer\n"
+ "Fixes/mods: (C) Copyright 2011 Tim E. Real (terminator356@users.sf.net)\nPublished under the GNU Public License";
QMessageBox* msgBox = new QMessageBox(caption, text, QMessageBox::NoIcon,
QMessageBox::Ok, Qt::NoButton, Qt::NoButton, this);
msgBox->exec();
@@ -851,8 +957,12 @@ void SimpleSynthGui::loadSetup()
if (theFile.read((char*)&initdata_len, sizeof(initdata_len)) == -1)
success = false;
- byte* init_data = new byte[initdata_len];
- if (theFile.read((char*)(init_data), initdata_len) == -1)
+ ///byte* init_data = new byte[initdata_len];
+ byte* init_data = new byte[initdata_len + 2]; // 2 for MFG ID and synth ID.
+ init_data[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ init_data[1] = SIMPLEDRUMS_UNIQUE_ID;
+ //if (theFile.read((char*)(init_data), initdata_len) == -1)
+ if (theFile.read((char*)(init_data + 2), initdata_len) == -1)
success = false;
if (!success) {
@@ -862,7 +972,8 @@ void SimpleSynthGui::loadSetup()
delete msgBox;
}
else {
- sendSysex(init_data, initdata_len);
+ ///sendSysex(init_data, initdata_len);
+ sendSysex(init_data, initdata_len + 2);
}
delete[] init_data;
@@ -883,9 +994,14 @@ void SimpleSynthGui::saveSetup()
if (filename != QString::null) {
lastSavedProject = filename;
- byte d[1];
- d[0] = SS_SYSEX_GET_INIT_DATA;
- sendSysex(d, 1); // Makes synth send gui initdata, where rest of the saving takes place
+ //byte d[1];
+ byte d[3];
+ //d[0] = SS_SYSEX_GET_INIT_DATA;
+ d[0] = MUSE_SYNTH_SYSEX_MFG_ID;
+ d[1] = SIMPLEDRUMS_UNIQUE_ID;
+ d[2] = SS_SYSEX_GET_INIT_DATA;
+ //sendSysex(d, 1); // Makes synth send gui initdata, where rest of the saving takes place
+ sendSysex(d, 3); // Makes synth send gui initdata, where rest of the saving takes place
}
}
diff --git a/muse2/synti/simpledrums2/simpledrumsgui.h b/muse2/synti/simpledrums2/simpledrumsgui.h
index be8c492d..af32e432 100644
--- a/muse2/synti/simpledrums2/simpledrumsgui.h
+++ b/muse2/synti/simpledrums2/simpledrumsgui.h
@@ -5,6 +5,7 @@
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// Contributer: (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -37,18 +38,19 @@ class QChannelSlider: public QSlider
Q_OBJECT
public:
- QChannelSlider(Qt::Orientation, int ch, QWidget* paren = 0);
+ QChannelSlider(Qt::Orientation, int ch, QWidget* parent = 0);
int getChannel();
void setChannel(int ch);
- public slots:
- virtual void setValue(int val);
+ ///public slots:
+ /// virtual void setValue(int val);
signals:
void valueChanged(int channel, int value);
-
+
protected:
int channel;
+ virtual void sliderChange(SliderChange change);
};
//--------------------------------------
@@ -58,14 +60,17 @@ class QInvertedSlider : public QSlider
{
Q_OBJECT
public:
- QInvertedSlider(Qt::Orientation o, QWidget* parent = 0)
- : QSlider(o, parent) {}
+ QInvertedSlider(Qt::Orientation o, QWidget* parent = 0);
+ ///: QSlider(o, parent) {}
- public slots:
- virtual void setValue(int val);
+ ///public slots:
+ /// virtual void setValue(int val);
signals:
void invertedValueChanged(int value);
+
+ protected:
+ virtual void sliderChange(SliderChange change);
};
//--------------------------------------
@@ -75,11 +80,10 @@ class QInvertedChannelSlider : public QChannelSlider
{
Q_OBJECT
public:
- QInvertedChannelSlider(Qt::Orientation o, int channel, QWidget* parent = 0)
- : QChannelSlider(o, channel, parent) {};
+ QInvertedChannelSlider(Qt::Orientation o, int channel, QWidget* parent = 0);
- public slots:
- virtual void setValue(int val);
+ ///public slots:
+ /// virtual void setValue(int val);
};
@@ -138,12 +142,13 @@ class QChannelDial : public QDial
signals:
void valueChanged(int channel, int fxid, int val);
- public slots:
- virtual void setValue(int val);
+ ///public slots:
+ /// virtual void setValue(int val);
protected:
int channel;
int sendfxid;
+ virtual void sliderChange(SliderChange change);
};
//--------------------------------------
@@ -160,7 +165,10 @@ class SimpleSynthGui : public QDialog, public Ui::SimpleDrumsGuiBase, public Mes
QGroupBox* channelButtonGroups[SS_NR_OF_CHANNELS];
QGroupBox* masterButtonGroup;
QGroupBox* mainGroupBox;
- QInvertedChannelSlider* volumeSliders[SS_NR_OF_CHANNELS];
+
+ ///QInvertedChannelSlider* volumeSliders[SS_NR_OF_CHANNELS];
+ QChannelSlider* volumeSliders[SS_NR_OF_CHANNELS]; // p4.0.27 Tim. Inverted not correct. Was WIP?
+
QChannelSlider* panSliders[SS_NR_OF_CHANNELS];
QChannelCheckbox* onOff[SS_NR_OF_CHANNELS];
QChannelCheckbox* nOffIgnore[SS_NR_OF_CHANNELS];
@@ -168,7 +176,10 @@ class SimpleSynthGui : public QDialog, public Ui::SimpleDrumsGuiBase, public Mes
QChannelButton* clearSampleButton[SS_NR_OF_CHANNELS];
QLabel* nOffLabel[SS_NR_OF_CHANNELS];
QLineEdit* sampleNameLineEdit[SS_NR_OF_CHANNELS];
- QInvertedSlider* masterSlider;
+
+ ///QInvertedSlider* masterSlider;
+ QSlider* masterSlider; // p4.0.27 Tim. Inverted not correct. Was WIP?
+
QChannelDial* sendFxDial[SS_NR_OF_CHANNELS][SS_NR_OF_SENDEFFECTS];
QPushButton* openPluginsButton;
diff --git a/muse2/synti/simpledrums2/ssplugin.cpp b/muse2/synti/simpledrums2/ssplugin.cpp
index 9d32b2c3..75559a8f 100644
--- a/muse2/synti/simpledrums2/ssplugin.cpp
+++ b/muse2/synti/simpledrums2/ssplugin.cpp
@@ -6,6 +6,7 @@
//
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
// Additions/modifications: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
// Copyright: See COPYING file that comes with this distribution
//
//
diff --git a/muse2/synti/simpledrums2/ssplugin.h b/muse2/synti/simpledrums2/ssplugin.h
index 64e80921..8750753b 100644
--- a/muse2/synti/simpledrums2/ssplugin.h
+++ b/muse2/synti/simpledrums2/ssplugin.h
@@ -6,6 +6,7 @@
//
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
// Additions/modifications: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
// Copyright: See COPYING file that comes with this distribution
//
//
diff --git a/muse2/synti/simpledrums2/ssplugingui.cpp b/muse2/synti/simpledrums2/ssplugingui.cpp
index d52d3a8f..31ac3ac4 100644
--- a/muse2/synti/simpledrums2/ssplugingui.cpp
+++ b/muse2/synti/simpledrums2/ssplugingui.cpp
@@ -5,6 +5,7 @@
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// Contributer: (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -56,18 +57,24 @@ SS_PluginChooser::SS_PluginChooser(QWidget* parent)
}
connect(okButton, SIGNAL(pressed()), SLOT(okPressed()));
connect(cancelButton, SIGNAL(pressed()), SLOT(cancelPressed()));
- connect(effectsListView, SIGNAL(selectionChanged(QTreeWidgetItem*)), SLOT(selectionChanged(QTreeWidgetItem*)));
- connect(effectsListView, SIGNAL(doubleClicked(QTreeWidgetItem*)), SLOT(doubleClicked(QTreeWidgetItem*)));
+
+ //connect(effectsListView, SIGNAL(selectionChanged(QTreeWidgetItem*)), SLOT(selectionChanged(QTreeWidgetItem*)));
+ //connect(effectsListView, SIGNAL(doubleClicked(QTreeWidgetItem*)), SLOT(doubleClicked(QTreeWidgetItem*)));
+ connect(effectsListView, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged())); // p4.0.27
+ connect(effectsListView, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(doubleClicked(QTreeWidgetItem*))); //
+
SS_TRACE_OUT
}
/*!
\fn SS_PluginChooser::selectionChanged(QListViewItem* item)
*/
-void SS_PluginChooser::selectionChanged(QTreeWidgetItem* item)
+//void SS_PluginChooser::selectionChanged(QTreeWidgetItem* item)
+void SS_PluginChooser::selectionChanged()
{
SS_TRACE_IN
- selectedItem = item;
+ //selectedItem = item;
+ selectedItem = effectsListView->currentItem();
SS_TRACE_OUT
}
@@ -95,9 +102,10 @@ void SS_PluginChooser::cancelPressed()
/*!
\fn SS_PluginChooser::doubleClicked(QListViewItem* item)
*/
-void SS_PluginChooser::doubleClicked(QTreeWidgetItem* /*item*/)
+void SS_PluginChooser::doubleClicked(QTreeWidgetItem* item)
{
SS_TRACE_IN
+ selectedItem = item; // p4.0.27 Tim
selectedPlugin = findSelectedPlugin();
SS_TRACE_OUT
done(QDialog::Accepted);
@@ -109,6 +117,8 @@ void SS_PluginChooser::doubleClicked(QTreeWidgetItem* /*item*/)
LadspaPlugin* SS_PluginChooser::findSelectedPlugin()
{
SS_TRACE_IN
+ if(!selectedItem) // p4.0.27 Tim
+ return 0;
LadspaPlugin* selected = 0;
for (iPlugin i=plugins.begin(); i != plugins.end(); i++) {
if ((*i)->name() == selectedItem->text(SS_PLUGINCHOOSER_NAMECOL))
@@ -299,7 +309,7 @@ void SS_PluginFront::updatePluginValue(unsigned k)
}
iPlugin i;
- for (i = plugins.begin(); j != k; i++, j++);
+ for (i = plugins.begin(); j != k; i++, j++) ;
plugin = (LadspaPlugin*) *(i);
setPluginName(plugin->label());
outGainSlider->setEnabled(true);
@@ -307,7 +317,7 @@ void SS_PluginFront::updatePluginValue(unsigned k)
expandButton->setEnabled(true);
pluginName->setEnabled(true);
onOff->setEnabled(true);
- onOff->setChecked(true);
+ ///onOff->setChecked(true);
SS_TRACE_OUT
}
@@ -359,6 +369,15 @@ void SS_PluginFront::setRetGain(int val)
}
/*!
+ \fn SS_PluginFront::setOnOff(bool val)
+ */
+void SS_PluginFront::setOnOff(bool val)
+ {
+ onOff->blockSignals(true);
+ onOff->setChecked(val);
+ onOff->blockSignals(false);
+ }
+/*!
\fn SS_PluginFront::expandButtonPressed()
*/
void SS_PluginFront::expandButtonPressed()
diff --git a/muse2/synti/simpledrums2/ssplugingui.h b/muse2/synti/simpledrums2/ssplugingui.h
index 3d77ecf0..99951d01 100644
--- a/muse2/synti/simpledrums2/ssplugingui.h
+++ b/muse2/synti/simpledrums2/ssplugingui.h
@@ -5,6 +5,7 @@
//
//
// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2004
+// Contributer: (C) Copyright 2011 Tim E. Real (terminator356 at users.sourceforge.net)
//
// Copyright: See COPYING file that comes with this distribution
//
@@ -83,11 +84,21 @@ class SS_ParameterSlider : public QSlider, public SS_ParameterWidget
virtual void setParamValue(int val) { SS_TRACE_IN setValue(val); SS_TRACE_OUT}
- public slots:
- virtual void setValue(int val) { SS_TRACE_IN QSlider::setValue(val); emit valueChanged(fxid, parameter, val); SS_TRACE_OUT }
+ ///public slots:
+ /// virtual void setValue(int val) { SS_TRACE_IN QSlider::setValue(val); emit valueChanged(fxid, parameter, val); SS_TRACE_OUT }
signals:
void valueChanged(int id, int param, int val);
+
+ protected:
+ virtual void sliderChange(SliderChange change) // p4.0.27 Tim
+ {
+ SS_TRACE_IN
+ QSlider::sliderChange(change);
+ if(change == QAbstractSlider::SliderValueChange)
+ emit valueChanged(fxid, parameter, value());
+ SS_TRACE_OUT
+ }
};
typedef std::list<SS_ParameterWidget*> SS_ParameterWidgetList;
@@ -110,7 +121,8 @@ class SS_PluginChooser : public QDialog, Ui::SS_PluginChooserBase
private slots:
void okPressed();
void cancelPressed();
- void selectionChanged(QTreeWidgetItem* item);
+ ///void selectionChanged(QTreeWidgetItem* item);
+ void selectionChanged();
void doubleClicked(QTreeWidgetItem* item);
private:
@@ -154,6 +166,7 @@ class SS_PluginFront : public QGroupBox
void clearPluginDisplay();
void setParameterValue(int param, int val);
void setRetGain(int val);
+ void setOnOff(bool val);
protected:
virtual QSize sizeHint() const;