Wrap ugen with interrupted interval

Always glad to help!

FYI: you will get faster (and better) answers by asking specific rather than abstract questions.

1 Like

Found an alternative method, which also works when the interval borders are moving. For example when you need to avoid the space around a recorderhead.
The first example is with static borders. The second is with moving borders.

//static borders
(
p = {
	var sig, lowerBound = 0.5, upperBound = 0.6, gap;
	
	gap = 1 - (upperBound - lowerBound);
	lowerBound = upperBound + gap;
	
	sig = SinOsc.ar(1).wrap(upperBound, lowerBound).wrap(0, 1);
	upperBound = upperBound.wrap(0, 1);
	lowerBound = lowerBound.wrap(0, 1);
	[sig, lowerBound, upperBound]
}.plot(3);
p.superpose = true;
)

(
//moving borders
p = {
	var sig, lowerBound = Phasor.ar(DC.ar(0), SampleDur.ir, 0, 10e10), upperBound = lowerBound + 0.1, gap;
	
	gap = 1 - (upperBound - lowerBound);
	lowerBound = upperBound + gap;
	
	sig = SinOsc.ar(1).wrap(upperBound, lowerBound).wrap(0, 1);
	upperBound = upperBound.wrap(0, 1);
	lowerBound = lowerBound.wrap(0, 1);
	[sig, lowerBound, upperBound]
}.plot(3);
p.superpose = true;
)

The last example is not completely ready to use for avoiding clicks. It works when lowerBound < upperBound. But in some cases when upperBound wraps around to 0 before lowerBound does, you get a small window where upperBound < lowerBound. For that situation an exception needs to be built in.

Besides skipping the interval: I made a method that just avoids the interval. These also might come in handy for live granulation. With this you can create clickfree grains in the ‘wake’ of the recorderhead, with making the most of the ‘clickfree’ space of the buffer.

Static borders:

(
//static interval
p = {
	var sig = SinOsc.ar(1).range(0, 1), lowerBound = 0.5, upperBound = 0.6, gap;

	gap = 1 - (upperBound - lowerBound);
	lowerBound = upperBound + gap;

	sig = sig * gap + upperBound;
	sig = sig.wrap(0, 1);
	lowerBound = lowerBound.wrap(0, 1);
	upperBound = upperBound.wrap(0, 1);
	[sig, lowerBound, upperBound]
}.plot(3);
p.superpose = true;
)

Moving borders:

(
//moving interval
p = {
	var sig = SinOsc.ar(1).range(0, 1), lowerBound = Phasor.ar(DC.ar(0), SampleDur.ir, 0, 10e10), upperBound = lowerBound + 0.1, gap;

	gap = 1 - (upperBound - lowerBound);
	lowerBound = upperBound + gap;

	sig = sig * gap + upperBound;
	sig = sig.wrap(0, 1);
	lowerBound = lowerBound.wrap(0, 1);
	upperBound = upperBound.wrap(0, 1);
	[sig, lowerBound, upperBound]
}.plot(3);
p.superpose = true;
)