Class FloatClockedSignalSource

java.lang.Object
eu.bandm.sig.adlib.FloatClockedSignalSource
All Implemented Interfaces:
CompilableControlFlow, CompilableDataFlow, FloatSignalSource, FloatSupplier, Realtime, SignalSource<Float>, Runnable, Supplier<Float>
Direct Known Subclasses:
Apdsr, DataLineSource, FloatCounter, FloatDelay, FloatIntegralLimited, FloatOscillator, FloatPfg, FloatResonator, FloatRingBuffer, FloatSamplePlayer, FloatSlider, FloatSlopeLimiter, FloatTwoTablesOscillator, Monodic_FM, Monodic_Table, TApdsr

public abstract class FloatClockedSignalSource extends Object implements FloatSignalSource, SignalSource<Float>, Realtime
Abstract base class for objects that emit a signal of type float, which attains new values only at clock events.

Note that object creation is not a clock event; whether instances of this class have a meaningful signal value depends on the particular subclass.

Subclasses must implement the method Realtime.run(), which should set the field out to a new value.

ATTENTION: This implements SignalSource, which defines the method get() for the boxed result. But it is not a subclass of ClockedSignalSource, because this would also add a boxed field named , which is not useful for the fast and dedicated way of operation.

  • Field Details

    • out

      protected float out
      The current value.
  • Constructor Details

    • FloatClockedSignalSource

      protected FloatClockedSignalSource()
      Creates a new instance with no specified initial value.
    • FloatClockedSignalSource

      protected FloatClockedSignalSource(float init)
      Creates a new instance with the given initial value.
      Parameters:
      init - the initial value.
  • Method Details

    • getAsFloat

      public final float getAsFloat()
      Returns the current value of the signal.

      Any implementation of this method should be stateless; its invocation should not have any side effect on the emitter or the observer, except for real time passing until its completion.

      Specified by:
      getAsFloat in interface FloatSignalSource
      Specified by:
      getAsFloat in interface FloatSupplier
      Returns:
      the current value of out.
    • get

      @Deprecated public final Float get()
      Deprecated.
      Returns the current value of the signal.
      Specified by:
      get in interface FloatSignalSource
      Specified by:
      get in interface SignalSource<Float>
      Specified by:
      get in interface Supplier<Float>
      Returns:
      the current value of out.
    • suppliedBy

      public static FloatClockedSignalSource suppliedBy(FloatSupplier supplier)
    • suppliedBy

      public static FloatClockedSignalSource suppliedBy(float init, FloatSupplier step)
    • delayedBy

      public FloatClockedSignalSource delayedBy(int length)
      Creates a wrapper that emits the same sequence of values as this object, but delayed by the given number of clock events. The prepended initial values are not specified.
      Parameters:
      length - the number of clock events to delay each signal value.
      Returns:
      a wrapper that emits the same sequence of values as this object, delayed by (length) clock events.
      Throws:
      IllegalArgumentException - if length < 0.
    • delayedWith

      public FloatClockedSignalSource delayedWith(float... initialValues)
      Creates a wrapper that emits the same sequence of values as this object, but delayed by a given number of clock events, prepending the given initial values.
      Parameters:
      initial - the number of clock events to delay each signal value.
      Returns:
      a wrapper that emits the same sequence of values as this object, but with initialValues prepended.
      Throws:
      IllegalArgumentException - if initialValues == null.
    • logged

      public Realtime logged(String name)
      Creates a wrapper that emits the same signal values as this object, but produces a logging output as side effect on each clock event.
      Parameters:
      name - the name to associate with the current signal value in logging output, or null for anonymous output.
      See Also:
    • logged

      public Realtime logged(String name, PrintStream out)
      Creates a wrapper that emits the same signal values as this object, but produces a logging output as side effect on each clock event.
      Parameters:
      name - the name to associate with the current signal value in logging output, or null for anonymous output.
      out - the output stream to use for logging.
      Throws:
      IllegalArgumentException - if out == null.
      See Also:
    • repeat

      public static FloatClockedSignalSource repeat(float... table)
      Creates an object that emits a given sequence of values, proceeding cyclically at each clock event.
      Parameters:
      table - an array of the values to attain cyclically
      Returns:
      an object that attains the value table[(n - 1) % table.length] at the n-th clock event.
    • iterate

      public static FloatClockedSignalSource iterate(FloatUnaryOperator op, float initial)
    • slide

      public static FloatClockedSignalSource slide(float sampleFreq, float duration)
      Creates an object that emits a signal rising at clock events in equal steps from 0 to 1, with a given slope.
      Parameters:
      sampleFreq - the number of clock events per time unit.
      duration - the length of the rise in time units.
      Returns:
      an object that emits a signal that is 0 at the first clock event, rises to 1 in (duration * sampleFreq) steps, and remains 1 afterwards.
    • switchOver

      public FloatClockedSignalSource switchOver(int countdown, FloatClockedSignalSource next)
    • doCompileDataFlow

      protected final <V, L> void doCompileDataFlow(CompilationContext<V,L> context)
    • random

      public static FloatClockedSignalSource random(ToFloatFunction<Random> fun)
    • randomUniform

      public static FloatClockedSignalSource randomUniform()
    • randomNormal

      public static FloatClockedSignalSource randomNormal()