Audio Scrubbing and Varispeed in Ecasound ECI
The Ecasound Control Interface (ECI) provides a programmatic API that allows developers to control Ecasound's multitrack audio processing engine from external languages like Python, C, C++, and Perl. While Ecasound is natively designed as a real-time recording and routing system, it exposes audio scrubbing and varispeed playback through a combination of low-latency transport-repositioning commands and real-time chain-operator parameter manipulation. This article outlines the architecture and specific ECI command paradigms used to achieve smooth directional scrubbing and variable-speed playback.
Audio Scrubbing Architecture in ECI
Audio scrubbing requires moving through an audio file backward and forward at varying speeds, typically driven by a jog wheel or mouse scrub bar, while outputting short bursts of audio to indicate position. Because Ecasound relies on an explicit setup and processing loop, scrubbing is implemented by controlling the chainsetup transport:
Direct Sample-Level Seeking: ECI exposes transport-positioning routines via commands such as
setpos [seconds]andsetpos-samples [samples]. For absolute transport management,cs-set-positionorcs-set-position-samplescan be executed. When an external interface captures scrubbing input, it sends high-frequencysetposorforward/rewindupdates directly througheci.command().Buffer Management for Low Latency: Default buffer sizes designed for multitrack recording produce too much latency for responsive scrubbing. To expose responsive scrub audio, the host application configures Ecasound's audio buffers to minimal sizes (e.g., via
-b:128or-b:256) before launching the engine. This ensures that seeking to a new offset flushes previous audio immediately and plays the audio localized to the target position.Step-by-Step Scrubbing Cycles: For precision scrubbing when the engine is not continuously running, applications use the single-iteration command:
engine-status cs-set-position-samples [sample_count] engine-run-slices [slice_count]By moving the position and processing a discrete number of slices (audio buffers), the engine outputs a small fragment of audio corresponding to that location and pauses, providing the classic digital audio workstation (DAW) scrubbing feel.
Implementing Varispeed Playback
In Ecasound, the transport clock is tied directly to the hardware audio output device's sample rate. Consequently, varispeed—changing the playback speed and pitch continuously in real time—cannot be executed by simply telling the master hardware engine to clock faster or slower. Instead, ECI exposes varispeed through real-time DSP manipulation and resampling operators.
Chain Operator Parameter Modulation (
copp): Ecasound allows dynamic adjustment of chain operators while the engine runs using dynamic parameter controls:cop-select [operator_index]: Selects the target DSP plugin or effect on the current chain.copp-select [parameter_index]: Selects the specific parameter (such as pitch ratio, tempo, or playback rate).copp-set [value]: Modifies the parameter in real time without stopping audio playback.
Resampling and Pitch/Time DSP Plugins: Varispeed can be achieved by routing audio through internal or external LADSPA/LV2 plugins that handle resampling, time-stretching, or pitch-shifting:
- Coupled Pitch and Speed (Tape-style Varispeed): A
real-time pitch-resampling LADSPA operator is inserted into the chain.
As the user alters speed, the external application scales the resampler
ratio via
copp-set. Ecasound processes the incoming audio stream through the dynamic resampler, accelerating or decelerating the playback speed while shifting the pitch proportionally. - Decoupled Speed (Time-Stretch): For tempo changes without pitch changes, operators such as those based on phase vocoders or granular synthesis (e.g., SoundTouch-based LADSPA plugins) are loaded. ECI targets the speed multiplier parameter dynamically, maintaining playback continuity.
- Coupled Pitch and Speed (Tape-style Varispeed): A
real-time pitch-resampling LADSPA operator is inserted into the chain.
As the user alters speed, the external application scales the resampler
ratio via
Interaction Flow via ECI
A typical client controlling both behaviors uses an event-driven loop communicating with the Ecasound daemon:
- For Scrubbing: The client intercepts pointer
movements, calculates the sample delta, issues
cs-set-position-samples, and triggers short processing slices if playback is stopped. - For Varispeed: The client tracks a slider or
jog-shuttle velocity, maps that value to a DSP resampling factor, and
issues
cop-setcommands to adjust the playback rate continuously on active audio chains.