summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank Neumann <beachnase@web.de>2008-02-20 23:31:25 +0000
committerFrank Neumann <beachnase@web.de>2008-02-20 23:31:25 +0000
commit065e9f71faa38082a757e416bced4a2345874235 (patch)
tree41bc3d804daa29453658a0c154e16e82918298b1
parent94a9f2b9f93394863cfa38af79ebfb40f11e06e5 (diff)
Port of simpledrums to Qt4.3
-rw-r--r--muse/CMakeLists.txt6
-rw-r--r--muse/ChangeLog3
-rw-r--r--muse/synti/simpledrums/CMakeLists.txt52
-rw-r--r--muse/synti/simpledrums/common.h11
-rw-r--r--muse/synti/simpledrums/simpledrums.cpp105
-rw-r--r--muse/synti/simpledrums/simpledrums.h4
-rw-r--r--muse/synti/simpledrums/simpledrumsgui.cpp146
-rw-r--r--muse/synti/simpledrums/simpledrumsgui.h9
-rw-r--r--muse/synti/simpledrums/ssplugin.cpp1
-rw-r--r--muse/synti/simpledrums/ssplugingui.cpp15
-rw-r--r--muse/synti/simpledrums/ssplugingui.h4
11 files changed, 311 insertions, 45 deletions
diff --git a/muse/CMakeLists.txt b/muse/CMakeLists.txt
index f518b9d0..d573c3e9 100644
--- a/muse/CMakeLists.txt
+++ b/muse/CMakeLists.txt
@@ -26,8 +26,8 @@ if (NOT CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR "lib")
endif (NOT CMAKE_INSTALL_LIBDIR)
-set(CMAKE_BUILD_TYPE debug)
-# set(CMAKE_BUILD_TYPE release)
+#set(CMAKE_BUILD_TYPE debug)
+set(CMAKE_BUILD_TYPE release)
# for debugging the make system uncomment next line:
# set(CMAKE_VERBOSE_MAKEFILE ON)
@@ -366,5 +366,5 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
INCLUDE(CPack)
ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
-subdirs(al awl grepmidi plugins midiplugins muse share doc synti)
+subdirs(al awl grepmidi plugins midiplugins muse share synti)
diff --git a/muse/ChangeLog b/muse/ChangeLog
index d109caae..652c5320 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,6 @@
+21.02. (fn)
+ - "Ported" simpledrums to Qt4 - it builds, runs, produces sound (and
+ compiler warnings); review is welcome. The GUI is rather large now.
21.1. (ws)
- fix: recorded midi events were echoed to midi output even if the "monitor"
switch was "off"
diff --git a/muse/synti/simpledrums/CMakeLists.txt b/muse/synti/simpledrums/CMakeLists.txt
new file mode 100644
index 00000000..b29bab02
--- /dev/null
+++ b/muse/synti/simpledrums/CMakeLists.txt
@@ -0,0 +1,52 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+QT4_WRAP_CPP ( simpledrums_mocs simpledrumsgui.h ssplugingui.h )
+QT4_WRAP_UI ( simpledrums_uis simpledrumsguibase.ui sspluginchooserbase.ui )
+
+add_library ( simpledrums SHARED
+ simpledrums.cpp
+ simpledrumsgui.cpp
+ simpledrums.h
+ ssplugin.cpp
+ ssplugingui.cpp
+ ssplugin.h
+ common.h
+ ${simpledrums_mocs}
+ ${simpledrums_uis}
+ )
+
+# - tell cmake to name target simpledrums.so instead of
+# libsimpledrums.so
+# - use precompiled header files
+#
+set_target_properties ( simpledrums
+ PROPERTIES PREFIX ""
+ COMPILE_FLAGS "-O6 -include ${PROJECT_BINARY_DIR}/all-pic.h"
+ )
+
+target_link_libraries(simpledrums
+ synti
+# awl
+ ${QT_LIBRARIES}
+ )
+
+install_targets ( /${CMAKE_INSTALL_LIBDIR}/${MusE_INSTALL_NAME}/synthi/ simpledrums )
+
diff --git a/muse/synti/simpledrums/common.h b/muse/synti/simpledrums/common.h
index 79148d42..e4763540 100644
--- a/muse/synti/simpledrums/common.h
+++ b/muse/synti/simpledrums/common.h
@@ -14,7 +14,7 @@
#include "muse/midictrl.h"
-#define SS_VERSIONSTRING "0.2"
+#define SS_VERSIONSTRING "1.0"
#define SS_DEBUG 0
#define SS_DEBUG_INIT 0
@@ -33,8 +33,6 @@
#define SS_DBG_LADSPA(string1) if (SS_DEBUG_LADSPA) fprintf(stderr, "%s:%d:%s: %s\n", __FILE__ , __LINE__ , __PRETTY_FUNCTION__, string1);
#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_TRACE_IN
-//#define SS_TRACE_OUT
#define SS_SYSEX_INIT_DATA_VERSION 1
#define SS_NR_OF_CHANNELS 16
@@ -88,10 +86,11 @@ typedef unsigned char byte;
enum {
SS_SYSEX_LOAD_SAMPLE = 0, // gui -> synth: tell synth to load sample
- SS_SYSEX_INIT_DATA, // synth reinitialization, this must not be changed since this value is written into proj file
+ SS_SYSEX_INIT_DATA, // synth reinitialization, the position of this (1) in the enum must not be changed since this value is written into proj file
SS_SYSEX_LOAD_SAMPLE_OK, // synth -> gui: tell gui sample loaded OK
SS_SYSEX_LOAD_SAMPLE_ERROR, // synth -> gui: tell gui sample ! loaded OK
SS_SYSEX_CLEAR_SAMPLE, // gui -> synth: tell synth to clear sample
+ SS_SYSEX_CLEAR_SAMPLE_OK, // synth->gui: confirm sample cleared OK
SS_SYSEX_LOAD_SENDEFFECT, // gui -> synth: tell synth to load laspa-effect
SS_SYSEX_LOAD_SENDEFFECT_OK,// synth->gui: plugin loaded ok
SS_SYSEX_LOAD_SENDEFFECT_ERROR, // synth->gui: plugin _not_ loaded ok
@@ -99,7 +98,9 @@ enum {
SS_SYSEX_CLEAR_SENDEFFECT_OK,// synth->gui: plugin cleared
SS_SYSEX_SET_PLUGIN_PARAMETER, //gui->synth: set plugin parameter
SS_SYSEX_SET_PLUGIN_PARAMETER_OK, // synth->gui: set plugin parameter (update gui)
- SS_SYSEX_ERRORMSG // synth -> gui: general error message from synth
+ SS_SYSEX_ERRORMSG, // synth -> gui: general error message from synth
+ SS_SYSEX_GET_INIT_DATA, // gui->synth: request init data
+ SS_SYSEX_SEND_INIT_DATA // synth->gui: give gui init data
};
extern int SS_samplerate;
diff --git a/muse/synti/simpledrums/simpledrums.cpp b/muse/synti/simpledrums/simpledrums.cpp
index 5b7d1c96..93be946d 100644
--- a/muse/synti/simpledrums/simpledrums.cpp
+++ b/muse/synti/simpledrums/simpledrums.cpp
@@ -12,7 +12,7 @@
#include "muse/midictrl.h"
#include "muse/midi.h"
-#include "libsynti/mpevent.h"
+#include "libsynti/midievent.h"
#include "simpledrums.h"
// #include <qstring.h>
#include <samplerate.h>
@@ -515,18 +515,7 @@ bool SimpleSynth::sysex(int /*len*/, const unsigned char* data)
case SS_SYSEX_CLEAR_SAMPLE:
{
int ch = data[1];
- if (channels[ch].sample) {
- SS_State prevstate = synth_state;
- SWITCH_CHAN_STATE(ch, SS_CHANNEL_INACTIVE);
- SWITCH_SYNTH_STATE(SS_CLEARING_SAMPLE);
- delete[] channels[ch].sample->data;
- delete channels[ch].sample;
- channels[ch].sample = 0;
- SWITCH_SYNTH_STATE(prevstate);
- if (SS_DEBUG_MIDI) {
- printf("Sysex cmd: clear sample - sample cleared on channel %d\n", ch);
- }
- }
+ clearSample(ch);
break;
}
@@ -571,6 +560,28 @@ bool SimpleSynth::sysex(int /*len*/, const unsigned char* data)
break;
}
+ case SS_SYSEX_GET_INIT_DATA:
+ {
+ int initdata_len = 0;
+ const byte* tmp_initdata = 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;
+
+ MidiEvent ev(0, ME_SYSEX, event_data, totlen);
+ gui->writeEvent(ev);
+ delete[] event_data;
+
+ break;
+ }
+
default:
if (SS_DEBUG_MIDI)
printf("Unknown sysex cmd received: %d\n", cmd);
@@ -875,6 +886,7 @@ void SimpleSynth::getInitData(int* n, const unsigned char** data)
// 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;
if (SS_DEBUG_INIT) {
@@ -1001,10 +1013,10 @@ void SimpleSynth::getInitData(int* n, const unsigned char** data)
// No plugin loaded:
else {
buffer[i] = SS_NO_PLUGIN;
- i++;
if (SS_DEBUG_INIT) {
printf("buffer[%d]: SS_NO_PLUGIN\n", i);
}
+ i++;
}
}
@@ -1028,10 +1040,10 @@ void SimpleSynth::parseInitData(const unsigned char* data)
if (SS_DEBUG_INIT) {
printf("Channel %d:\n", ch);
- printf("buffer[%d] - channels[ch].volume_ctrlval = \t%d\n", ptr-data, *ptr);
- printf("buffer[%d] - channels[ch].pan = \t\t%d\n", ptr-data+1, *(ptr+1));
- printf("buffer[%d] - channels[ch].noteoff_ignore = \t%d\n", ptr-data+2, *(ptr+2));
- printf("buffer[%d] - channels[ch].channel_on = \t%d\n", ptr-data+3, *(ptr+3));
+ printf("buffer[%ld] - channels[ch].volume_ctrlval = \t%d\n", ptr-data, *ptr);
+ printf("buffer[%ld] - channels[ch].pan = \t\t%d\n", ptr-data+1, *(ptr+1));
+ printf("buffer[%ld] - channels[ch].noteoff_ignore = \t%d\n", ptr-data+2, *(ptr+2));
+ printf("buffer[%ld] - channels[ch].channel_on = \t%d\n", ptr-data+3, *(ptr+3));
}
updateVolume(ch, *(ptr));
guiUpdateVolume(ch, *(ptr));
@@ -1080,6 +1092,11 @@ void SimpleSynth::parseInitData(const unsigned char* data)
//printf("We should load %s\n", filenametmp.c_str());
loadSample(ch, filenametmp.c_str());
}
+ else {
+ //Clear sample
+ clearSample(ch);
+ guiNotifySampleCleared(ch);
+ }
}
//Master vol:
master_vol_ctrlval = *(ptr);
@@ -1099,6 +1116,8 @@ void SimpleSynth::parseInitData(const unsigned char* data)
ptr++;
for (int i=0; i<SS_NR_OF_SENDEFFECTS; i++) {
+ if (SS_DEBUG_INIT)
+ printf("buffer[%ld] - sendeffect[%d], labelnamelen=%d\n", ptr-data, i, *ptr);
int labelnamelen = *(ptr);
if (labelnamelen != SS_NO_PLUGIN) {
@@ -1128,11 +1147,15 @@ void SimpleSynth::parseInitData(const unsigned char* data)
gui->writeEvent(ev);
for (int j=0; j<params; j++) {
+ if (SS_DEBUG_INIT)
+ printf("buffer[%ld] - sendeffect[%d], parameter[%d]=%d\n", ptr-data, i, j, *ptr);
setFxParameter(i, j, sendEffects[i].plugin->convertGuiControlValue(j, *(ptr)));
ptr++;
}
}
else {
+ if (sendEffects[i].plugin)
+ cleanupPlugin(i);
ptr++;
}
}
@@ -1580,6 +1603,8 @@ void SimpleSynth::cleanupPlugin(int id)
plugin->stop();
SS_DBG2("Stopped fx", plugin->label().toLatin1().data());
sendEffects[id].nrofparameters = 0;
+ sendEffects[id].state = SS_SENDFX_OFF;
+ sendEffects[id].plugin = 0;
byte d[2];
d[0] = SS_SYSEX_CLEAR_SENDEFFECT_OK;
@@ -1648,3 +1673,47 @@ void SimpleSynth::guiUpdateFxParameter(int fxid, int param, float val)
}
+/*!
+ \fn SimpleSynth::clearSample(int ch)
+ \brief Clears a sample (actually clears a channel)
+ */
+void SimpleSynth::clearSample(int ch)
+ {
+ SS_TRACE_IN
+ if (channels[ch].sample) {
+ if (SS_DEBUG)
+ printf("Clearing sample on channel %d\n", ch);
+ SS_State prevstate = synth_state;
+ SWITCH_CHAN_STATE(ch, SS_CHANNEL_INACTIVE);
+ SWITCH_SYNTH_STATE(SS_CLEARING_SAMPLE);
+ if (channels[ch].sample->data) {
+ delete[] channels[ch].sample->data;
+ channels[ch].sample->data = 0;
+ }
+ if (channels[ch].sample) {
+ delete channels[ch].sample;
+ channels[ch].sample = 0;
+ }
+ SWITCH_SYNTH_STATE(prevstate);
+ guiNotifySampleCleared(ch);
+ if (SS_DEBUG) {
+ printf("Clear sample - sample cleared on channel %d\n", ch);
+ }
+ }
+ SS_TRACE_OUT
+ }
+
+
+/*!
+ \fn SimpleSynth::guiNotifySampleCleared(int ch)
+ */
+void SimpleSynth::guiNotifySampleCleared(int ch)
+ {
+ SS_TRACE_IN
+ byte d[2];
+ d[0] = SS_SYSEX_CLEAR_SAMPLE_OK;
+ d[1] = (byte) ch;
+ MidiEvent ev(0, ME_SYSEX, d, 2);
+ gui->writeEvent(ev);
+ SS_TRACE_OUT
+ }
diff --git a/muse/synti/simpledrums/simpledrums.h b/muse/synti/simpledrums/simpledrums.h
index 01621fbf..d52f90af 100644
--- a/muse/synti/simpledrums/simpledrums.h
+++ b/muse/synti/simpledrums/simpledrums.h
@@ -15,7 +15,7 @@
#include <sndfile.h>
#include "libsynti/mess.h"
#include "common.h"
-#include "libsynti/mpevent.h"
+#include "libsynti/midievent.h"
#include "simpledrumsgui.h"
#include "ssplugin.h"
@@ -142,6 +142,7 @@ private:
void parseInitData(const unsigned char* data);
void updateVolume(int ch, int in_volume_ctrlval);
void updateBalance(int ch, int pan);
+ void guiNotifySampleCleared(int ch);
void guiUpdateBalance(int ch, int bal);
void guiUpdateVolume(int ch, int val);
void guiUpdateNoff(int ch, bool b);
@@ -153,6 +154,7 @@ private:
void setSendFxLevel(int channel, int effectid, double val);
void cleanupPlugin(int id);
void setFxParameter(int fxid, int param, float val);
+ void clearSample(int ch);
double master_vol;
int master_vol_ctrlval;
diff --git a/muse/synti/simpledrums/simpledrumsgui.cpp b/muse/synti/simpledrums/simpledrumsgui.cpp
index ba99dc6c..bc3e3e92 100644
--- a/muse/synti/simpledrums/simpledrumsgui.cpp
+++ b/muse/synti/simpledrums/simpledrumsgui.cpp
@@ -11,7 +11,7 @@
//
#include "simpledrumsgui.h"
-#include "libsynti/mpevent.h"
+#include "libsynti/midievent.h"
#include "muse/midi.h"
#include "ssplugingui.h"
@@ -209,7 +209,7 @@ SimpleSynthGui::SimpleSynthGui()
//this->setFixedHeight(SS_GUI_WINDOW_HEIGHT);
for (int i=0; i<SS_NR_OF_CHANNELS; i++) {
channelButtonGroups[i] = new QGroupBox(this);
- channelButtonGroups[i]->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
+// channelButtonGroups[i]->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
channelButtonGroups[i]->setTitle(QString::number(i + 1));
QString name = QString("volumeSlider");
@@ -221,7 +221,7 @@ SimpleSynthGui::SimpleSynthGui()
inchnlLayout->setAlignment(Qt::AlignHCenter);
onOff[i] = new QChannelCheckbox(channelButtonGroups[i], i);
- onOff[i]->setMinimumSize(SS_ONOFF_WIDTH, SS_ONOFF_HEIGHT);
+// onOff[i]->setMinimumSize(SS_ONOFF_WIDTH, SS_ONOFF_HEIGHT);
onOff[i]->setToolTip("Channel " + QString::number(i + 1) + " on/off");
inchnlLayout->addWidget(onOff[i]);
connect(onOff[i], SIGNAL(channelState(int, bool)), SLOT(channelOnOff(int, bool)));
@@ -230,19 +230,19 @@ SimpleSynthGui::SimpleSynthGui()
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]->setMinimumSize(SS_VOLSLDR_WIDTH, SS_VOLSLDR_LENGTH);
+// 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);
+// setMinimumSize(SS_VOLSLDR_WIDTH, SS_VOLSLDR_LENGTH);
inchnlLayout->addWidget(volumeSliders[i]);
connect(volumeSliders[i], SIGNAL(valueChanged(int, int)), SLOT(volumeChanged(int, int)));
nOffLabel[i] = new QLabel(channelButtonGroups[i]);
- nOffLabel[i]->setMinimumSize(SS_NONOFF_LABEL_WIDTH, SS_NONOFF_LABEL_HEIGHT);
+// nOffLabel[i]->setMinimumSize(SS_NONOFF_LABEL_WIDTH, SS_NONOFF_LABEL_HEIGHT);
nOffLabel[i]->setText("nOff");
inchnlLayout->addWidget(nOffLabel[i]);
nOffIgnore[i] = new QChannelCheckbox(channelButtonGroups[i], i);
- nOffIgnore[i]->setMinimumSize(SS_NONOFF_WIDTH, SS_NONOFF_HEIGHT);
+// nOffIgnore[i]->setMinimumSize(SS_NONOFF_WIDTH, SS_NONOFF_HEIGHT);
nOffIgnore[i]->setToolTip("Note off ignore, channel " + QString::number(i + 1));
inchnlLayout->addWidget(nOffIgnore[i]);
connect(nOffIgnore[i], SIGNAL(channelState(int, bool)),SLOT(channelNoteOffIgnore(int, bool)));
@@ -250,7 +250,7 @@ SimpleSynthGui::SimpleSynthGui()
panSliders[i] = new QChannelSlider(Qt::Horizontal, i, channelButtonGroups[i]);
panSliders[i]->setRange(0, 127);
panSliders[i]->setValue(SS_PANSLDR_DEFAULT_VALUE);
- panSliders[i]->setMinimumSize(SS_PANSLDR_WIDTH, SS_PANSLDR_LENGTH);
+// panSliders[i]->setMinimumSize(SS_PANSLDR_WIDTH, SS_PANSLDR_LENGTH);
panSliders[i]->setToolTip("Pan, channel " + QString::number(i + 1));
inchnlLayout->addWidget(panSliders[i]);
connect(panSliders[i], SIGNAL(valueChanged(int, int)), SLOT(panChanged(int, int)));
@@ -299,13 +299,13 @@ SimpleSynthGui::SimpleSynthGui()
channelLayout->addWidget(masterButtonGroup);
QVBoxLayout* mbgLayout = new QVBoxLayout(masterButtonGroup);
mbgLayout->setAlignment(Qt::AlignCenter);
- masterButtonGroup->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
+// masterButtonGroup->setMinimumSize(SS_BTNGRP_WIDTH, SS_BTNGRP_HEIGHT);
masterSlider = new QInvertedSlider(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->setMinimumSize(SS_MASTERSLDR_WIDTH, SS_MASTERSLDR_HEIGHT);
+// masterSlider->setMinimumSize(SS_MASTERSLDR_WIDTH, SS_MASTERSLDR_HEIGHT);
connect(masterSlider, SIGNAL(invertedValueChanged(int)), SLOT(masterVolChanged(int)));
//Main groupbox
@@ -329,13 +329,13 @@ SimpleSynthGui::SimpleSynthGui()
strip->addWidget(sampleNameLineEdit[i]);
loadSampleButton[i] = new QChannelButton(mainGroupBox, "L", i);
- loadSampleButton[i]->setMinimumSize(SS_SAMPLE_LOAD_WIDTH, SS_SAMPLE_LOAD_HEIGHT);
+// loadSampleButton[i]->setMinimumSize(SS_SAMPLE_LOAD_WIDTH, SS_SAMPLE_LOAD_HEIGHT);
loadSampleButton[i]->setToolTip("Load sample on channel " + QString::number(i + 1));
strip->addWidget(loadSampleButton[i]);
connect(loadSampleButton[i], SIGNAL(channelState(int, bool)), SLOT(loadSampleDialogue(int)));
clearSampleButton[i] = new QChannelButton(mainGroupBox, "C", i);
- clearSampleButton[i]->setMinimumSize(SS_SAMPLE_CLEAR_WIDTH, SS_SAMPLE_CLEAR_HEIGHT);
+// clearSampleButton[i]->setMinimumSize(SS_SAMPLE_CLEAR_WIDTH, SS_SAMPLE_CLEAR_HEIGHT);
clearSampleButton[i]->setToolTip("Clear sample on channel " + QString::number(i + 1));
strip->addWidget(clearSampleButton[i]);
connect(clearSampleButton[i], SIGNAL(channelState(int, bool)), SLOT(clearSample(int)));
@@ -352,12 +352,24 @@ SimpleSynthGui::SimpleSynthGui()
openPluginsButton = new QPushButton("&Send Effects");
openPluginsButton->setToolTip("Configure LADSPA send effects");
connect(openPluginsButton, SIGNAL(clicked()), SLOT(openPluginButtonClicked()));
- rbLayout->addWidget(openPluginsButton, 2, 1, Qt::AlignLeft | Qt::AlignVCenter);
+ rbLayout->addWidget(openPluginsButton, 2, 1, Qt::AlignCenter | Qt::AlignVCenter);
aboutButton = new QPushButton("About SimpleDrums");
connect(aboutButton, SIGNAL(clicked()), SLOT(aboutButtonClicked()));
//TD rbLayout->addRowSpacing(3, 20);
rbLayout->addWidget(aboutButton, 4, 1, Qt::AlignLeft | Qt::AlignVCenter);
+
+ loadButton = new QPushButton(tr("&Load setup"), rbPanel);
+ connect(loadButton, SIGNAL(clicked()), SLOT(loadSetup()));
+ saveButton = new QPushButton(tr("&Save setup"), rbPanel);
+ connect(saveButton, SIGNAL(clicked()), SLOT(saveSetup()));
+ //rbLayout->addWidget(openPluginsButton, 1, 1, Qt::AlignCenter | Qt::AlignVCenter);
+// rbLayout->addRowSpacing(2, 20);
+ rbLayout->addWidget(loadButton, 3, 1, Qt::AlignCenter | Qt::AlignVCenter);
+ rbLayout->addWidget(saveButton, 4, 1, Qt::AlignCenter | Qt::AlignVCenter);
+// rbLayout->addRowSpacing(5, 20);
+ rbLayout->addWidget(aboutButton, 6, 1, Qt::AlignCenter | Qt::AlignVCenter);
+
lastDir = "";
//Connect socketnotifier to fifo
QSocketNotifier* s = new QSocketNotifier(readFd, QSocketNotifier::Read);
@@ -540,6 +552,15 @@ void SimpleSynthGui::processEvent(const MidiEvent& ev)
break;
}
+ case SS_SYSEX_CLEAR_SAMPLE_OK: {
+ if (SS_DEBUG_MIDI) {
+ printf("SimpleSynthGui - sysex clear samle OK on channel: %d\n", *(data+1));
+ }
+ byte ch = *(data+1);
+ sampleNameLineEdit[ch]->setText("");
+ break;
+ }
+
case SS_SYSEX_SET_PLUGIN_PARAMETER_OK: {
if (SS_DEBUG_MIDI) {
printf("SimpleSynthGui - plugin parameter OK on fxid: %d\n", *(data+1));
@@ -553,6 +574,45 @@ void SimpleSynthGui::processEvent(const MidiEvent& ev)
break;
}
+ case SS_SYSEX_SEND_INIT_DATA: {
+// FN: TODO
+#if 1
+ const unsigned initdata_len = ev.len() - 1;
+ byte* init_data = (data + 1);
+ QFileInfo fileInfo = QFileInfo(lastSavedProject);
+
+ lastProjectDir = fileInfo.path();
+ if (fileInfo.suffix() != "sds" && fileInfo.suffix() != "SDS") {
+ lastSavedProject += ".sds";
+ fileInfo = QFileInfo(lastSavedProject);
+ }
+ QFile theFile(fileInfo.filePath());
+
+ // Write data
+ if (theFile.open(QIODevice::WriteOnly)) {
+ theFile.write((const char*)&initdata_len, sizeof(initdata_len)); // First write length
+ if (theFile.write((const char*)init_data, initdata_len) == -1) {
+ // Fatal error writing
+ QMessageBox* msgBox = new QMessageBox(QMessageBox::Warning, "SimpleDrums error Dialog", "Fatal error when writing to file. Setup not saved.",
+ QMessageBox::Ok, this);
+ msgBox->exec();
+ delete msgBox;
+ }
+ theFile.close();
+ }
+ else {
+ // An error occured when opening
+ QMessageBox* msgBox = new QMessageBox(QMessageBox::Warning, "SimpleDrums error Dialog", "Error opening file. Setup was not saved.",
+ QMessageBox::Ok, this);
+ msgBox->exec();
+ delete msgBox;
+ }
+#endif
+
+ break;
+ }
+
+
default:
if (SS_DEBUG_MIDI) {
printf("SimpleSynthGui::processEvent - unknown sysex cmd received: %d\n", cmd);
@@ -632,7 +692,7 @@ void SimpleSynthGui::loadSampleDialogue(int channel)
this,
tr("Load sample dialog"),
lastDir,
- QString("*.wav;*.WAV"));
+ QString("*.wav *.WAV"));
if (filename != QString::null) {
QFileInfo fi(filename);
@@ -761,3 +821,61 @@ void SimpleSynthGui::aboutButtonClicked()
QMessageBox::Ok, Qt::NoButton, Qt::NoButton, this);
msgBox->exec();
}
+
+
+/*!
+ \fn SimpleSynthGui::loadSetup()
+ \brief Load setup from file
+ */
+void SimpleSynthGui::loadSetup()
+ {
+ bool success = true;
+ QString filename =
+ QFileDialog::getOpenFileName(this, "Load setup dialog", lastProjectDir,
+ QString("*.sds *.SDS"));
+
+ if (filename != QString::null) {
+ QFile theFile(filename);
+ if (theFile.open(QIODevice::ReadOnly)) {
+ unsigned initdata_len = 0;
+ 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)
+ success = false;
+
+ if (!success) {
+ QMessageBox* msgBox = new QMessageBox(QMessageBox::Warning, "SimpleDrums Error Dialog", "Error opening/reading from file. Setup not loaded.",
+ QMessageBox::Ok, this);
+ msgBox->exec();
+ delete msgBox;
+ }
+ else {
+ sendSysex(init_data, initdata_len);
+ }
+
+ delete[] init_data;
+ }
+ }
+ }
+
+
+/*!
+ \fn SimpleSynthGui::saveSetup()
+ \brief Save setup to file
+ */
+void SimpleSynthGui::saveSetup()
+ {
+ QString filename =
+ QFileDialog::getSaveFileName(this, "Save setup dialog", lastProjectDir,
+ QString("*.sds *.SDS"));
+
+ 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
+ }
+ }
+
diff --git a/muse/synti/simpledrums/simpledrumsgui.h b/muse/synti/simpledrums/simpledrumsgui.h
index 7291169d..b3436f5d 100644
--- a/muse/synti/simpledrums/simpledrumsgui.h
+++ b/muse/synti/simpledrums/simpledrumsgui.h
@@ -13,7 +13,7 @@
#define __MUSE_TESTOGUI_H__
#include "libsynti/gui.h"
-#include "simpledrumsguibase.h"
+#include "ui_simpledrumsguibase.h"
#include "common.h"
class QButtonGroup;
@@ -164,8 +164,13 @@ class SimpleSynthGui : public QDialog, public Ui::SimpleDrumsGuiBase, public Mes
QPushButton* openPluginsButton;
QPushButton* aboutButton;
+ QPushButton* loadButton;
+ QPushButton* saveButton;
+
QString lastDir;
+ QString lastSavedProject;
+ QString lastProjectDir;
SS_PluginGui* pluginGui;
public:
@@ -191,6 +196,8 @@ class SimpleSynthGui : public QDialog, public Ui::SimpleDrumsGuiBase, public Mes
void sendFxChanged(int ch, int fxid, int val);
void openPluginButtonClicked();
void aboutButtonClicked();
+ void loadSetup();
+ void saveSetup();
};
diff --git a/muse/synti/simpledrums/ssplugin.cpp b/muse/synti/simpledrums/ssplugin.cpp
index 24ee9b21..8d5c3d8f 100644
--- a/muse/synti/simpledrums/ssplugin.cpp
+++ b/muse/synti/simpledrums/ssplugin.cpp
@@ -252,6 +252,7 @@ void LadspaPlugin::stop()
if (handle) {
SS_DBG_LADSPA2("Trying to stop plugin", label().toLatin1().data());
if (plugin->deactivate) {
+ SS_DBG_LADSPA2("Deactivating ", label().toLatin1().data());
plugin->deactivate(handle);
active = false;
}
diff --git a/muse/synti/simpledrums/ssplugingui.cpp b/muse/synti/simpledrums/ssplugingui.cpp
index ec55b9c3..0428988b 100644
--- a/muse/synti/simpledrums/ssplugingui.cpp
+++ b/muse/synti/simpledrums/ssplugingui.cpp
@@ -229,9 +229,16 @@ SS_PluginFront::~SS_PluginFront()
void SS_PluginFront::clearPluginDisplay()
{
SS_TRACE_IN
+ if (expanded)
+ expandButtonPressed();
+
pluginName->setText("No plugin loaded");
pluginName->setEnabled(false);
onOff->setEnabled(false);
+ onOff->blockSignals(true);
+ onOff->setChecked(false);
+ onOff->blockSignals(false);
+
clearFxButton->setEnabled(false);
expandButton->setEnabled(false);
outGainSlider->setEnabled(false);
@@ -514,4 +521,10 @@ void SS_PluginGui::pluginFrontSizeChanged(int /*fxid*/, int val)
adjustSize();
}
-
+SS_PluginFront* SS_PluginGui::getPluginFront(unsigned i)
+ {
+ SS_TRACE_IN
+ if (i<SS_NR_OF_SENDEFFECTS)
+ SS_TRACE_OUT
+ return pluginFronts[i];
+ }
diff --git a/muse/synti/simpledrums/ssplugingui.h b/muse/synti/simpledrums/ssplugingui.h
index 2f2159b0..d613fd46 100644
--- a/muse/synti/simpledrums/ssplugingui.h
+++ b/muse/synti/simpledrums/ssplugingui.h
@@ -13,7 +13,7 @@
#ifndef __SS_PLUGINGUI_H__
#define __SS_PLUGINGUI_H__
-#include "sspluginchooserbase.h"
+#include "ui_sspluginchooserbase.h"
#include "common.h"
#include "ssplugin.h"
@@ -187,7 +187,7 @@ class SS_PluginGui : public QDialog
public:
SS_PluginGui(QWidget* parent);
- SS_PluginFront* getPluginFront(unsigned i) { SS_TRACE_IN if (i<SS_NR_OF_SENDEFFECTS) SS_TRACE_OUT return pluginFronts[i];}
+ SS_PluginFront* getPluginFront(unsigned i);
~SS_PluginGui() {}
private slots:
void pluginFrontSizeChanged(int fxid, int val);