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_%gain_%: The initial volume level represented as a percentage (e.g.,100for unity gain / 0 dB,0for silence,200for a +6 dB boost).
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,highparam_id: The target effect parameter index. For-ea, set this to1.type: The control response curve. Use1for linear scaling or2for logarithmic/exponential scaling.controller: The MIDI Continuous Controller (CC) number (e.g.,7for standard MIDI Volume,1for the Mod Wheel).channel: The MIDI channel number (1through16).low: The parameter value when the MIDI CC is at minimum (0). Typically0for mute.high: The parameter value when the MIDI CC is at maximum (127). For example,100for unity gain or150for extra headroom.
3. Selecting the MIDI Input
(-Md)
Ecasound must be instructed where to listen for MIDI messages using
the -Md option:
- ALSA Sequencer (Dynamic port):
-Md:alsaseqcreates an ALSA MIDI client that can be routed using tools likeaconnectorqjackctl. - Raw MIDI Device:
-Md:rawmidi,/dev/midi1listens directly on a specific hardware device node.
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,100Logarithmic 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,120Once executed, movement from the assigned MIDI controller instantly adjusts the audio gain in real time.