I'm getting started with Faust and haven't been able to figure out a simple
way to apply an operator between two blocks of N parallel signals. For
example:

```
N = 2;
a = par(i, N, 0.5);
b = par(i, N, 0.1);
```

I'm looking to create a third set of N parallel signals (`c`) where `c[i] =
a[i] + b[i]`

The most straight-forward way I could imagine for doing this would be to
simply write `c = a+b` but this doesn't seem to work for values of `N>1`
because + can only take two inputs.

So I implemented a generic "bus operator" as follows:

```
bop(f, a : b) = par(i, N, f(a: ba.selector(i, N), b: ba.selector(i, N)) );
```

Now I can define `c = bop(+, a : b)` and this seems to be working fine for
arbitrary values of N. However, when chaining multiple blocks of parallel
signals, the invocation syntax is not ideal. For three blocks x, y, z of N
signals each I'd have to write:

```
bop(+, bop(*, x : y) : z)
```

Is there any way to rewrite the bop function so that it can be invoked in a
more intuitive way? For example:

```
s = x : bop(*, y) : bop(+, z)
```

would result in N parallel signals `s[i] = x[i]*y[i] + z[i]`.

Alternatively, I'd be happy to use a best practice / recommended pattern
for dealing with parallel operators.
_______________________________________________
Faudiostream-users mailing list
Faudiostream-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-users

Reply via email to