Compare commits

...

17 Commits
0.5 ... master

Author SHA1 Message Date
nixo 6d5a3b1ef4 add guix build file 2020-07-25 21:44:33 +02:00
nixo e00ab5e45b Fix jog back on djcontrol instinct 2020-07-25 21:30:17 +02:00
Albert Graef b6068a73c0 Minimal Mackie emulation for the Harley Benton MP-100 a.k.a. MeloAudio MIDI Commander. 2019-12-18 10:56:19 +01:00
Albert Graef dc626710e6 Install midizap-mode automatically if Emacs is found during installation. Update the documentation. 2018-11-16 21:18:54 +01:00
Albert Graef 8c622bd085 midizap-mode: Add keysyms to auto-complete keywords table. 2018-11-16 20:37:58 +01:00
Albert Graef e53e3b3140 Add some snippets for Emacs yasnippets. 2018-11-13 08:31:41 +01:00
Albert Graef 8fef722919 Remove unneeded changes to midizap mode syntax table. 2018-11-11 18:59:24 +01:00
Albert Graef 24e346c733 Comment changes. 2018-11-11 10:12:21 +01:00
Albert Graef 240d30da7d Comment changes. 2018-11-11 00:31:31 +01:00
Albert Graef 951fa8fb17 Update the manual. 2018-11-10 23:46:20 +01:00
Albert Graef 7954230468 Add an Emacs mode for midizaprc files. 2018-11-10 23:45:56 +01:00
Albert Graef 357836a383 Fix glitches in regexes. 2018-11-06 07:31:56 +01:00
Albert Graef c2160b9893 Typo in the manual. 2018-10-16 08:33:48 +02:00
Albert Graef 7ce7f3c30b Fix up the detection of our own ports in the connection callback. 2018-10-16 08:29:22 +02:00
Albert Graef 15b8b574b3 Update the manual. 2018-10-15 06:23:23 +02:00
Albert Graef b39484c0ac Make the -r optional, so that just 'midizap rcfile' will work. 2018-10-15 05:56:47 +02:00
Albert Graef 4947aca50f Fix an obscure bug in copying anyshift mod translations which might errorneously override the modulus in an existing translation. 2018-10-15 03:26:31 +02:00
14 changed files with 1377 additions and 1067 deletions

View File

@ -7,6 +7,12 @@ bindir=$(DESTDIR)$(prefix)/bin
mandir=$(DESTDIR)$(prefix)/share/man/man1
datadir=$(DESTDIR)/etc
# See whether emacs is installed and try to guess its installation prefix.
emacs_prefix = $(patsubst %/bin/emacs,%,$(shell which emacs 2>/dev/null))
ifneq ($(strip $(emacs_prefix)),)
elispdir = $(emacs_prefix)/share/emacs/site-lisp
endif
# Check to see whether we have Jack installed. Needs pkg-config.
JACK := $(shell pkg-config --libs jack 2>/dev/null)
@ -18,7 +24,7 @@ INSTALL_TARGETS = midizap $(wildcard midizap.1)
.PHONY: all world install uninstall man pdf clean realclean
all: midizap
all: midizap midizap-mode.el
# This also creates the manual page (see below).
world: all man
@ -27,6 +33,12 @@ install: all
install -d $(bindir) $(datadir) $(mandir)
install midizap $(bindir)
install -m 0644 example.midizaprc $(datadir)/midizaprc
ifneq ($(elispdir),)
# If emacs was found, or elispdir was specified manually, install
# midizap-mode.el into the elispdir directory.
install -d $(DESTDIR)$(elispdir)
install -m 0644 midizap-mode.el $(DESTDIR)$(elispdir)
endif
# If present, the manual page will be installed along with the program.
ifneq ($(findstring midizap.1, $(INSTALL_TARGETS)),)
install -m 0644 midizap.1 $(mandir)
@ -56,7 +68,7 @@ midizap.pdf: midizap.1
man -Tpdf ./midizap.1 > $@
clean:
rm -f midizap keys.h $(OBJ)
rm -f midizap keys.h keys.el midizap-mode.el $(OBJ)
realclean:
rm -f midizap midizap.1 midizap.pdf keys.h $(OBJ)
@ -64,6 +76,12 @@ realclean:
keys.h: keys.sed /usr/include/X11/keysymdef.h
sed -f keys.sed < /usr/include/X11/keysymdef.h > keys.h
keys.el: keywords.sed /usr/include/X11/keysymdef.h
sed -f keywords.sed < /usr/include/X11/keysymdef.h | tr '\n' ' ' > keys.el
midizap-mode.el: midizap-mode.el.in keys.el
sed '/;; keysyms/r keys.el' < midizap-mode.el.in > midizap-mode.el
readconfig.o: midizap.h keys.h
midizap.o: midizap.h jackdriver.h
jackdriver.o: jackdriver.h

View File

