# A simple way or formula to set a cycle of waveform per cps for stethoscope

Has anyone ever found a simple way or formula to set a cycle of waveform per cps for a stethoscope? I can find the approximate values for some frequencies but cannot find a general formula…

``````(
w = Window.new("my own scope", Rect(20, 20, 400, 500));
w.view.decorator = FlowLayout(w.view.bounds);
c = Stethoscope(s, 4, view:w.view);
w.onClose = { c.free }; // don't forget this
w.front;

x = { |freq| SinOsc.ar(freq * (1..4)) * 0.1 };
)

(
y = x.play(args:[freq:20]);
c.xZoom_(0.42655)
)

(
y.set(\freq, 30);
c.xZoom_(0.42655 * 3 / 2)
)

(
y.set(\freq, 50);
c.xZoom_(0.42655 * 5 / 2)
)

(
y.set(\freq, 70);
c.xZoom_(0.426488981905 * 7 / 2)
)

y.release
``````

An easier way would be to make `{....}.plot` embeddable:

You can use the cycle method like this:

``````(
w = Window.new("my own scope", Rect(20, 20, 400, 400));
w.view.decorator = FlowLayout(w.view.bounds);
c = Stethoscope(s, 4, view:w.view);
w.onClose = { c.free }; // don't forget this
w.front;
x = { |freq| SinOsc.ar(freq * (1..4)) * 0.3 };
)

(
y = x.play(args:[freq:200]);
c.cycle_(s.sampleRate / 200)
)

y.release

(
y = x.play(args:[freq:300]);
c.cycle_(s.sampleRate / 300)
)

y.release
``````

Sometimes you still get some movement. In the example, on my system freq of 200 moves a bit, but freq 300 is locked.

Best,
Paul

1 Like

Thank you so much! This example is great!
I have also tried to use `.cycle’ but not as successfully as this!