/usr/share/doc/ecasound/eci_doc.html is in ecasound-doc 2.9.1-7build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 | <!DOCTYPE html>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<meta name="generator" content="hevea 2.23">
<style type="text/css">
.li-itemize{margin:1ex 0ex;}
.li-enumerate{margin:1ex 0ex;}
.dd-description{margin:0ex 0ex 1ex 4ex;}
.dt-description{margin:0ex;}
.toc{list-style:none;}
.footnotetext{margin:0ex; padding:0ex;}
div.footnotetext P{margin:0px; text-indent:1em;}
.thefootnotes{text-align:left;margin:0ex;}
.dt-thefootnotes{margin:0em;}
.dd-thefootnotes{margin:0em 0em 0em 2em;}
.footnoterule{margin:1em auto 1em 0px;width:50%;}
.caption{padding-left:2ex; padding-right:2ex; margin-left:auto; margin-right:auto}
.title{margin:2ex auto;text-align:center}
.titlemain{margin:1ex 2ex 2ex 1ex;}
.titlerest{margin:0ex 2ex;}
.center{text-align:center;margin-left:auto;margin-right:auto;}
.flushleft{text-align:left;margin-left:0ex;margin-right:auto;}
.flushright{text-align:right;margin-left:auto;margin-right:0ex;}
div table{margin-left:inherit;margin-right:inherit;margin-bottom:2px;margin-top:2px}
td table{margin:auto;}
table{border-collapse:collapse;}
td{padding:0;}
.cellpadding0 tr td{padding:0;}
.cellpadding1 tr td{padding:1px;}
pre{text-align:left;margin-left:0ex;margin-right:auto;}
blockquote{margin-left:4ex;margin-right:4ex;text-align:left;}
td p{margin:0px;}
.boxed{border:1px solid black}
.textboxed{border:1px solid black}
.vbar{border:none;width:2px;background-color:black;}
.hbar{border:none;height:2px;width:100%;background-color:black;}
.hfill{border:none;height:1px;width:200%;background-color:black;}
.vdisplay{border-collapse:separate;border-spacing:2px;width:auto; empty-cells:show; border:2px solid red;}
.vdcell{white-space:nowrap;padding:0px; border:2px solid green;}
.display{border-collapse:separate;border-spacing:2px;width:auto; border:none;}
.dcell{white-space:nowrap;padding:0px; border:none;}
.dcenter{margin:0ex auto;}
.vdcenter{border:solid #FF8000 2px; margin:0ex auto;}
.minipage{text-align:left; margin-left:0em; margin-right:auto;}
.marginpar{border:solid thin black; width:20%; text-align:left;}
.marginparleft{float:left; margin-left:0ex; margin-right:1ex;}
.marginparright{float:right; margin-left:1ex; margin-right:0ex;}
.theorem{text-align:left;margin:1ex auto 1ex 0ex;}
.part{margin:2ex auto;text-align:center}
</style>
<title>Ecasound Control Interface Guide
</title>
</head>
<body >
<!--HEVEA command line is: /usr/bin/hevea -o html_ecidoc/eci_doc.html ./eci_doc.latex -->
<!--CUT STYLE article--><!--CUT DEF section 1 --><table class="title"><tr><td style="padding:1ex"><h1 class="titlemain">Ecasound Control Interface Guide</h1><h3 class="titlerest">Kai Vehmanen, Brad Bowman, Tony Leake, Jan Weil, Mario Lang</h3><h3 class="titlerest">03062006</h3></td></tr>
</table><!--TOC section id="sec1" Contents-->
<h2 id="sec1" class="section">Contents</h2><!--SEC END --><ul class="toc"><li class="li-toc">
<a href="#sec2">1  Introduction</a>
</li><li class="li-toc"><a href="#sec3">2  Document history</a>
</li><li class="li-toc"><a href="#sec4">3  General</a>
<ul class="toc"><li class="li-toc">
<a href="#sec5">3.1  What’s it good for?</a>
</li><li class="li-toc"><a href="#sec6">3.2  Services and behaviour</a>
<ul class="toc"><li class="li-toc">
<a href="#sec7">3.2.1  Actions</a>
</li><li class="li-toc"><a href="#sec8">3.2.2  Return values</a>
</li><li class="li-toc"><a href="#sec9">3.2.3  Errors</a>
</li><li class="li-toc"><a href="#sec10">3.2.4  Other</a>
</li></ul>
</li><li class="li-toc"><a href="#sec11">3.3  Porting to new environments</a>
</li></ul>
</li><li class="li-toc"><a href="#sec12">4  Implementations</a>
<ul class="toc"><li class="li-toc">
<a href="#sec13">4.1  General</a>
<ul class="toc"><li class="li-toc">
<a href="#sec14">4.1.1  Overview</a>
</li><li class="li-toc"><a href="#sec15">4.1.2  Usage</a>
</li><li class="li-toc"><a href="#sec16">4.1.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec17">4.2  Notes Concerning Standalone ECI Implementations</a>
</li><li class="li-toc"><a href="#sec18">4.3  C++</a>
<ul class="toc"><li class="li-toc">
<a href="#sec19">4.3.1  Overview</a>
</li><li class="li-toc"><a href="#sec20">4.3.2  Usage</a>
</li><li class="li-toc"><a href="#sec21">4.3.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec22">4.4  C</a>
<ul class="toc"><li class="li-toc">
<a href="#sec23">4.4.1  Overview</a>
</li><li class="li-toc"><a href="#sec24">4.4.2  Usage</a>
</li><li class="li-toc"><a href="#sec25">4.4.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec26">4.5  Emacs</a>
<ul class="toc"><li class="li-toc">
<a href="#sec27">4.5.1  Overview</a>
</li><li class="li-toc"><a href="#sec28">4.5.2  Usage</a>
</li><li class="li-toc"><a href="#sec29">4.5.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec30">4.6  Python</a>
<ul class="toc"><li class="li-toc">
<a href="#sec31">4.6.1  Overview</a>
</li><li class="li-toc"><a href="#sec32">4.6.2  Usage</a>
</li><li class="li-toc"><a href="#sec33">4.6.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec34">4.7  Perl</a>
<ul class="toc"><li class="li-toc">
<a href="#sec35">4.7.1  Overview</a>
</li><li class="li-toc"><a href="#sec36">4.7.2  Usage</a>
</li><li class="li-toc"><a href="#sec37">4.7.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec38">4.8  PHP</a>
<ul class="toc"><li class="li-toc">
<a href="#sec39">4.8.1  Overview</a>
</li><li class="li-toc"><a href="#sec40">4.8.2  Usage</a>
</li><li class="li-toc"><a href="#sec41">4.8.3  Example</a>
</li></ul>
</li><li class="li-toc"><a href="#sec42">4.9  Ruby</a>
<ul class="toc"><li class="li-toc">
<a href="#sec43">4.9.1  Overview</a>
</li><li class="li-toc"><a href="#sec44">4.9.2  Usage</a>
</li><li class="li-toc"><a href="#sec45">4.9.3  Example</a>
</li></ul>
</li></ul>
</li><li class="li-toc"><a href="#sec46">5  Application development</a>
<ul class="toc"><li class="li-toc">
<a href="#sec47">5.1  Tips for debugging</a>
</li></ul>
</li></ul>
<!--TOC section id="sec2" Introduction-->
<h2 id="sec2" class="section">1  Introduction</h2><!--SEC END --><p>
The idea behind the Ecasound Control Interface (ECI) is to take a subset of
functionality provided by libecasound, provide a simple API for it, and
port it to various languages. At the moment, implementations of the
ECI API are available for C, C++, elisp, Python and Ruby. These all
come by default with the Ecasound package. Additional implementations,
for example for Perl and PHP, are distributed independently. </p><p>ECI is heavily based on Ecasound’s interactive mode (EIAM), and the
services it provides. See <span style="font-family:monospace">ecasound-iam(1) manual page</span> for
a detailed EIAM documentation.</p>
<!--TOC section id="sec3" Document history-->
<h2 id="sec3" class="section">2  Document history</h2><!--SEC END --><ul class="itemize"><li class="li-itemize">
04.06.2006 - Added more information to the “Tips for debugging” section.
</li><li class="li-itemize">21.03.2005 - Updated the “Tips for debugging” section.
</li><li class="li-itemize">25.09.2004 - Updated the “Return values” section based on feedback
from Adam Linson.
</li><li class="li-itemize">02.05.2004 - “Emacs” section added (written by Mario Lang).
</li><li class="li-itemize">28.11.2003 - “Ruby” section added (written by Jan Weil).
Updated the introduction.
</li><li class="li-itemize">26.11.2003 - Fix filename for the alternative Python API (eci.py).
</li><li class="li-itemize">18.11.2003 - Typo fixes. Updated documentation to reflect the new
naming convention (ecasound refers to the binary,
Ecasound refers to the whole package).
</li><li class="li-itemize">26.10.2002 - Changed the C++ linking example.
</li><li class="li-itemize">24.10.2002 - Added “Notes Concerning Standalone ECI Implementations”
section. Added compilation examples.
</li><li class="li-itemize">06.10.2002 - Added “Application development” section.
</li><li class="li-itemize">05.10.2002 - Changed the libecasoundc link path.
</li><li class="li-itemize">29.09.2002 - “PHP” section added (written by Tony Leake).
</li><li class="li-itemize">25.04.2002 - Changed headers path from “<ecasoundc/file.h>” to
“<file.h>” and added library version number to
link instructions.
</li><li class="li-itemize">21.10.2001 - Added this history section. Minor changes to
ECI examples.
</li></ul>
<!--TOC section id="sec4" General-->
<h2 id="sec4" class="section">3  General</h2><!--SEC END --><p>
ECI doesn’t provide any routines that directly manipulate audio or
Ecasound objects. What it does provide is an easy and generic way
to issue EIAM (Ecasound Inter-Active Mode) commands, access the
command return-values and perform error handling.</p><p>This approach has two benefits. First, it is possible to keep the API
small, and thus make it easier to port ECI to new languages. Secondly,
it’s possible to keep ECI relatively stable. Ecasound itself is a large,
developing library. New features are added all the time, and from time
to time, older parts of the library will get rewritten to better suit
new uses. Now for application developers wanting to take advantage of
libecasound, these constant changes are very annoying, especially if
your specific app doesn’t need the latest new features. In these
cases, ECI is the best platform for application development.</p>
<!--TOC subsection id="sec5" What’s it good for?-->
<h3 id="sec5" class="subsection">3.1  What’s it good for?</h3><!--SEC END --><p>Specific tasks ECI is aimed at:</p><ul class="itemize"><li class="li-itemize">
1. automating (scripting in its traditional sense)
</li><li class="li-itemize">2. frontends (generic / specialized)
</li><li class="li-itemize">3. sound services to other apps
</li></ul>
<!--TOC subsection id="sec6" Services and behaviour-->
<h3 id="sec6" class="subsection">3.2  Services and behaviour</h3><!--SEC END --><p>Here is a list of services provided by all ECI implementations:</p>
<!--TOC subsubsection id="sec7" Actions-->
<h4 id="sec7" class="subsubsection">3.2.1  Actions</h4><!--SEC END --><dl class="description"><dt class="dt-description">
<span style="font-weight:bold">command(string)</span></dt><dd class="dd-description">
Issue an EIAM command.</dd><dt class="dt-description"><span style="font-weight:bold">command_float_arg(string, float)</span></dt><dd class="dd-description">
Issue an EIAM command. This function can be used instead of
<em>command(string)</em>, if the command in question requires exactly one
numerical parameter. This way it’s possible to avoid the extra
string -> float conversion, which would lead to lost precision.
</dd></dl>
<!--TOC subsubsection id="sec8" Return values-->
<h4 id="sec8" class="subsubsection">3.2.2  Return values</h4><!--SEC END --><p>
Each EIAM command has exactly one return value type. After a command
has been issued, only one last_type() functions returns a non-empty
value. For example, last_float() only returns a valid value if
<em>last_type() == ’f’</em> holds true. Not all EIAM commands return
a value (return type is void).</p><dl class="description"><dt class="dt-description">
<span style="font-weight:bold">last_string()</span></dt><dd class="dd-description">
Returns the last string return value.</dd><dt class="dt-description"><span style="font-weight:bold">last_string_list()</span></dt><dd class="dd-description">
Returns the last collection of strings (one or more strings).</dd><dt class="dt-description"><span style="font-weight:bold">last_float()</span></dt><dd class="dd-description">
Returns the last floating-point return value. Note! last_float()
doesn’t refer to the C/C++ type ’float’. In most implementations,
floats are 64bit values (doubles in C/C++).</dd><dt class="dt-description"><span style="font-weight:bold">last_integer()</span></dt><dd class="dd-description">
Returns the last integer return value. This function is also
used to return boolean values, where non-zero means ’true’
and zero ’false’.</dd><dt class="dt-description"><span style="font-weight:bold">last_long_integer()</span></dt><dd class="dd-description">
Returns the last long integer return value. Long integers are
used to pass values like ’length_in_samples’ and ’length_in_bytes’.
It’s implementation specific whether there’s any real difference
between integers and long integers.
</dd></dl>
<!--TOC subsubsection id="sec9" Errors-->
<h4 id="sec9" class="subsubsection">3.2.3  Errors</h4><!--SEC END --><dl class="description"><dt class="dt-description">
<span style="font-weight:bold">error()</span></dt><dd class="dd-description">
Returns true (!= 0) if error has occured during the execution
of last EIAM command. Otherwise returns false (= 0).</dd><dt class="dt-description"><span style="font-weight:bold">last_error()</span></dt><dd class="dd-description">
Returns a string describing the last error. If the last EIAM command
was executed successfully, last_error() returns an empty string.</dd></dl>
<!--TOC subsubsection id="sec10" Other-->
<h4 id="sec10" class="subsubsection">3.2.4  Other</h4><!--SEC END --><dl class="description"><dt class="dt-description">
<span style="font-weight:bold">initialize()</span></dt><dd class="dd-description">
Reserve resources.</dd><dt class="dt-description"><span style="font-weight:bold">cleanup()</span></dt><dd class="dd-description">
Free all reserved resources.
</dd></dl>
<!--TOC subsection id="sec11" Porting to new environments-->
<h3 id="sec11" class="subsection">3.3  Porting to new environments</h3><!--SEC END --><p>
Porting ECI to new languages should be easy. All there is to do is
to implement the services listed in the previous section to the target
language. In most cases it’s to easiest to use the C++ or C ECI
as the underlying implementation to build upon.</p>
<!--TOC section id="sec12" Implementations-->
<h2 id="sec12" class="section">4  Implementations</h2><!--SEC END -->
<!--TOC subsection id="sec13" General-->
<h3 id="sec13" class="subsection">4.1  General</h3><!--SEC END -->
<!--TOC subsubsection id="sec14" Overview-->
<h4 id="sec14" class="subsubsection">4.1.1  Overview</h4><!--SEC END --><p>
This section contains overview of how ECI is implemented in the
discussed language (eg. as a single class, set of classes, set of
routines, etc).</p>
<!--TOC subsubsection id="sec15" Usage-->
<h4 id="sec15" class="subsubsection">4.1.2  Usage</h4><!--SEC END --><p>
A quick tutorial to get you started.</p>
<!--TOC subsubsection id="sec16" Example-->
<h4 id="sec16" class="subsubsection">4.1.3  Example</h4><!--SEC END --><p>
Implementation of the following:
</p><ol class="enumerate" type=1><li class="li-enumerate">
Setup ECI to read audio from file, apply a 100Hz lowpass filter, and
send it to the soundcard (/dev/dsp).
</li><li class="li-enumerate">Every second, check the current position. If the stream has
been running for over 15 seconds, exit immediately. Also,
every second, increase the lowpass filter’s cutoff frequency
by 500Hz.
</li><li class="li-enumerate">Stop the stream (if not already finished) and disconnect the
chainsetup. Print chain operator status info.
</li></ol>
<!--TOC subsection id="sec17" Notes Concerning Standalone ECI Implementations-->
<h3 id="sec17" class="subsection">4.2  Notes Concerning Standalone ECI Implementations</h3><!--SEC END --><p>The C implementation of ECI is not directly linked against the main
Ecasound libraries. Instead, the ecasound executable is launched
on the background and command pipes are used to communicate with it.</p><p>The launched ecasound executable can be selected by using the
<em>ECASOUND</em> environment variable. If it is not defined,
the C ECI implementation will try to launch “ecasound” (ie.
has to be somewhere in PATH). </p><p>In addition to the C implementation, this also affects all
ECI implementations that are based on the C version. Currently
this includes at least the Perl, PHP and Python ECI modules.</p>
<!--TOC subsection id="sec18" C++-->
<h3 id="sec18" class="subsection">4.3  C++</h3><!--SEC END -->
<!--TOC subsubsection id="sec19" Overview-->
<h4 id="sec19" class="subsubsection">4.3.1  Overview</h4><!--SEC END --><p>
C++ implementation is based around the ECA_CONTROL_INTERFACE class.
STL vector is used for representing collections of objects
(last_string_list()).</p>
<!--TOC subsubsection id="sec20" Usage-->
<h4 id="sec20" class="subsubsection">4.3.2  Usage</h4><!--SEC END --><ol class="enumerate" type=1><li class="li-enumerate">
#include <eca-control-interface.h>
</li><li class="li-enumerate">create an instance of the ECA_CONTROL_INTERFACE class
and use its member functions
</li><li class="li-enumerate">link you app agains libecasoundc (-lecasoundc)
</li><li class="li-enumerate">compilation example: <em>c++ -o ecidoc_example ecidoc_example.cpp ‘libecasoundc-config –cflags –libs‘</em>
</li></ol>
<!--TOC subsubsection id="sec21" Example-->
<h4 id="sec21" class="subsubsection">4.3.3  Example</h4><!--SEC END --><pre class="verbatim">
#include <iostream>
#include <unistd.h>
#include <eca-control-interface.h>
int main(int argc, char *argv[])
{
double cutoff_inc = 500.0;
ECA_CONTROL_INTERFACE e;
e.command("cs-add play_chainsetup");
e.command("c-add 1st_chain");
e.command("ai-add some_file.wav");
e.command("ao-add /dev/dsp");
e.command("cop-add -efl:100");
e.command("cop-select 1");
e.command("copp-select 1");
e.command("cs-connect");
e.command("start");
while(1) {
sleep(1);
e.command("engine-status");
if (e.last_string() != "running") break;
e.command("get-position");
double curpos = e.last_float();
if (curpos > 15.0) break;
e.command("copp-get");
double next_cutoff = cutoff_inc + e.last_float();
e.command_float_arg("copp-set", next_cutoff);
}
e.command("stop");
e.command("cs-disconnect");
e.command("cop-status");
cerr << "Chain operator status: " << e.last_string() << endl;
return(0);
}
</pre>
<!--TOC subsection id="sec22" C-->
<h3 id="sec22" class="subsection">4.4  C</h3><!--SEC END -->
<!--TOC subsubsection id="sec23" Overview-->
<h4 id="sec23" class="subsubsection">4.4.1  Overview</h4><!--SEC END --><p>
All C ECI functions are prefixed with "eci_". When returning string
values, a const pointer to a null-terminated char array (const char*)
is returned. It’s important to keep in mind that these are "borrowed"
references. If you need to later use the data, you must copy
it to application’s own buffers.</p><p>Returning a list of strings is implemented using two functions:
<em>eci_last_string_list_count()</em> returns the number of strings
available, and <em>eci_last_string_list_item(int n)</em> returns a
pointer (const char*) to the string at index <em>n</em>.</p><p><em>Note!</em> As of Ecasound 2.0.1, the C ECI implementation also
provides reentrant access to the ECI API. These
alternative routines are marked with ’_r’ postfix.</p>
<!--TOC subsubsection id="sec24" Usage-->
<h4 id="sec24" class="subsubsection">4.4.2  Usage</h4><!--SEC END --><ol class="enumerate" type=1><li class="li-enumerate">
#include <ecasoundc.h>
</li><li class="li-enumerate">use the eci_* routines
</li><li class="li-enumerate">link your app against libecasoundc (-lecasoundc)
</li><li class="li-enumerate">compilation example: <em>gcc -o ecidoc_example ecidoc_example.c ‘libecasoundc-config –cflags –libs‘</em>
</li></ol>
<!--TOC subsubsection id="sec25" Example-->
<h4 id="sec25" class="subsubsection">4.4.3  Example</h4><!--SEC END --><pre class="verbatim">
#include <stdio.h>
#include <unistd.h>
#include <ecasoundc.h>
int main(int argc, char *argv[])
{
double cutoff_inc = 500.0;
eci_init();
eci_command("cs-add play_chainsetup");
eci_command("c-add 1st_chain");
eci_command("ai-add some_file.wav");
eci_command("ao-add /dev/dsp");
eci_command("cop-add -efl:100");
eci_command("cop-select 1");
eci_command("copp-select 1");
eci_command("cs-connect");
eci_command("start");
while(1) {
double curpos, next_cutoff;
sleep(1);
eci_command("engine-status");
if (strcmp(eci_last_string(), "running") != 0) break;
eci_command("get-position");
curpos = eci_last_float();
if (curpos > 15.0) break;
eci_command("copp-get");
next_cutoff = cutoff_inc + eci_last_float();
eci_command_float_arg("copp-set", next_cutoff);
}
eci_command("stop");
eci_command("cs-disconnect");
eci_command("cop-status");
printf("Chain operator status: %s", eci_last_string());
eci_cleanup();
return(0);
}
</pre>
<!--TOC subsection id="sec26" Emacs-->
<h3 id="sec26" class="subsection">4.5  Emacs</h3><!--SEC END -->
<!--TOC subsubsection id="sec27" Overview-->
<h4 id="sec27" class="subsubsection">4.5.1  Overview</h4><!--SEC END --><p>
The Ecasound package comes with an ’Ecasound’ library for Emacs included.
ecasound.el is a implementation of the ECI API for Emacs, as well
as an interactive interface to Ecasound sessions implemented
on top of that. Simply use "M-x ecasound RET" to fire up an
interactive Ecasound session.</p><p>All Emacs Lisp ECI functions are prefixed with “eci”.
’ecasound.el’ is implemented in a high level manner which means
that you won’t find most of the commands known from libecasoundc like
last_string, last_float, etc.
Instead of that every call to function "eci-command", which accepts all
the well known IAM commands, returns ecasound’s response in an appropriate type
automatically.
If an error occurs, e. g. there’s a typo in a command or a file is not found,
the function returns “nil”. In all other cases, either an automatically
converted Lisp value is returned, or “t” in the case where there was no
particular value returned.</p><p>Additionally, most of the available IAM commands have their own Emacs Lisp
function including documentation and possibly a parameter list. All these
functions are interactive, so you can use them in ecasound-iam-mode simply
by invoking them via M-x or by pressing an assigned key combination.
Emacs will prompt you for the required parameters, providing completion
wherever possible.</p><p>As a convention, "eci-command" and its variants do take a buffer or process
as an optional last argument. If this is “nil”, the current
buffer is assumed to be the ecasound session refered to by this call.
This makes it possible to use several ECI sessions concurrently, dispatching
on the buffer or process in use.</p>
<!--TOC subsubsection id="sec28" Usage-->
<h4 id="sec28" class="subsubsection">4.5.2  Usage</h4><!--SEC END --><ol class="enumerate" type=1><li class="li-enumerate">
make ecasound.el available in your “load-path”
</li><li class="li-enumerate">(require ’ecasound)
</li><li class="li-enumerate">create a buffer with an associated Ecasound session (“eci-init”)
</li><li class="li-enumerate">use “eci” functions with the new buffer
</li></ol>
<!--TOC subsubsection id="sec29" Example-->
<h4 id="sec29" class="subsubsection">4.5.3  Example</h4><!--SEC END --><pre class="verbatim">
(require 'ecasound)
(defun example (file &optional cutoff-increment session)
(unless cutoff-increment (setq cutoff-increment 500.0))
(with-current-buffer (or session (eci-init))
(eci-cs-add "play_chainsetup")
(eci-c-add "1st_chain")
(eci-ai-add file)
(eci-ao-add "/dev/dsp")
(eci-cop-add "-efl:100")
(eci-cop-select 1)
(eci-copp-select 1)
(eci-cs-connect)
(eci-start)
(sit-for 1)
(while (and (string= (eci-engine-status) "running")
(<= (eci-get-position) 15))
(eci-copp-set (+ cutoff-increment (eci-copp-get)))
(sit-for 1))
(eci-command "stop")
(when (eci-cs-disconnect)
(destructuring-bind
((cop n1 (copp n2 val)))
(cdr (assoc "1st_chain" (eci-cop-status)))
(message "%s %s is now %f" cop copp val)))))
</pre><p>NOTE: function “eci-cop-status” is actually a very high level function
which already converts the returned information to a nested list
structure.</p><p>For more complex examples of the Emacs Lisp ECI implementation, see function
“eci-example”, “ecasound-normalize” and “ecasound-signalview” in
ecasound.el.</p>
<!--TOC subsection id="sec30" Python-->
<h3 id="sec30" class="subsection">4.6  Python</h3><!--SEC END -->
<!--TOC subsubsection id="sec31" Overview-->
<h4 id="sec31" class="subsubsection">4.6.1  Overview</h4><!--SEC END --><p>
Python implementation is based around the ECA_CONTROL_INTERFACE class.
Lists are used for representing collections of objects.</p><p>Note! Eric S. Tiedemann has written an alternative Python interface
to ECI. You’ll find this interface included in the main
Ecasound packege, in “pyecasound/eci.py”. To use this instead
of the standard interface, just ’import eci’ and you’re set! :)</p>
<!--TOC subsubsection id="sec32" Usage-->
<h4 id="sec32" class="subsubsection">4.6.2  Usage</h4><!--SEC END --><ol class="enumerate" type=1><li class="li-enumerate">
import pyeca
</li><li class="li-enumerate">create an instance of the ECA_CONTROL_INTERFACE class
and use its member functions
</li><li class="li-enumerate">python ’yourapp.py’ and that’s it :)
</li></ol>
<!--TOC subsubsection id="sec33" Example-->
<h4 id="sec33" class="subsubsection">4.6.3  Example</h4><!--SEC END --><pre class="verbatim">
#!/usr/local/bin/python
import time
from pyeca import *
e = ECA_CONTROL_INTERFACE()
e.command("cs-add play_chainsetup")
e.command("c-add 1st_chain")
e.command("ai-add some_file.wav")
e.command("ao-add /dev/dsp")
e.command("cop-add -efl:100")
e.command("cop-select 1")
e.command("copp-select 1")
e.command("cs-connect")
e.command("start")
cutoff_inc = 500.0
while 1:
time.sleep(1)
e.command("engine-status")
if e.last_string() != "running": break
e.command("get-position")
curpos = e.last_float()
if curpos > 15: break
e.command("copp-get")
next_cutoff = cutoff_inc + e.last_float()
e.command_float_arg("copp-set", next_cutoff)
e.command("stop")
e.command("cs-disconnect")
e.command("cop-status")
print "Chain operator status: ", e.last_string()
</pre>
<!--TOC subsection id="sec34" Perl-->
<h3 id="sec34" class="subsection">4.7  Perl</h3><!--SEC END -->
<!--TOC subsubsection id="sec35" Overview-->
<h4 id="sec35" class="subsubsection">4.7.1  Overview</h4><!--SEC END --><p>
Audio::Ecasound provides perl bindings to the Ecasound
control interface of the Ecasound program. You can use
perl to automate or interact with Ecasound so you don’t
have to turn you back on the adoring masses packed into
Wembly Stadium.</p><p>Audio::Ecasound was written by Brad Bowman. At the moment this module
is not distributed with Ecasound. To get the latest version, check the
following <span style="font-family:monospace">CPAN link</span>.</p>
<!--TOC subsubsection id="sec36" Usage-->
<h4 id="sec36" class="subsubsection">4.7.2  Usage</h4><!--SEC END --><p>
See the below example. For more info, here’s another
<span style="font-family:monospace">CPAN link</span>.</p>
<!--TOC subsubsection id="sec37" Example-->
<h4 id="sec37" class="subsubsection">4.7.3  Example</h4><!--SEC END --><p>
use Audio::Ecasound qw(:simple);</p><pre class="verbatim">
eci("cs-add play_chainsetup");
eci("c-add 1st_chain");
eci("ai-add some_file.wav");
eci("ao-add /dev/dsp");
# multiple \n separated commands
eci("cop-add -efl:100
# with comments
cop-select 1
copp-select 1
cs-connect");
eci("start");
my $cutoff_inc = 500.0;
while (1) {
sleep(1);
last if eci("engine-status") ne "running";
my $curpos = eci("get-position");
last if $curpos > 15;
my $next_cutoff = $cutoff_inc + eci("copp-get");
# Optional float argument
eci("copp-set", $next_cutoff);
}
eci("stop");
eci("cs-disconnect");
print "Chain operator status: ", eci("cop-status");
</pre>
<!--TOC subsection id="sec38" PHP-->
<h3 id="sec38" class="subsection">4.8  PHP</h3><!--SEC END -->
<!--TOC subsubsection id="sec39" Overview-->
<h4 id="sec39" class="subsubsection">4.8.1  Overview</h4><!--SEC END --><p>
This PHP extension provides bindings to the Ecasound
control interface. It is useful both for scripting Ecasound
and for writing graphical audio applications with PHP Gtk.</p><p>The PHP Ecasound extension was written by Tony Leake. At the moment this module
is not distributed with Ecasound. The latest version and example scripts, are
available from <span style="font-family:monospace">http://www.webwise-data.co.uk/php_audio/php_audio_extension.html</span>.</p>
<!--TOC subsubsection id="sec40" Usage-->
<h4 id="sec40" class="subsubsection">4.8.2  Usage</h4><!--SEC END --><ol class="enumerate" type=1><li class="li-enumerate">
Obtain and build the Ecasound PHP extension
</li><li class="li-enumerate">Initialise Ecasound, eci_int();
</li><li class="li-enumerate">Issue EAM commands eg, eci_command("cs-add my_chain_setup");
</li><li class="li-enumerate">Free resources, eci_cleanup();
</li></ol>
<!--TOC subsubsection id="sec41" Example-->
<h4 id="sec41" class="subsubsection">4.8.3  Example</h4><!--SEC END --><pre class="verbatim">
Implementation of the following:
1. Setup ECI to read audio from file, apply a 100Hz lowpass filter,
and send it to the soundcard (/dev/dsp).
2. Every second, check the current position. If the stream has been
running for over 15 seconds, exit immediately. Also, every second,
increase the lowpass filter's cutoff frequency by 500Hz.
3. Stop the stream (if not already finished) and disconnect the chainsetup.
Print chain operator status info
<?php
$cutoff_inc = 500.0;
$curpos=0;
$next_cutoff=0;
eci_init();
eci_command("cs-add play_chainsetup");
eci_command("c-add 1st_chain");
eci_command("ai-add /tmp/somefile.wav");
eci_command("ao-add /dev/dsp");
eci_command("cop-add -efl:10");
eci_command("cop-select 1");
eci_command("copp-select 1");
eci_command("cs-connect");
eci_command("start");
while(1) {
sleep(1);
eci_command("engine-status");
if (eci_last_string() !="running"){
break;
}
eci_command("get-position");
$curpos = eci_last_float();
if ($curpos > 15.0){
break;
}
eci_command("copp-get");
$next_cutoff = $cutoff_inc + eci_last_float();
eci_command_float_arg("copp-set",$next_cutoff);
}
eci_command("stop");
eci_command("cs-disconnect");
eci_command("cop-status");
printf("Chain operator status: %s", eci_last_string());
eci_cleanup();
?>
</pre>
<!--TOC subsection id="sec42" Ruby-->
<h3 id="sec42" class="subsection">4.9  Ruby</h3><!--SEC END -->
<!--TOC subsubsection id="sec43" Overview-->
<h4 id="sec43" class="subsubsection">4.9.1  Overview</h4><!--SEC END --><p>
The Ecasound package comes with an ’Ecasound’ module for Ruby included.
If ruby is detected during the installation process it is installed
automatically (assuming you are installing ecasound from source code).
The module contains the class definition of a native ecasound control interface
called "ControlInterface".</p><p>’Ecasound::ControlInterface’ is implemented in a high level manner which means
that you won’t find most of the commands known from libecasoundc like
last_string, last_float, etc.
Instead of that every call to the instance method "command", which accepts all
the well known IAM commands, returns ecasound’s response in an appropriate type
automatically.
If an error occurs, e. g. there’s a typo in a command or a file is not found,
an exception of type EcasoundError is raised.</p>
<!--TOC subsubsection id="sec44" Usage-->
<h4 id="sec44" class="subsubsection">4.9.2  Usage</h4><!--SEC END --><ol class="enumerate" type=1><li class="li-enumerate">
require ’ecasound’
</li><li class="li-enumerate">create an instance of Ecasound::ControlInterface
</li><li class="li-enumerate">use it’s command method to send IAM commands to ecasound
</li><li class="li-enumerate">catch an EcasoundError if necessary
</li></ol>
<!--TOC subsubsection id="sec45" Example-->
<h4 id="sec45" class="subsubsection">4.9.3  Example</h4><!--SEC END --><pre class="verbatim">
#!/usr/bin/env ruby
require "ecasound"
SOME_FILE = "path/to/file.wav"
e = Ecasound::ControlInterface.new()
e.command("cs-add play_chainsetup")
e.command("c-add 1st_chain")
e.command("ai-add #{SOME_FILE}")
e.command("ao-add /dev/dsp")
e.command("cop-add -efl:100")
e.command("cop-select 1")
e.command("copp-select 1")
e.command("cs-connect")
e.command("start")
cutoff_inc = 500.0
loop do
sleep(1)
break if e.command("engine-status") != "running"
break if e.command("get-position") > 15
e.command("copp-set #{cutoff_inc + e.command('copp-get')}")
end
e.command("stop")
e.command("cs-disconnect")
$stdout << "Chain operator status: " + e.command("cop-status") + "\n"
</pre>
<!--TOC section id="sec46" Application development-->
<h2 id="sec46" class="section">5  Application development</h2><!--SEC END -->
<!--TOC subsection id="sec47" Tips for debugging-->
<h3 id="sec47" class="subsection">5.1  Tips for debugging</h3><!--SEC END --><p>Here’s a few tips what to do if the ECI app you have developed
is not working correctly.</p><ol class="enumerate" type=1><li class="li-enumerate">
Check your Ecasound installation. Try to run the “ecasound”
console user-interface and verify that the basic functionality
is working (ie. something like “ecasound -i foo.wav -o
/dev/dsp”.</li><li class="li-enumerate">If developing in C or C++, check that your application
is correcly linked: “ldd /path/to/myapp”. All the libraries
should be properly found.</li><li class="li-enumerate">Check error conditions. You should remember to check
for errors in your ECI apps using the eci_error() and
eci_last_error() functions. Especially when intializing
ECI for the first time and after important commands
like “cs-connect”, you should always check for errors.</li><li class="li-enumerate">Use the ECASOUND_LOGFILE environment variable to write all
engine output to a separate logfile. See ecasound(1) manpage
for details on how to use this mechanism. Requires Ecasound
version 2.4.5 or newer.</li><li class="li-enumerate">Utilize the “int-log-history” ECI command added to
version 2.4.0 of Ecasound. Recent messages from the
engine can help to track down the problem. Before use, you
need to first set the history length to a non-zero value with
“int-set-log-history-length”.</li><li class="li-enumerate">Launch Ecasound in interactive mode (“ecasound -c”),
and issue the commands your ECI application is using,
manually one-by-one and see what happens. If something
goes wrong, increase Ecasound’s debug level (for instance
“-ddd”) and re-run the test. </li></ol><!--CUT END -->
<!--HTMLFOOT-->
<!--ENDHTML-->
<!--FOOTER-->
<hr style="height:2"><blockquote class="quote"><em>This document was translated from L<sup>A</sup>T<sub>E</sub>X by
</em><a href="http://hevea.inria.fr/index.html"><em>H</em><em><span style="font-size:small"><sup>E</sup></span></em><em>V</em><em><span style="font-size:small"><sup>E</sup></span></em><em>A</em></a><em>.</em></blockquote></body>
</html>
|