Class FloatSamplePlayer

All Implemented Interfaces:
CompilableControlFlow, CompilableDataFlow, FloatSignalSource, FloatSupplier, Realtime, SignalSource<Float>, Runnable, Supplier<Float>

public class FloatSamplePlayer extends FloatClockedSignalSource
Pitch calculation:
With "increment==1.0", this code plays one array position in one run-step. The increment must be adjusted according the "recorded pitch" and the "recording sampling rate".
ATTENTION: "phase" is realized as "double" value.
(Backward mode and pingpong mode can be realized by data transformation, currently not supported.)
   addSegment  (null       na.     duration)       -> play pause of given duration
   addSegment  (float[]    1       na        na    -> play segment once
   addSegment  (float[]    -1      start     end   -> loop infinite
   addSegment  (float[]    n       start     end   -> loop n times, then play tail 
                                                              (or next segment)
   end_loop(n)   --> overwrite loopCount with "n"
   clear()       --> hard delete all
 
Cf FloatPfg
  • Field Details

    • qSize

      protected final int qSize
    • width

      protected final int width
    • freq

      protected final float freq
    • period

      protected final float period
    • increment

      protected final FloatSignalSource increment
    • _noDC

      protected boolean _noDC
    • data

      protected final float @Opt [][] data
    • delay

      protected final float[] delay
      duration of delay.
    • start

      protected final int[] start
      start index into data array.
    • from

      protected final int[] from
    • to

      protected final int[] to
    • loopcount

      protected final int[] loopcount
      -1 for infinitely often; will be changed dynamically later.
    • write

      protected int write
    • read

      protected int read
    • index

      protected int index
    • phase

      protected double phase
    • time

      protected double time
  • Constructor Details

    • FloatSamplePlayer

      public FloatSamplePlayer(float freq, int qSize, int width, FloatSignalSource increment)
  • Method Details

    • run

      public void run()
      GLO IN phase points to the next sample to be output, relative to the start of the currently played range.
    • clear

      public void clear()
    • set

      public void set(float out)
    • clear

      public void clear(float out)
    • set_noDC

      public void set_noDC(boolean n)
      Setting to "true" means not to output a constant "direct current" value !=0f in pauses and after data end.
    • _noDC

      protected void _noDC()
    • complete

      protected void complete()
    • play_pause

      public boolean play_pause(float duration)
    • play_once

      public boolean play_once(float[] data)
    • play_once

      public boolean play_once(float[] data, int from, int to)
    • play_loop

      public boolean play_loop(float[] data)
    • play_loop

      public boolean play_loop(float[] data, int from, int to)
    • play_ntimes

      public boolean play_ntimes(float[] data, int loopcount)
    • play_ntimes

      public boolean play_ntimes(float[] data, int from, int to, int loopcount)
    • end_loop

      public void end_loop()
    • end_loop

      public void end_loop(int n)
      Used to replace an infinite loop count with only "n" remaining loops.
    • checkLoopCount

      protected void checkLoopCount(int n)
    • _add

      protected boolean _add(float[] data, int loopcount)
    • _add

      protected boolean _add(float[] data, float delay, int from, int to, int loopcount)
    • dump

      public void dump()