Package com.io7m.jsamplebuffer.vanilla
Class SampleBufferDouble
- java.lang.Object
-
- com.io7m.jsamplebuffer.vanilla.SampleBufferDouble
-
- All Implemented Interfaces:
SampleBufferReadableType,SampleBufferType
public final class SampleBufferDouble extends java.lang.Object implements SampleBufferType
A sample buffer usingdoubleelements.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intchannels()static SampleBufferTypecreateWithByteBuffer(int channels, long frames, double sample_rate, java.util.function.LongFunction<java.nio.ByteBuffer> create)Create a sample buffer.static SampleBufferTypecreateWithDirectBuffer(int channels, long frames, double sample_rate)Create a sample buffer.static SampleBufferTypecreateWithHeapBuffer(int channels, long frames, double sample_rate)Create a sample buffer.doubleframeGetExact(long index)Get the value of frameindex.voidframeGetExact(long index, double[] output)Get the value of frameindex.longframes()voidframeSetAll(long index, double value)Set the value of frameindex.voidframeSetExact(long index, double c0)Set the value of frameindex.voidframeSetExact(long index, double[] value)Set the value of frameindex.voidframeSetExact(long index, double c0, double c1)Set the value of frameindex.doublesampleRate()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.io7m.jsamplebuffer.api.SampleBufferReadableType
samples
-
-
-
-
Method Detail
-
createWithByteBuffer
public static SampleBufferType createWithByteBuffer(int channels, long frames, double sample_rate, java.util.function.LongFunction<java.nio.ByteBuffer> create)
Create a sample buffer.- Parameters:
channels- The number of channels per frameframes- The number of frames in the buffercreate- A function that allocates a byte buffer for the samplessample_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 frameframes- The number of frames in the buffersample_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 frameframes- The number of frames in the buffersample_rate- The sample rate in hz- Returns:
- A new sample buffer
-
frameSetAll
public void frameSetAll(long index, double value) throws java.lang.IllegalArgumentExceptionDescription copied from interface:SampleBufferTypeSet the value of frameindex. If the underlying buffer contains more than one channel, then the given value is inserted into all channels in the frame.- Specified by:
frameSetAllin interfaceSampleBufferType- Parameters:
index- The frame indexvalue- The input- Throws:
java.lang.IllegalArgumentException
-
frameSetExact
public void frameSetExact(long index, double c0, double c1) throws java.lang.IllegalArgumentExceptionDescription copied from interface:SampleBufferTypeSet the value of frameindex.- Specified by:
frameSetExactin interfaceSampleBufferType- Parameters:
index- The frame indexc0- The input for channel 0c1- The input for channel 1- Throws:
java.lang.IllegalArgumentException- Ifchannels() != 2
-
frameSetExact
public void frameSetExact(long index, double c0) throws java.lang.IllegalArgumentExceptionDescription copied from interface:SampleBufferTypeSet the value of frameindex.- Specified by:
frameSetExactin interfaceSampleBufferType- Parameters:
index- The frame indexc0- The input for channel 0- Throws:
java.lang.IllegalArgumentException- Ifchannels() != 1
-
frameSetExact
public void frameSetExact(long index, double[] value) throws java.lang.IllegalArgumentExceptionDescription copied from interface:SampleBufferTypeSet the value of frameindex. The input value is assumed to contain one sample for each of the channels in the frame.- Specified by:
frameSetExactin interfaceSampleBufferType- Parameters:
index- The frame indexvalue- The input- Throws:
java.lang.IllegalArgumentException- Ifvalue.length != channels()
-
channels
public int channels()
- Specified by:
channelsin interfaceSampleBufferReadableType- Returns:
- The number of channels in a frame
-
frames
public long frames()
- Specified by:
framesin interfaceSampleBufferReadableType- Returns:
- The number of frames in the buffer
-
sampleRate
public double sampleRate()
- Specified by:
sampleRatein interfaceSampleBufferReadableType- Returns:
- The sample rate in hz
-
frameGetExact
public void frameGetExact(long index, double[] output) throws java.lang.IllegalArgumentExceptionDescription copied from interface:SampleBufferReadableTypeGet the value of frameindex.- Specified by:
frameGetExactin interfaceSampleBufferReadableType- Parameters:
index- The frame indexoutput- The output- Throws:
java.lang.IllegalArgumentException- Ifoutput.length != channels()
-
frameGetExact
public double frameGetExact(long index) throws com.io7m.jranges.RangeCheckExceptionDescription copied from interface:SampleBufferReadableTypeGet the value of frameindex.- Specified by:
frameGetExactin interfaceSampleBufferReadableType- Parameters:
index- The frame index- Returns:
- The value in the frame
- Throws:
com.io7m.jranges.RangeCheckException
-
-