@ -6,7 +6,7 @@ midizap -- control your multimedia applications with MIDI
# Synopsis
midizap [-hkn] [-d[rskmj]] [-j *name*] [-ost[*n*]] [-P[*prio*]] [-r *rcfile*]
midizap [-hkn] [-d[rskmj]] [-j *name*] [-ost[*n*]] [-P[*prio*]] [[-r] *rcfile*]
# Options
@ -31,8 +31,8 @@ midizap [-hkn] [-d[rskmj]] [-j *name*] [-ost[*n*]] [-P[*prio*]] [-r *rcfile*]
-P[*prio*]
: Run with the given real-time priority (default: 90). See Section *Jack-Related Options*.
-r *rcfile*
: Set the configuration file name. Default: taken from the MIDIZAP_CONFIG_FILE environment variable if it exists, or ~/.midizaprc if it exists, /etc/midizaprc otherwise. See Section *Configuration File*.
[-r] *rcfile*
: Set the configuration file name. The `-r` is optional, but still supported for backward compatibility. Default: taken from the MIDIZAP_CONFIG_FILE environment variable if it exists, or ~/.midizaprc if it exists, /etc/midizaprc otherwise. See Section *Configuration File*.
-s[*n*]
: Pass through system messages from MIDI input to output; *n* optionally specifies the port (0 = none, 1 = first, 2 = second port only), default is pass-through on both ports (if available). This overrides the corresponding directive in the configuration file. See Section *Jack-Related Options*.
@ -42,13 +42,11 @@ midizap [-hkn] [-d[rskmj]] [-j *name*] [-ost[*n*]] [-P[*prio*]] [-r *rcfile*]
# Description
midizap lets you control your multimedia applications using [MIDI][], the Musical Instrument Digital Interface. Modern MIDI controllers are often USB class devices which can be connected to computers without any ado. midizap makes it possible to use this gear with just about any X11-based application. To these ends, it translates Jack MIDI input into X keyboard and mouse events, and optionally MIDI output. It does this by matching the `WM_CLASS` and `WM_NAME` properties of the window that has the keyboard focus against the regular expressions for each application section in its configuration (midizaprc) file. If a regex matches, the corresponding set of translations is used. If a matching section cannot be found, or if it doesn't define a suitable translation, the program falls back to a set of translations in a default section at the end of the file, if available.
midizap lets you control your multimedia applications using [MIDI][], the venerable "Musical Instrument Digital Interface" protocol which has been around since the 1980s. Modern MIDI controllers are usually USB class devices which don't require any special interface or driver, and they are often much cheaper than more specialized gear. With midizap you can leverage these devices to control just about any X11-based application. To these ends, it translates Jack MIDI input into X keyboard and mouse events, and optionally MIDI output. It does this by matching the class and title of the focused window against the regular expressions for each application section in its configuration (midizaprc) file. If a regex matches, the corresponding set of translations is used. If a matching section cannot be found, or if it doesn't define a suitable translation, the program falls back to a set of default translations.
The midizaprc file is just an ordinary text file which you can edit to configure the program. The configuration language is fairly straightforward, basically the file is just a list of MIDI messages (denoted with familiar human-readable mnemonics, no hex numbers!) and their translations, which is divided into sections for different applications. An example.midizaprc file is included in the sources to get you started, and you can find some more examples of configuration files for various purposes in the examples directory.
The midizaprc file is just an ordinary text file which you can edit to configure the program. The configuration language is fairly straightforward, basically the file is just a list of MIDI messages (denoted with familiar human-readable mnemonics, no hex numbers!) and their translations. An example.midizaprc file is included in the sources to get you started, and you can find more examples of configuration files for various purposes in the examples subdirectory.
midizap provides you with a way to hook up just about any MIDI controller to your applications. Even if your target application already supports MIDI, midizap's MIDI output option will be useful if your controller can't work directly with the application because of protocol incompatibilities. In particular, you can use midizap to turn pretty much any MIDI controller with enough faders and buttons into a Mackie-compatible mixing console ready to be used with most DAW (digital audio workstation) programs. Another common use case is video editing software, which rarely offers built-in MIDI support. midizap allows you to map the faders, encoders and buttons of your MIDI controller to keyboard commands of your video editor for cutting, marking, playback, scrolling, zooming, etc.
In other words, as long as the target application can be controlled with simple keyboard shortcuts and/or MIDI commands, chances are that midizap can make it work (at least to some extent) with your controller.
Even if your target application already supports MIDI, midizap's MIDI output option will be useful if your controller can't work directly with the application because of protocol incompatibilities. In particular, you can use midizap to turn any MIDI controller with enough faders and buttons into a Mackie-compatible device ready to be used with most DAW (digital audio workstation) programs. Another common use case is photo and video editing software. This kind of software often lacks built-in MIDI support, and midizap can then be used to map the faders, encoders and buttons of your MIDI controller to keyboard commands for adjusting colors, cutting, marking, playback, scrolling, zooming, etc. In other words, as long as the target application can be controlled with simple keyboard shortcuts and/or MIDI commands, chances are that midizap can make it work (at least to some extent) with your controller.
# Installation
@ -58,6 +56,8 @@ First, make sure that you have the required dependencies installed. The program
Then just run `make` and `sudo make install`. This installs the example.midizaprc file as /etc/midizaprc, and the midizap program and the manual page in the default install location. Usually this will be under /usr/local, but the installation prefix can be changed with the `prefix` variable in the Makefile. Also, package maintainers can use the `DESTDIR` variable to install into a staging directory for packaging purposes.
For users of the Emacs text editor we provide a midizap mode which does syntax-highlighting of midizaprc files and also lets you launch a midizap session in an Emacs buffer. If Emacs was found during installation, the midizap-mode.el file is installed into the share/emacs/site-lisp directory along with the other files. The Makefile tries to guess the proper installation prefix, but if necessary you can also set the `elispdir` variable or copy the file manually to a directory on your Emacs load-path. Please check midizap-mode.el for more detailed instructions.
# Configuration File
After installation the system-wide default configuration file will be in /etc/midizaprc, where the program will be able to find it. We recommend copying this file to your home directory, renaming it to .midizaprc:
@ -66,17 +66,21 @@ After installation the system-wide default configuration file will be in /etc/mi
The ~/.midizaprc file, if it exists, takes priority over /etc/midizaprc, so it becomes your personal default midizap configuration. The midizaprc file included in the distribution is really just an example; you're expected to edit this file to adjust the bindings for the MIDI controllers and the applications that you use.
It is also possible to specify the configuration file to be used, by invoking midizap with the `-r` option followed by the name of the midizaprc file on the command line. This is often used with more specialized configurations dealing with specific applications or MIDI controllers. E.g., to try one of sample configurations in the sources: `midizap -r examples/MPKmini2.midizaprc`
It is also possible to specify the configuration file to be used, by invoking midizap with the name of the midizaprc file on the command line. This is often used with more specialized configurations dealing with specific applications or MIDI controllers. E.g., to try one of the sample configurations in the sources:
~~~
midizap examples/APCmini.midizaprc
~~~
The program automatically reloads the midizaprc file whenever it notices that the file has been changed. Thus you can edit the file while the program keeps running, and have the changes take effect immediately without having to restart the program. When working on new translations, you may want to run the program in a terminal, and employ some or all of the debugging options explained below to see exactly how your translations are being processed.
# Basic Usage
The midizap program is a command line application, so you typically run it from the terminal. However, it is also possible to launch it from your Jack session manager (see *Jack-Related Options* below) or from your desktop environment's startup files once you've set up everything to your liking.
The midizap program is a command line application, so you typically run it from the terminal. However, it is also possible to launch it from your Jack session manager (see *Jack-Related Options* below) or from your desktop environment's startup files once you've set up everything to your liking. If you're an Emacs user, you can conveniently edit and launch midizap configurations using midizap's Emacs mode; please check the midizap-mode.el file included in the sources for details.
Try `midizap -h` for a brief summary of the available options with which the program can be invoked.
midizap uses [Jack][] for doing all its MIDI input and output, so you need to be able to run Jack and connect the Jack MIDI inputs and outputs of the program. We recommend using a Jack front-end and patchbay program like [QjackCtl][] for this purpose. In QjackCtl's setup, make sure that you have selected `seq` as the MIDI driver. This exposes the ALSA sequencer ports of your MIDI hardware and other non-Jack ALSA MIDI applications as Jack MIDI ports, so that they can easily be connected to midizap. As an alternative, you can also run [a2jmidid][] as a separate ALSA-Jack MIDI bridge. (The latter method works well with both Jack1 and Jack2. Jack's built-in ALSA-Jack MIDI bridge also works very well in Jack1, but in Jack2 it doesn't list the ALSA ports by their name, which makes it rather unusable there because you'll have to guess which port represents which device or application.)
midizap uses [Jack][] for doing all its MIDI input and output, so you need to be able to run Jack and connect the Jack MIDI inputs and outputs of the program. We recommend using a Jack front-end and patchbay program like [QjackCtl][] for this purpose. In QjackCtl's setup, make sure that you have selected `seq` as the MIDI driver. This exposes the ALSA sequencer ports of your MIDI hardware and other non-Jack ALSA MIDI applications as Jack MIDI ports, so that they can easily be connected to midizap. As an alternative, you can also run [a2jmidid][] as a separate ALSA-Jack MIDI bridge. The latter method works well with both Jack1 and Jack2. Jack's built-in bridge also does the job in Jack1, but in Jack2 it doesn't list the ALSA ports by their name, so it's better to use a2jmidid in that case. When in doubt, just use a2jmidid. You can have QJackCtl autostart a2jmidid by placing the command `a2jmidid -e &` into the "Execute script after Startup" field which can be found under "Options" in QJackctl's Setup dialog.
Having that set up, start Jack, make sure that your MIDI controller is connected, and try running `midizap` from the command line (without any arguments). In QjackCtl, open the Connections dialog and activate the second tab named "MIDI", which shows all available Jack MIDI inputs and outputs. On the right side of the MIDI tab, you should now see a client named `midizap` with one MIDI input port named `midi_in`. That's the one you need to connect to your MIDI controller, whose output port should be visible under the `alsa_midi` client on the left side of the dialog (or the `a2j` client, if you're using a2jmidid).
@ -143,9 +147,7 @@ Besides MIDI notes and control change (`CC`) messages, the midizap program also
# Jack-Related Options
There are some additional directives (and corresponding command line options) to configure midizap's Jack setup in various ways. We take a look at these in the following. If both the command line options and directives in the midizaprc file are used, the former take priority, so that it's possible to override the configuration settings from the command line.
Note that all these options can only be set at program startup. If you later edit the corresponding directives in the configuration file, the changes won't take effect until you restart the program.
There are some additional directives (and corresponding command line options) to configure midizap's Jack setup in various ways. If both the command line options and directives in the midizaprc file are used, the former take priority, so that it's possible to override the configuration settings from the command line. Note that all these options can only be set at program startup. If you later edit the corresponding directives in the configuration file, the changes won't take effect until you restart the program.
## Jack Client Name and MIDI Port Setup
@ -169,9 +171,11 @@ Not very surprisingly, at least one output port is needed if you want to output
## MIDI Connections
Setting up all the required connections for the Jack MIDI ports can be a tedious and error-prone task, especially if you have to deal with complex setups involving feedback and/or multiple midizap instances. It's all to easy to mess this up when doing it manually, and either end up with a dysfunctional setup or, even worse, MIDI feedback loops crashing your Jack MIDI clients. While it's possible to automatize the MIDI connections, e.g., with QjackCtl's persistent MIDI patchbay facility, this is often inconvenient if you need to accommodate multiple midizap configurations and you already have a complicated studio setup which you don't want to mess with.
Setting up all the required connections for the Jack MIDI ports can be a tedious and error-prone task, especially if you have to deal with complex setups involving feedback and/or multiple midizap instances. It's all to easy to mess this up when doing it manually, and end up with a dysfunctional setup or, even worse, MIDI feedback loops crashing your Jack MIDI clients. While it's possible to automatize the MIDI connections, e.g., with QjackCtl's persistent MIDI patchbay facility, this is often inconvenient if you need to accommodate multiple midizap configurations and you already have a complicated studio setup which you don't want to mess with.
As a remedy, midizap offers its own built-in patchbay functionality using the `JACK_IN` and `JACK_OUT` directives, which let you specify the required connections in the configuration itself and be done with it. The port number is tacked on to the directive, so, e.g., `JACK_IN2` connects the second input port (if the port number is omitted then the first port is assumed). The directive is followed by an (extended) regular expression (see the regex(7) manual page) to be matched against the Jack MIDI ports of your devices and applications. A connection will be established automatically by midizap whenever a Jack MIDI port matches the regular expression, as well as the port type and I/O direction. This also works dynamically, as new devices get added and new applications are launched at runtime.
As a remedy, midizap offers its own built-in patchbay functionality using the `JACK_IN` and `JACK_OUT` directives, which let you specify the required connections in the configuration itself and be done with it. The port number is tacked on to the directive, so, e.g., `JACK_IN2` connects the second input port. If the port number is omitted then it defaults to 1, so both `JACK_OUT1` and just `JACK_OUT` connect the first output port. The directive is followed by a regular expression to be matched against the Jack MIDI ports of your devices and applications. Please see the regex(7) manual page for a discussion of the syntax and meaning of regular expressions. Note that regular expressions come in two different flavors, "basic" and "extended"; midizap uses the latter kind.
A connection will be established automatically by midizap whenever a MIDI port belonging to another Jack client matches the regular expression, as well as the port type and I/O direction. This also works dynamically, as new devices get added and new applications are launched at runtime.
For instance, the following lines (from the XTouchONE.midizaprc example) connect midizap to an X-Touch One device on one side and Ardour's Mackie control port on the other:
@ -184,12 +188,18 @@ JACK_OUT2 X-Touch One MIDI 1
To break this down, the X-Touch One device will be connected to midizap's first input port, midizap's first output port to Ardour's Mackie control input, Ardour's Mackie control output to midizap's second input port, and midizap's second output port back to the device. This is a typical setup for bidirectional communication between controller and application as described in the *MIDI Feedback* section. The sample configurations in the examples folder in the sources have all been set up in this manner, so that they will create the required connections automatically.
Please note that at this time, the built-in patchbay is only available through these directives, there are no corresponding command line options. Also, only one directive can be specified for each port, but since midizap will connect to all ports matching the given regular expression, you can connect to more than one application or device by just listing all the alternatives. For instance, to have midizap's output connected to both Ardour and Pd, you might use a directive like:
Please note that in the present implementation, the built-in patchbay is only available through these directives, there are no corresponding command line options. Also, only one directive can be specified for each port, but since midizap will connect to all ports matching the given regular expression, you can connect to more than one application or device by just listing all the alternatives. For instance, to have midizap's output connected to both Ardour and Pd, you might use a directive like:
~~~
JACK_OUT1 ardour:MIDI control in|Pure Data Midi-In 1
~~~
All matches are done against full port names including the *client-name*`:` prefix, so you can specify exactly which ports of which clients should be connected. However, note that in contrast to the QJackCtl patchbay, midizap does substring matches by default, so that, e.g., `MIDI control` will match *any* Ardour MIDI control port, in any instance of the program (and also ports with the same name in other programs). If you want to specify an exact match, you need to use the `^` and `$` anchors as follows:
~~~
JACK_OUT1 ^ardour:MIDI control in$
~~~
## Pass-Through
If at least one output port is available then it also becomes possible to pass through MIDI messages from input to output unchanged. Two options are available for this: `-t` which passes through any ordinary (non-system) message for which there are no translations (not even in the default section), and `-s` which passes through all system messages. The former is convenient if the incoming MIDI data only needs to be modified in a few places to deal with slight variations in the protocol. The latter may be needed when the input data may contain system messages; midizap cannot translate these, but it can pass them on unchanged when necessary. You can find examples for both use cases in the examples folder in the sources.
@ -204,7 +214,7 @@ Various Jack session managers are available for Linux, but if you're running Qja
## Realtime Priorities
Finally, midizap also offers an option to run the program with *real-time priorities*. Jack itself usually does that anyway where needed, but midizap's main thread won't unless you run it with the `-P` option (`midizap -P`, or `midizap -P80` if you also want to specify the priority). Using this option, midizap should be able to get down to MIDI latencies in the 1 msec ballpark which should be good enough for most purposes. (Note that there's no need to use this option unless you actually notice high latencies or jitter in the MIDI output.)
Finally, midizap also offers an option to run the program with *real-time priorities*. Jack itself usually does that anyway where needed, but midizap's main thread won't unless you run it with the `-P` option. Using this option, midizap should be able to get down to MIDI latencies in the 1 msec ballpark which should be good enough for most purposes. (Note that there's no need to use this option unless you actually notice high latencies or jitter in the MIDI output.)
# Translation Syntax
@ -253,7 +263,7 @@ The header is followed by a list of translations which define what output should
Example:
~~~
[Terminal] CLASS ^.*-terminal.*|konsole|xterm$
[Terminal] CLASS ^(.*-terminal.*|konsole|xterm)$
F5 XK_Up
F#5 "pwd"
G5 XK_Down
@ -848,7 +858,7 @@ CC1[128] $CC0 # don't do this!
midizap *will* catch such mishaps after a few iterations, but it's better to avoid them in the first place. We mention in passing that in theory, recursive macro calls in conjunction with value lists and change detection make the configuration language Turing-complete. However, there's a quite stringent limit on the number of recursive calls, and there are no variables and no iteration constructs, so these facilities aren't really suitable for general-purpose programming.
But there's still a lot of fun to be had with macros despite their limitations. Here's another instructive example which spits out the individual bits of a controller value, using the approach that we discussed earlier in the context of nibble extraction. Input comes from `CC7` in the example, and bit #*i* of the controller value becomes `CC`*i* in the output, where *i* runs from 0 to 6. Note that each of these rules uses a successively smaller power of 2 as modulus and passes on the remainder to the next rule, while transposition is used to extract and output the topmost bit in the quotient.
But there's still a lot of fun to be had with macros despite their limitations. Here's another instructive example which spits out the individual bits of a controller value, using the approach that we discussed earlier in the context of nibble extraction. Input comes from `CC7` in the example, and bit #*i* of the controller value becomes `CC`*i* in the output, where *i* runs from 0 to 6. Note that each of these rules uses a successively smaller power of 2 as modulus and passes on the remainder to the next rule, while transposition is used to extract and output the topmost bit in the quotient. (You may want to run this example with debugging enabled to see what exactly is going on there.)
~~~
CC7[64]{0} $CC6 CC6'
@ -859,9 +869,7 @@ CC3[4]{0} $CC2 CC2'
CC2[2]{0} CC0 CC1'
~~~
You may want to run this example with debugging enabled to see what exactly is going on there.
The "naming" of macros is another issue worth discussing here. In principle, any message which can occur on the left-hand side of a mod translation (i.e., everything but `PC`) can also be used as a macro. Unfortunately, in general you can't be sure which messages might show up in *real* MIDI input. For instance, in the example above the macro translations for `CC2` to `CC6` might also be triggered by real MIDI input instead of macro calls. While this may be useful at times, e.g., for testing purposes, it is most likely going to confuse unsuspecting end users. As a remedy, midizap also provides a special kind of *macro event*, denoted `M0` to `M127`. These "synthetic" messages work exactly like `CC` messages, but they are guaranteed to never occur as real input, and they can *only* be used in macro calls and on the left-hand side of mod translations. We can rewrite the previous example using macro events as follows:
In principle, any message which can occur on the left-hand side of a mod translation (i.e., everything but `PC`) can also be used as a macro. Unfortunately, in general you can't be sure which messages might show up in *real* MIDI input. For instance, in the example above the macro translations for `CC2` to `CC6` might also be triggered by real MIDI input instead of macro calls. While this may be useful at times, e.g., for testing purposes, it is most likely going to confuse unsuspecting end users. As a remedy, midizap also provides a special kind of *macro event*, denoted `M0` to `M127`. These "synthetic" messages work exactly like `CC` messages, but they are guaranteed to never occur as real input, and they can *only* be used in macro calls and on the left-hand side of mod translations. We can rewrite the previous example using macro events as follows:
~~~
CC7[64]{0} $M6 CC6'
@ -911,9 +919,7 @@ translation ::= midi-token { key-token | midi-token }
directive ::= "DEBUG_REGEX" | "DEBUG_STROKES" | "DEBUG_KEYS" |
"DEBUG_MIDI" | "MIDI_OCTAVE" number |
"JACK_NAME" string | "JACK_PORTS" number |
"JACK_IN" regex | "JACK_OUT" regex |
"JACK_IN1" regex | "JACK_OUT1" regex |
"JACK_IN2" regex | "JACK_OUT2" regex |
"JACK_IN" [number] regex | "JACK_OUT" [number] regex |
"PASSTHROUGH" [ number ] |
"SYSTEM_PASSTHROUGH" [ number ]
@ -961,7 +967,7 @@ midizap is free and open source software licensed under the GPLv3, please see th
Copyright 2013 Eric Messick (FixedImagePhoto.com/Contact)
Copyright 2018 Albert Graef (<aggraef@gmail.com>)
This is a version of Eric Messick's ShuttlePRO program which has been redesigned to work with Jack MIDI instead of the Contour Design Shuttle devices. ShuttlePRO was written in 2013 by Eric Messick, based on earlier code by Trammell Hudson and Arendt David. The MIDI support was added by Albert Gräf. All the key and mouse translation features of the original program still work as before, but it goes without saying that the configuration language and the translation code have undergone some substantial changes to accommodate the MIDI input and output facilities. The Jack MIDI backend is based on code from Spencer Jackson's osc2midi utility, and on the simple_session_client.c example available in the Jack git repository.
midizap is a heavily modified version of the ShuttlePRO program which was written in 2013 by Eric Messick, based on earlier code by Trammell Hudson and Arendt David. All the key and mouse translation features of the original program still work as before, but it goes without saying that the configuration language and the translation code have undergone some substantial changes to accommodate the MIDI input and output facilities. The Jack MIDI backend is based on code from Spencer Jackson's osc2midi utility, and on the simple_session_client.c example available in the Jack git repository.
[MIDI]: https://www.midi.org/
[OSC]: http://opensoundcontrol.org/

View File

@ -150,7 +150,7 @@
# WM_CLASS). These have very similar key bindings, see e.g.:
# https://www.shotcut.org/howtos/keyboard-shortcuts/
[Kdenlive/Shotcut] ^shotcut|kdenlive$
[Kdenlive/Shotcut] ^(shotcut|kdenlive)$
# Both Kdenlive and Shotcut use the J-K-L shortcuts, where each
# successive J or L key decrements or increments the playback speed. We

View File

@ -1,6 +1,12 @@
# Mackie emulation for the AKAI APCmini
# This turns the APCmini into a Mackie-compatible controller, so that it can
# be used with Linux DAW programs like Ardour. The emulation is complicated
# by the APCmini having no encoders, no motorized faders, and not nearly as
# many dedicated buttons as a Mackie device. But it offers enough controls to
# be usable as a basic DAW controller. Tested with Ardour.
# Copyright (c) 2018 Albert Graef <aggraef@gmail.com>
# Copying and distribution of this file, with or without modification, are
@ -11,40 +17,29 @@
JACK_NAME "midizap-APCmini"
JACK_PORTS 2
# This turns the APCmini into a Mackie-compatible controller, so that it can
# be used with Linux DAW programs like Ardour. The emulation is complicated
# by the APCmini having no encoders, no motorized faders, and not nearly as
# many dedicated buttons as a Mackie device. But it offers enough controls to
# be usable as a basic DAW controller. I tested it with Ardour.
# SETUP: In Ardour, enable the Mackie control surface, then connect Ardour's
# Mackie control ports to midizap's midi_out and midi_in2 ports, and the
# APCmini to midizap's midi_in and midi_out2 ports. The following lines will
# take care of setting up all the connections automatically, but you still
# need to enable the Mackie control surface in Ardour, so that Ardour exposes
# the Mackie control ports.
# SETUP: The following lines will take care of setting up all the connections
# automatically, but you still need to enable the Mackie control surface in
# Ardour, so that Ardour exposes the Mackie control ports.
JACK_IN1 APC MINI MIDI 1
JACK_OUT1 ardour:mackie control in
JACK_IN2 ardour:mackie control out
JACK_OUT2 APC MINI MIDI 1
# PROTOCOL DOCUMENTATION: The Mackie protocol is fairly ubiquitous, but since
# manufacturers can't be bothered to properly *document* their stuff these
# days, we have to rely on volunteers who do their work using some reverse
# engineering. Here are the links that I found most useful:
# http://www.budgetfeatures.com/XctlDOC/Xctl Protocol for X-Touch V1.0.pdf
# (This chart really is a piece of art. It's actually about the Behringer
# X-Touch, but since that device is Mackie-compatible, there's a wealth of
# useful information in there; just ignore the bits which pertain to Xctl.)
# There's another fairly comprehensive one here (lacks the feedback messages,
# though):
# PROTOCOL DOCUMENTATION: The Mackie Control (MC) protocol is fairly
# ubiquitous, but since manufacturers can't be bothered to properly document
# their stuff these days, we have to rely on volunteers who do their work
# using some reverse engineering. Here are the links that I found most
# useful:
# This is fairly comprehensive, but lacks the feedback messages:
# http://www.jjlee.com/qlab/Mackie Control MIDI Map.pdf
# This chart really is a piece of art. It's actually about the Behringer
# X-Touch and its Xctl protocol, but there's useful information about MC in
# there as well:
# http://www.budgetfeatures.com/XctlDOC/Xctl Protocol for X-Touch V1.0.pdf
# Information about the APCmini can be found in the Akai forums here:
# http://community.akaipro.com/akai_professional/topics/midi-information-for-apc-mini

59
examples/MP100.midizaprc Normal file
View File

@ -0,0 +1,59 @@
# Minimal Mackie emulation for the Harley Benton MP-100 a.k.a. MeloAudio MIDI
# Commander foot controller (https://meloaudio.com)
# This device is rather limited in what it can do as a Mackie controller (no
# feedback, just 4 switches, 4 toggles, and 2 continuous controllers), but it
# may still come in handy to guitarists for basic hands-free DAW control. Note
# that we can't make good use of the bank switches on the device (the two
# extra switches on the right), since these always emit a PC message, which
# interferes with our use of the PC messages for the transport controls. It
# may be possible to do something better by configuring a custom mode on the
# device, but here we stick to what's available in the factory settings.
# Copyright (c) 2019 Albert Graef <aggraef@gmail.com>
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any
# warranty.
JACK_NAME "midizap-MP100"
JACK_PORTS 1
# Auto-connect to the MP-100 on the input, and Ardour's Mackie control input
# on the output side.
JACK_IN TSMIDI.* MIDI 1
JACK_OUT ardour:mackie control in
# The following configuration assumes that the MP-100 is set to mode 1 (JAMP),
# which is the default. Note that the controller numbers for the top row and
# the expression pedal inputs are specific to JAMP mode, so you will have to
# adjust these if you run the device in a different host mode. As implemented
# below, the controls are laid out as follows:
# top row: [mute] [solo] [rec] [select] EXP1: volume (current channel)
# bottom row: [stop] [play] [chan<] [chan>] EXP2: volume (master)
[MIDI]
# Note that MCP expects a note-on/off pair for each activation of the
# mure/solo/rec/select switches, while the MP-100 top switches act as toggles,
# so we have to use suitable mod translations for the top row.
# top row (mute/solo/rec/select for current channel)
CC22[] E1{127} E1{0} # Mute
CC25[] G#0{127} G#0{0} # Solo
CC24[] C0{127} C0{0} # Rec
CC26[] C2{127} C2{0} # Select
# bottom row (basic transport and bank controls)
PC0 A7 # Stop
PC1 A#7 # Play
PC2 C4 # Channel Left
PC3 C#4 # Channel Right
# EXP-1 and EXP-2 (current channel and master volume)
CC4[] PB[129]-1 # Volume
CC7[] PB[129]-9 # Master

View File

@ -435,10 +435,10 @@ connect_callback(jack_port_id_t a, jack_port_id_t b, int yn, void *seqq)
const char *aname = jack_port_name(ap);
const char *bname = jack_port_name(bp);
size_t l = strlen(seq->client_name);
if (!strncmp(seq->client_name, aname, l))
if (jack_port_is_mine(seq->jack_client, ap))
printf("%-*s %s: %s\n", (int)l+10, aname,
(yn ? "connected to" : "disconnected from"), bname);
else if (!strncmp(seq->client_name, bname, l))
else if (jack_port_is_mine(seq->jack_client, bp))
printf("%-*s %s: %s\n", (int)l+10, bname,
(yn ? "connected to" : "disconnected from"), aname);
}

3
keywords.sed Normal file
View File

@ -0,0 +1,3 @@
/^\#define/!d
s/^\#define //
s/^\([^[:space:]]*\).*$/"\1"/

112
midizap-mode.el.in Normal file
View File

@ -0,0 +1,112 @@
;;; midizap-mode.el --- midizap syntax highlighting for Emacs.
;;; Commentary:
;;; This is a simple mode for editing midizaprc files which provides basic
;;; syntax highlighting, and a command midizap-mode-run, bound to C-c C-c,
;;; which lets you quickly launch a midizap session (with options) on the
;;; edited midizaprc file in an Emacs buffer.
;;; Install this anywhere where Emacs finds it (e.g., in the Emacs site-lisp
;;; directory -- usually under /usr/share/emacs/site-lisp on Un*x systems, or
;;; in any directory on the Emacs load-path) and load it in your .emacs as
;;; follows:
;;; (require 'midizap-mode)
;;; The mode also supports auto-completion of midizaprc keywords, to make this
;;; work you'll need the auto-complete package available from MELPA, please
;;; check: https://github.com/auto-complete/auto-complete.
;;; In the midizap-mode subdirectory you'll find some snippets to be used with
;;; yasnippet (https://github.com/joaotavora/yasnippet); to use these, copy
;;; the entire folder to your ~/.emacs.d/snippets directory.
;;; Code:
(require 'comint)
(defconst midizap-keywords
(list
"DEBUG_REGEX" "DEBUG_STROKES" "DEBUG_KEYS" "DEBUG_MIDI"
"MIDI_OCTAVE" "JACK_NAME" "JACK_PORTS"
"JACK_IN" "JACK_IN1" "JACK_IN2"
"JACK_OUT" "JACK_OUT1" "JACK_OUT2"
"PASSTHROUGH" "SYSTEM_PASSTHROUGH"
"RELEASE" "SHIFT" "SHIFT1" "SHIFT2" "SHIFT3" "SHIFT4"
"CLASS" "TITLE"
;; keysyms
))
;;;###autoload
(define-generic-mode 'midizap-mode
nil
midizap-keywords
'(("^[[:blank:]]*\\(#.*\\)" 1 'font-lock-comment-face t)
("[[:blank:]]+\\(#.*\\)" 1 'font-lock-comment-face t)
("^[[:blank:]]*\\[\\([^\n[]+\\)\\]\\(.*\\)"
1 'font-lock-variable-name-face)
("\\<\\(\\([Kk][Pp]:\\)?[A-Ga-g][#Bb]?-?[0-9]+\\|\\([Mm]\\|[Cc][Hh]\\|[Pp][Bb]\\|[Pp][Cc]\\|[Cc][Cc]\\|[Cc][Pp]\\)[0-9]*\\|XK_[A-Za-z_0-9]+\\(/[UDH]\\)?\\)\\>" 1 'default)
("\\<\\([0-9]+\\)\\>" 1 'font-lock-constant-face))
(list "\\.midizaprc\\'")
(list 'midizap-mode-setup-function)
"Generic mode for midizap configuration files.")
(defvar midizap-mode-keymap (make-sparse-keymap)
"Keymap for midizap-mode.")
(defvar midizap-command "midizap -drk ")
(defvar ac-sources)
(defvar midizap-mode-ac-source
'((candidates . midizap-keywords)))
(defun midizap-mode-run (command)
"Run the current midizaprc file with COMMAND in a comint buffer."
(interactive
(list
(let ((command (eval midizap-command)))
(read-string "Run midizap with: " command))))
(unless (equal command (eval midizap-command))
(setq midizap-command command))
(save-some-buffers)
(let* ((file (buffer-file-name))
(buf-name (concat "*" file "*")))
(with-current-buffer (get-buffer-create buf-name)
(erase-buffer)
(comint-mode)
(comint-exec
buf-name
file
shell-file-name
nil
(list "-c" (concat command " " file)))
(display-buffer buf-name))))
(define-key midizap-mode-keymap "\C-c\C-c" 'midizap-mode-run)
(defun midizap-mode-setup-function ()
"Custom setup function for midizap-mode."
(make-local-variable 'parse-sexp-ignore-comments)
(make-local-variable 'comment-start)
(make-local-variable 'comment-start-skip)
(make-local-variable 'comment-end)
(setq parse-sexp-ignore-comments t
comment-end ""
comment-start "# "
comment-start-skip "# *"
)
(if (boundp 'ac-sources)
(progn
(add-to-list 'ac-modes 'midizap-mode)
(add-to-list 'ac-sources 'midizap-mode-ac-source))
(message "You may want to install and use auto-complete"))
(use-local-map midizap-mode-keymap)
)
(provide 'midizap-mode)
;; End:
;;; midizap-mode.el ends here

27
midizap-mode/midizaprc Normal file
View File

@ -0,0 +1,27 @@
# -*- mode: snippet -*-
# name: midizaprc template
# key: #
# --
# midizap configuration template for Emacs (requires yasnippet)
# Jack client name and ports/connections
# NOTE: Remove the JACK_PORTS and JACK_OUT lines if you don't need MIDI
# output. For bidirectional setups, use JACK_PORTS 2 and add JACK_IN2,
# JACK_OUT2 and a [MIDI2] section for the feedback connection.
JACK_NAME "${1:client-name}"
JACK_PORTS 1
JACK_IN ${2:controller-regex}
JACK_OUT ${3:application-regex}
# common debugging options (uncomment as needed)
#DEBUG_REGEX
#DEBUG_KEYS
#DEBUG_MIDI
# translations go here
[MIDI]

5
midizap-mode/section Normal file
View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: section header
# key: [
# --
[${1:name}] ${2:regex}

2038
midizap.1

File diff suppressed because it is too large Load Diff

View File

@ -1428,10 +1428,10 @@ handle_event(uint8_t *msg, uint8_t portno, int depth, int recursive)
} else if (msg[2] > 64) {
int step = get_cc_step(tr, portno, chan, msg[1], -1);
if (step) {
int d = (msg[2]-64)/step;
uint8_t d = (msg[2]-128)/step;
while (d) {
send_strokes(tr, portno, status, chan, msg[1], 0, 0, -1, depth);
d--;
d++;
}
}
}
@ -1609,7 +1609,7 @@ handle_event(uint8_t *msg, uint8_t portno, int depth, int recursive)
void help(char *progname)
{
fprintf(stderr, "Usage: %s [-hkn] [-d[rskmj]] [-ost[n]] [-j name] [-P[prio]] [-r rcfile]\n", progname);
fprintf(stderr, "Usage: %s [-hkn] [-d[rskmj]] [-ost[n]] [-j name] [-P[prio]] [[-r] rcfile]\n", progname);
fprintf(stderr, "-h print this message\n");
fprintf(stderr, "-d debug (r = regex, s = strokes, k = keys, m = midi, j = jack; default: all)\n");
fprintf(stderr, "-j jack client name (default: midizap)\n");
@ -1842,11 +1842,16 @@ main(int argc, char **argv)
}
}
if (optind < argc) {
if (optind+1 < argc) {
help(argv[0]);
exit(1);
}
if (optind < argc) {
config_file_name = argv[optind];
add_command(absolute_path(argv[optind]), 1);
}
if (command_line) jack_command_line = command_line;
initdisplay();

51
midizap.scm Normal file
View File

@ -0,0 +1,51 @@
(define-module (guixpkgs midizap)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system gnu)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (gnu packages xorg)
#:use-module (gnu packages audio)
#:use-module (guix gexp))
(define-public midizap
(package
(name "midizap")
(version "0.8")
(source
(local-file "." "midizap" #:recursive? #t)
;; (origin
;; (method git-fetch)
;; (uri (git-reference
;; (url "https://github.com/agraef/midizap.git")
;; (commit version)))
;; (sha256
;; (base32
;; "0y31fnffl31n9lpkiw1dc3q4rnpfnras30n9y2h5j6586dkmgni4")))
)
(arguments
`(#:tests? #f ; no check target
#:make-flags
(list "CC=gcc"
(string-append "DESTDIR=" %output)
"prefix=")
#:phases
(modify-phases %standard-phases
(replace 'configure
(lambda* (#:key inputs outputs #:allow-other-keys)
(substitute* "Makefile"
(("/usr/include/X11/")
(string-append (assoc-ref inputs "xorgproto") "/include/X11/"))
(("-lXtst") "-lXtst -ljack"))
#t)))))
;; (native-inputs `(("pkg-config" ,pkg-config)))
(inputs `(("jack" ,jack-1)
("libx11" ,libx11)
("libxtst" ,libxtst)
("xorgproto" ,xorgproto)))
(build-system gnu-build-system)
(home-page "")
(synopsis "")
(description "")
(license license:gpl2+)))
midizap

View File

@ -1380,7 +1380,8 @@ static void dup_stroke_data(stroke_data **sd, uint16_t *n, uint16_t *a,
{
for (int i = 0; i < n1; i++) {
if (sd1[i].anyshift) {
for (int index = 0; index < 2; index++) {
int nindex = sd1[i].mod?1:2; // no release seq in mod translations
for (int index = 0; index < nindex; index++) {
stroke **t =
sd0 && check_stroke_data(sd0, sd1[i].chan, sd1[i].data, n0) ? 0 :
find_stroke_data(sd, sd1[i].chan, sd1[i].data, index,