Skip to main content

Python library for reading and writing Native Instruments Traktor Pro TSI mapping files

Project description

py-ni-traktor-tsi

Python library for reading and writing Native Instruments Traktor Pro TSI mapping files.

What is TSI?

TSI files are Traktor's controller mapping format. They contain XML with a Base64-encoded binary blob using a nested TLV (Tag-Length-Value) structure. This library handles the binary format so you can programmatically create and modify mappings.

Installation

pip install -e .

Usage

Parse an existing TSI

from traktor_tsi import parse_tsi, get_device_info

binary = parse_tsi("my_mapping.tsi")
info = get_device_info(binary)
print(info)
# {'name': 'Traktor.Kontrol X1 MK2.Default', 'comment': 'My Mapping', ...}

Build a mapping entry

from traktor_tsi import (
    build_cmai, build_cmad_button, build_ddcb,
    rebuild_tsi, write_tsi,
    CMD_SLOT_MUTE, slot_target,
)

# Mute toggle for Deck A, Stem 1
cmad = build_cmad_button(target=slot_target('A', 1), interaction_mode=1)
cmai = build_cmai(midi_idx=0, mapping_type=0, cmd_id=CMD_SLOT_MUTE, cmad_payload=cmad)

ddcb = build_ddcb([cmai], ['Left.HotCue 1'])
new_binary = rebuild_tsi(original_binary, ddcb, comment='My Stems Mapping')
write_tsi(new_binary, 'output.tsi', 'template.tsi')

CMAD field reference

Offset Field Description
0 DeviceType Always 4
4 ControlType 0=Button, 1=Knob, 0xFFFF=Output
8 InteractionMode 1=Toggle, 2=Direct, 3=Absolute, 8=Output
12 Target Deck/slot/FX assignment (0-15)
20 Invert 0 or 1
52 Cond1ModifierCmd Modifier command ID for condition 1
56 Cond1Value Required modifier value
60 Cond2Value Condition 2 value
64 Cond2ModifierCmd Modifier command ID for condition 2
100 TriggerRelease 0=on press, 1=on release

Example: X1 MK2 Stems

See examples/x1_mk2_stems.py - generates a 188-entry mapping that turns the X1 MK2 into a dedicated stems controller for 4 decks.

python -m examples.x1_mk2_stems \
    --source StemsX1MK2.tsi \
    --output X1_MK2_Stems_trosha_b.tsi

Binary format

The TSI binary uses nested TLV chunks (4-byte ASCII tag + 4-byte BE length + payload):

DIOM > DIOI, DEVS > DEVI > DDAT > DDIF, DDIV, DDIC, DDPT, DDDC, DDCB, DVST

Command IDs sourced from cmdr-editor.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_ni_traktor_tsi-0.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_ni_traktor_tsi-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file py_ni_traktor_tsi-0.1.1.tar.gz.

File metadata

  • Download URL: py_ni_traktor_tsi-0.1.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_ni_traktor_tsi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a20a4961f73f49c129a3ed844504ba59155fe37cebeba47d6394ea71f6d55adb
MD5 c79b068375887ce8782b3efc241cc223
BLAKE2b-256 f4066437db8a838d5f9967e9635bd0d11b099b7465b9e33e097395d260c48110

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_ni_traktor_tsi-0.1.1.tar.gz:

Publisher: publish.yml on troshab/py-ni-traktor-tsi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_ni_traktor_tsi-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_ni_traktor_tsi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d042f82882dbea45be2592567e55be92132408b5391ea31206c59c3a4a57334b
MD5 2534688bf2004157595ed6d5aca9da9f
BLAKE2b-256 784b203013069f4edaabf775f2162052a9f5012e68b0a00196aaf8f9417bb369

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_ni_traktor_tsi-0.1.1-py3-none-any.whl:

Publisher: publish.yml on troshab/py-ni-traktor-tsi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page