Offset x-axis of function plot

hey, i would like to plot a function and would like to offset the x-axis, to see if all of the phasor wraps and the derived triggers are aligned perfectly.

simplified example here:

(
{
	var phase = (Phasor.ar(0, 100 * SampleDur.ir) - SampleDur.ir).wrap(0, 1);
	var trig = HPZ1.ar(phase) < 0;
	[phase, trig];
}.plot(0.00021);
)

how can i do that? thanks :slight_smile:

Iā€™m not exactly sure of what you need. Maybe one of these?:

(
{
	var phase = (Phasor.ar(0, 100 * SampleDur.ir) - SampleDur.ir).wrap(0, 1);
	var trig = HPZ1.ar(phase) < 0;
	[phase, trig];
}.plot(0.00021, minval: -1, maxval: 1);
)
(
{
	var phase = (Phasor.ar(0, 100 * SampleDur.ir) - SampleDur.ir).wrap(0, 1);
	var trig = HPZ1.ar(phase) < 0;
	[phase, trig].madd(2, -1);
}.plot(0.00021, minval: -1, maxval: 1);
)

hey, thanks. setting minval / maxval ist just changing the y-axis scaling. Im familiar with that. I would like to either zoom in at each phasors wrap or offset the x-axis for the plot, so i could inspect these points in greater detail.

Here one possible way to zoom in, using Function method .loadToFloatArray with ScaledUserViewContainer from the wslib quark:

(
{
	var phase = (Phasor.ar(0, 100 * SampleDur.ir) - SampleDur.ir).wrap(0, 1);
	var trig = HPZ1.ar(phase) < 0;
	[phase, trig];
}.loadToFloatArray(0.03, action: { arg array;
	var d, u;
	{
		d = array.as(Array).clump(2).flop;	// split into 2 arrays
		// d[0].size.debug("d[0].size");				
		u = ScaledUserViewContainer(nil, Rect(10, 35, 490, 400));
		u.maxZoom = 30; // set higher if you want more zoom range
		u.unscaledDrawFunc = {arg view;
			d.do({arg item, i;
				var col = [Color.red, Color.green][i];
				Pen.color = col;
				Pen.moveTo(0 @ item[0] );
				item.do({arg val, ind;
					var x = ind / item.size;
					var y = (1 - val) ;
					Pen.lineTo(view.translateScale(Point(x,y)));
				});
				Pen.stroke;
			});
		};		
	}.defer // defer gui process
});
)

thanks alot :slight_smile: this is very useful!

1 Like

Thanks so much again, this has been really helpful already to figure out if triggers are off by one sample or ramps really start at a sample count of 0. I have put it into my utils.scd file.

1 Like