mirror of
https://github.com/alsa-project/alsa-tools.git
synced 2025-10-29 05:40:25 -04:00
us428control support for mixxx
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 Signed-off-by: Cedric GESTES <goctaf@gmail.com>
This commit is contained in:
parent
b956edf51f
commit
b715a9637d
8 changed files with 395 additions and 153 deletions
|
|
@ -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,23 +72,101 @@ void Cus428State::SendVolume(usX2Y_volume &V)
|
|||
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);
|
||||
else
|
||||
UserSliderChangedTo(S, New);
|
||||
}
|
||||
|
||||
void Cus428State::SliderSend(int S)
|
||||
void Cus428State::UserKnobChangedTo(eKnobs K, bool V)
|
||||
{
|
||||
Midi.SendMidiControl(0x40 + S, ((unsigned char*)us428_ctls)[S] / 2);
|
||||
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)
|
||||
{
|
||||
switch (K & ~(StateInputMonitor() ? 3 : -1)) {
|
||||
|
|
@ -109,75 +192,7 @@ void Cus428State::KnobChangedTo(eKnobs K, bool V)
|
|||
}
|
||||
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, bool V)
|
|||
}
|
||||
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);
|
||||
}
|
||||
} 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) {
|
||||
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 W, char Diff)
|
|||
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::WheelChangedTo(E_In84 W, char Diff)
|
|||
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 ( unsigned char T )
|
|||
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 ( unsigned char T )
|
|||
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]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue