/traktor-s4-mk1-midify

Get MIDI signals from a Traktor S4 DJ controller under linux

Primary LanguagePythonMIT LicenseMIT

traktor-s4-mk1-midify

Translate events from a Traktor S4 mk1 DJ controller generated by the linux snd-usb-caiaq kernel module to MIDI signals which can be used by Mixxx (virtual DJ software).

Setup

  1. Check that you have the snd-usb-caiaq kernel module enabled:
    # lsmod | grep snd_usb_caiaq
    snd_usb_caiaq          57344  0
    snd_rawmidi            36864  3 snd_seq_midi,snd_usbmidi_lib,snd_usb_caiaq
    snd_pcm               106496  14 snd_hda_codec_hdmi,snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_sof,snd_sof_intel_hda_common,snd_soc_core,snd_hda_core,snd_usb_caiaq,snd_pcm_dmaengine
    snd                    90112  33 snd_hda_codec_generic,snd_seq,snd_seq_device,snd_hda_codec_hdmi,snd_hwdep,snd_hda_intel,snd_usb_audio,snd_usbmidi_lib,snd_hda_codec,snd_hda_codec_realtek,snd_timer,snd_compress,thinkpad_acpi,snd_soc_core,snd_pcm,snd_usb_caiaq,snd_rawmidi
  2. Check that you have amixer/aplay - on Ubuntu they're in the alsa-utils package:
    # amixer controls
    numid=43,iface=CARD,name='HDMI/DP,pcm=10 Jack'
    numid=19,iface=CARD,name='HDMI/DP,pcm=3 Jack'
    numid=25,iface=CARD,name='HDMI/DP,pcm=7 Jack'
    ...
    # aplay -l |grep Traktor
    card 1: TraktorKontrolS [Traktor Kontrol S4], device 0: Traktor Kontrol S4 [Traktor Kontrol S4]
  3. You will need the following packages in order to build and install: libasound2-dev and libjack-dev (on Ubuntu these can be install using apt)
  4. Install this package using pip install . in the project root dir (Python 3 / pip required)
  5. Run traktor-s4-mk1-midify and check that the controller is detected:
    # traktor-s4-mk1-midify
    Jog sensitivity must be between 1 and 100. Using default value (5).
    Detected ALSA device:
    card 1: TraktorKontrolS [Traktor Kontrol S4], device 0: Traktor Kontrol S4 [Traktor Kontrol S4]
    Detected evdev:
    Traktor Kontrol S4      /dev/input/event6       usb-0000:07:00.0-2.2/input0
  6. Launch Mixxx and configure it to use the MIDI device named traktor-s4-mk1-midify

Usage

You should ensure traktor-s4-mk1-midify is running before starting Mixxx. You could run it in the background using screen or similar.

For example, this command would run traktor-s4-mk1-midify the background and then launch Mixxx:

screen -dmS ts4m traktor-s4-mk1-midify && mixxx

CLI options:

# traktor-s4-mk1-midify -h
usage: traktor-s4-mk1-midify [-h] [-j JOG_SENSITIVITY] [-d]

Convert events generated by the snd-usb-caiaq kernel module to MIDI signals

options:
  -h, --help            show this help message and exit
  -j JOG_SENSITIVITY, --jog_sensitivity JOG_SENSITIVITY
                        Adjust jog wheel sensitivity (min: 1, max: 100, default: 5)
  -d, --debug           Show debug log messages

Notes

  • LEDs are controlled by shelling out to ALSA. See the output below for an idea of what can be controlled this way. (Note: the controller seems to need to be communicating with Mixxx and/or this program to work properly):
    # amixer -c TraktorKontrolS controls |grep -i sync
    numid=79,iface=HWDEP,name='LED: Deck A: Sync'
    numid=123,iface=HWDEP,name='LED: Deck B: Sync'
    
    [13] blaxpot@whydah-navi ~
    # amixer -c TraktorKontrolS cset numid=79 31
    numid=79,iface=HWDEP,name='LED: Deck A: Sync'
      ; type=INTEGER,access=rw------,values=1,min=0,max=31,step=0
      : values=31
  • Get debug logs from Mixxx: mixxx --controllerDebug --developer
  • Configure inputs / outputs properly in ~/.asoundrc:
    pcm.TraktorS4InputCOutputMain { type plug; slave.pcm "hw:TraktorKontrolS,0,0"; }
    pcm.TraktorS4InputDOutputHeadphones { type plug; slave.pcm "hw:TraktorKontrolS,0,1"; }