us428control support for mixxx
PATCH 1/1 us428control support for mixxx
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.
us428control/Cus428Midi.h +14 -5
@@ -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.
us428control/Cus428State.cc +307 -119
473 lines not on this page · raw message
us428control/Cus428State.h +19 -2
@@ -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
us428control/us428control.cc +18 -8
@@ -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) {
us428control/usbus428ctldefs.h +8 -3
@@ -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 ));
-------------------------------------------------------------------------
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
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel