Parse Multi-Line Responses in Python Ecasound ECI
This article explains how to retrieve and process multi-line output from Ecasound using the Python Ecasound Control Interface (ECI) wrapper. When querying audio engine status, chain setups, or track configurations, Ecasound frequently returns output spanning multiple lines. The Python ECI implementation provides a dedicated method designed specifically to parse these responses into a native Python data structure.
The last_string_list()
Method
The Python ECI wrapper provides the
last_string_list() method to handle
multi-line string responses from the Ecasound engine.
While scalar queries that produce a single result can be retrieved
using last_string(), any command that returns a list of
items or multiline output stores its result in an internal tokenized
array. Calling last_string_list() fetches this array and
automatically converts it into a native Python list of strings
(list[str]), where each line or item corresponds to an
individual list element.
How to Use
last_string_list()
To retrieve multi-line output, issue the command via the
command() method on your ECI instance, and then call
last_string_list() immediately afterward:
from pyecasound import ECA_CONTROL_INTERFACE
# Initialize the ECI instance
eci = ECA_CONTROL_INTERFACE()
# Issue a command that generates multi-line output
eci.command("cs-list")
# Retrieve the output as a Python list of strings
chainsetup_list = eci.last_string_list()
# Process each line
for item in chainsetup_list:
print(item)Common Commands
Requiring last_string_list()
You should use last_string_list() with commands that
query object collections or system state, including:
cs-list: Lists all available chainsetups.c-list: Lists all chains attached to the currently selected chainsetup.ai-listandao-list: Lists active audio inputs and outputs.cop-list: Lists chain operators attached to the current chain.engine-status: Returns the current multi-line operating state of the audio engine.
If last_string() is mistakenly called after these
commands, it will typically return only the first token or empty data,
making last_string_list() essential for proper output
parsing.