* [PATCH] us428control support for mixxx
@ 2006-09-30 16:06 CTAF ctaf
2006-10-04 16:16 ` Takashi Iwai
0 siblings, 1 reply; 7+ messages in thread
From: CTAF ctaf @ 2006-09-30 16:06 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 284 bytes --]
This patch allow to change the mapping of the us428, the new mapping is used
with mixxx.
To use the new mapping:
./us428control -m mixxx
I already posted an older version on the bug tracker, but I had'nt have
response for it.
thanks.
Signed-off-by: Cedric GESTES <goctaf@gmail.com>
[-- Attachment #1.2: Type: text/html, Size: 363 bytes --]
[-- Attachment #2: us428control-mixxx-v3.patch --]
[-- Type: text/x-patch, Size: 18216 bytes --]
diff -r 7f7a0bf510a4 us428control/Cus428Midi.h
--- a/us428control/Cus428Midi.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428Midi.h Sat Sep 30 18:05:42 2006 +0200
@@ -87,14 +87,23 @@ class Cus428Midi {
return Err;
}
- int SendMidiControl(char Param, char Val){
- snd_seq_ev_set_controller(&Ev, 15, Param, Val & 0x7F);
+ int SendMidiControl(char Channel, char Param, char Val){
+ snd_seq_ev_set_controller(&Ev, Channel, Param, Val & 0x7F);
SubMitEvent();
return 0;
- }
+ }
- int SendMidiControl(Cus428State::eKnobs K, bool Down){
- return SendMidiControl(KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
+ int SendMidiNote(char Channel, char Note, char Val){
+ if (!Val)
+ snd_seq_ev_set_noteoff(&Ev, Channel, Note, Val & 0x7F);
+ else
+ snd_seq_ev_set_noteon(&Ev, Channel, Note, Val & 0x7F);
+ SubMitEvent();
+ return 0;
+ }
+
+ int SendMidiControl(char Channel, Cus428State::eKnobs K, bool Down){
+ return SendMidiControl(Channel, KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
}
// To parse and dispatch input MIDI events.
diff -r 7f7a0bf510a4 us428control/Cus428State.cc
--- a/us428control/Cus428State.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428State.cc Sat Sep 30 18:05:42 2006 +0200
@@ -46,7 +46,6 @@ void Cus428State::InitDevice(void)
SliderChangedTo(eFaderM, ((unsigned char*)(us428ctls_sharedmem->CtlSnapShot + us428ctls_sharedmem->CtlSnapShotLast))[eFaderM]);
}
-
int Cus428State::LightSend()
{
int Next = us428ctls_sharedmem->p4outLast + 1;
@@ -57,6 +56,11 @@ int Cus428State::LightSend()
return us428ctls_sharedmem->p4outLast = Next;
}
+void Cus428State::SliderSend(int S)
+{
+ Midi.SendMidiControl(15, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
+}
+
void Cus428State::SendVolume(usX2Y_volume &V)
{
int Next = us428ctls_sharedmem->p4outLast + 1;
@@ -67,22 +71,100 @@ void Cus428State::SendVolume(usX2Y_volum
us428ctls_sharedmem->p4outLast = Next;
}
+void Cus428State::UserSliderChangedTo(int S, unsigned char New)
+{
+ SliderSend(S);
+}
+
void Cus428State::SliderChangedTo(int S, unsigned char New)
{
- if (StateInputMonitor() && S <= eFader3
- || S == eFaderM) {
+ if (StateInputMonitor() && S <= eFader3 || S == eFaderM) {
usX2Y_volume &V = Volume[S >= eFader4 ? eFader4 : S];
V.SetTo(S, New);
if (S == eFaderM || !LightIs(eL_Mute0 + S))
SendVolume(V);
}
- else SliderSend(S);
-}
-
-void Cus428State::SliderSend(int S)
-{
- Midi.SendMidiControl(0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
-}
+ else
+ UserSliderChangedTo(S, New);
+}
+
+void Cus428State::UserKnobChangedTo(eKnobs K, bool V)
+{
+ switch (K) {
+ case eK_STOP:
+ if (verbose > 1)
+ printf("Knob STOP now %i\n", V);
+ if (V) TransportToggle(T_STOP);
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_PLAY:
+ if (verbose > 1)
+ printf("Knob PLAY now %i", V);
+ if (V) TransportToggle(T_PLAY);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Play));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_REW:
+ if (verbose > 1)
+ printf("Knob REW now %i", V);
+ if (V) TransportToggle(T_REW);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Rew));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_FFWD:
+ if (verbose > 1)
+ printf("Knob FFWD now %i", V);
+ if (V) TransportToggle(T_F_FWD);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_FFwd));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_RECORD:
+ if (verbose > 1)
+ printf("Knob RECORD now %i", V);
+ if (V) TransportToggle(T_RECORD);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Record));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_SET:
+ if (verbose > 1)
+ printf("Knob SET now %i", V);
+ bSetLocate = V;
+ break;
+ case eK_LOCATE_L:
+ if (verbose > 1)
+ printf("Knob LOCATE_L now %i", V);
+ if (V) {
+ if (bSetLocate)
+ aWheel_L = aWheel;
+ else {
+ aWheel = aWheel_L;
+ LocateSend();
+ }
+ }
+ break;
+ case eK_LOCATE_R:
+ if (verbose > 1)
+ printf("Knob LOCATE_R now %i", V);
+ if (V) {
+ if (bSetLocate)
+ aWheel_R = aWheel;
+ else {
+ aWheel = aWheel_R;
+ LocateSend();
+ }
+ }
+ break;
+ default:
+ if (verbose > 1)
+ printf("Knob %i now %i\n", K, V);
+ Midi.SendMidiControl(15, K, V);
+ }
+}
+
void Cus428State::KnobChangedTo(eKnobs K, bool V)
{
@@ -109,121 +191,36 @@ void Cus428State::KnobChangedTo(eKnobs K
}
break;
default:
- switch (K) {
- case eK_STOP:
- if (verbose > 1)
- printf("Knob STOP now %i\n", V);
- if (V) TransportToggle(T_STOP);
- Midi.SendMidiControl(K, V);
- break;
- case eK_PLAY:
- if (verbose > 1)
- printf("Knob PLAY now %i", V);
- if (V) TransportToggle(T_PLAY);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Play));
- Midi.SendMidiControl(K, V);
- break;
- case eK_REW:
- if (verbose > 1)
- printf("Knob REW now %i", V);
- if (V) TransportToggle(T_REW);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Rew));
- Midi.SendMidiControl(K, V);
- break;
- case eK_FFWD:
- if (verbose > 1)
- printf("Knob FFWD now %i", V);
- if (V) TransportToggle(T_F_FWD);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_FFwd));
- Midi.SendMidiControl(K, V);
- break;
- case eK_RECORD:
- if (verbose > 1)
- printf("Knob RECORD now %i", V);
- if (V) TransportToggle(T_RECORD);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Record));
- Midi.SendMidiControl(K, V);
- break;
- case eK_SET:
- if (verbose > 1)
- printf("Knob SET now %i", V);
- bSetLocate = V;
- break;
- case eK_LOCATE_L:
- if (verbose > 1)
- printf("Knob LOCATE_L now %i", V);
- if (V) {
- if (bSetLocate)
- aWheel_L = aWheel;
- else {
- aWheel = aWheel_L;
- LocateSend();
- }
- }
- break;
- case eK_LOCATE_R:
- if (verbose > 1)
- printf("Knob LOCATE_R now %i", V);
- if (V) {
- if (bSetLocate)
- aWheel_R = aWheel;
- else {
- aWheel = aWheel_R;
- LocateSend();
- }
- }
- break;
- case eK_InputMonitor:
- if (verbose > 1)
- printf("Knob InputMonitor now %i", V);
- if (V) {
- if (StateInputMonitor()) {
- SelectInputMonitor = Light[0].Value;
- MuteInputMonitor = Light[2].Value;
- } else {
- Select = Light[0].Value;
- Mute = Light[2].Value;
- }
- LightSet(eL_InputMonitor, ! StateInputMonitor());
- Light[0].Value = StateInputMonitor() ? SelectInputMonitor : Select;
- Light[2].Value = StateInputMonitor() ? MuteInputMonitor : Mute;
- LightSend();
- }
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_InputMonitor));
- break;
- default:
- if (verbose > 1)
- printf("Knob %i now %i\n", K, V);
- Midi.SendMidiControl(K, V);
- }
+ if (K == eK_InputMonitor)
+ {
+ if (verbose > 1)
+ printf("Knob InputMonitor now %i", V);
+ if (V) {
+ if (StateInputMonitor()) {
+ SelectInputMonitor = Light[0].Value;
+ MuteInputMonitor = Light[2].Value;
+ } else {
+ Select = Light[0].Value;
+ Mute = Light[2].Value;
+ }
+ LightSet(eL_InputMonitor, ! StateInputMonitor());
+ Light[0].Value = StateInputMonitor() ? SelectInputMonitor : Select;
+ Light[2].Value = StateInputMonitor() ? MuteInputMonitor : Mute;
+ LightSend();
+ }
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_InputMonitor));
+ }
+ else
+ UserKnobChangedTo(K, V);
}
}
-
-void Cus428State::WheelChangedTo(E_In84 W, char Diff)
+void Cus428State::UserWheelChangedTo(E_In84 W, char Diff)
{
char Param;
switch (W) {
case eWheelPan:
- if (StateInputMonitor() && Light[0].Value) {
- int index = 0;
-
- while( index < 4 && (1 << index) != Light[0].Value)
- index++;
-
- if (index >= 4)
- return;
-
- Volume[index].PanTo(Diff, us428_ctls->Knob(eK_SET));
- if (!LightIs(eL_Mute0 + index))
- SendVolume(Volume[index]);
- return;
- }
Param = 0x4D;
break;
case eWheelGain:
@@ -241,7 +238,27 @@ void Cus428State::WheelChangedTo(E_In84
WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
break;
}
- Midi.SendMidiControl(Param, ((unsigned char *) us428_ctls)[W]);
+ Midi.SendMidiControl(15, Param, ((unsigned char *) us428_ctls)[W]);
+}
+
+void Cus428State::WheelChangedTo(E_In84 W, char Diff)
+{
+ if (W == eWheelPan && StateInputMonitor() && Light[0].Value)
+ {
+ int index = 0;
+
+ while( index < 4 && (1 << index) != Light[0].Value)
+ index++;
+
+ if (index >= 4)
+ return;
+
+ Volume[index].PanTo(Diff, us428_ctls->Knob(eK_SET));
+ if (!LightIs(eL_Mute0 + index))
+ SendVolume(Volume[index]);
+ return;
+ }
+ UserWheelChangedTo(W, Diff);
}
@@ -444,3 +461,174 @@ void Cus428State::MmcReset()
LocateSend();
}
+Cus428StateMixxx::Cus428StateMixxx(struct us428ctls_sharedmem* Pus428ctls_sharedmem):Cus428State(Pus428ctls_sharedmem)
+{
+ focus = 0;
+ eq = 0;
+ LightSet(eL_Low, 1);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+}
+
+void Cus428StateMixxx::UserKnobChangedTo(eKnobs K, bool V)
+{
+ switch (K) {
+ case eK_BANK_L:
+ if (verbose > 1)
+ printf("Knob BANK_L now %i", V);
+ if (V) LightSet(eL_BankL, !LightIs(eL_BankL));
+ LightSend();
+ Midi.SendMidiNote(0, 51, V ? 127 : 0);
+ break;
+ case eK_BANK_R:
+ if (verbose > 1)
+ printf("Knob BANK_R now %i", V);
+ if (V) LightSet(eL_BankR, !LightIs(eL_BankR));
+ LightSend();
+ Midi.SendMidiNote(1, 51, V ? 127 : 0);
+ break;
+ case eK_REW:
+ if (verbose > 1)
+ printf("Knob REW now %i", V);
+ Midi.SendMidiNote(focus, 60, V ? 127 : 0);
+ break;
+ case eK_FFWD:
+ if (verbose > 1)
+ printf("Knob FFWD now %i", V);
+ Midi.SendMidiNote(focus, 61, V ? 127 : 0);
+ break;
+ case eK_STOP:
+ if (verbose > 1)
+ printf("Knob STOP now %i\n", V);
+ Midi.SendMidiNote(focus, 62, V ? 127 : 0);
+ break;
+ case eK_PLAY:
+ if (verbose > 1)
+ printf("Knob PLAY now %i", V);
+ Midi.SendMidiNote(focus, 63, V ? 127 : 0);
+ break;
+ case eK_RECORD:
+ if (verbose > 1)
+ printf("Knob RECORD now %i", V);
+ Midi.SendMidiNote(focus, 64, V ? 127 : 0);
+ break;
+ case eK_LOW:
+ if (verbose > 1)
+ printf("Knob LOW now %i", V);
+ if (V)
+ {
+ eq = 0;
+ LightSet(eL_Low, 1);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_LOWMID:
+ if (verbose > 1)
+ printf("Knob LOWMID now %i", V);
+ if (V)
+ {
+ eq = 1;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 1);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_HIMID:
+ if (verbose > 1)
+ printf("Knob HIMID now %i", V);
+ if (V)
+ {
+ eq = 2;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 1);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_HIGH:
+ if (verbose > 1)
+ printf("Knob HIGH now %i", V);
+ if (V)
+ {
+ eq = 3;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 1);
+ LightSend();
+ }
+ break;
+ case eK_SET:
+ if (verbose > 1)
+ printf("Knob SET now %i", V);
+ Midi.SendMidiNote(focus, 65, V ? 127 : 0);
+ break;
+ case eK_LOCATE_L:
+ if (verbose > 1)
+ printf("Knob LOCATE_L now %i", V);
+ if (V) {
+ focus = 0;
+ }
+ break;
+ case eK_LOCATE_R:
+ if (verbose > 1)
+ printf("Knob LOCATE_R now %i", V);
+ if (V) {
+ focus = 1;
+ }
+ break;
+ default:
+ if (verbose > 1)
+ printf("Knob %i now %i\n", K, V);
+ Midi.SendMidiNote(0, K, V);
+ }
+}
+
+void Cus428StateMixxx::UserSliderChangedTo(int S, unsigned char New)
+{
+ // if (verbose > 1)
+ // printf("Slider : %d - %d - %d\n", S, New, ((unsigned char*)us428_ctls)[S]);
+ Midi.SendMidiControl(0, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
+}
+
+void Cus428StateMixxx::UserWheelChangedTo(E_In84 W, char Diff)
+{
+ char Param;
+ char Value;
+ char Channel;
+ //if (verbose > 1)
+ // printf("Slider : %d - %d - %d\n", W, Diff, ((unsigned char *) us428_ctls)[W]);
+
+ Channel = 0;
+ switch (W) {
+ case eWheelGain:
+ Param = 0x48 + eq * 4;
+ break;
+ case eWheelFreq:
+ Param = 0x49 + eq * 4;
+ break;
+ case eWheelQ:
+ Param = 0x4A + eq * 4;
+ break;
+ case eWheelPan:
+ Param = 0x4B + eq * 4;
+ break;
+ case eWheel:
+ Param = 0x60;
+ Channel = focus;
+ // Update the absolute wheel position.
+ //WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
+ break;
+ }
+ Value = 64 + Diff;
+ Midi.SendMidiControl(Channel, Param, Value);
+ // Midi.SendMidiControl(0, Param, ((unsigned char *) us428_ctls)[W]);
+}
diff -r 7f7a0bf510a4 us428control/Cus428State.h
--- a/us428control/Cus428State.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428State.h Sat Sep 30 18:05:42 2006 +0200
@@ -84,10 +84,15 @@ class Cus428State: public us428_lights{
eK_F3,
};
void InitDevice(void);
+
void KnobChangedTo(eKnobs K, bool V);
void SliderChangedTo(int S, unsigned char New);
+ void WheelChangedTo(E_In84 W, char Diff);
+ virtual void UserSliderChangedTo(int S, unsigned char New);
+ virtual void UserWheelChangedTo(E_In84 W, char Diff);
+ virtual void UserKnobChangedTo(eKnobs K, bool V);
+
void SliderSend(int S);
- void WheelChangedTo(E_In84 W, char Diff);
Cus428_ctls *Set_us428_ctls(Cus428_ctls *New) {
Cus428_ctls *Old = us428_ctls;
us428_ctls = New;
@@ -104,7 +109,7 @@ class Cus428State: public us428_lights{
void TransportSend();
// Reset internal MMC state.
void MmcReset();
- private:
+ protected:
void SendVolume(usX2Y_volume &V);
struct us428ctls_sharedmem* us428ctls_sharedmem;
bool StateInputMonitor() {
@@ -140,6 +145,18 @@ class Cus428State: public us428_lights{
int aWheelSpeed;
};
+
+class Cus428StateMixxx: public Cus428State{
+public:
+ Cus428StateMixxx(struct us428ctls_sharedmem* Pus428ctls_sharedmem);
+ void UserKnobChangedTo(eKnobs K, bool V);
+ void UserSliderChangedTo(int S, unsigned char New);
+ void UserWheelChangedTo(E_In84 W, char Diff);
+protected:
+ int focus;
+ int eq;
+};
+
extern Cus428State* OneState;
#endif
diff -r 7f7a0bf510a4 us428control/us428control.cc
--- a/us428control/us428control.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/us428control.cc Sat Sep 30 18:05:42 2006 +0200
@@ -61,7 +61,8 @@ static void usage(void)
{
printf("Tascam US-428 Control\n");
printf("version %s\n", VERSION);
- printf("usage: "PROGNAME" [-v verbosity_level 0..2] [-c card] [-D device] [-u usb-device]\n");
+ printf("usage: "PROGNAME" [-v verbosity_level 0..2] [-c card] [-D device] [-u usb-device] [-m mode]\n");
+ printf("mode is one of (native, mixxx)\n");
}
/*
* check the name id of the given hwdep handle
@@ -76,14 +77,14 @@ static int check_hwinfo(snd_hwdep_t *hw,
return err;
if (strcmp(snd_hwdep_info_get_id(info), id))
return -ENODEV;
- if (usb_dev_name)
+ if (usb_dev_name)
if (strcmp(snd_hwdep_info_get_name(info), usb_dev_name))
return -ENODEV;
return 0; /* ok */
}
-int US428Control(const char* DevName)
+int US428Control(const char* DevName, int mode)
{
snd_hwdep_t *hw;
int err;
@@ -117,7 +118,11 @@ int US428Control(const char* DevName)
return -ENOMEM;
}
us428ctls_sharedmem->CtlSnapShotRed = us428ctls_sharedmem->CtlSnapShotLast;
- OneState = new Cus428State(us428ctls_sharedmem);
+ if (mode == 1)
+ OneState = new Cus428StateMixxx(us428ctls_sharedmem);
+ else
+ OneState = new Cus428State(us428ctls_sharedmem);
+
OneState->InitDevice();
while ((pollrc = poll(pfds, npfd, 60000)) >= 0) {
@@ -152,12 +157,13 @@ int main (int argc, char *argv[])
int main (int argc, char *argv[])
{
int c;
+ int mode = 0;
int card = -1;
char *device_name = NULL,
*usb_device_name = getenv("DEVICE");
char name[64];
- while ((c = getopt(argc, argv, "c:D:u:v:")) != -1) {
+ while ((c = getopt(argc, argv, "c:D:u:v:m:")) != -1) {
switch (c) {
case 'c':
card = atoi(optarg);
@@ -171,6 +177,10 @@ int main (int argc, char *argv[])
case 'v':
verbose = atoi(optarg);
break;
+ case 'm':
+ if (!strcmp(optarg, "mixxx"))
+ mode = 1;
+ break;
default:
usage();
return 1;
@@ -190,18 +200,18 @@ int main (int argc, char *argv[])
}
}
if (device_name) {
- return US428Control(device_name) != 0;
+ return US428Control(device_name, mode) != 0;
}
if (card >= 0) {
sprintf(name, "hw:%d", card);
- return US428Control(name) != 0;
+ return US428Control(name, mode) != 0;
}
/* probe the all cards */
for (c = 0; c < SND_CARDS; c++) {
// verbose--;
sprintf(name, "hw:%d", c);
- if (! US428Control(name))
+ if (!US428Control(name, mode))
card = c;
}
if (card < 0) {
diff -r 7f7a0bf510a4 us428control/usbus428ctldefs.h
--- a/us428control/usbus428ctldefs.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/usbus428ctldefs.h Sat Sep 30 18:05:42 2006 +0200
@@ -64,7 +64,7 @@ struct us428_ctls{
unsigned char Select;
unsigned char Mute;
unsigned char UNKNOWN;
- unsigned char Switch;
+ unsigned char Switch;
unsigned char Wheel[5];
};
@@ -119,7 +119,7 @@ typedef struct usX2Y_volume {
if (Grob) {
static int GrobVals[] = {-128, -64, 0, 64, 127};
int i = 4;
- while (i >= 0 && GrobVals[i] > Pan)
+ while (i >= 0 && GrobVals[i] > Pan)
i--;
if (GrobVals[i] != Pan && RawValue < 0)
i++;
@@ -158,7 +158,12 @@ struct us428_lights{
eL_FFwd = 29,
eL_Play = 30,
eL_Record = 31,
- eL_Null
+ eL_AnalogDigital = 32,
+ eL_Null = 34,
+ eL_Low = 36,
+ eL_LowMid = 37,
+ eL_HiMid = 38,
+ eL_High = 39
};
bool LightIs(int L){
return Light[L / 8].Value & (1 << (L % 8));
[-- Attachment #3: Type: text/plain, Size: 348 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 161 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] us428control support for mixxx
@ 2006-10-01 8:20 GESTES Cedric
0 siblings, 0 replies; 7+ messages in thread
From: GESTES Cedric @ 2006-10-01 8:20 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
This patch allow to change the midi mapping of the us428, the new
mapping is used with mixxx.
To use the new mapping:
./us428control -m mixxx
I have splitted the class who does the mapping, it is more easy to add
new mapping now.
Furthermore I need to find a way to communicate with the program, to
change mapping on the fly.
Cause currently us428control is launched from udev, and to change the
mapping you should kill the previous us428control and launch another.
I already posted an older version on the bug tracker, but I had'nt have
response for it. (with different addrese cause gmail bounce my mail to
sf.net)
thanks.
Signed-off-by: Cedric GESTES <ctaf.audio@laposte.net>
[-- Attachment #2: us428control-mixxx-v3.patch --]
[-- Type: text/x-patch, Size: 18216 bytes --]
diff -r 7f7a0bf510a4 us428control/Cus428Midi.h
--- a/us428control/Cus428Midi.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428Midi.h Sat Sep 30 18:05:42 2006 +0200
@@ -87,14 +87,23 @@ class Cus428Midi {
return Err;
}
- int SendMidiControl(char Param, char Val){
- snd_seq_ev_set_controller(&Ev, 15, Param, Val & 0x7F);
+ int SendMidiControl(char Channel, char Param, char Val){
+ snd_seq_ev_set_controller(&Ev, Channel, Param, Val & 0x7F);
SubMitEvent();
return 0;
- }
+ }
- int SendMidiControl(Cus428State::eKnobs K, bool Down){
- return SendMidiControl(KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
+ int SendMidiNote(char Channel, char Note, char Val){
+ if (!Val)
+ snd_seq_ev_set_noteoff(&Ev, Channel, Note, Val & 0x7F);
+ else
+ snd_seq_ev_set_noteon(&Ev, Channel, Note, Val & 0x7F);
+ SubMitEvent();
+ return 0;
+ }
+
+ int SendMidiControl(char Channel, Cus428State::eKnobs K, bool Down){
+ return SendMidiControl(Channel, KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
}
// To parse and dispatch input MIDI events.
diff -r 7f7a0bf510a4 us428control/Cus428State.cc
--- a/us428control/Cus428State.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428State.cc Sat Sep 30 18:05:42 2006 +0200
@@ -46,7 +46,6 @@ void Cus428State::InitDevice(void)
SliderChangedTo(eFaderM, ((unsigned char*)(us428ctls_sharedmem->CtlSnapShot + us428ctls_sharedmem->CtlSnapShotLast))[eFaderM]);
}
-
int Cus428State::LightSend()
{
int Next = us428ctls_sharedmem->p4outLast + 1;
@@ -57,6 +56,11 @@ int Cus428State::LightSend()
return us428ctls_sharedmem->p4outLast = Next;
}
+void Cus428State::SliderSend(int S)
+{
+ Midi.SendMidiControl(15, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
+}
+
void Cus428State::SendVolume(usX2Y_volume &V)
{
int Next = us428ctls_sharedmem->p4outLast + 1;
@@ -67,22 +71,100 @@ void Cus428State::SendVolume(usX2Y_volum
us428ctls_sharedmem->p4outLast = Next;
}
+void Cus428State::UserSliderChangedTo(int S, unsigned char New)
+{
+ SliderSend(S);
+}
+
void Cus428State::SliderChangedTo(int S, unsigned char New)
{
- if (StateInputMonitor() && S <= eFader3
- || S == eFaderM) {
+ if (StateInputMonitor() && S <= eFader3 || S == eFaderM) {
usX2Y_volume &V = Volume[S >= eFader4 ? eFader4 : S];
V.SetTo(S, New);
if (S == eFaderM || !LightIs(eL_Mute0 + S))
SendVolume(V);
}
- else SliderSend(S);
-}
-
-void Cus428State::SliderSend(int S)
-{
- Midi.SendMidiControl(0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
-}
+ else
+ UserSliderChangedTo(S, New);
+}
+
+void Cus428State::UserKnobChangedTo(eKnobs K, bool V)
+{
+ switch (K) {
+ case eK_STOP:
+ if (verbose > 1)
+ printf("Knob STOP now %i\n", V);
+ if (V) TransportToggle(T_STOP);
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_PLAY:
+ if (verbose > 1)
+ printf("Knob PLAY now %i", V);
+ if (V) TransportToggle(T_PLAY);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Play));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_REW:
+ if (verbose > 1)
+ printf("Knob REW now %i", V);
+ if (V) TransportToggle(T_REW);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Rew));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_FFWD:
+ if (verbose > 1)
+ printf("Knob FFWD now %i", V);
+ if (V) TransportToggle(T_F_FWD);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_FFwd));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_RECORD:
+ if (verbose > 1)
+ printf("Knob RECORD now %i", V);
+ if (V) TransportToggle(T_RECORD);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Record));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_SET:
+ if (verbose > 1)
+ printf("Knob SET now %i", V);
+ bSetLocate = V;
+ break;
+ case eK_LOCATE_L:
+ if (verbose > 1)
+ printf("Knob LOCATE_L now %i", V);
+ if (V) {
+ if (bSetLocate)
+ aWheel_L = aWheel;
+ else {
+ aWheel = aWheel_L;
+ LocateSend();
+ }
+ }
+ break;
+ case eK_LOCATE_R:
+ if (verbose > 1)
+ printf("Knob LOCATE_R now %i", V);
+ if (V) {
+ if (bSetLocate)
+ aWheel_R = aWheel;
+ else {
+ aWheel = aWheel_R;
+ LocateSend();
+ }
+ }
+ break;
+ default:
+ if (verbose > 1)
+ printf("Knob %i now %i\n", K, V);
+ Midi.SendMidiControl(15, K, V);
+ }
+}
+
void Cus428State::KnobChangedTo(eKnobs K, bool V)
{
@@ -109,121 +191,36 @@ void Cus428State::KnobChangedTo(eKnobs K
}
break;
default:
- switch (K) {
- case eK_STOP:
- if (verbose > 1)
- printf("Knob STOP now %i\n", V);
- if (V) TransportToggle(T_STOP);
- Midi.SendMidiControl(K, V);
- break;
- case eK_PLAY:
- if (verbose > 1)
- printf("Knob PLAY now %i", V);
- if (V) TransportToggle(T_PLAY);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Play));
- Midi.SendMidiControl(K, V);
- break;
- case eK_REW:
- if (verbose > 1)
- printf("Knob REW now %i", V);
- if (V) TransportToggle(T_REW);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Rew));
- Midi.SendMidiControl(K, V);
- break;
- case eK_FFWD:
- if (verbose > 1)
- printf("Knob FFWD now %i", V);
- if (V) TransportToggle(T_F_FWD);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_FFwd));
- Midi.SendMidiControl(K, V);
- break;
- case eK_RECORD:
- if (verbose > 1)
- printf("Knob RECORD now %i", V);
- if (V) TransportToggle(T_RECORD);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Record));
- Midi.SendMidiControl(K, V);
- break;
- case eK_SET:
- if (verbose > 1)
- printf("Knob SET now %i", V);
- bSetLocate = V;
- break;
- case eK_LOCATE_L:
- if (verbose > 1)
- printf("Knob LOCATE_L now %i", V);
- if (V) {
- if (bSetLocate)
- aWheel_L = aWheel;
- else {
- aWheel = aWheel_L;
- LocateSend();
- }
- }
- break;
- case eK_LOCATE_R:
- if (verbose > 1)
- printf("Knob LOCATE_R now %i", V);
- if (V) {
- if (bSetLocate)
- aWheel_R = aWheel;
- else {
- aWheel = aWheel_R;
- LocateSend();
- }
- }
- break;
- case eK_InputMonitor:
- if (verbose > 1)
- printf("Knob InputMonitor now %i", V);
- if (V) {
- if (StateInputMonitor()) {
- SelectInputMonitor = Light[0].Value;
- MuteInputMonitor = Light[2].Value;
- } else {
- Select = Light[0].Value;
- Mute = Light[2].Value;
- }
- LightSet(eL_InputMonitor, ! StateInputMonitor());
- Light[0].Value = StateInputMonitor() ? SelectInputMonitor : Select;
- Light[2].Value = StateInputMonitor() ? MuteInputMonitor : Mute;
- LightSend();
- }
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_InputMonitor));
- break;
- default:
- if (verbose > 1)
- printf("Knob %i now %i\n", K, V);
- Midi.SendMidiControl(K, V);
- }
+ if (K == eK_InputMonitor)
+ {
+ if (verbose > 1)
+ printf("Knob InputMonitor now %i", V);
+ if (V) {
+ if (StateInputMonitor()) {
+ SelectInputMonitor = Light[0].Value;
+ MuteInputMonitor = Light[2].Value;
+ } else {
+ Select = Light[0].Value;
+ Mute = Light[2].Value;
+ }
+ LightSet(eL_InputMonitor, ! StateInputMonitor());
+ Light[0].Value = StateInputMonitor() ? SelectInputMonitor : Select;
+ Light[2].Value = StateInputMonitor() ? MuteInputMonitor : Mute;
+ LightSend();
+ }
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_InputMonitor));
+ }
+ else
+ UserKnobChangedTo(K, V);
}
}
-
-void Cus428State::WheelChangedTo(E_In84 W, char Diff)
+void Cus428State::UserWheelChangedTo(E_In84 W, char Diff)
{
char Param;
switch (W) {
case eWheelPan:
- if (StateInputMonitor() && Light[0].Value) {
- int index = 0;
-
- while( index < 4 && (1 << index) != Light[0].Value)
- index++;
-
- if (index >= 4)
- return;
-
- Volume[index].PanTo(Diff, us428_ctls->Knob(eK_SET));
- if (!LightIs(eL_Mute0 + index))
- SendVolume(Volume[index]);
- return;
- }
Param = 0x4D;
break;
case eWheelGain:
@@ -241,7 +238,27 @@ void Cus428State::WheelChangedTo(E_In84
WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
break;
}
- Midi.SendMidiControl(Param, ((unsigned char *) us428_ctls)[W]);
+ Midi.SendMidiControl(15, Param, ((unsigned char *) us428_ctls)[W]);
+}
+
+void Cus428State::WheelChangedTo(E_In84 W, char Diff)
+{
+ if (W == eWheelPan && StateInputMonitor() && Light[0].Value)
+ {
+ int index = 0;
+
+ while( index < 4 && (1 << index) != Light[0].Value)
+ index++;
+
+ if (index >= 4)
+ return;
+
+ Volume[index].PanTo(Diff, us428_ctls->Knob(eK_SET));
+ if (!LightIs(eL_Mute0 + index))
+ SendVolume(Volume[index]);
+ return;
+ }
+ UserWheelChangedTo(W, Diff);
}
@@ -444,3 +461,174 @@ void Cus428State::MmcReset()
LocateSend();
}
+Cus428StateMixxx::Cus428StateMixxx(struct us428ctls_sharedmem* Pus428ctls_sharedmem):Cus428State(Pus428ctls_sharedmem)
+{
+ focus = 0;
+ eq = 0;
+ LightSet(eL_Low, 1);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+}
+
+void Cus428StateMixxx::UserKnobChangedTo(eKnobs K, bool V)
+{
+ switch (K) {
+ case eK_BANK_L:
+ if (verbose > 1)
+ printf("Knob BANK_L now %i", V);
+ if (V) LightSet(eL_BankL, !LightIs(eL_BankL));
+ LightSend();
+ Midi.SendMidiNote(0, 51, V ? 127 : 0);
+ break;
+ case eK_BANK_R:
+ if (verbose > 1)
+ printf("Knob BANK_R now %i", V);
+ if (V) LightSet(eL_BankR, !LightIs(eL_BankR));
+ LightSend();
+ Midi.SendMidiNote(1, 51, V ? 127 : 0);
+ break;
+ case eK_REW:
+ if (verbose > 1)
+ printf("Knob REW now %i", V);
+ Midi.SendMidiNote(focus, 60, V ? 127 : 0);
+ break;
+ case eK_FFWD:
+ if (verbose > 1)
+ printf("Knob FFWD now %i", V);
+ Midi.SendMidiNote(focus, 61, V ? 127 : 0);
+ break;
+ case eK_STOP:
+ if (verbose > 1)
+ printf("Knob STOP now %i\n", V);
+ Midi.SendMidiNote(focus, 62, V ? 127 : 0);
+ break;
+ case eK_PLAY:
+ if (verbose > 1)
+ printf("Knob PLAY now %i", V);
+ Midi.SendMidiNote(focus, 63, V ? 127 : 0);
+ break;
+ case eK_RECORD:
+ if (verbose > 1)
+ printf("Knob RECORD now %i", V);
+ Midi.SendMidiNote(focus, 64, V ? 127 : 0);
+ break;
+ case eK_LOW:
+ if (verbose > 1)
+ printf("Knob LOW now %i", V);
+ if (V)
+ {
+ eq = 0;
+ LightSet(eL_Low, 1);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_LOWMID:
+ if (verbose > 1)
+ printf("Knob LOWMID now %i", V);
+ if (V)
+ {
+ eq = 1;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 1);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_HIMID:
+ if (verbose > 1)
+ printf("Knob HIMID now %i", V);
+ if (V)
+ {
+ eq = 2;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 1);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_HIGH:
+ if (verbose > 1)
+ printf("Knob HIGH now %i", V);
+ if (V)
+ {
+ eq = 3;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 1);
+ LightSend();
+ }
+ break;
+ case eK_SET:
+ if (verbose > 1)
+ printf("Knob SET now %i", V);
+ Midi.SendMidiNote(focus, 65, V ? 127 : 0);
+ break;
+ case eK_LOCATE_L:
+ if (verbose > 1)
+ printf("Knob LOCATE_L now %i", V);
+ if (V) {
+ focus = 0;
+ }
+ break;
+ case eK_LOCATE_R:
+ if (verbose > 1)
+ printf("Knob LOCATE_R now %i", V);
+ if (V) {
+ focus = 1;
+ }
+ break;
+ default:
+ if (verbose > 1)
+ printf("Knob %i now %i\n", K, V);
+ Midi.SendMidiNote(0, K, V);
+ }
+}
+
+void Cus428StateMixxx::UserSliderChangedTo(int S, unsigned char New)
+{
+ // if (verbose > 1)
+ // printf("Slider : %d - %d - %d\n", S, New, ((unsigned char*)us428_ctls)[S]);
+ Midi.SendMidiControl(0, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
+}
+
+void Cus428StateMixxx::UserWheelChangedTo(E_In84 W, char Diff)
+{
+ char Param;
+ char Value;
+ char Channel;
+ //if (verbose > 1)
+ // printf("Slider : %d - %d - %d\n", W, Diff, ((unsigned char *) us428_ctls)[W]);
+
+ Channel = 0;
+ switch (W) {
+ case eWheelGain:
+ Param = 0x48 + eq * 4;
+ break;
+ case eWheelFreq:
+ Param = 0x49 + eq * 4;
+ break;
+ case eWheelQ:
+ Param = 0x4A + eq * 4;
+ break;
+ case eWheelPan:
+ Param = 0x4B + eq * 4;
+ break;
+ case eWheel:
+ Param = 0x60;
+ Channel = focus;
+ // Update the absolute wheel position.
+ //WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
+ break;
+ }
+ Value = 64 + Diff;
+ Midi.SendMidiControl(Channel, Param, Value);
+ // Midi.SendMidiControl(0, Param, ((unsigned char *) us428_ctls)[W]);
+}
diff -r 7f7a0bf510a4 us428control/Cus428State.h
--- a/us428control/Cus428State.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428State.h Sat Sep 30 18:05:42 2006 +0200
@@ -84,10 +84,15 @@ class Cus428State: public us428_lights{
eK_F3,
};
void InitDevice(void);
+
void KnobChangedTo(eKnobs K, bool V);
void SliderChangedTo(int S, unsigned char New);
+ void WheelChangedTo(E_In84 W, char Diff);
+ virtual void UserSliderChangedTo(int S, unsigned char New);
+ virtual void UserWheelChangedTo(E_In84 W, char Diff);
+ virtual void UserKnobChangedTo(eKnobs K, bool V);
+
void SliderSend(int S);
- void WheelChangedTo(E_In84 W, char Diff);
Cus428_ctls *Set_us428_ctls(Cus428_ctls *New) {
Cus428_ctls *Old = us428_ctls;
us428_ctls = New;
@@ -104,7 +109,7 @@ class Cus428State: public us428_lights{
void TransportSend();
// Reset internal MMC state.
void MmcReset();
- private:
+ protected:
void SendVolume(usX2Y_volume &V);
struct us428ctls_sharedmem* us428ctls_sharedmem;
bool StateInputMonitor() {
@@ -140,6 +145,18 @@ class Cus428State: public us428_lights{
int aWheelSpeed;
};
+
+class Cus428StateMixxx: public Cus428State{
+public:
+ Cus428StateMixxx(struct us428ctls_sharedmem* Pus428ctls_sharedmem);
+ void UserKnobChangedTo(eKnobs K, bool V);
+ void UserSliderChangedTo(int S, unsigned char New);
+ void UserWheelChangedTo(E_In84 W, char Diff);
+protected:
+ int focus;
+ int eq;
+};
+
extern Cus428State* OneState;
#endif
diff -r 7f7a0bf510a4 us428control/us428control.cc
--- a/us428control/us428control.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/us428control.cc Sat Sep 30 18:05:42 2006 +0200
@@ -61,7 +61,8 @@ static void usage(void)
{
printf("Tascam US-428 Control\n");
printf("version %s\n", VERSION);
- printf("usage: "PROGNAME" [-v verbosity_level 0..2] [-c card] [-D device] [-u usb-device]\n");
+ printf("usage: "PROGNAME" [-v verbosity_level 0..2] [-c card] [-D device] [-u usb-device] [-m mode]\n");
+ printf("mode is one of (native, mixxx)\n");
}
/*
* check the name id of the given hwdep handle
@@ -76,14 +77,14 @@ static int check_hwinfo(snd_hwdep_t *hw,
return err;
if (strcmp(snd_hwdep_info_get_id(info), id))
return -ENODEV;
- if (usb_dev_name)
+ if (usb_dev_name)
if (strcmp(snd_hwdep_info_get_name(info), usb_dev_name))
return -ENODEV;
return 0; /* ok */
}
-int US428Control(const char* DevName)
+int US428Control(const char* DevName, int mode)
{
snd_hwdep_t *hw;
int err;
@@ -117,7 +118,11 @@ int US428Control(const char* DevName)
return -ENOMEM;
}
us428ctls_sharedmem->CtlSnapShotRed = us428ctls_sharedmem->CtlSnapShotLast;
- OneState = new Cus428State(us428ctls_sharedmem);
+ if (mode == 1)
+ OneState = new Cus428StateMixxx(us428ctls_sharedmem);
+ else
+ OneState = new Cus428State(us428ctls_sharedmem);
+
OneState->InitDevice();
while ((pollrc = poll(pfds, npfd, 60000)) >= 0) {
@@ -152,12 +157,13 @@ int main (int argc, char *argv[])
int main (int argc, char *argv[])
{
int c;
+ int mode = 0;
int card = -1;
char *device_name = NULL,
*usb_device_name = getenv("DEVICE");
char name[64];
- while ((c = getopt(argc, argv, "c:D:u:v:")) != -1) {
+ while ((c = getopt(argc, argv, "c:D:u:v:m:")) != -1) {
switch (c) {
case 'c':
card = atoi(optarg);
@@ -171,6 +177,10 @@ int main (int argc, char *argv[])
case 'v':
verbose = atoi(optarg);
break;
+ case 'm':
+ if (!strcmp(optarg, "mixxx"))
+ mode = 1;
+ break;
default:
usage();
return 1;
@@ -190,18 +200,18 @@ int main (int argc, char *argv[])
}
}
if (device_name) {
- return US428Control(device_name) != 0;
+ return US428Control(device_name, mode) != 0;
}
if (card >= 0) {
sprintf(name, "hw:%d", card);
- return US428Control(name) != 0;
+ return US428Control(name, mode) != 0;
}
/* probe the all cards */
for (c = 0; c < SND_CARDS; c++) {
// verbose--;
sprintf(name, "hw:%d", c);
- if (! US428Control(name))
+ if (!US428Control(name, mode))
card = c;
}
if (card < 0) {
diff -r 7f7a0bf510a4 us428control/usbus428ctldefs.h
--- a/us428control/usbus428ctldefs.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/usbus428ctldefs.h Sat Sep 30 18:05:42 2006 +0200
@@ -64,7 +64,7 @@ struct us428_ctls{
unsigned char Select;
unsigned char Mute;
unsigned char UNKNOWN;
- unsigned char Switch;
+ unsigned char Switch;
unsigned char Wheel[5];
};
@@ -119,7 +119,7 @@ typedef struct usX2Y_volume {
if (Grob) {
static int GrobVals[] = {-128, -64, 0, 64, 127};
int i = 4;
- while (i >= 0 && GrobVals[i] > Pan)
+ while (i >= 0 && GrobVals[i] > Pan)
i--;
if (GrobVals[i] != Pan && RawValue < 0)
i++;
@@ -158,7 +158,12 @@ struct us428_lights{
eL_FFwd = 29,
eL_Play = 30,
eL_Record = 31,
- eL_Null
+ eL_AnalogDigital = 32,
+ eL_Null = 34,
+ eL_Low = 36,
+ eL_LowMid = 37,
+ eL_HiMid = 38,
+ eL_High = 39
};
bool LightIs(int L){
return Light[L / 8].Value & (1 << (L % 8));
[-- Attachment #3: Type: text/plain, Size: 348 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 161 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] us428control support for mixxx
2006-09-30 16:06 CTAF ctaf
@ 2006-10-04 16:16 ` Takashi Iwai
2006-10-04 17:04 ` CTAF ctaf
[not found] ` <1a9cd1af0610050549l4e92a8a5v21256f05f7606440@mail.gmail.com>
0 siblings, 2 replies; 7+ messages in thread
From: Takashi Iwai @ 2006-10-04 16:16 UTC (permalink / raw)
To: CTAF ctaf; +Cc: alsa-devel
At Sat, 30 Sep 2006 18:06:53 +0200,
CTAF ctaf wrote:
>
> This patch allow to change the mapping of the us428, the new mapping is used with
> mixxx.
> To use the new mapping:
> ./us428control -m mixxx
>
> I already posted an older version on the bug tracker, but I had'nt have response for
> it.
> thanks.
>
> Signed-off-by: Cedric GESTES <goctaf@gmail.com>
Thanks. Through a quick look, the changes seem OK to me.
But, could you fix the indent before merging to the tree?
Karsten's original code uses 8-char tabs for indentation while you're
using 2-chars.
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] us428control support for mixxx
2006-10-04 16:16 ` Takashi Iwai
@ 2006-10-04 17:04 ` CTAF ctaf
[not found] ` <1a9cd1af0610050549l4e92a8a5v21256f05f7606440@mail.gmail.com>
1 sibling, 0 replies; 7+ messages in thread
From: CTAF ctaf @ 2006-10-04 17:04 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 750 bytes --]
yes I will change the indent, and resend you the patch. Thanks for your code
review.
On 10/4/06, Takashi Iwai <tiwai@suse.de> wrote:
>
> At Sat, 30 Sep 2006 18:06:53 +0200,
> CTAF ctaf wrote:
> >
> > This patch allow to change the mapping of the us428, the new mapping is
> used with
> > mixxx.
> > To use the new mapping:
> > ./us428control -m mixxx
> >
> > I already posted an older version on the bug tracker, but I had'nt have
> response for
> > it.
> > thanks.
> >
> > Signed-off-by: Cedric GESTES <goctaf@gmail.com>
>
> Thanks. Through a quick look, the changes seem OK to me.
> But, could you fix the indent before merging to the tree?
> Karsten's original code uses 8-char tabs for indentation while you're
> using 2-chars.
>
>
> Takashi
>
[-- Attachment #1.2: Type: text/html, Size: 1126 bytes --]
[-- Attachment #2: Type: text/plain, Size: 348 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #3: Type: text/plain, Size: 161 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] us428control support for mixxx
@ 2006-10-05 0:39 gtrfree
0 siblings, 0 replies; 7+ messages in thread
From: gtrfree @ 2006-10-05 0:39 UTC (permalink / raw)
To: alsa-devel
GESTES Cedric wrote:
> This patch allow to change the midi mapping of the us428, the new
> mapping is used with mixxx.
> To use the new mapping:
> ../us428control -m mixxx
>
> I have splitted the class who does the mapping, it is more easy to add
> new mapping now.
> Furthermore I need to find a way to communicate with the program, to
> change mapping on the fly.
> Cause currently us428control is launched from udev, and to change the
> mapping you should kill the previous us428control and launch another.
>
> I already posted an older version on the bug tracker, but I had'nt have
> response for it. (with different addrese cause gmail bounce my mail to
> sf.net)
> thanks.
>
Hi, I'm not a developer, just an user... and I'm new with Linux so don't count too much my opinion. ;-)
I'm running OpenSuSE 10.1 - 32bits and seems that the us428control in 'mixxx mode' doesn't work. It starts good but only the lights in the eq sections lit, nothing more.
When I run Mixxx in Jack-mode there isn't 'something' to connect to the Tascam control into the QJackctl midi-window (I mean some 'mixxx-control input').
If I start Mixxx in standard mode, there isn't the Tascam to choose in the midi configuration. Anyway I tried every option with no results (Play, stop and faders don't work with Mixxx).
Sorry to carry bad news but I repeat: I'm very new with Linux (still fighting with 3-4 us428 inputs!) and I hope it's just a problem of mine, not Mixxx or your patch.
Cheers.
--
---------------------------------------------------------------
Mettiti al centro del mondo! Crea il tuo blog e condividi con
i tuoi amici idee, immagini e video, da web e da cellulare!
http://beta.dada.net/
---------------------------------------------------------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] us428control support for mixxx
[not found] ` <1a9cd1af0610050549l4e92a8a5v21256f05f7606440@mail.gmail.com>
@ 2006-10-05 12:51 ` CTAF ctaf
2006-10-05 13:00 ` Takashi Iwai
1 sibling, 0 replies; 7+ messages in thread
From: CTAF ctaf @ 2006-10-05 12:51 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1.1: Type: text/plain, Size: 759 bytes --]
here is the patch with good indentation :-)
Signed-off-by: Cedric GESTES <goctaf@gmail.com>
On 10/4/06, Takashi Iwai <tiwai@suse.de> wrote:
>
> At Sat, 30 Sep 2006 18:06:53 +0200,
> CTAF ctaf wrote:
> >
> > This patch allow to change the mapping of the us428, the new mapping is
> used with
> > mixxx.
> > To use the new mapping:
> > ./us428control -m mixxx
> >
> > I already posted an older version on the bug tracker, but I had'nt have
> response for
> > it.
> > thanks.
> >
> > Signed-off-by: Cedric GESTES <goctaf@gmail.com >
>
> Thanks. Through a quick look, the changes seem OK to me.
> But, could you fix the indent before merging to the tree?
> Karsten's original code uses 8-char tabs for indentation while you're
> using 2-chars.
>
>
> Takashi
>
[-- Attachment #1.2: Type: text/html, Size: 1583 bytes --]
[-- Attachment #2: us428control-mixxx-v4.patch --]
[-- Type: text/x-patch, Size: 23343 bytes --]
diff -r 7f7a0bf510a4 us428control/Cus428Midi.cc
--- a/us428control/Cus428Midi.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428Midi.cc Thu Oct 05 14:28:57 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
*
* Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de>
@@ -78,7 +79,7 @@ char Cus428Midi::KnobParam[] = {
0x35,
0x36,
0x37,
- };
+};
extern int verbose;
diff -r 7f7a0bf510a4 us428control/Cus428Midi.h
--- a/us428control/Cus428Midi.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428Midi.h Thu Oct 05 14:28:17 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
*
* Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de>
@@ -62,7 +63,7 @@
class Cus428Midi {
- public:
+public:
Cus428Midi():
Seq(0){}
@@ -87,14 +88,23 @@ class Cus428Midi {
return Err;
}
- int SendMidiControl(char Param, char Val){
- snd_seq_ev_set_controller(&Ev, 15, Param, Val & 0x7F);
+ int SendMidiControl(char Channel, char Param, char Val){
+ snd_seq_ev_set_controller(&Ev, Channel, Param, Val & 0x7F);
SubMitEvent();
return 0;
- }
+ }
- int SendMidiControl(Cus428State::eKnobs K, bool Down){
- return SendMidiControl(KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
+ int SendMidiNote(char Channel, char Note, char Val){
+ if (!Val)
+ snd_seq_ev_set_noteoff(&Ev, Channel, Note, Val & 0x7F);
+ else
+ snd_seq_ev_set_noteon(&Ev, Channel, Note, Val & 0x7F);
+ SubMitEvent();
+ return 0;
+ }
+
+ int SendMidiControl(char Channel, Cus428State::eKnobs K, bool Down){
+ return SendMidiControl(Channel, KnobParam[K - Cus428State::eK_RECORD], Down ? 0x7F : 0);
}
// To parse and dispatch input MIDI events.
@@ -106,7 +116,7 @@ class Cus428Midi {
// Made public for friendliness.
snd_seq_t *Seq;
- private:
+private:
int Port;
snd_seq_event_t Ev;
int SubMitEvent(){
diff -r 7f7a0bf510a4 us428control/Cus428State.cc
--- a/us428control/Cus428State.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428State.cc Thu Oct 05 14:43:00 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
* Controller for Tascam US-X2Y
*
@@ -46,7 +47,6 @@ void Cus428State::InitDevice(void)
SliderChangedTo(eFaderM, ((unsigned char*)(us428ctls_sharedmem->CtlSnapShot + us428ctls_sharedmem->CtlSnapShotLast))[eFaderM]);
}
-
int Cus428State::LightSend()
{
int Next = us428ctls_sharedmem->p4outLast + 1;
@@ -57,6 +57,11 @@ int Cus428State::LightSend()
return us428ctls_sharedmem->p4outLast = Next;
}
+void Cus428State::SliderSend(int S)
+{
+ Midi.SendMidiControl(15, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
+}
+
void Cus428State::SendVolume(usX2Y_volume &V)
{
int Next = us428ctls_sharedmem->p4outLast + 1;
@@ -67,22 +72,100 @@ void Cus428State::SendVolume(usX2Y_volum
us428ctls_sharedmem->p4outLast = Next;
}
+void Cus428State::UserSliderChangedTo(int S, unsigned char New)
+{
+ SliderSend(S);
+}
+
void Cus428State::SliderChangedTo(int S, unsigned char New)
{
- if (StateInputMonitor() && S <= eFader3
- || S == eFaderM) {
+ if (StateInputMonitor() && S <= eFader3 || S == eFaderM) {
usX2Y_volume &V = Volume[S >= eFader4 ? eFader4 : S];
V.SetTo(S, New);
if (S == eFaderM || !LightIs(eL_Mute0 + S))
SendVolume(V);
}
- else SliderSend(S);
-}
-
-void Cus428State::SliderSend(int S)
-{
- Midi.SendMidiControl(0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
-}
+ else
+ UserSliderChangedTo(S, New);
+}
+
+void Cus428State::UserKnobChangedTo(eKnobs K, bool V)
+{
+ switch (K) {
+ case eK_STOP:
+ if (verbose > 1)
+ printf("Knob STOP now %i\n", V);
+ if (V) TransportToggle(T_STOP);
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_PLAY:
+ if (verbose > 1)
+ printf("Knob PLAY now %i", V);
+ if (V) TransportToggle(T_PLAY);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Play));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_REW:
+ if (verbose > 1)
+ printf("Knob REW now %i", V);
+ if (V) TransportToggle(T_REW);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Rew));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_FFWD:
+ if (verbose > 1)
+ printf("Knob FFWD now %i", V);
+ if (V) TransportToggle(T_F_FWD);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_FFwd));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_RECORD:
+ if (verbose > 1)
+ printf("Knob RECORD now %i", V);
+ if (V) TransportToggle(T_RECORD);
+ if (verbose > 1)
+ printf(" Light is %i\n", LightIs(eL_Record));
+ Midi.SendMidiControl(15, K, V);
+ break;
+ case eK_SET:
+ if (verbose > 1)
+ printf("Knob SET now %i", V);
+ bSetLocate = V;
+ break;
+ case eK_LOCATE_L:
+ if (verbose > 1)
+ printf("Knob LOCATE_L now %i", V);
+ if (V) {
+ if (bSetLocate)
+ aWheel_L = aWheel;
+ else {
+ aWheel = aWheel_L;
+ LocateSend();
+ }
+ }
+ break;
+ case eK_LOCATE_R:
+ if (verbose > 1)
+ printf("Knob LOCATE_R now %i", V);
+ if (V) {
+ if (bSetLocate)
+ aWheel_R = aWheel;
+ else {
+ aWheel = aWheel_R;
+ LocateSend();
+ }
+ }
+ break;
+ default:
+ if (verbose > 1)
+ printf("Knob %i now %i\n", K, V);
+ Midi.SendMidiControl(15, K, V);
+ }
+}
+
void Cus428State::KnobChangedTo(eKnobs K, bool V)
{
@@ -109,75 +192,7 @@ void Cus428State::KnobChangedTo(eKnobs K
}
break;
default:
- switch (K) {
- case eK_STOP:
- if (verbose > 1)
- printf("Knob STOP now %i\n", V);
- if (V) TransportToggle(T_STOP);
- Midi.SendMidiControl(K, V);
- break;
- case eK_PLAY:
- if (verbose > 1)
- printf("Knob PLAY now %i", V);
- if (V) TransportToggle(T_PLAY);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Play));
- Midi.SendMidiControl(K, V);
- break;
- case eK_REW:
- if (verbose > 1)
- printf("Knob REW now %i", V);
- if (V) TransportToggle(T_REW);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Rew));
- Midi.SendMidiControl(K, V);
- break;
- case eK_FFWD:
- if (verbose > 1)
- printf("Knob FFWD now %i", V);
- if (V) TransportToggle(T_F_FWD);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_FFwd));
- Midi.SendMidiControl(K, V);
- break;
- case eK_RECORD:
- if (verbose > 1)
- printf("Knob RECORD now %i", V);
- if (V) TransportToggle(T_RECORD);
- if (verbose > 1)
- printf(" Light is %i\n", LightIs(eL_Record));
- Midi.SendMidiControl(K, V);
- break;
- case eK_SET:
- if (verbose > 1)
- printf("Knob SET now %i", V);
- bSetLocate = V;
- break;
- case eK_LOCATE_L:
- if (verbose > 1)
- printf("Knob LOCATE_L now %i", V);
- if (V) {
- if (bSetLocate)
- aWheel_L = aWheel;
- else {
- aWheel = aWheel_L;
- LocateSend();
- }
- }
- break;
- case eK_LOCATE_R:
- if (verbose > 1)
- printf("Knob LOCATE_R now %i", V);
- if (V) {
- if (bSetLocate)
- aWheel_R = aWheel;
- else {
- aWheel = aWheel_R;
- LocateSend();
- }
- }
- break;
- case eK_InputMonitor:
+ if (K == eK_InputMonitor) {
if (verbose > 1)
printf("Knob InputMonitor now %i", V);
if (V) {
@@ -195,22 +210,40 @@ void Cus428State::KnobChangedTo(eKnobs K
}
if (verbose > 1)
printf(" Light is %i\n", LightIs(eL_InputMonitor));
- break;
- default:
- if (verbose > 1)
- printf("Knob %i now %i\n", K, V);
- Midi.SendMidiControl(K, V);
- }
- }
-}
-
-
-void Cus428State::WheelChangedTo(E_In84 W, char Diff)
+ } else
+ UserKnobChangedTo(K, V);
+ }
+}
+
+void Cus428State::UserWheelChangedTo(E_In84 W, char Diff)
{
char Param;
switch (W) {
case eWheelPan:
- if (StateInputMonitor() && Light[0].Value) {
+ Param = 0x4D;
+ break;
+ case eWheelGain:
+ Param = 0x48;
+ break;
+ case eWheelFreq:
+ Param = 0x49;
+ break;
+ case eWheelQ:
+ Param = 0x4A;
+ break;
+ case eWheel:
+ Param = 0x60;
+ // Update the absolute wheel position.
+ WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
+ break;
+ }
+ Midi.SendMidiControl(15, Param, ((unsigned char *) us428_ctls)[W]);
+}
+
+void Cus428State::WheelChangedTo(E_In84 W, char Diff)
+{
+ if (W == eWheelPan && StateInputMonitor() && Light[0].Value)
+ {
int index = 0;
while( index < 4 && (1 << index) != Light[0].Value)
@@ -224,24 +257,7 @@ void Cus428State::WheelChangedTo(E_In84
SendVolume(Volume[index]);
return;
}
- Param = 0x4D;
- break;
- case eWheelGain:
- Param = 0x48;
- break;
- case eWheelFreq:
- Param = 0x49;
- break;
- case eWheelQ:
- Param = 0x4A;
- break;
- case eWheel:
- Param = 0x60;
- // Update the absolute wheel position.
- WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
- break;
- }
- Midi.SendMidiControl(Param, ((unsigned char *) us428_ctls)[W]);
+ UserWheelChangedTo(W, Diff);
}
@@ -249,9 +265,9 @@ void Cus428State::LocateWheel ( unsigned
void Cus428State::LocateWheel ( unsigned char *tc )
{
aWheel = (60 * 60 * 30) * (int) tc[0] // hh - hours [0..23]
- + ( 60 * 30) * (int) tc[1] // mm - minutes [0..59]
- + ( 30) * (int) tc[2] // ss - seconds [0..59]
- + (int) tc[3]; // ff - frames [0..29]
+ + ( 60 * 30) * (int) tc[1] // mm - minutes [0..59]
+ + ( 30) * (int) tc[2] // ss - seconds [0..59]
+ + (int) tc[3]; // ff - frames [0..29]
}
@@ -276,8 +292,8 @@ void Cus428State::WheelDelta ( int W )
if (dW > 0 && dW > +W_DELTA_MIN)
dW -= W_DELTA_MAX;
else
- if (dW < 0 && dW < -W_DELTA_MIN)
- dW += W_DELTA_MAX;
+ if (dW < 0 && dW < -W_DELTA_MIN)
+ dW += W_DELTA_MAX;
W0 = W;
aWheel += dW;
@@ -356,7 +372,7 @@ void Cus428State::TransportToggle ( unsi
uTransport = T_STOP;
Midi.SendMmcCommand(MMC_CMD_STOP);
} else {
- uTransport &= T_RECORD;
+ uTransport &= T_RECORD;
uTransport |= T_PLAY;
Midi.SendMmcCommand(MMC_CMD_PLAY);
}
@@ -366,7 +382,7 @@ void Cus428State::TransportToggle ( unsi
uTransport &= ~T_RECORD;
Midi.SendMmcCommand(MMC_CMD_RECORD_EXIT);
} else {
- uTransport &= T_PLAY;
+ uTransport &= T_PLAY;
uTransport |= T_RECORD;
Midi.SendMmcCommand(uTransport & T_PLAY ? MMC_CMD_RECORD_STROBE : MMC_CMD_RECORD_PAUSE);
}
@@ -444,3 +460,181 @@ void Cus428State::MmcReset()
LocateSend();
}
+Cus428StateMixxx::Cus428StateMixxx(struct us428ctls_sharedmem* Pus428ctls_sharedmem):Cus428State(Pus428ctls_sharedmem)
+{
+ focus = 0;
+ eq = 0;
+ LightSet(eL_Low, 1);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+}
+
+void Cus428StateMixxx::UserKnobChangedTo(eKnobs K, bool V)
+{
+ switch (K) {
+ case eK_BANK_L:
+ if (verbose > 1)
+ printf("Knob BANK_L now %i", V);
+ if (V) LightSet(eL_BankL, !LightIs(eL_BankL));
+ LightSend();
+ Midi.SendMidiNote(0, 51, V ? 127 : 0);
+ break;
+ case eK_BANK_R:
+ if (verbose > 1)
+ printf("Knob BANK_R now %i", V);
+ if (V) LightSet(eL_BankR, !LightIs(eL_BankR));
+ LightSend();
+ Midi.SendMidiNote(1, 51, V ? 127 : 0);
+ break;
+ case eK_REW:
+ if (verbose > 1)
+ printf("Knob REW now %i", V);
+ Midi.SendMidiNote(focus, 60, V ? 127 : 0);
+ break;
+ case eK_FFWD:
+ if (verbose > 1)
+ printf("Knob FFWD now %i", V);
+ Midi.SendMidiNote(focus, 61, V ? 127 : 0);
+ break;
+ case eK_STOP:
+ if (verbose > 1)
+ printf("Knob STOP now %i\n", V);
+ Midi.SendMidiNote(focus, 62, V ? 127 : 0);
+ break;
+ case eK_PLAY:
+ if (verbose > 1)
+ printf("Knob PLAY now %i", V);
+ Midi.SendMidiNote(focus, 63, V ? 127 : 0);
+ break;
+ case eK_RECORD:
+ if (verbose > 1)
+ printf("Knob RECORD now %i", V);
+ Midi.SendMidiNote(focus, 64, V ? 127 : 0);
+ break;
+ case eK_LOW:
+ if (verbose > 1)
+ printf("Knob LOW now %i", V);
+ if (V)
+ {
+ eq = 0;
+ LightSet(eL_Low, 1);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_LOWMID:
+ if (verbose > 1)
+ printf("Knob LOWMID now %i", V);
+ if (V)
+ {
+ eq = 1;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 1);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_HIMID:
+ if (verbose > 1)
+ printf("Knob HIMID now %i", V);
+ if (V)
+ {
+ eq = 2;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 1);
+ LightSet(eL_High, 0);
+ LightSend();
+ }
+ break;
+ case eK_HIGH:
+ if (verbose > 1)
+ printf("Knob HIGH now %i", V);
+ if (V)
+ {
+ eq = 3;
+ LightSet(eL_Low, 0);
+ LightSet(eL_LowMid, 0);
+ LightSet(eL_HiMid, 0);
+ LightSet(eL_High, 1);
+ LightSend();
+ }
+ break;
+ case eK_SET:
+ if (verbose > 1)
+ printf("Knob SET now %i", V);
+ Midi.SendMidiNote(focus, 65, V ? 127 : 0);
+ break;
+ case eK_LOCATE_L:
+ if (verbose > 1)
+ printf("Knob LOCATE_L now %i", V);
+ if (V) {
+ focus = 0;
+ }
+ break;
+ case eK_LOCATE_R:
+ if (verbose > 1)
+ printf("Knob LOCATE_R now %i", V);
+ if (V) {
+ focus = 1;
+ }
+ break;
+ default:
+ if (verbose > 1)
+ printf("Knob %i now %i\n", K, V);
+ if (K >= eK_Select0 && K <= eK_Select0 + 7) {
+ if (V) LightSet(eL_Select0 + (K - eK_Select0), !LightIs(eL_Select0 + (K - eK_Select0)));
+ LightSend();
+ } else if (K >= eK_Mute0 && K <= eK_Mute0 + 7) {
+ if (V) LightSet(eL_Mute0 + (K - eK_Mute0), !LightIs(eL_Mute0 + (K - eK_Mute0)));
+ LightSend();
+ }
+ Midi.SendMidiNote(0, K, V);
+ }
+}
+
+void Cus428StateMixxx::UserSliderChangedTo(int S, unsigned char New)
+{
+ // if (verbose > 1)
+ // printf("Slider : %d - %d - %d\n", S, New, ((unsigned char*)us428_ctls)[S]);
+ Midi.SendMidiControl(0, 0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
+}
+
+void Cus428StateMixxx::UserWheelChangedTo(E_In84 W, char Diff)
+{
+ char Param;
+ char Value;
+ char Channel;
+ //if (verbose > 1)
+ // printf("Slider : %d - %d - %d\n", W, Diff, ((unsigned char *) us428_ctls)[W]);
+
+ Channel = 0;
+ switch (W) {
+ case eWheelGain:
+ Param = 0x48 + eq * 4;
+ break;
+ case eWheelFreq:
+ Param = 0x49 + eq * 4;
+ break;
+ case eWheelQ:
+ Param = 0x4A + eq * 4;
+ break;
+ case eWheelPan:
+ Param = 0x4B + eq * 4;
+ break;
+ case eWheel:
+ Param = 0x60;
+ Channel = focus;
+ // Update the absolute wheel position.
+ //WheelDelta((int) ((unsigned char *) us428_ctls)[W]);
+ break;
+ }
+ Value = 64 + Diff;
+ Midi.SendMidiControl(Channel, Param, Value);
+ //Midi.SendMidiControl(0, Param, ((unsigned char *) us428_ctls)[W]);
+}
diff -r 7f7a0bf510a4 us428control/Cus428State.h
--- a/us428control/Cus428State.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428State.h Thu Oct 05 14:27:54 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
* Controller for Tascam US-X2Y
*
@@ -24,7 +25,7 @@
#include "Cus428_ctls.h"
class Cus428State: public us428_lights{
- public:
+public:
Cus428State(struct us428ctls_sharedmem* Pus428ctls_sharedmem)
:us428ctls_sharedmem(Pus428ctls_sharedmem)
,MuteInputMonitor(0)
@@ -39,12 +40,12 @@ class Cus428State: public us428_lights{
,bSetLocate(false)
,uTransport(0)
,aWheelSpeed(0)
- {
- init_us428_lights();
- for (int v = 0; v < 5; ++v) {
- Volume[v].init(v);
- }
+ {
+ init_us428_lights();
+ for (int v = 0; v < 5; ++v) {
+ Volume[v].init(v);
}
+ }
enum eKnobs{
eK_RECORD = 72,
eK_PLAY,
@@ -84,10 +85,15 @@ class Cus428State: public us428_lights{
eK_F3,
};
void InitDevice(void);
+
void KnobChangedTo(eKnobs K, bool V);
void SliderChangedTo(int S, unsigned char New);
+ void WheelChangedTo(E_In84 W, char Diff);
+ virtual void UserSliderChangedTo(int S, unsigned char New);
+ virtual void UserWheelChangedTo(E_In84 W, char Diff);
+ virtual void UserKnobChangedTo(eKnobs K, bool V);
+
void SliderSend(int S);
- void WheelChangedTo(E_In84 W, char Diff);
Cus428_ctls *Set_us428_ctls(Cus428_ctls *New) {
Cus428_ctls *Old = us428_ctls;
us428_ctls = New;
@@ -104,7 +110,7 @@ class Cus428State: public us428_lights{
void TransportSend();
// Reset internal MMC state.
void MmcReset();
- private:
+protected:
void SendVolume(usX2Y_volume &V);
struct us428ctls_sharedmem* us428ctls_sharedmem;
bool StateInputMonitor() {
@@ -121,9 +127,9 @@ class Cus428State: public us428_lights{
usX2Y_volume_t Volume[5];
char MuteInputMonitor,
- Mute,
- SelectInputMonitor,
- Select;
+ Mute,
+ SelectInputMonitor,
+ Select;
Cus428_ctls *us428_ctls;
// Differential wheel tracking.
int W0;
@@ -140,6 +146,18 @@ class Cus428State: public us428_lights{
int aWheelSpeed;
};
+
+class Cus428StateMixxx: public Cus428State{
+public:
+ Cus428StateMixxx(struct us428ctls_sharedmem* Pus428ctls_sharedmem);
+ void UserKnobChangedTo(eKnobs K, bool V);
+ void UserSliderChangedTo(int S, unsigned char New);
+ void UserWheelChangedTo(E_In84 W, char Diff);
+protected:
+ int focus;
+ int eq;
+};
+
extern Cus428State* OneState;
#endif
diff -r 7f7a0bf510a4 us428control/Cus428_ctls.cc
--- a/us428control/Cus428_ctls.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428_ctls.cc Thu Oct 05 14:25:18 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
* Controller for Tascam US-X2Y
*
@@ -25,7 +26,7 @@
Cus428State* OneState;
-void
+void
Cus428_ctls::dump(int n)
{
for (int m = 0; m < n; m++)
@@ -35,7 +36,7 @@ Cus428_ctls::dump(int n)
printf("\n");
}
-void
+void
Cus428_ctls::analyse(Cus428_ctls *Previous, unsigned n)
{
Cus428_ctls *PreviousL = Previous ? Previous : new Cus428_ctls();
@@ -43,7 +44,7 @@ Cus428_ctls::analyse(Cus428_ctls *Previo
for (; n < 9; n++) { //Sliders
char Diff = DiffValAt(PreviousL, n);
if (Diff)
- OneState->SliderChangedTo(n, ValAt(n));
+ OneState->SliderChangedTo(n, ValAt(n));
}
for (; n < 16; n++) { //Knobs
unsigned char Diff = DiffBitAt(PreviousL, n);
@@ -57,7 +58,7 @@ Cus428_ctls::analyse(Cus428_ctls *Previo
for (; n < sizeof(*this); n++) { //wheels
char Diff = DiffValAt(PreviousL, n);
if (Diff)
- OneState->WheelChangedTo((E_In84)n, Diff);
+ OneState->WheelChangedTo((E_In84)n, Diff);
}
if (0 == Previous)
delete PreviousL;
diff -r 7f7a0bf510a4 us428control/Cus428_ctls.h
--- a/us428control/Cus428_ctls.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/Cus428_ctls.h Thu Oct 05 14:28:25 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
* Controller for Tascam US-X2Y
*
@@ -24,7 +25,7 @@
class Cus428_ctls: public us428_ctls{
- public:
+public:
Cus428_ctls() {
memset(this, 0, sizeof(*this));
}
@@ -33,7 +34,7 @@ class Cus428_ctls: public us428_ctls{
bool Knob( int K) {
return ((char*)this)[K / 8] & (1 << K % 8);
}
- protected:
+protected:
unsigned char ValAt(int i) {
return ((unsigned char*)this)[i];
}
diff -r 7f7a0bf510a4 us428control/us428control.cc
--- a/us428control/us428control.cc Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/us428control.cc Thu Oct 05 14:28:34 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
* Controller for Tascam US-X2Y
*
@@ -61,7 +62,8 @@ static void usage(void)
{
printf("Tascam US-428 Control\n");
printf("version %s\n", VERSION);
- printf("usage: "PROGNAME" [-v verbosity_level 0..2] [-c card] [-D device] [-u usb-device]\n");
+ printf("usage: "PROGNAME" [-v verbosity_level 0..2] [-c card] [-D device] [-u usb-device] [-m mode]\n");
+ printf("mode is one of (native, mixxx)\n");
}
/*
* check the name id of the given hwdep handle
@@ -76,14 +78,14 @@ static int check_hwinfo(snd_hwdep_t *hw,
return err;
if (strcmp(snd_hwdep_info_get_id(info), id))
return -ENODEV;
- if (usb_dev_name)
+ if (usb_dev_name)
if (strcmp(snd_hwdep_info_get_name(info), usb_dev_name))
return -ENODEV;
return 0; /* ok */
}
-int US428Control(const char* DevName)
+int US428Control(const char* DevName, int mode)
{
snd_hwdep_t *hw;
int err;
@@ -117,7 +119,11 @@ int US428Control(const char* DevName)
return -ENOMEM;
}
us428ctls_sharedmem->CtlSnapShotRed = us428ctls_sharedmem->CtlSnapShotLast;
- OneState = new Cus428State(us428ctls_sharedmem);
+ if (mode == 1)
+ OneState = new Cus428StateMixxx(us428ctls_sharedmem);
+ else
+ OneState = new Cus428State(us428ctls_sharedmem);
+
OneState->InitDevice();
while ((pollrc = poll(pfds, npfd, 60000)) >= 0) {
@@ -152,12 +158,13 @@ int main (int argc, char *argv[])
int main (int argc, char *argv[])
{
int c;
+ int mode = 0;
int card = -1;
char *device_name = NULL,
*usb_device_name = getenv("DEVICE");
char name[64];
- while ((c = getopt(argc, argv, "c:D:u:v:")) != -1) {
+ while ((c = getopt(argc, argv, "c:D:u:v:m:")) != -1) {
switch (c) {
case 'c':
card = atoi(optarg);
@@ -170,6 +177,10 @@ int main (int argc, char *argv[])
break;
case 'v':
verbose = atoi(optarg);
+ break;
+ case 'm':
+ if (!strcmp(optarg, "mixxx"))
+ mode = 1;
break;
default:
usage();
@@ -190,18 +201,18 @@ int main (int argc, char *argv[])
}
}
if (device_name) {
- return US428Control(device_name) != 0;
+ return US428Control(device_name, mode) != 0;
}
if (card >= 0) {
sprintf(name, "hw:%d", card);
- return US428Control(name) != 0;
+ return US428Control(name, mode) != 0;
}
/* probe the all cards */
for (c = 0; c < SND_CARDS; c++) {
- // verbose--;
+ // verbose--;
sprintf(name, "hw:%d", c);
- if (! US428Control(name))
+ if (!US428Control(name, mode))
card = c;
}
if (card < 0) {
diff -r 7f7a0bf510a4 us428control/usbus428ctldefs.h
--- a/us428control/usbus428ctldefs.h Tue Sep 12 15:35:53 2006 +0200
+++ b/us428control/usbus428ctldefs.h Thu Oct 05 14:29:28 2006 +0200
@@ -1,3 +1,4 @@
+/* -*- mode:C++; indent-tabs-mode:t; tab-width:8; c-basic-offset: 8 -*- */
/*
*
* Copyright (c) 2003 by Karsten Wiese <annabellesgarden@yahoo.de>
@@ -64,7 +65,7 @@ struct us428_ctls{
unsigned char Select;
unsigned char Mute;
unsigned char UNKNOWN;
- unsigned char Switch;
+ unsigned char Switch;
unsigned char Wheel[5];
};
@@ -82,15 +83,15 @@ enum {
typedef struct usX2Y_volume {
unsigned char Channel,
- LH,
- LL,
- RH,
- RL;
+ LH,
+ LL,
+ RH,
+ RL;
unsigned char Slider;
char Pan,
- Mute;
-#ifdef __cplusplus
- public:
+ Mute;
+#ifdef __cplusplus
+public:
void init(unsigned char _Channel) {
memset(this, 0, sizeof(*this));
Channel = _Channel;
@@ -119,7 +120,7 @@ typedef struct usX2Y_volume {
if (Grob) {
static int GrobVals[] = {-128, -64, 0, 64, 127};
int i = 4;
- while (i >= 0 && GrobVals[i] > Pan)
+ while (i >= 0 && GrobVals[i] > Pan)
i--;
if (GrobVals[i] != Pan && RawValue < 0)
i++;
@@ -145,7 +146,7 @@ struct us428_lights{
struct us428_lights{
us428_setByte_t Light[7];
#ifdef __cplusplus
- public:
+public:
enum eLight{
eL_Select0 = 0,
eL_Rec0 = 8,
@@ -158,7 +159,12 @@ struct us428_lights{
eL_FFwd = 29,
eL_Play = 30,
eL_Record = 31,
- eL_Null
+ eL_AnalogDigital = 32,
+ eL_Null = 34,
+ eL_Low = 36,
+ eL_LowMid = 37,
+ eL_HiMid = 38,
+ eL_High = 39
};
bool LightIs(int L){
return Light[L / 8].Value & (1 << (L % 8));
[-- Attachment #3: Type: text/plain, Size: 348 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 161 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] us428control support for mixxx
[not found] ` <1a9cd1af0610050549l4e92a8a5v21256f05f7606440@mail.gmail.com>
2006-10-05 12:51 ` CTAF ctaf
@ 2006-10-05 13:00 ` Takashi Iwai
1 sibling, 0 replies; 7+ messages in thread
From: Takashi Iwai @ 2006-10-05 13:00 UTC (permalink / raw)
To: CTAF ctaf; +Cc: alsa-devel
At Thu, 5 Oct 2006 14:49:35 +0200,
CTAF ctaf wrote:
>
> here is the patch with good indentation :-)
Thanks, applied to ALSA HG tree now.
Takashi
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-10-05 13:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-01 8:20 [PATCH] us428control support for mixxx GESTES Cedric
-- strict thread matches above, loose matches on Subject: below --
2006-10-05 0:39 gtrfree
2006-09-30 16:06 CTAF ctaf
2006-10-04 16:16 ` Takashi Iwai
2006-10-04 17:04 ` CTAF ctaf
[not found] ` <1a9cd1af0610050549l4e92a8a5v21256f05f7606440@mail.gmail.com>
2006-10-05 12:51 ` CTAF ctaf
2006-10-05 13:00 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.