summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-11-10 16:34:03 +0000
committerWerner Schweer <ws.seh.de>2006-11-10 16:34:03 +0000
commite5f527212d97e779f14f28ecb91121c21cfd2c08 (patch)
treebaddb014cb0f854348a76229efc9fa1449b63b47
parentc929c5ccee3d955f6ca03877f33b6842f89046aa (diff)
add layer feature to splitlayer midi plugin
-rw-r--r--muse/midiplugins/splitlayer/splitlayer.cpp55
-rw-r--r--muse/midiplugins/splitlayer/splitlayer.h3
-rw-r--r--muse/midiplugins/splitlayer/splitlayergui.cpp67
-rw-r--r--muse/midiplugins/splitlayer/splitlayergui.h7
4 files changed, 114 insertions, 18 deletions
diff --git a/muse/midiplugins/splitlayer/splitlayer.cpp b/muse/midiplugins/splitlayer/splitlayer.cpp
index cc0cf53b..46357585 100644
--- a/muse/midiplugins/splitlayer/splitlayer.cpp
+++ b/muse/midiplugins/splitlayer/splitlayer.cpp
@@ -54,13 +54,16 @@ bool SplitLayer::init()
data.startPitch[0] = 0;
data.endPitch[0] = 128;
data.pitchOffset[0] = 0;
+ data.veloOffset[0] = 0;
for (int i = 1; i < MIDI_CHANNELS; ++i) {
data.startVelo[i] = 0;
data.endVelo[i] = 0;
data.startPitch[i] = 0;
data.endPitch[i] = 0;
data.pitchOffset[i] = 0;
+ data.veloOffset[i] = 0;
}
+ memset(notes, 0, 128 * sizeof(int));
learnMode = false;
gui = new SplitLayerGui(this, 0);
gui->hide();
@@ -100,9 +103,12 @@ void SplitLayer::setGeometry(int x, int y, int w, int h)
void SplitLayer::process(unsigned, unsigned, MidiEventList* il, MidiEventList* ol)
{
for (iMidiEvent i = il->begin(); i != il->end(); ++i) {
- if (i->type() != ME_NOTEON && i->type() != ME_NOTEOFF)
+ if (i->type() != ME_NOTEON && i->type() != ME_NOTEOFF) {
ol->insert(*i);
+ continue;
+ }
int pitch = i->dataA();
+ int velo = i->dataB();
if (learnMode) {
if (learnStartPitch)
data.startPitch[learnChannel] = pitch;
@@ -110,19 +116,44 @@ void SplitLayer::process(unsigned, unsigned, MidiEventList* il, MidiEventList* o
data.endPitch[learnChannel] = pitch;
learnMode = false;
gui->sendResetLearnMode();
+ return;
+ }
+ if (i->type() == ME_NOTEON && velo) {
+ for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
+ MidiEvent event(*i);
+ if (pitch >= data.startPitch[ch]
+ && pitch < data.endPitch[ch]
+ && velo >= data.startVelo[ch]
+ && velo < data.endVelo[ch]) {
+ event.setChannel(ch);
+ int p = pitch;
+ int v = velo;
+ p += data.pitchOffset[ch];
+ if (p > 127)
+ p = 127;
+ else if (p < 0)
+ p = 0;
+ v += data.veloOffset[ch];
+ if (v > 127)
+ v = 127;
+ else if (v < 0)
+ v = 0;
+ event.setA(p);
+ event.setB(v);
+ ol->insert(event);
+ notes[pitch] |= (1 << ch);
+ }
+ }
}
- for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
- MidiEvent event(*i);
- if (pitch >= data.startPitch[ch] && pitch < data.endPitch[ch]) {
- event.setChannel(ch);
- pitch += data.pitchOffset[ch];
- if (pitch > 127)
- pitch = 127;
- else if (pitch < 0)
- pitch = 0;
- event.setA(pitch);
- ol->insert(event);
+ else {
+ for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
+ if (notes[pitch] & (1 << ch)) {
+ MidiEvent event(*i);
+ event.setChannel(ch);
+ ol->insert(event);
+ }
}
+ notes[pitch] = 0;
}
}
}
diff --git a/muse/midiplugins/splitlayer/splitlayer.h b/muse/midiplugins/splitlayer/splitlayer.h
index cc548a5b..7c213c01 100644
--- a/muse/midiplugins/splitlayer/splitlayer.h
+++ b/muse/midiplugins/splitlayer/splitlayer.h
@@ -38,8 +38,9 @@ class SplitLayer : public Mempi {
int startPitch[MIDI_CHANNELS];
int endPitch[MIDI_CHANNELS];
int pitchOffset[MIDI_CHANNELS];
+ int veloOffset[MIDI_CHANNELS];
} data;
-
+ int notes[128]; // bitmapped note-on/channel values
bool learnMode;
int learnChannel;
bool learnStartPitch;
diff --git a/muse/midiplugins/splitlayer/splitlayergui.cpp b/muse/midiplugins/splitlayer/splitlayergui.cpp
index c6578736..e3620f71 100644
--- a/muse/midiplugins/splitlayer/splitlayergui.cpp
+++ b/muse/midiplugins/splitlayer/splitlayergui.cpp
@@ -36,9 +36,15 @@ SplitLayerGui::SplitLayerGui(SplitLayer* f, QWidget* parent)
QSignalMapper* m1 = new QSignalMapper(this);
QSignalMapper* m2 = new QSignalMapper(this);
QSignalMapper* m3 = new QSignalMapper(this);
+ QSignalMapper* m4 = new QSignalMapper(this);
+ QSignalMapper* m5 = new QSignalMapper(this);
+ QSignalMapper* m6 = new QSignalMapper(this);
connect(m1, SIGNAL(mapped(int)), SLOT(startPitchChanged(int)));
connect(m2, SIGNAL(mapped(int)), SLOT(endPitchChanged(int)));
connect(m3, SIGNAL(mapped(int)), SLOT(pitchOffsetChanged(int)));
+ connect(m4, SIGNAL(mapped(int)), SLOT(startVeloChanged(int)));
+ connect(m5, SIGNAL(mapped(int)), SLOT(endVeloChanged(int)));
+ connect(m6, SIGNAL(mapped(int)), SLOT(veloOffsetChanged(int)));
for (int i = 0; i < MIDI_CHANNELS; ++i) {
QLabel* l = new QLabel(QString("Ch %1").arg(i+1));
grid->addWidget(l, i, 0);
@@ -61,7 +67,7 @@ SplitLayerGui::SplitLayerGui(SplitLayer* f, QWidget* parent)
connect(rb1, SIGNAL(triggered(QAction*)), SLOT(learnStartPitch(QAction*)));
p2[i] = new Awl::PitchEdit(0);
- p1[i]->setToolTip(tr("end pitch for split"));
+ p2[i]->setToolTip(tr("end pitch for split"));
connect(p2[i], SIGNAL(valueChanged(int)), m2, SLOT(map()));
m2->setMapping(p2[i], i);
@@ -75,16 +81,37 @@ SplitLayerGui::SplitLayerGui(SplitLayer* f, QWidget* parent)
connect(rb2, SIGNAL(triggered(QAction*)), SLOT(learnEndPitch(QAction*)));
p3[i] = new Awl::PitchEdit(0);
- p1[i]->setToolTip(tr("pitch offset for split"));
+ p3[i]->setToolTip(tr("pitch offset for split"));
p3[i]->setDeltaMode(true);
connect(p3[i], SIGNAL(valueChanged(int)), m3, SLOT(map()));
m3->setMapping(p3[i], i);
+ p4[i] = new QSpinBox;
+ p4[i]->setRange(0, 127);
+ p4[i]->setToolTip(tr("start velocity for split"));
+ connect(p4[i], SIGNAL(valueChanged(int)), m4, SLOT(map()));
+ m4->setMapping(p4[i], i);
+
+ p5[i] = new QSpinBox;
+ p5[i]->setRange(0, 127);
+ p5[i]->setToolTip(tr("end velocity for split"));
+ connect(p5[i], SIGNAL(valueChanged(int)), m5, SLOT(map()));
+ m5->setMapping(p5[i], i);
+
+ p6[i] = new QSpinBox;
+ p6[i]->setRange(-127, 127);
+ p6[i]->setToolTip(tr("velocity offset for split"));
+ connect(p6[i], SIGNAL(valueChanged(int)), m6, SLOT(map()));
+ m6->setMapping(p6[i], i);
+
grid->addWidget(p1[i], i, 1);
- grid->addWidget(rb1, i, 2);
+ grid->addWidget(rb1, i, 2);
grid->addWidget(p2[i], i, 3);
- grid->addWidget(rb2, i, 4);
+ grid->addWidget(rb2, i, 4);
grid->addWidget(p3[i], i, 5);
+ grid->addWidget(p4[i], i, 6);
+ grid->addWidget(p5[i], i, 7);
+ grid->addWidget(p6[i], i, 8);
}
int filedes[2]; // 0 - reading 1 - writing
if (pipe(filedes) == -1) {
@@ -110,11 +137,14 @@ void SplitLayerGui::init()
p1[i]->setValue(sl->data.startPitch[i]);
p2[i]->setValue(sl->data.endPitch[i]);
p3[i]->setValue(sl->data.pitchOffset[i]);
+ p4[i]->setValue(sl->data.startVelo[i]);
+ p5[i]->setValue(sl->data.endVelo[i]);
+ p6[i]->setValue(sl->data.veloOffset[i]);
}
}
//---------------------------------------------------------
-// learStartPitch
+// learnStartPitch
//---------------------------------------------------------
void SplitLayerGui::learnStartPitch(QAction* a)
@@ -175,6 +205,33 @@ void SplitLayerGui::pitchOffsetChanged(int n)
}
//---------------------------------------------------------
+// startVeloChanged
+//---------------------------------------------------------
+
+void SplitLayerGui::startVeloChanged(int n)
+ {
+ sl->data.startVelo[n] = p4[n]->value();
+ }
+
+//---------------------------------------------------------
+// endVeloChanged
+//---------------------------------------------------------
+
+void SplitLayerGui::endVeloChanged(int n)
+ {
+ sl->data.endVelo[n] = p5[n]->value();
+ }
+
+//---------------------------------------------------------
+// veloOffsetChanged
+//---------------------------------------------------------
+
+void SplitLayerGui::veloOffsetChanged(int n)
+ {
+ sl->data.veloOffset[n] = p6[n]->value();
+ }
+
+//---------------------------------------------------------
// resetLearnMode
//---------------------------------------------------------
diff --git a/muse/midiplugins/splitlayer/splitlayergui.h b/muse/midiplugins/splitlayer/splitlayergui.h
index 2d10ec4b..4f2006ca 100644
--- a/muse/midiplugins/splitlayer/splitlayergui.h
+++ b/muse/midiplugins/splitlayer/splitlayergui.h
@@ -36,6 +36,10 @@ class SplitLayerGui : public QWidget {
Awl::PitchEdit* p1[16];
Awl::PitchEdit* p2[16];
Awl::PitchEdit* p3[16];
+ QSpinBox* p4[16];
+ QSpinBox* p5[16];
+ QSpinBox* p6[16];
+
QAction* a1[16];
QAction* a2[16];
int fd1, fd2;
@@ -47,6 +51,9 @@ class SplitLayerGui : public QWidget {
void endPitchChanged(int);
void pitchOffsetChanged(int);
void resetLearnMode(int);
+ void startVeloChanged(int);
+ void endVeloChanged(int);
+ void veloOffsetChanged(int);
public:
SplitLayerGui(SplitLayer*, QWidget* parent=0);