rsc3/doc-schelp/HelpSource/Classes/SCEnvelopeEdit.schelp

176 lines
3.9 KiB
Text

class:: SCEnvelopeEdit
summary:: An envelope editor view
categories:: GUI>Kits>Cocoa
related:: Classes/EnvelopeView
description::
An editable Envelope view.
subsection:: Some Important Issues Regarding SCEnvelopeEdit
The breakpoints are color coded as follows:
table::
## blue || normal
## red || sustain node
## green || loop node
::
classmethods::
method:: new
argument:: parent
The parent view.
argument:: bounds
An instance of link::Classes/Rect::, or a link::Classes/Point:: indicating code::width@height::.
argument:: env
The envelope. An instance of link::Classes/Env::.
argument:: pointsPerSegment
The resolution in points per segment. Default value is 10.
method:: paletteExample
argument:: parent
argument:: bounds
subsection:: Subclassing and Internal Methods
The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.
method:: viewClass
instancemethods::
method:: refresh
If the link::Classes/Env:: object is modified directly, this needs to be called to update the GUI.
maxLevel
Changes maximum level shown in editor.
argument:: level
An instance of link::Classes/Float::.
method:: minLevel
Changes minimum level shown in editor.
argument:: level
An instance of link::Classes/Float::.
method:: minTime
Changes minimum time (sec) shown in editor. Negative times are okay because link::Classes/Env:: uses inter-node durations.
argument:: sec
An instance of link::Classes/Float::. Seconds.
method:: maxTime
Changes maximum time (sec) shown in editor.
argument:: sec
An instance of link::Classes/Float::. Seconds.
subsection:: Subclassing and Internal Methods
The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.
method:: defaultMouseDownAction
argument:: x
argument:: y
argument:: modifiers
argument:: buttonNumber
argument:: clickCount
method:: env
argument:: e
method:: addBreakPoint
argument:: level
method:: insertAtTime
argument:: time
argument:: level
method:: pointsPerSegment
method:: initSCEnvelopeEdit
argument:: argEnv
argument:: argPPS
argument:: setMinMax
method:: redraw
method:: updateAll
method:: updateSegment
argument:: segNum
method:: clear
examples::
Make a basic editor:
code::
(
e = Env([1, 2], [10]);
w = Window("Env Editor", Rect(200, 200, 300, 200));
v = SCEnvelopeEdit(w, w.view.bounds.moveBy(20, 20).resizeBy(-40, -40), e, 20).resize_(5);
w.front;
)
v.addBreakPoint;
(
v.clear;
v.redraw;
v;
)
v.maxLevel_(2); // to give more headroom
v.maxTime_(2); // to increase release point
v.minTime_(-1); // to increase attack time
e.curves_('sin'); // env object is changed
v.refresh; // must refresh editor
::
Controlling a Synth
code::
s.boot;
(
e = Env([0, 1, 0.7, 0.9, 0], [0.03, 0.03, 0.03, 0.03], 'sin');
f = Env([0, 1, 0.7, 0.9, 0], [0.03, 0.03, 0.03, 0.03], 'sin');
w = Window("Shards", Rect(100, 100, 500, 400));
v = SCEnvelopeEdit(w, w.view.bounds.resizeBy(-20, -200), e, 10).resize_(2);
StaticText(w, v.bounds).string_(" amplitude").resize_(2);
x = SCEnvelopeEdit(w, v.bounds.moveBy(0, 200), f, 10).resize_(2);
StaticText(w, x.bounds).string_(" frequency").resize_(2);
w.front;
)
(
SynthDef("sineBlip", {
arg freq = 440, vol = 0.1, la0, la1, la2, la3, la4, ta0, ta1, ta2, ta3, crva,
lf0, lf1, lf2, lf3, lf4, tf0, tf1, tf2, tf3, crvf;
var signal, fenv, aenv;
fenv = EnvGen.ar(Env([lf0, lf1, lf2, lf3, lf4], [tf0, tf1, tf2, tf3], crvf));
aenv = EnvGen.ar(Env([la0, la1, la2, la3, la4], [ta0, ta1, ta2, ta3], crva), doneAction: Done.freeSelf);
signal = SinOsc.ar([freq, freq*2] * fenv) * aenv * vol;
Out.ar(0, signal.dup);
}).add;
)
(
Routine({
var par, indices;
indices = (2..21);
loop({
par = (indices +++ (
v.env.levels ++
v.env.times ++
v.env.curves ++
x.env.levels ++
x.env.times ++
x.env.curves)).flatten;
s.sendBundle(s.latency, [\s_new, "sineBlip", -1, 1, 1, \freq, exprand(4e3,11e3)] ++ par);
0.04.wait;
});
}).play;
)
::