Class SampleBufferDouble

java.lang.Object
com.io7m.jsamplebuffer.vanilla.SampleBufferDouble
All Implemented Interfaces:
SampleBufferReadableType, SampleBufferType

public final class SampleBufferDouble extends Object implements SampleBufferType
A sample buffer using double elements.
  • Method Details

    • createWithByteBuffer

      public static SampleBufferType createWithByteBuffer(int channels, long frames, double sample_rate, LongFunction<ByteBuffer> create)
      Create a sample buffer.
      Parameters:
      channels - The number of channels per frame
      frames - The number of frames in the buffer
      create - A function that allocates a byte buffer for the samples
      sample_rate - The sample rate in hz
      Returns:
      A new sample buffer
    • createWithDirectBuffer

      public static SampleBufferType createWithDirectBuffer(int channels, long frames, double sample_rate)
      Create a sample buffer. The underlying buffer will be allocated using direct memory.
      Parameters:
      channels - The number of channels per frame
      frames - The number of frames in the buffer
      sample_rate - The sample rate in hz
      Returns:
      A new sample buffer
    • createWithHeapBuffer

      public static SampleBufferType createWithHeapBuffer(int channels, long frames, double sample_rate)
      Create a sample buffer. The underlying buffer will be heap-allocated.
      Parameters:
      channels - The number of channels per frame
      frames - The number of frames in the buffer
      sample_rate - The sample rate in hz
      Returns:
      A new sample buffer
    • frameSetAll

      public void frameSetAll(long index, double value) throws IllegalArgumentException
      Description copied from interface: SampleBufferType
      Set the value of frame index. If the underlying buffer contains more than one channel, then the given value is inserted into all channels in the frame.
      Specified by:
      frameSetAll in interface SampleBufferType
      Parameters:
      index - The frame index
      value - The input
      Throws:
      IllegalArgumentException
    • frameSetExact

      public void frameSetExact(long index, double c0, double c1) throws IllegalArgumentException
      Description copied from interface: SampleBufferType
      Set the value of frame index.
      Specified by:
      frameSetExact in interface SampleBufferType
      Parameters:
      index - The frame index
      c0 - The input for channel 0
      c1 - The input for channel 1
      Throws:
      IllegalArgumentException - If channels() != 2
    • frameSetExact

      public void frameSetExact(long index, double c0) throws IllegalArgumentException
      Description copied from interface: SampleBufferType
      Set the value of frame index.
      Specified by:
      frameSetExact in interface SampleBufferType
      Parameters:
      index - The frame index
      c0 - The input for channel 0
      Throws:
      IllegalArgumentException - If channels() != 1
    • frameSetExact

      public void frameSetExact(long index, double[] value) throws IllegalArgumentException
      Description copied from interface: SampleBufferType
      Set the value of frame index. The input value is assumed to contain one sample for each of the channels in the frame.
      Specified by:
      frameSetExact in interface SampleBufferType
      Parameters:
      index - The frame index
      value - The input
      Throws:
      IllegalArgumentException - If value.length != channels()
    • channels

      public int channels()
      Specified by:
      channels in interface SampleBufferReadableType
      Returns:
      The number of channels in a frame
    • frames

      public long frames()
      Specified by:
      frames in interface SampleBufferReadableType
      Returns:
      The number of frames in the buffer
    • sampleRate

      public double sampleRate()
      Specified by:
      sampleRate in interface SampleBufferReadableType
      Returns:
      The sample rate in hz
    • frameGetExact

      public void frameGetExact(long index, double[] output) throws IllegalArgumentException
      Description copied from interface: SampleBufferReadableType
      Get the value of frame index.
      Specified by:
      frameGetExact in interface SampleBufferReadableType
      Parameters:
      index - The frame index
      output - The output
      Throws:
      IllegalArgumentException - If output.length != channels()
    • frameGetExact

      public double frameGetExact(long index) throws com.io7m.jranges.RangeCheckException
      Description copied from interface: SampleBufferReadableType
      Get the value of frame index.
      Specified by:
      frameGetExact in interface SampleBufferReadableType
      Parameters:
      index - The frame index
      Returns:
      The value in the frame
      Throws:
      com.io7m.jranges.RangeCheckException