Skip to content

Commit

Permalink
fix multichannel output unlacing
Browse files Browse the repository at this point in the history
  • Loading branch information
elgiano committed May 19, 2024
1 parent 68c8924 commit f03bc68
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Then, use CMake to configure:

Libtorch is found automatically if installed system-wise. If you followed the official install instruction for libtorch (link above), you need to add it to CMAKE_PREFIX_PATH:

cmake .. -DCMAKE_PREFIX_PAH=/path/to/libtorch/
cmake .. -DCMAKE_PREFIX_PATH=/path/to/libtorch/

It's expected that the SuperCollider repo is cloned at `../supercollider` relative to this repo. If
it's not: add the option `-DSC_PATH=/path/to/sc/source`.
Expand Down
13 changes: 5 additions & 8 deletions plugins/NNModel/sc/NNUGens.sc
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ NNUGen : MultiOutUGen {
};

outputs = NNUGen.ar(model.idx, idx, bufferSize, this.numOutputs, warmup, debug, nBatches, inputs ++ attrParams);
// ugen outputs interlaced batched outputs: unlace
// e.g. a0, b0, a1, b1 ... -> unlace to [[a0,a1], [b0,b1]]
if (nBatches > 1) {
outputs = outputs.unlace(nBatches);
if (this.numOutputs == 1) {
// flat [[a0], [b0]] to [a0, b0]
outputs = outputs.flatten;
}
// ugen outputs is not interlaced batches: clump
// e.g. [a0, a1, b0, b1] -> clump to [[a0,a1], [b0,b1]]
// note that if numOutputs is 1 [a0,b0] doesn't need to be clumped
if (nBatches > 1 && {this.numOutputs > 1}) {
outputs = outputs.clump(this.numOutputs);
};
^outputs
}
Expand Down

0 comments on commit f03bc68

Please sign in to comment.