[Ecls-list] ECL to forge sounds in realtime

Tito Latini tito.01beta at gmail.com
Wed Jul 3 16:16:09 UTC 2013

Thank you for the detailed information.

On Wed, Jul 03, 2013 at 04:31:03PM +0200, Juan Jose Garcia-Ripoll wrote:

> You still can use inline C versions, but I would like to include C-A-S in
> ECL as well -- the problem being that since I do not know which API would
> be best (small but still useful), this is not yet implemented.

ok, I can start with the atomic builtins used in gcc for the initial tests.

> I do not see why/how your code is cons-free. I see a lot of structures,
> lists, closures being constructed, so it is really hard to see how indeed
> it is going to execute cons-free at run time. I see, however, several
> problems.
> One is that you do not declare certain variables, such as the ones in
> with-foreign-symbols. I presume this expands to a LET form, but
> uninitialized LET forms (as in (LET (A) (SETF A 4.0d0))) prevent ECL from
> inferring the type of the variable -- it is always of type T, as it is
> assigned NIL at the beginning, following the standard.

oh yes, the example is a little obscure, it is like to play without
showing one's cards. The expansion of WITH-FOREIGN-SYMBOLS is

                  (#:AMP849 (CFFI:MEM-AREF #:C-ARRAY-SAMPLE6 'SAMPLE 1))
                  (#:POS850 (CFFI:MEM-AREF #:C-ARRAY-SAMPLE6 'SAMPLE 2))
                  (#:%FREQ106852 (CFFI:MEM-AREF #:C-ARRAY-SAMPLE6 'SAMPLE 3))
                  (#:%AMP107853 (CFFI:MEM-AREF #:C-ARRAY-SAMPLE6 'SAMPLE 4))


The type of the C array is double by default. The SAMPLE type is an
alias for :double if it is used with CFFI and DOUBLE-FLOAT with lisp.
In this way there is not garbage during the performance because the
memory is allocated on the C heap. The performance function is at the
end of the example, the LAMBDA after the :PERF-FUNCTION keyword.
There are also C arrays for int32 (only on x86 because FIXNUM is good
with x86_64) and int64 when it is not possible to use FIXNUM in lisp.

The result is very good, similar to the performance sample by sample
of the famous audio engines written in C.

Tito Latini

More information about the ecl-devel mailing list