Package com.jogamp.opengl.util.av
Class AudioSink.AudioFormat
java.lang.Object
com.jogamp.opengl.util.av.AudioSink.AudioFormat
- Enclosing interface:
- AudioSink
Specifies the linear audio PCM format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal int
Number of channels.final boolean
Fixed or floating point values.final boolean
final boolean
Planar or packed samples.final int
Sample rate in Hz (1/s).final int
Sample size in bits.final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionAudioFormat
(int sampleRate, int sampleSize, int channelCount, boolean signed, boolean fixedP, boolean planar, boolean littleEndian) -
Method Summary
Modifier and TypeMethodDescriptionfinal int
getBytesDuration
(int byteCount) Returns the duration in milliseconds of the given byte count according tosampleSize
,channelCount
andsampleRate
.final int
getBytesSampleCount
(int byteCount) Returns the sample count of given byte count according to thesampleSize
, i.e.:final int
getDurationsByteSize
(int millisecs) Returns the byte size of the given milliseconds according tosampleSize
,channelCount
andsampleRate
.final int
getFrameCount
(int millisecs, float frameDuration) Returns the rounded frame count of the given milliseconds and frame duration.final int
getSamplesByteCount
(int sampleCount) Returns the byte size of given sample count according to thesampleSize
, i.e.:final float
getSamplesDuration
(int sampleCount) Returns the duration in milliseconds of the given sample count per frame and channel according to thesampleRate
, i.e.toString()
-
Field Details
-
sampleRate
public final int sampleRateSample rate in Hz (1/s). -
sampleSize
public final int sampleSizeSample size in bits. -
channelCount
public final int channelCountNumber of channels. -
signed
public final boolean signed -
fixedP
public final boolean fixedPFixed or floating point values. Floating point 'float' hassampleSize
32, 'double' hassampleSize
64. -
planar
public final boolean planarPlanar or packed samples. If planar, each channel has their own data buffer. If packed, channel data is interleaved in one buffer. -
littleEndian
public final boolean littleEndian
-
-
Constructor Details
-
AudioFormat
public AudioFormat(int sampleRate, int sampleSize, int channelCount, boolean signed, boolean fixedP, boolean planar, boolean littleEndian) - Parameters:
sampleRate
- sample rate in Hz (1/s)sampleSize
- sample size in bitschannelCount
- number of channelssigned
- true if signed number, false for unsignedfixedP
- true for fixed point value, false for unsigned floating point value with a sampleSize of 32 (float) or 64 (double)planar
- true for planar data package (each channel in own data buffer), false for packed data channels interleaved in one buffer.littleEndian
- true for little-endian, false for big endian
-
-
Method Details
-
getDurationsByteSize
public final int getDurationsByteSize(int millisecs) Returns the byte size of the given milliseconds according tosampleSize
,channelCount
andsampleRate
.Time -> Byte Count
-
getBytesDuration
public final int getBytesDuration(int byteCount) Returns the duration in milliseconds of the given byte count according tosampleSize
,channelCount
andsampleRate
.Byte Count -> Time
-
getSamplesDuration
public final float getSamplesDuration(int sampleCount) Returns the duration in milliseconds of the given sample count per frame and channel according to thesampleRate
, i.e.( 1000f * sampleCount ) / sampleRate
Sample Count -> Time
- Parameters:
sampleCount
- sample count per frame and channel
-
getFrameCount
public final int getFrameCount(int millisecs, float frameDuration) Returns the rounded frame count of the given milliseconds and frame duration.Math.max( 1, millisecs / frameDuration + 0.5f )
Note:
frameDuration
can be derived by sample count per frame and channel viagetSamplesDuration(int)
.Frame Time -> Frame Count
- Parameters:
millisecs
- time in millisecondsframeDuration
- duration per frame in milliseconds.
-
getSamplesByteCount
public final int getSamplesByteCount(int sampleCount) Returns the byte size of given sample count according to thesampleSize
, i.e.:sampleCount * ( sampleSize / 8 )
Note: To retrieve the byte size for all channels, you need to pre-multiply
sampleCount
withchannelCount
.Sample Count -> Byte Count
- Parameters:
sampleCount
- sample count
-
getBytesSampleCount
public final int getBytesSampleCount(int byteCount) Returns the sample count of given byte count according to thesampleSize
, i.e.:( byteCount * 8 ) / sampleSize
Note: If
byteCount
covers all channels and you request the sample size per channel, you need to divide the result bysampleCount
bychannelCount
.Byte Count -> Sample Count
- Parameters:
byteCount
- number of bytes
-
toString
-