Mapping MIDI Pitch Bend to Resampling in Ecasound
Ecasound does not natively support mapping MIDI pitch bend messages directly to dynamic audio resampling rates out of the box. While Ecasound includes powerful routing, processing, and MIDI control capabilities, its internal resampling engine operates with fixed sample-rate conversion settings rather than a continuously modulated resampler. Achieving real-time resampling or pitch modulation via MIDI pitch bend requires utilizing external plugins, MIDI translation utilities, or the Ecasound Control Interface (ECI).
Core Limitations in Ecasound
Two specific architectural factors prevent direct pitch-bend-to-resampling control in standard Ecasound setups:
- Fixed Resampling Pipeline: Ecasound handles sample
rate conversion automatically between chains, audio inputs, and outputs
using libraries like
libsamplerate. This conversion rate is determined during chain setup and remains static throughout the processing loop, meaning the core engine does not expose the resampling factor as a dynamically automatable parameter. - MIDI Message Handling: Ecasound’s dynamic parameter
mapping argument (
-km) is designed primarily for standard 7-bit MIDI Continuous Controllers (CC 0–127). The MIDI pitch bend wheel uses a dedicated 14-bit message format, which is not directly selectable as a control source inside Ecasound's built-in controller mapping system.
How to Implement the Functionality
To achieve variable-rate resampling or pitch changes driven by pitch bend, you must bypass the static resampler and configure an automatable processing chain:
1. Translate Pitch Bend to MIDI CC
Because Ecasound’s -km parameter expects MIDI CC
messages, use an external MIDI routing tool such as
mididings or a Pure Data patch. Convert the 14-bit pitch
bend events coming from your MIDI controller into standard 7-bit MIDI CC
messages (for example, MIDI CC 20) and forward them to a virtual ALSA or
JACK MIDI port connected to Ecasound.
2. Use a Real-Time Pitch or Varispeed LADSPA Plugin
Instead of altering the global stream resampling rate, insert a LADSPA plugin capable of real-time pitch modification or variable-speed resampling into your Ecasound chain. Common options include LADSPA pitch-shifting plugins (such as TAP Pitch Shifter) or time-stretching/resampling plugins.
3. Map the Control Signal in Ecasound
Once the plugin is in place and the MIDI messages are formatted as
CCs, use the -km flag to bind the incoming CC to the
plugin's frequency or pitch multiplier parameter:
ecasound -i:input.wav -o:alsa -el:tap_pitch,0,0,1 -km:1,1,20,0,2,1In this setup:
-elloads the designated plugin with initial parameters.-kmbinds controller mapping: it takes the controller source (MIDI channel 1, CC 20) and scales it across the designated range to modulate the plugin parameter in real time.
Programmatic Control via ECI
If LADSPA plugins are insufficient and you need custom dynamic
resampling logic, use the Ecasound Control Interface (ECI) with a
language like Python. A script can listen directly to raw ALSA or JACK
MIDI pitch bend events and dynamically adjust chain or plugin parameters
using ECI commands, bypassing the limitations of the command-line
-km syntax.