Interface DoubleClockedSignalSource
- All Superinterfaces:
AbstractClockedSignalSource,AbstractSignalSource,CompilableControlFlow,CompilableDataFlow,Component,DoubleSignalSource,DoubleSupplier,Process
- All Known Subinterfaces:
DoubleADSR
- All Known Implementing Classes:
CompilableDoubleStoredSignalSource,DoubleClockedSignalSource.AbstractRandom,DoubleDelay,DoubleEnvelope,DoubleFMOsci,DoubleFractionalDelay,DoubleMultiDelay,DoubleOctaveRepeatingTabledTuning,DoubleProcessMux,DoubleSaH,DoubleStoredSignalSource,DoubleTableOscillator,DoubleUpsamplingSignalSource
double whose observable state is
driven by a clock.
This interface excludes signal sources whose state changes asynchronously, but is neutral with respect to whether values are computed on the fly when demanded, or stored when available and then just retrieved.
The operation of the driving clock works as specified by the Process superinterface. For example, a main loop may use the following
pattern:
RealtimeContext rc = ...;
DoubleClockedSignalSource c = ...;
c.setRealtimeContext(rc);
c.init();
while (...) {
c.step();
double v = c.getAsDouble();
...
}
Every iteration of the main loop increases the clock index of the
component c. The behavior of instances of this interface is
typically specified in terms of the current clock index.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface eu.bandm.sig.adlib2.Process
Process.Proxy -
Field Summary
Fields inherited from interface eu.bandm.sig.adlib2.AbstractClockedSignalSource
STREAM_CHARACTERISTICS, STREAM_SIZE -
Method Summary
Modifier and TypeMethodDescriptionstatic DoubleClockedSignalSourceadHoc(double... elems) Returns a new signal source that produces the given values, one per clock tick.default DoubleClockedSignalSourcestatic DoubleClockedSignalSourceclock(Optional<ConstantRealtimeContext> context) Returns a signal source that displays how much model time has passed since the first clock tick.default DoubleClockedSignalSourcecompile()Returns a new signal source that realizes the same behavior as this signal source with specialized code.static DoubleClockedSignalSourcecycle(double... elems) Returns a new signal source that produces the given values repeatedly, one per clock tick.default voiddrain(RealtimeContext rc, double[] buffer) Write elements from this signal source to a buffer.default voiddrain(RealtimeContext rc, double[] buffer, int offset, int length) Write elements from this signal source to a buffer.static DoubleClockedSignalSourceReturns a new signal source whose value is the amount of model time that is projected to elapse between the current and the next clock tick.default DoubleClockedSignalSourcestatic DoubleClockedSignalSourceofSpliterator(Supplier<? extends Spliterator.OfDouble> spliterator, DoubleSupplier afterwards) static DoubleClockedSignalSourceofStream(Supplier<? extends DoubleStream> stream) static DoubleClockedSignalSourceofStream(Supplier<? extends DoubleStream> stream, DoubleSupplier afterwards) static DoubleClockedSignalSourcerandom()static DoubleClockedSignalSourcerandom(long seed) static DoubleClockedSignalSourcerandom(OptionalLong seed) static DoubleClockedSignalSourcestatic DoubleClockedSignalSourcerandomGaussian(long seed) static DoubleClockedSignalSourcerandomGaussian(OptionalLong seed) static DoubleClockedSignalSourceReturns a new signal source whose value is the reciprocal of amount of model time that is projected to elapse between the current and the next clock tick.default Spliterator.OfDoubledefault DoubleStreamstream()Methods inherited from interface eu.bandm.sig.adlib2.compile.CompilableDataFlow
compileDataFlowTo, hasDataFlowIOMethods inherited from interface eu.bandm.sig.adlib2.DoubleSignalSource
abs, add, asDouble, asFloat, asInt, ceil, compileDataFlow, compileMainSignalSource, DEBUG, defined, delayed, delayed, divide, equal, floor, getAsDouble, getConstantAsDouble, getValueClass, glidingAverage, glidingStandardDeviation, glidingSum, glidingVariance, greaterOrEqual, greaterThan, guard, hasConstantAsDouble, invariant, lessOrEqual, lessThan, map, max, min, modulo, multiply, negate, negative, nonEqual, nonnegative, nonpositive, nonzero, notANumber, positive, power, probe, publishStoredValueVariable, relateWith, sampleAndHold, selectAffine, series, sqrt, stored, subtract, zero, zeroCrossing, zipWithMethods inherited from interface eu.bandm.sig.adlib2.Process
afterEvery, andThen, compileAsMainProcess, compileControlFlow, compileInitialization, every, every, getProcess, hasControlFlowIO, hasInitializationIO, init, setRealtimeContext, step
-
Method Details
-
after
-
during
-
adHoc
Returns a new signal source that produces the given values, one per clock tick.After the given values are exhausted, that is after as many clock ticks as there are elements in the array, the default value of the element type is held indefinitely.
At clock index
n,this.getAsDouble() == (n < elems.length ? elems[n] : 0d)holds.- Parameters:
elems- the array of values to produce
-
cycle
Returns a new signal source that produces the given values repeatedly, one per clock tick.When the given values are exhausted the iteration starts over.
At clock index
n,this.getAsDouble() == elems[n % elems.length]holds.- Parameters:
elems- the array of values to produce
-
compile
Returns a new signal source that realizes the same behavior as this signal source with specialized code.The resulting object displays the same long-term behavior (reaction with output values to realtime events) as this signal source. Its internal state is undefined phase until initialized properly.
Specialized JVM byte code is generated, and a new class is loaded for the implementation. It can be expected to execute more efficiently than the original after a warm-up phase, subject to the usual conditions of JVM just-in-time compilation. Hence compilation is recommended for components to be used in tight long-running loops, but not for one-off or infrequent computations.
The original and the compiled instance do not share state phase or memory; their life cycles are independent except for shared non-compilable components. For the latter reason, it is recommended not to use both instances concurrently.
-
stream
-
spliterator
-
ofStream
-
ofStream
@Undocumented static DoubleClockedSignalSource ofStream(Supplier<? extends DoubleStream> stream, DoubleSupplier afterwards) -
ofSpliterator
@Undocumented static DoubleClockedSignalSource ofSpliterator(Supplier<? extends Spliterator.OfDouble> spliterator, DoubleSupplier afterwards) -
dt
Returns a new signal source whose value is the amount of model time that is projected to elapse between the current and the next clock tick.- See Also:
-
rate
Returns a new signal source whose value is the reciprocal of amount of model time that is projected to elapse between the current and the next clock tick. -
clock
Returns a signal source that displays how much model time has passed since the first clock tick.Initialization resets the value to zero.
-
random
-
random
-
random
-
randomGaussian
-
randomGaussian
-
randomGaussian
-
drain
Write elements from this signal source to a buffer.Invoking this method as
drain(rc, b)is equivalent to invokingdrain(rc, b, 0, b.length).- Parameters:
rc- the realtime contextbuffer- the buffer to write to- See Also:
-
drain
Write elements from this signal source to a buffer.This method first invokes
Process.setRealtimeContext(RealtimeContext)andProcess.init()to put this signal source in a deterministic initial state. Then it iteratesProcess.step()andDoubleSignalSource.getAsDouble()in turn to obtain successive values to write into the buffer.Invalid uses that would cause write access outside the bounds of the buffer are detected late; all preceding valid effects occur before an exception is thrown.
- Parameters:
rc- the realtime contextbuffer- the buffer to write tooffset- the first index to write tolength- the number of values to write- Throws:
NullPointerException- isbufferis nullIllegalArgumentException- iflengthis negativeArrayIndexOutOfBoundsException- ifoffset < 0oroffset + length > buffer.length
-