summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim E. Real <terminator356@users.sourceforge.net>2013-09-01 21:18:19 -0400
committerTim E. Real <terminator356@users.sourceforge.net>2013-09-01 21:18:19 -0400
commit9d08fbdd3ee0e41dd6d13206a31043b72684ada4 (patch)
tree1c277a8f2969d781018983b73670b848fedfd6b4
parent0fcaab02e0958d5d10957954f23caed7548e1568 (diff)
Midi Input Transformator plugin mods/fixes:
Fixed bugs loading procVal2Op from song. New! Added 'Program' event type + 'Toggle' processing Value#2 operation.
-rw-r--r--muse2/ChangeLog9
-rw-r--r--muse2/muse/miditransform.cpp28
-rw-r--r--muse2/muse/miditransform.h17
-rw-r--r--muse2/muse/mplugins/midiitransform.cpp59
-rw-r--r--muse2/muse/mplugins/midiitransform.h1
-rw-r--r--muse2/muse/widgets/itransformbase.ui15
6 files changed, 120 insertions, 9 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index 37efb381..4eaf5f1c 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,12 @@
+01.09.2013:
+ - Mods/fixes to Midi Input Transformator plugin: (Tim)
+ Fixed some bugs when reading procVal2Op from song.
+ 'Program' is now allowed 'Event type' selection.
+ 'Toggle' is a new Processing Value#2 Operation. It toggles between Value#1 and Value#2.
+ This means for example a standard midi foot controller (which only sends program changes)
+ can now be used to send TOGGLED midi CC values, say back to an effects unit
+ thus the foot controller becomes like regular 'chained' stomp boxes, operating
+ upon individual effects.
14.05.2013:
- When midi in is enabled in drum editor the selected track is moved along with
the triggered key (rj)
diff --git a/muse2/muse/miditransform.cpp b/muse2/muse/miditransform.cpp
index 247fdaf8..f9289dcc 100644
--- a/muse2/muse/miditransform.cpp
+++ b/muse2/muse/miditransform.cpp
@@ -45,7 +45,7 @@ namespace MusECore {
//
// Order of events:
-// Note, Poly Pressure, Control, AfterTouch, Pitch Bend, NRPN, RPN
+// Note, Poly Pressure, Control, AfterTouch, Pitch Bend, NRPN, RPN, Program
//
#define MIDITRANSFORM_NOTE 0
#define MIDITRANSFORM_POLY 1
@@ -54,11 +54,12 @@ namespace MusECore {
#define MIDITRANSFORM_PITCHBEND 4
#define MIDITRANSFORM_NRPN 5
#define MIDITRANSFORM_RPN 6
+#define MIDITRANSFORM_PROGRAM 7
static int eventTypeTable[] = {
MIDITRANSFORM_NOTE, MIDITRANSFORM_POLY, MIDITRANSFORM_CTRL, MIDITRANSFORM_ATOUCH,
- MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN
+ MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN, MIDITRANSFORM_PROGRAM
};
static int procVal2Map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11 };
@@ -543,6 +544,8 @@ void MidiTransformerDialog::transformEvent(MusECore::Event& event, MusECore::Mid
val = cmt->procVal1a;
}
break;
+ default:
+ break;
}
if (val < 0)
val = 0;
@@ -596,6 +599,7 @@ void MidiTransformerDialog::transformEvent(MusECore::Event& event, MusECore::Mid
case MusECore::ScaleMap:
case MusECore::Keep:
case MusECore::Flip:
+ case MusECore::Toggle:
break;
}
if (val < 0)
@@ -632,6 +636,7 @@ void MidiTransformerDialog::transformEvent(MusECore::Event& event, MusECore::Mid
case MusECore::Keep:
case MusECore::Flip:
case MusECore::Value:
+ case MusECore::Toggle:
break;
}
if (len < 0)
@@ -664,6 +669,7 @@ void MidiTransformerDialog::transformEvent(MusECore::Event& event, MusECore::Mid
case MusECore::Keep:
case MusECore::Flip:
case MusECore::Value:
+ case MusECore::Toggle:
break;
}
if (pos < 0)
@@ -1196,6 +1202,8 @@ void MidiTransformerDialog::procVal1OpSel(int val)
procVal1a->setEnabled(true);
procVal1b->setEnabled(true);
break;
+ default:
+ break;
}
procVal1aChanged(data->cmt->procVal1a);
procVal1bChanged(data->cmt->procVal1b);
@@ -1209,7 +1217,15 @@ void MidiTransformerDialog::procVal2OpSel(int val)
{
MusECore::TransformOperator op = MusECore::TransformOperator(MusECore::procVal2Map[val]);
data->cmt->procVal2 = op;
+ procVal2OpUpdate(op);
+ }
+
+//---------------------------------------------------------
+// procVal2OpUpdate
+//---------------------------------------------------------
+void MidiTransformerDialog::procVal2OpUpdate(MusECore::TransformOperator op)
+ {
switch (op) {
case MusECore::Keep:
case MusECore::Invert:
@@ -1756,6 +1772,14 @@ bool MidiTransformerDialog::typesMatch(MusECore::Event& e, unsigned selType)
matched = (c == MusECore::MidiController::RPN);
}
}
+ case MIDITRANSFORM_PROGRAM:
+ {
+ if (e.type() == MusECore::Controller) {
+ MusECore::MidiController::ControllerType c = MusECore::midiControllerType(e.dataA());
+ matched = (c == MusECore::MidiController::Program);
+ }
+ break;
+ }
default:
fprintf(stderr, "Error matching type in MidiTransformerDialog: unknown eventtype!\n");
break;
diff --git a/muse2/muse/miditransform.h b/muse2/muse/miditransform.h
index 2ed366bf..e8022277 100644
--- a/muse2/muse/miditransform.h
+++ b/muse2/muse/miditransform.h
@@ -49,7 +49,21 @@ enum TransformFunction {
enum TransformOperator {
Keep, Plus, Minus, Multiply, Divide, Fix, Value, Invert,
- ScaleMap, Flip, Dynamic, Random
+ ScaleMap, Flip, Dynamic, Random, Toggle
+ };
+
+class TransformToggleState {
+ private:
+ bool _ctrlStates[128];
+
+ public:
+ TransformToggleState()
+ {
+ for(int i = 0; i < 128; ++i)
+ _ctrlStates[i] = false;
+ }
+ bool ctrlState(int ctl_num) { return _ctrlStates[ctl_num & 0x7f]; }
+ void setCtrlState(int ctl_num, bool state) { _ctrlStates[ctl_num & 0x7f] = state; }
};
extern void writeMidiTransforms(int level, Xml& xml);
@@ -92,6 +106,7 @@ class MidiTransformerDialog : public QDialog, public Ui::MidiTransformDialogBase
void procEventTypeSel(int);
void procVal1OpSel(int);
void procVal2OpSel(int);
+ void procVal2OpUpdate(MusECore::TransformOperator op);
void procLenOpSel(int);
void procPosOpSel(int);
void funcOpSel(int);
diff --git a/muse2/muse/mplugins/midiitransform.cpp b/muse2/muse/mplugins/midiitransform.cpp
index 4be99f9d..dea7ce8b 100644
--- a/muse2/muse/mplugins/midiitransform.cpp
+++ b/muse2/muse/mplugins/midiitransform.cpp
@@ -51,20 +51,21 @@
#define MIDITRANSFORM_PITCHBEND 4
#define MIDITRANSFORM_NRPN 5
#define MIDITRANSFORM_RPN 6
+#define MIDITRANSFORM_PROGRAM 7
namespace MusECore {
static int selTypeTable[] = {
MIDITRANSFORM_NOTE, MIDITRANSFORM_POLY, MIDITRANSFORM_CTRL, MIDITRANSFORM_ATOUCH,
- MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN
+ MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN, MIDITRANSFORM_PROGRAM
};
static int procTypeTable[] = {
MIDITRANSFORM_POLY, MIDITRANSFORM_CTRL, MIDITRANSFORM_ATOUCH,
- MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN
+ MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN, MIDITRANSFORM_PROGRAM
};
-static int procVal2Map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11 };
+static int procVal2Map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12 };
struct TDict {
TransformFunction id;
@@ -86,6 +87,8 @@ class MidiInputTransformation {
QString name;
QString comment;
+ MusECore::TransformToggleState toggleState;
+
ValOp selEventOp;
int selType;
@@ -145,7 +148,7 @@ class MidiInputTransformation {
procChannelb = 0;
}
void write(int level, Xml& xml) const;
- int apply(MidiRecordEvent& ev) const;
+ int apply(MidiRecordEvent& ev);
bool typesMatch(MidiRecordEvent& e, int selType) const;
};
@@ -234,7 +237,7 @@ static bool filterValOp(ValOp op, int val, int val1, int val2)
// 2 - event changed
//---------------------------------------------------------
-int MidiInputTransformation::apply(MidiRecordEvent& event) const
+int MidiInputTransformation::apply(MidiRecordEvent& event)
{
int t = event.type();
@@ -312,6 +315,9 @@ int MidiInputTransformation::apply(MidiRecordEvent& event) const
event.setType(ME_CONTROLLER);
}
break;
+ case MIDITRANSFORM_PROGRAM:
+ event.setType(ME_PROGRAM);
+ break;
default:
break;
}
@@ -366,6 +372,8 @@ int MidiInputTransformation::apply(MidiRecordEvent& event) const
val = procVal1a;
}
break;
+ default:
+ break;
}
if (val < 0)
val = 0;
@@ -414,6 +422,28 @@ int MidiInputTransformation::apply(MidiRecordEvent& event) const
val = procVal2a;
}
break;
+ case Toggle:
+ {
+ if(event.type() == ME_CONTROLLER)
+ {
+ int num = event.dataA();
+ bool state = toggleState.ctrlState(num);
+ if(state)
+ {
+ state = false;
+ val = procVal2a;
+ }
+ else
+ {
+ state = true;
+ val = procVal2b;
+ }
+ toggleState.setCtrlState(num, state);
+ }
+ else
+ printf("toggle implemented only for controllers\n");
+ }
+ break;
case ScaleMap:
case Keep:
case Flip:
@@ -469,6 +499,7 @@ int MidiInputTransformation::apply(MidiRecordEvent& event) const
case ScaleMap:
case Keep:
case Flip:
+ case Toggle:
break;
}
if (val < 0)
@@ -521,6 +552,7 @@ int MidiInputTransformation::apply(MidiRecordEvent& event) const
case ScaleMap:
case Keep:
case Flip:
+ case Toggle:
break;
}
if (val < 0)
@@ -578,6 +610,9 @@ bool MidiInputTransformation::typesMatch(MidiRecordEvent& e, int selType) const
}
}
break;
+ case MIDITRANSFORM_PROGRAM:
+ matched = (t == ME_PROGRAM);
+ break;
default:
fprintf(stderr, "Error matching type in MidiTransformerDialog: unknown eventtype!\n");
break;
@@ -1116,6 +1151,7 @@ void MidiInputTransformDialog::procVal1OpSel(int val)
case MusECore::Random:
case MusECore::ScaleMap:
case MusECore::Dynamic:
+ case MusECore::Toggle:
procVal1a->setDecimals(0);
procVal1a->setEnabled(true);
procVal1b->setEnabled(true);
@@ -1133,7 +1169,15 @@ void MidiInputTransformDialog::procVal2OpSel(int val)
{
MusECore::TransformOperator op = MusECore::TransformOperator(MusECore::procVal2Map[val]);
cmt->procVal2 = op;
+ procVal2OpUpdate(op);
+ }
+//---------------------------------------------------------
+// procVal2OpUpdate
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal2OpUpdate(MusECore::TransformOperator op)
+ {
switch (op) {
case MusECore::Keep:
case MusECore::Invert:
@@ -1156,6 +1200,7 @@ void MidiInputTransformDialog::procVal2OpSel(int val)
break;
case MusECore::Random:
case MusECore::Dynamic:
+ case MusECore::Toggle:
procVal2a->setDecimals(0);
procVal2a->setEnabled(true);
procVal2b->setEnabled(true);
@@ -1192,7 +1237,7 @@ void MidiInputTransformDialog::funcOpSel(int val)
if (isFuncOp) {
procEventOpSel(cmt->procEvent);
procVal1OpSel(cmt->procVal1);
- procVal2OpSel(cmt->procVal2);
+ procVal2OpUpdate(cmt->procVal2);
procPortOpSel(cmt->procPort);
procChannelOpSel(cmt->procChannel);
}
@@ -1507,6 +1552,7 @@ void MidiInputTransformDialog::procPortOpSel(int val)
case MusECore::Random:
case MusECore::ScaleMap:
case MusECore::Dynamic:
+ case MusECore::Toggle:
procPortVala->setDecimals(0);
procPortVala->setEnabled(true);
procPortValb->setEnabled(true);
@@ -1563,6 +1609,7 @@ void MidiInputTransformDialog::procChannelOpSel(int val)
case MusECore::Random:
case MusECore::ScaleMap:
case MusECore::Dynamic:
+ case MusECore::Toggle:
procChannelVala->setDecimals(0);
procChannelVala->setEnabled(true);
procChannelValb->setEnabled(true);
diff --git a/muse2/muse/mplugins/midiitransform.h b/muse2/muse/mplugins/midiitransform.h
index 30dabd13..b183bc53 100644
--- a/muse2/muse/mplugins/midiitransform.h
+++ b/muse2/muse/mplugins/midiitransform.h
@@ -84,6 +84,7 @@ class MidiInputTransformDialog : public QDialog, public Ui::MidiInputTransformDi
void procEventTypeSel(int);
void procVal1OpSel(int);
void procVal2OpSel(int);
+ void procVal2OpUpdate(MusECore::TransformOperator op);
void funcOpSel(int);
void presetChanged(QListWidgetItem*);
void nameChanged(const QString&);
diff --git a/muse2/muse/widgets/itransformbase.ui b/muse2/muse/widgets/itransformbase.ui
index 52c29a7e..882f383f 100644
--- a/muse2/muse/widgets/itransformbase.ui
+++ b/muse2/muse/widgets/itransformbase.ui
@@ -94,6 +94,11 @@
<string>RPN</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>Program</string>
+ </property>
+ </item>
</widget>
</item>
<item row="0" column="2">
@@ -432,6 +437,11 @@
<string>RPN</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>Program</string>
+ </property>
+ </item>
</widget>
</item>
<item row="1" column="1">
@@ -615,6 +625,11 @@
<string>Random</string>
</property>
</item>
+ <item>
+ <property name="text">
+ <string>Toggle</string>
+ </property>
+ </item>
</widget>
</item>
<item row="1" column="4">