Next  |  Prev  |  Up  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Example 2

The program
  process = ffunction(int fn(int), "<math.h>", "-lm");
compiles to
  ...
  /* link with : "-lm" */
  #include "<math.h>"
  ...
  virtual void compute(int count, FAUSTFLOAT** inputs, FAUSTFLOAT** outputs) {
    FAUSTFLOAT* input0 = inputs[0];
    FAUSTFLOAT* output0 = outputs[0];
    for (int i = 0; (i < count); i = (i + 1)) {
      output0[i] = FAUSTFLOAT(int(fn(int(float(input0[i])))));
    }
  }
  ...
Note the explicit float to int conversions.

A foreign function can have zero or more input arguments, and it must return a single FAUSTFLOAT as output.


Next  |  Prev  |  Up  |  Top  |  JOS Index  |  JOS Pubs  |  JOS Home  |  Search

Download aspf.pdf
[Comment on this page via email]

``Audio Signal Processing in Faust'', by Julius O. Smith III.
Copyright © 2022-05-05 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA),   Stanford University
CCRMA