Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiOutUGen with numchannels less than 1 return an empty array #1686

Closed
telephon opened this issue Oct 16, 2015 · 0 comments
Closed

MultiOutUGen with numchannels less than 1 return an empty array #1686

telephon opened this issue Oct 16, 2015 · 0 comments
Assignees
Milestone

Comments

@telephon
Copy link
Member

A nil argument for numChannels is presumably a result of a mistake. It can be hard to trace down.

E.g.:

b = Buffer(s); PlayBuf.ar(b.numChannels)

Returns [], because b has not yet been assigned a number of channels, so it is essentially PlayBuf.ar(nil).

I'd suggest that throwing an error would be better, even though I can imagine that in some cases, one could make use of the current behavior.

Fix:

in MultiOutUGen:

initOutputs { arg numChannels, rate;
        if(numChannels.isNil or: { numChannels < 1 }) { Error("%: wrong number of channels (%)".format(this, numChannels)).throw };
        channels = Array.fill(numChannels, { arg i;
            OutputProxy(rate, this, i);
        });
        if (numChannels == 1, {
            ^channels.at(0)
        });
        ^channels
    }
@telephon telephon self-assigned this Oct 16, 2015
@telephon telephon added this to the 3.7.x milestone Nov 19, 2015
telephon added a commit to telephon/supercollider that referenced this issue Feb 1, 2016
Both 0 and nil make no sense for MultiOutUGen. This fixes supercollider#1686.
@telephon telephon modified the milestones: 3.8, 3.7.x Feb 1, 2016
telephon added a commit to telephon/supercollider that referenced this issue Feb 20, 2016
Both 0 and nil make no sense for MultiOutUGen. This fixes supercollider#1686.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant