Package com.io7m.jsamplebuffer.vanilla
Class SampleBufferFloat
java.lang.Object
com.io7m.jsamplebuffer.vanilla.SampleBufferFloat
- All Implemented Interfaces:
SampleBufferReadableType
,SampleBufferType
A sample buffer using
float
elements.-
Method Summary
Modifier and TypeMethodDescriptionint
channels()
static SampleBufferType
createWithByteBuffer
(int channels, long frames, double sample_rate, LongFunction<ByteBuffer> create) Create a sample buffer.static SampleBufferType
createWithDirectBuffer
(int channels, long frames, double sample_rate) Create a sample buffer.static SampleBufferType
createWithHeapBuffer
(int channels, long frames, double sample_rate) Create a sample buffer.double
frameGetExact
(long index) Get the value of frameindex
.void
frameGetExact
(long index, double[] output) Get the value of frameindex
.long
frames()
void
frameSetAll
(long index, double value) Set the value of frameindex
.void
frameSetExact
(long index, double c0) Set the value of frameindex
.void
frameSetExact
(long index, double[] value) Set the value of frameindex
.void
frameSetExact
(long index, double c0, double c1) Set the value of frameindex
.double
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 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 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
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
Description copied from interface:SampleBufferType
Set 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:
frameSetAll
in interfaceSampleBufferType
- Parameters:
index
- The frame indexvalue
- The input- Throws:
IllegalArgumentException
-
frameSetExact
Description copied from interface:SampleBufferType
Set the value of frameindex
.- Specified by:
frameSetExact
in interfaceSampleBufferType
- Parameters:
index
- The frame indexc0
- The input for channel 0c1
- The input for channel 1- Throws:
IllegalArgumentException
- Ifchannels() != 2
-
frameSetExact
Description copied from interface:SampleBufferType
Set the value of frameindex
.- Specified by:
frameSetExact
in interfaceSampleBufferType
- Parameters:
index
- The frame indexc0
- The input for channel 0- Throws:
IllegalArgumentException
- Ifchannels() != 1
-
frameSetExact
Description copied from interface:SampleBufferType
Set the value of frameindex
. The input value is assumed to contain one sample for each of the channels in the frame.- Specified by:
frameSetExact
in interfaceSampleBufferType
- Parameters:
index
- The frame indexvalue
- The input- Throws:
IllegalArgumentException
- Ifvalue.length != channels()
-
channels
public int channels()- Specified by:
channels
in interfaceSampleBufferReadableType
- Returns:
- The number of channels in a frame
-
frames
public long frames()- Specified by:
frames
in interfaceSampleBufferReadableType
- Returns:
- The number of frames in the buffer
-
sampleRate
public double sampleRate()- Specified by:
sampleRate
in interfaceSampleBufferReadableType
- Returns:
- The sample rate in hz
-
frameGetExact
Description copied from interface:SampleBufferReadableType
Get the value of frameindex
.- Specified by:
frameGetExact
in interfaceSampleBufferReadableType
- Parameters:
index
- The frame indexoutput
- The output- Throws:
IllegalArgumentException
- Ifoutput.length != channels()
-
frameGetExact
public double frameGetExact(long index) throws com.io7m.jranges.RangeCheckException Description copied from interface:SampleBufferReadableType
Get the value of frameindex
.- Specified by:
frameGetExact
in interfaceSampleBufferReadableType
- Parameters:
index
- The frame index- Returns:
- The value in the frame
- Throws:
com.io7m.jranges.RangeCheckException
-