Skip to main content

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

Release files for py-ni-traktor-tsi 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-ni-traktor-tsi 0.2.0
File Size Uploaded
py_ni_traktor_tsi-0.2.0.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-ni-traktor-tsi 0.2.0
File Interpreter ABI Platform
py_ni_traktor_tsi-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.8 kB

Release files / py_ni_traktor_tsi-0.2.0.tar.gz

Download URL py_ni_traktor_tsi-0.2.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6b405053e29dfb879960ab72f6bbd243bd84f74ebf4af41f2a00668b8a74045f
BLAKE2b-256 checksum
How to use checksums
004ae5f548c1e7e144423efd0cde4018633ff056fe10ea3aa30c5aa27e9e19c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2026.

Transparency log

Release files / py_ni_traktor_tsi-0.2.0-py3-none-any.whl

Download URL py_ni_traktor_tsi-0.2.0-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae4b0e6296c3c5ed1b7ac68a99ec3510257fcd72456d9e7ff630ee0a43b99991
BLAKE2b-256 checksum
How to use checksums
ba1ab8414b1c835cc1754e1ddd7a26ed2d9081b9f7d020639435bcc04870af23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page