Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

SequenceableCollection resamp0/1 broken (e.g. SplayAz) #727

Closed
Sciss opened this Issue · 1 comment

3 participants

@Sciss
Owner

The following shows the problem:

SynthDef(\test1, { SplayAz.ar(2, DC.ar(0))});

which boils down to

[0].resamp1(1)

Since I don't see any change in the resamp methods, perhaps somehow 0/0 was giving inf in an older SC version (3.5). Now it (correctly) gives nan, so there needs to be a protection against division by zero.

I suggest to change the following two lines:

https://github.com/supercollider/supercollider/blob/master/SCClassLibrary/Common/Collections/SequenceableCollection.sc#L246

https://github.com/supercollider/supercollider/blob/master/SCClassLibrary/Common/Collections/SequenceableCollection.sc#L251

to

var factor = this.size - 1 / (newSize - 1).max(1);
@LucaDanieli

I think that SuperCollider isn't able to get a valid value from the operation "a/0".
We could just return "^this" for newSize=1, just not to create errors. The problem is that we have an interval, and resamp1(1) should return a number, which is ok in case our Collection is just one number. But in case our Collection was an Array, what would be the right number to represent that Array? Could we maybe return the average between the first and last values?

resamp1 { arg newSize;
if ( newSize==1, { ^this } , {
var factor = this.size - 1 / (newSize - 1);
^this.species.fill(newSize, { |i| this.blendAt(i * factor) })
}

@telephon telephon closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.