Map MIDI CC to Audio Gain in Ecasound

This guide explains how to map a hardware or software MIDI Continuous Controller (CC) to control audio gain in real time using Ecasound. By attaching the -km controller preset directly to Ecasound's -ea amplify effect and routing a designated MIDI input, you can dynamically modulate volume levels from any standard MIDI controller knob, slider, or fader.

1. The Audio Gain Operator (-ea)

Ecasound controls volume using the linear amplify operator:

-ea:gain_%

Because -ea accepts one parameter, the gain percentage corresponds to parameter index 1.

2. The Controller Mapping Operator (-km)

To bind MIDI input to an effect parameter, append the -km operator directly after the effect:

-km:param_id,type,controller,channel,low,high

3. Selecting the MIDI Input (-Md)

Ecasound must be instructed where to listen for MIDI messages using the -Md option:

4. Complete Command Examples

Linear Mapping with ALSA Sequencer

To map MIDI CC 7 (Volume) on MIDI Channel 1 to an audio stream, adjusting gain linearly from 0% to 100%:

ecasound -i:input.wav -o:alsa -Md:alsaseq -ea:100 -km:1,1,7,1,0,100

Logarithmic Response with ALSA Hardware Port

Human hearing perceives volume logarithmically. To use an exponential response curve (type 2) using CC 11 (Expression) on Channel 1 directly from an ALSA sequencer port (e.g., port 20:0):

ecasound -i:input.wav -o:alsa -Md:alsaseq,20:0 -ea:100 -km:1,2,11,1,0,120

Once executed, movement from the assigned MIDI controller instantly adjusts the audio gain in real time.