prko
January 25, 2024, 5:09pm
1
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
prko
January 25, 2024, 7:00pm
2
An easier way would be to make {....}.plot
embeddable:
supercollider:develop
← prko:topic/adding_parent_to_{}.plot
opened 06:20PM - 25 Jan 24 UTC
## Purpose and Motivation
To display one or more cycles of a waveform statica… lly in a window or view.
Some examples:
- In the following code, I want to display the quasi-real-time waveform of the configuration: https://sccode.org/1-5hC
- Embedding a `Stethoscope` is possible, but statically adapting the waveform to the scope view area is not easy.
https://scsynth.org/t/a-simple-way-or-formula-to-set-a-cycle-of-waveform-per-cps-for-stethoscope/8861
- `Function.plot` cannot currently be embedded in a `Window` or `View`. For example, if I am not mistaken, the following plotted result cannot be placed in a `Window`:
```
{ SinOsc.ar }.plot(0.01)
```
With this PR, the plotted result above can be embedded as follows:
```
(
var w = Window("The parent of a ploter").front;
{ SinOsc.ar }.plot(0.01, parent: w)
)
```
## Types of changes
- Documentation
- New feature
## To-do list
- [x] Code is tested
- [x] All tests are passing
- [x] Updated documentation
- [x] This PR is ready for review
TXMod
January 31, 2024, 5:53pm
3
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
prko
January 31, 2024, 11:40pm
4
Thank you so much! This example is great!
I have also tried to use `.cycle’ but not as successfully as this!