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.0.tar.gz (7.6 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.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_ni_traktor_tsi-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 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.0.tar.gz
Algorithm Hash digest
SHA256 a8247ed778cc8b0ad353c41cfb8759f96826eb6db047b15d8955223a59d694d6
MD5 7a6d75a8e681e880711d66ba7693de39
BLAKE2b-256 2fa0dbfe5eeb12a1a91f6d5a3ad64f42102e8ff267430ace765804bd24ba4422

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_ni_traktor_tsi-0.1.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_ni_traktor_tsi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e714fbb3ab4f5edf806dc1430fbe7a39df5a529df5f5828e4c8044446c7381a
MD5 0ef3bd15e6cc6215f9516fa163eddc4f
BLAKE2b-256 f7e09f38bc54ccdeec9c9783ac802e69641de94e7eb0086024ee27484ac7a2b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_ni_traktor_tsi-0.1.0-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