object EnvGen extends ProductReader[EnvGen] with Serializable
An envelope generator UGen. It uses a break point description in its envelope
input, typically coming from an Env
object. The envelope may be re-triggered
using the gate
input. Upon start and upon re-triggering, the envelope
,
levelScale
, levelBias
and timeScale
parameters are polled and remain
constant for the duration of the envelope.
To construct a manual envelope without the use of the Env
class, the format
should be as follows:
val env = Seq[GE](startLevel, numSegments, releaseNode, loopNode, targetLevel1, duration1, curveType1, curvature1, targetLevel2, duration2, curveType2, curvature2, ...)
Where the curve-type is one of Curve.step.id
, Curve.lin.id
,
Curve.exp.id
, etc. The curvature values are only relevant for the parametric
curve type. The releaseNode
and loopNode
parameters are segment indices or
the special value -99
indicating that there are no release or loop segments.
Note: The actual minimum duration of a segment is not zero, but one sample step for audio rate and one block for control rate. This may result in asynchronicity when in two envelopes of different number of levels, the envelope times add up to the same total duration. Similarly, when modulating times, the new time is only updated at the end of the current segment; this may lead to asynchronicity of two envelopes with modulated times.
Examples
// percussive one-shot
play { PinkNoise.ar(EnvGen.kr(Env.perc, doneAction = freeSelf)) }
// fixed duration amplitude envelope play { val env = Env(0, Seq(0.01 -> 1, 0.5 -> 0.5, 0.02 -> 1, 0.5 -> 0)) SinOsc.ar(470) * EnvGen.kr(env, doneAction = freeSelf) }
// amplitude and frequency modulation play { val env = Env(0, Seq(0.01 -> 1, 0.5 -> 0.5, 0.02 -> 0.8, 0.5 -> 0, 0.2 -> 1.2, 0.5 -> 0)) val gate = Impulse.kr(MouseX.kr(0.2, 3), 0.5) val gen = EnvGen.kr(env, gate) SinOsc.ar(270, SinOsc.ar(gen * 473)) * gen * 0.2 }
// Dust-triggered envelope play { val c = Curve.parametric(-4) val env = Env(0, Seq((0.05,0.5,c), (0.1,0.0,c), (0.01,1.0,c), (1.0,0.9,c), (1.5,0.0,c))) val gen = EnvGen.ar(env, Dust.ar(1)) SinOsc.ar(gen * 1000 + 440) * gen * 0.1 }
// two channels play { val p = Curve.parametric(-4) def mkEnv(a: Double, b: Double) = { val env = Env(0.0, Seq((0.05,a,p), (0.1,0.0,p), (0.01,1.0,p), (1.0,b,p), (1.5,0.0,p))) EnvGen.ar(env, Dust.ar(1)) } val gen: GE = Seq(mkEnv(-0.2, -0.4), mkEnv(0.5, 0.9)) SinOsc.ar(gen * 440 + 550) * gen * 0.1 }
// control gate and done-action val x = play { var gen = EnvGen.kr(Env.adsr(), "gate".kr(0), doneAction = "done".kr(0)) SinOsc.ar(440) * gen * 0.1 } x.set("gate" -> 1) // turn on x.set("gate" -> 0) // turn off x.set("gate" -> 1) // turn on x.set("done" -> freeSelf.id, "gate" -> 0) // turn off and free
// fast triggering play { val freq = MouseX.kr(1, 100, 1) val gate = Impulse.ar(freq) val env = Env.perc(0.1, 0.9) val gen = EnvGen.ar(env, gate = gate, timeScale = freq.reciprocal) SinOsc.ar(440) * gen * 0.1 }
- Alphabetic
- By Inheritance
- EnvGen
- Serializable
- ProductReader
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def ar(envelope: GE, gate: GE = 1, levelScale: GE = 1.0f, levelBias: GE = 0.0f, timeScale: GE = 1.0f, doneAction: GE = doNothing): EnvGen
- envelope
the description of the envelope break-points. Typically you pass an instance of
Env
which will then automatically expand to the correct format.- gate
triggers the envelope and holds it open while greater than zero. If the envelope is of fixed duration (e.g.
Env.linen
,Env.perc
), thegate
argument is used as a simple trigger. If it contains a sustained segment (e.g.Env.adsr
,Env.asr
), the envelope is held open until the gate becomes 0, at which point is released. Ifgate
is less than zero, a release is enforced with duration-1.0 - gate
.- levelScale
amplitude factor with which the nominal envelope is multiplied.
- levelBias
amplitude offset which is added to the nominal envelope.
- timeScale
time scale factor with which the envelope segment durations are multiplied.
- doneAction
action to be performed when the envelope reaches its end point.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def kr(envelope: GE, gate: GE = 1, levelScale: GE = 1.0f, levelBias: GE = 0.0f, timeScale: GE = 1.0f, doneAction: GE = doNothing): EnvGen
- envelope
the description of the envelope break-points. Typically you pass an instance of
Env
which will then automatically expand to the correct format.- gate
triggers the envelope and holds it open while greater than zero. If the envelope is of fixed duration (e.g.
Env.linen
,Env.perc
), thegate
argument is used as a simple trigger. If it contains a sustained segment (e.g.Env.adsr
,Env.asr
), the envelope is held open until the gate becomes 0, at which point is released. Ifgate
is less than zero, a release is enforced with duration-1.0 - gate
.- levelScale
amplitude factor with which the nominal envelope is multiplied.
- levelBias
amplitude offset which is added to the nominal envelope.
- timeScale
time scale factor with which the envelope segment durations are multiplied.
- doneAction
action to be performed when the envelope reaches its end point.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def read(in: RefMapIn, key: String, arity: Int): EnvGen
- Definition Classes
- EnvGen → ProductReader
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated