Cross-Reference List of all Variables in a MT Pro Project

FlorianBome

2018-02-05 14:52:08

A user of MIDI Translator Pro created a small utility to create a cross reference of all used variables in a MIDI Translator Pro project. It outputs two lists: 1) by variable in which translators the variable is used, and 2) by translator, which variables are used in a given translator.

Such functionality is planned for a future version of MIDI Translator Pro, but for now this utility might be useful for you.

Usage: 1) open the project file in MIDI Translator Pro 2) Use File|Export Project As Text to save the file as a text file 3) run the attached .exe file (a command line window appears) 4) from an explorer window, drag the exported .txt file to the command line. Press the BACKSPACE key 4 times to remove the .txt file extension, then ENTER 5) the program creates a file with appended name "-Liste Variables.txt" which contains the cross-reference

Note: the program is French, but it should be easy to use it with the instructions above.

Example output:

C:\Novation_Launchpad_Pong.txt
--------------------------------------

ORDRE ALPHABETIQUE DES VARIABLES
--------------------------------
Variable - Translator
i0 000.000
i0 002.008
i0 002.009
i1 000.000
i1 002.008
i1 002.009
i2 000.000
i2 002.008
i2 002.009
i3 000.000
i3 002.008
(...)
Nombre variables :  90 
  
ORDRE DES TRANSLATORS
---------------------
Translator - Variable
000.000 i0
000.000 i1
000.000 i2
000.000 i3
000.000 kc
000.000 ks
000.000 kt
000.000 lx
000.000 ly
001.018 pp
002.000 kg
002.001 kx
002.001 ky
002.001 lx
002.001 ly
002.003 kg
002.006 kr
002.007 ks
(...)

Note that the program is not foolproof and provided to you without warranty of any kind. Bome Software has not created this program and merely makes it available as a courtesy.


Attachments:

mtpro_varlist_v6.exe

Steve-Bome Forum Moderator

2018-02-05 16:22:48

comment

Nice,

I might try this sometime if I get a large file from someone else that is not well documented. Usually I don’t need to do this for my project files as I document all of my variables. I usually document all global variable in a preset I call “Init” with translator “Init Global Variables”. For local variables I document them within each translator. In addition to initializing them I put in comments prior to the initialization, what each is for: example

//fader 1 target
g1=0
// fader 1 current postion
ga=0
// fader 1 timer running statuts
ha=0
// precision
ia=3

Steve-Bome Forum Moderator

2018-02-06 19:58:39

I created a quick and dirty awk script that does something similar. Right now it seems to handles rules section pretty well but I have yet to figure out how to implement input and output.

I invoke it with the following *nix command

awk -f scriptfilename inputfilename | sort | uniq

Here is the script. Anyone, feel free to improve on it and re-publish/share.

Steve

bome@sniz.biz

Independent Bome Programming Specialist

Bome Q&A moderator

————–

 

BEGIN {IGNORECASE }
match($0, /([x].*)(Translator.*)/,a) {tr++; name[tr]=a[2] ;}
# I don’t think I need the below unless I want to print it
#/.*//.*/ {print}
match($0,/(.*)([g-z][a-z0-9])([=<>])/, a) {var=a[2]; var2[var,tr]++ }
#;printf(“%s:%s:%sn”,name[tr],var, var2[var,tr]) }
match($0,/([=<>])([g-z][a-z0-9])(.*)/,a) {var=a[2]; var2[var,tr]++ }
match($0,/(==)([g-z][a-z0-9])(.*)/,a) {var=a[2]; var2[var,tr]++ }
match($0,/(.*)([g-z][a-z0-9])(==)/, a) {var=a[2]; var2[var,tr]++ }
match($0,/(!=)([g-z][a-z0-9])(.*)/,a) {var=a[2]; var2[var,tr]++ }
match($0,/(.*)([g-z][a-z0-9])(!=)/, a) {var=a[2]; var2[var,tr]++ }
match($0,/(.*then.*)([g-z][a-z0-9])(=)/, a) {var=a[2]; var2[var,tr]++ }
match($0,/(.*then.*)(=)([g-z][a-z0-9])/,a) {var=a[3]; var2[var,tr]++ }
# The below matches input and output but still needs work. Commenting out for now
# First
#match($0,/(^Incoming[^’]*)(‘)([g-z][a-z0-9])(‘)/,a) {var=a[3]; var2[var,tr]++ }
# Need to figure out if any others might need to iterate over the string
# Last
#match($0,/(^Incoming.*)(‘)([g-z][a-z0-9])(‘)/,a) {var=a[3]; var2[var,tr]++ }
# First
#match($0,/(^Outgoing: MIDI[^s]*)(s)([g-z][a-z0-9])(s)/,a) {var=a[3]; var2[var,tr]++ }
# Last
#match($0,/(^Outgoing: MIDI.*)(s)([g-z][a-z0-9])(s)/,a) {var=a[3]; var2[var,tr]++ }
END {
for (y in var2)
{
z = substr(y,3,length(y))
b = substr(y,4)
#print b,
print name[b], substr(y,1,2)
}
#for (x=1; x<=tr ; x++)
#print x ,” “name[x]
#print tr ” Total Translators”
}

 

Steve-Bome Forum Moderator

2018-02-11 17:46:46

I just updated my awk file that captures all global variables (hopefully I covered all cases)

It is attached below

# bmt.awk
# Document all Global Variables in a Bome BMT Project File
# By Steven J. Caldwell 11-Feb-2018
# please send any corrections to the author
# bome@sniz.biz
# Steps
# 1) Eport your project into a text file
# 2) Run the following command
# $awk -f bmt.awk filename | sort -t: -k 1 -n | uniq > outputfile
# Caputures global variables only and saves to the output file
# Format of output file will look like this
# …data excluded above
# 26.3: Bank Select LSB – gb
# 26.3: Bank Select LSB – gd
# 26.3: Bank Select LSB – gf
# 26.3: Bank Select LSB – ha
# 26.3: Bank Select LSB – hb
# 26.3: Bank Select LSB – hc
# 314 Total Translators

 

 


Attachments:

bmt.awk

pedro.estrela

2020-01-30 00:14:17

this AWK script is really useful. A minor improvement is that it ignores local variables


 

This is a small wrapper around it that automates the grepping and post-formatting, and adds an outgoing timers (useful to show the code flow):
https://github.com/pestrela/music_scripts/blob/master/traktor/tools_traktor/bome_analyse_project.sh

 

This python tool shows the unused variables that are still free to use:

https://github.com/pestrela/music_scripts/blob/master/traktor/tools_traktor/bome_find_unused_vars.py

Steve-Bome Forum Moderator

2020-01-30 00:22:41

Hi, feel free to reach out to me via email whenever. I've made several revisions since I posted this almost a year ago. It keeps getting better.

Steve Caldwell
Bome Q and A Moderator and
Independent Bome Consultant/Specialist
bome@sniz.biz

NK

2020-02-24 17:42:04

Did you ever think about clear names for variables? Should not to hard to implement and would be really helpful if you could see

"ga - shift toggle"

"gb - option toggle"

"gc - whatever"

and so on in the dropdown. You would know which variables are already in use and what they mean instantly instead of strange stuff like documentation at some other place.

Steve-Bome Forum Moderator

2020-02-24 18:46:03

comment

Yes that is on the "wish list" Steve Caldwell Bome Q and A Moderator and Independent Bome Consultant/Specialist bome@sniz.biz

pedro.estrela

2020-10-04 19:11:50

comment

I've added this post to the advanced mappings index: https://www.bomeloft.com/support/kb/index-of-advanced-posts-and-tools