Just to make this clear, even this simplified version crashes:
var downShift = 0;
var inPitch = 61;
var pitches = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while(pitches[inPitch - downShift % 12] == 0, {downShift =
downShift + 1});
downShift.postln
On Dec 13, 2007 2:26 AM, Greg Sabo <gregsabo@xxxxxxxxx> wrote:
Wow, this function should be ungodly simple, but it always
hangs...why?
This is in a PitchClassSet Class, the pitches are represented by
an array
of 0s and 1s. (1 means that pitch is present)
The user passes an midi note value and the function should return
the
nearest pitch that is present in the PC set.
the .isEmpty function does as expected...if the PC set is empty
then it
won't be able to find the
nearest present value, of course.
What's wrong with my code?
Thanks!
findNearest { arg inPitch;
var upShift = 0;
var downShift = 0;
if(this.isEmpty, {^inPitch});
while(pitches[inPitch + upShift % 12] != 1, {upShift =
upShift +
1});
while(pitches[inPitch - downShift % 12] != 1, {downShift =
downShift + 1});
if(upShift > downShift, {^(inPitch - downShift)},
{^(inPitch +
upShift)});
}
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users