supercollider
supercollider copied to clipboard
Add the parent argument to all .plot and .plotAudio methods to easily place them in a parent window.
Purpose and Motivation
To display one or more cycles of a waveform statically 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 aWindow
orView
. For example, if I am not mistaken, the following plotted result cannot be placed in aWindow
:{ SinOsc.ar }.plot(0.01)
With this PR, the plotted result above can be embedded as follows:
(
var w = Window("The parent of a plotter").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
AbstractFunction will also need this, and I would say that Env, Buffer, Wavetable, Bus, ArrayedCollection should have it too. Maybe others I could have missed.
The whole interface of plot is messy, because it has a long history. One day, we can maybe have a different method that is the same everywhere.
But until then, we should keep it as reasonable as possible ...
@telephon Thank you for your kind comments!
I have added the parent
argument to all plot
and plotAudio
methods in the plotView.sc file.
I also updated the WaveTable
, Buffer
and Env
documentation for the corresponding parts. For ArrayedCollection
and Bus
, there are no argument explanations, so I did not change them.
The following code blocks are the test code:
testing plotAudio
(
var w = Window("parent");
var busAudio = Bus.audio(s, 2);
busAudio.plotAudio(parent: w);
w.front
)
(
var w = Window("parent");
var busCotrol = Bus.control(s, 1).set(0.1);
busCotrol.plotAudio(parent: w);
w.front
)
testing plot
with a routine
(
s.waitForBoot {
var w = Window("parent");
var testItems = (
anArrayedCollection: [1, 2, 3],
aFunction: { SinOsc.ar },
aBusAudio: Bus.audio(s, 2),
aBusControl: Bus.control(s, 1).set(0.1),
aWaveTable: Wavetable.sineFill(512, 1.0 / [1, 2, 3, 4, 5, 6]),
aBuffer: Buffer.read(s, Platform.resourceDir +/+ "sounds/sinedPink.aiff"),
anEnv: Env.perc
);
s.sync;
w.front;
testItems.do { |item|
item.plot(parent: w);
1.wait
};
}
)
testing individual plot
methods
(
var w = Window("parent");
[1, 2, 3].plot(parent: w);
w.front
)
(
var w = Window("parent");
{SinOsc.ar}.plot(parent: w);
w.front
)
(
var w = Window("parent");
var busAudio = Bus.audio(s, 2);
busAudio.plot(parent: w);
w.front
)
(
var w = Window("parent");
var busCotrol = Bus.control(s, 1).set(0.1);
busCotrol.plot(parent: w);
w.front
)
(
var w = Window("parent");
Wavetable.sineFill(512, 1.0/[1, 2, 3, 4, 5, 6]).plot(parent: w);
w.front
)
(
s.waitForBoot {
var w = Window("parent");
var buf = Buffer.read(s, Platform.resourceDir +/+ "sounds/sinedPink.aiff");
s.sync;
buf.plot(parent: w);
w.front
}
)
(
var w = Window("parent");
Env.perc.plot(parent: w);
w.front
)
@telephon
An example that shows an audio bus and the physical stereo output busses would be good. Will the examples in the following thread do the job? One thing I am afraid of is the 0.135.wait;
part. It works on my laptop, but will be different on other machines.
https://scsynth.org/t/plotaudio-and-the-practical-use-case-for-plotting-an-audio-bus/9143/3?u=prko
https://scsynth.org/t/plotaudio-and-the-practical-use-case-for-plotting-an-audio-bus/9143/3?u=prko
@telephon Thank you! The example is added! Your example clarified three things that were a bit unclear to me!
@telephon
Added additional explanation to Bus.audio
and Bus.new
for easy understanding of these methods.
I realised that I missed updating AbstractFunction.schelp. Also, I realised that there was a conflict, so I resolved it.
Sorry for not checking this carefully. I added the parent
argument to BusPlug
.
In the following screenshots you can see what I did:
@capital-G Thanks! I resolved this!