MIDI Scaling in Ecasound Controller Mappings

In Ecasound, continuous MIDI control is configured using the -km controller option, which maps incoming MIDI Continuous Controller (CC) messages to chain operator effect parameters. This article explains how Ecasound handles linear versus exponential scaling across controller mappings, detailing the -km command syntax, how curve types are determined, and how to achieve non-linear parameter control.

The MIDI Controller Mapping Syntax

Ecasound uses a unified syntax for attaching a MIDI Continuous Controller to any effect parameter:

-km:fx_param,low_val,high_val,controller,channel

The arguments represent:

Linear vs. Exponential Scaling Behavior

Ecasound does not feature a dedicated syntax argument (such as a curve flag or keyword) within the -km option to switch manually between linear and exponential curves. Instead, the scaling behavior is determined by the underlying parameter definition:

1. Linear Scaling (Default Behavior)

For all built-in Ecasound chain operators and linear LADSPA plugin parameters, Ecasound applies a straight linear interpolation between low_val and high_val:

\[\text{Parameter Value} = \text{low\_val} + \left(\frac{\text{MIDI Value}}{127}\right) \times (\text{high\_val} - \text{low\_val})\]

An example of standard linear mapping (e.g., controlling a volume parameter on operator 1 with MIDI CC 7 on channel 1):

-km:1,0,100,7,1

2. Exponential / Logarithmic Scaling (LADSPA Port Hints)

When controlling parameters of LADSPA plugins, Ecasound queries the plugin descriptor's port hints. If a parameter includes the LADSPA_HINT_LOGARITHMIC property (common for frequencies, resonance, and cutoff values):

-km:2,20,20000,74,1

Because parameter 2 in this context is flagged logarithmically in the plugin's metadata, a MIDI value of 64 will sit at the geometric mean rather than the arithmetic midpoint, providing smooth, natural sweeps for perceptual audio parameters.

Implementing Custom Exponential Scaling on Linear Parameters

If an exponential response is required on an Ecasound parameter that defaults to linear behavior, the scaling must be handled outside the -km argument using one of two approaches:

  1. Pre-scaling MIDI CC Data: Route incoming MIDI through an external MIDI processor (such as mididings) before it reaches Ecasound. The processor remaps the linear CC input curve to an exponential curve before passing it to Ecasound's virtual ALSA MIDI port.
  2. Intermediate Control Plugins: Route the MIDI controller to a LADSPA control-rate shaping plugin with logarithmic input, and route that plugin's output to the target parameter.