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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_ni_traktor_tsi-0.2.0.tar.gz.
File metadata
- Download URL: py_ni_traktor_tsi-0.2.0.tar.gz
- Upload date:
- Size: 18.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b405053e29dfb879960ab72f6bbd243bd84f74ebf4af41f2a00668b8a74045f
|
|
| MD5 |
463c95f73364f6f9197c1ffd1188d13f
|
|
| BLAKE2b-256 |
004ae5f548c1e7e144423efd0cde4018633ff056fe10ea3aa30c5aa27e9e19c0
|
Provenance
The following attestation bundles were made for py_ni_traktor_tsi-0.2.0.tar.gz:
Publisher:
publish.yml on troshab/py-ni-traktor-tsi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ni_traktor_tsi-0.2.0.tar.gz -
Subject digest:
6b405053e29dfb879960ab72f6bbd243bd84f74ebf4af41f2a00668b8a74045f - Sigstore transparency entry: 1008288061
- Sigstore integration time:
-
Permalink:
troshab/py-ni-traktor-tsi@72000aafef83d1f336f61af71dca103b00c58260 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/troshab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@72000aafef83d1f336f61af71dca103b00c58260 -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_ni_traktor_tsi-0.2.0-py3-none-any.whl.
File metadata
- Download URL: py_ni_traktor_tsi-0.2.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae4b0e6296c3c5ed1b7ac68a99ec3510257fcd72456d9e7ff630ee0a43b99991
|
|
| MD5 |
c7d2e0a22d2568d766d452d11a721ea4
|
|
| BLAKE2b-256 |
ba1ab8414b1c835cc1754e1ddd7a26ed2d9081b9f7d020639435bcc04870af23
|
Provenance
The following attestation bundles were made for py_ni_traktor_tsi-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on troshab/py-ni-traktor-tsi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_ni_traktor_tsi-0.2.0-py3-none-any.whl -
Subject digest:
ae4b0e6296c3c5ed1b7ac68a99ec3510257fcd72456d9e7ff630ee0a43b99991 - Sigstore transparency entry: 1008288065
- Sigstore integration time:
-
Permalink:
troshab/py-ni-traktor-tsi@72000aafef83d1f336f61af71dca103b00c58260 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/troshab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@72000aafef83d1f336f61af71dca103b00c58260 -
Trigger Event:
release
-
Statement type: