GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
com.jogamp.common.av.AudioFormat Class Reference

Specifies the linear audio PCM format. More...

Collaboration diagram for com.jogamp.common.av.AudioFormat:

Public Member Functions

 AudioFormat (final int sampleRate, final int sampleSize, final int channelCount, final boolean signed, final boolean fixedP, final boolean planar, final boolean littleEndian)
 
final int getDurationsByteSize (final float duration)
 Returns the byte size of the given duration in seconds according to sampleSize, channelCount and sampleRate. More...
 
final float getBytesDuration (final int byteCount)
 Returns the duration in seconds of the given byte count according to sampleSize, channelCount and sampleRate. More...
 
final float getSamplesDuration (final int sampleCount)
 Returns the duration in seconds of the given sample count per frame and channel according to the sampleRate, i.e. More...
 
final int getFrameCount (final float duration, final float frameDuration)
 Returns the rounded frame count of the given duration and frame duration, both in seconds. More...
 
final int getSamplesByteCount (final int sampleCount)
 Returns the byte size of given sample count according to the sampleSize, i.e. More...
 
final int getBytesSampleCount (final int byteCount)
 Returns the sample count of given byte count according to the sampleSize, i.e. More...
 
String toString ()
 

Public Attributes

final int sampleRate
 Sample rate in Hz (1/s, e.g. More...
 
final int sampleSize
 Sample size in bits, e.g. More...
 
final int channelCount
 Number of channels, e.g. More...
 
final boolean signed
 Signed PCM values if true, otherwise unsigned values. More...
 
final boolean fixedP
 Fixed or floating point values. More...
 
final boolean planar
 Planar or packed samples. More...
 
final boolean littleEndian
 Little-endian byte order if true, otherwise big endian byte order. More...
 

Detailed Description

Specifies the linear audio PCM format.

Definition at line 33 of file AudioFormat.java.

Constructor & Destructor Documentation

◆ AudioFormat()

com.jogamp.common.av.AudioFormat.AudioFormat ( final int  sampleRate,
final int  sampleSize,
final int  channelCount,
final boolean signed  ,
final boolean  fixedP,
final boolean  planar,
final boolean  littleEndian 
)
Parameters
sampleRatesample rate in Hz (1/s), e.g. 44100 Hz
sampleSizesample size in bits, e.g. 16 bits
channelCountnumber of channels, e.g. 2 channels for stereo
signedtrue if signed PCM values, false for unsigned values
fixedPtrue for fixed point values, false for unsigned floating point values with a sampleSize of 32 (float) or 64 (double)
planartrue for planar data package (each channel in own data buffer), false for packed data channels interleaved in one buffer.
littleEndiantrue for little-endian byte order, false for big endian byte order

Definition at line 43 of file AudioFormat.java.

Member Function Documentation

◆ getBytesDuration()

final float com.jogamp.common.av.AudioFormat.getBytesDuration ( final int  byteCount)

Returns the duration in seconds of the given byte count according to sampleSize, channelCount and sampleRate.

 final float bytesPerSample = sampleSize/8;
 return byteCount / ( channelCount * bytesPerSample * sampleRate )

<p<blockquote>‍

Byte Count -> Time

Parameters
byteCountsize in bytes

Definition at line 110 of file AudioFormat.java.

◆ getBytesSampleCount()

final int com.jogamp.common.av.AudioFormat.getBytesSampleCount ( final int  byteCount)

Returns the sample count of given byte count according to the sampleSize, i.e.

:

 ( byteCount * 8 ) / sampleSize

<p<blockquote>‍

Note: If byteCount covers all channels and you request the sample size per channel, you need to divide the result by sampleCount by channelCount.

Byte Count -> Sample Count

Parameters
byteCountnumber of bytes

Definition at line 185 of file AudioFormat.java.

◆ getDurationsByteSize()

final int com.jogamp.common.av.AudioFormat.getDurationsByteSize ( final float  duration)

Returns the byte size of the given duration in seconds according to sampleSize, channelCount and sampleRate.

 final float bytesPerSample = sampleSize/8;
 return Math.round( duration * channelCount * bytesPerSample * sampleRate );

<p<blockquote>‍

Time -> Byte Count

Parameters
durationduration in seconds

Definition at line 93 of file AudioFormat.java.

◆ getFrameCount()

final int com.jogamp.common.av.AudioFormat.getFrameCount ( final float  duration,
final float  frameDuration 
)

Returns the rounded frame count of the given duration and frame duration, both in seconds.

    Math.max(1, Math.round( duration / frameDuration ))

<p<blockquote>‍

Note: frameDuration can be derived by sample count per frame and channel via getSamplesDuration(int) or by byte count via getBytesDuration(int).

Frame Time -> Frame Count

Parameters
durationduration in seconds
frameDurationduration per frame in seconds, i.e. 1/frame_rate
See also
getSamplesDuration(int)
getBytesDuration(int)

Definition at line 147 of file AudioFormat.java.

◆ getSamplesByteCount()

final int com.jogamp.common.av.AudioFormat.getSamplesByteCount ( final int  sampleCount)

Returns the byte size of given sample count according to the sampleSize, i.e.

:

 sampleCount * ( sampleSize / 8 )

<p<blockquote>‍

Note: To retrieve the byte size for all channels, you need to pre-multiply sampleCount with channelCount.

Sample Count -> Byte Count

Parameters
sampleCountsample count

Definition at line 166 of file AudioFormat.java.

◆ getSamplesDuration()

final float com.jogamp.common.av.AudioFormat.getSamplesDuration ( final int  sampleCount)

Returns the duration in seconds of the given sample count per frame and channel according to the sampleRate, i.e.

   (float)sampleCount / sampleRate

<p<blockquote>‍

Sample Count -> Time

Parameters
sampleCountsample count per frame and channel

Definition at line 126 of file AudioFormat.java.

◆ toString()

String com.jogamp.common.av.AudioFormat.toString ( )

Definition at line 190 of file AudioFormat.java.

Member Data Documentation

◆ channelCount

final int com.jogamp.common.av.AudioFormat.channelCount

Number of channels, e.g.

2 channels for stereo.

Definition at line 66 of file AudioFormat.java.

◆ fixedP

final boolean com.jogamp.common.av.AudioFormat.fixedP

Fixed or floating point values.

Floating point 'float' has sampleSize 32, 'double' has sampleSize 64.

Definition at line 70 of file AudioFormat.java.

◆ littleEndian

final boolean com.jogamp.common.av.AudioFormat.littleEndian

Little-endian byte order if true, otherwise big endian byte order.

Definition at line 74 of file AudioFormat.java.

◆ planar

final boolean com.jogamp.common.av.AudioFormat.planar

Planar or packed samples.

If planar, each channel has their own data buffer. If packed, channel data is interleaved in one buffer.

Definition at line 72 of file AudioFormat.java.

◆ sampleRate

final int com.jogamp.common.av.AudioFormat.sampleRate

Sample rate in Hz (1/s, e.g.

44100 Hz.

Definition at line 62 of file AudioFormat.java.

◆ sampleSize

final int com.jogamp.common.av.AudioFormat.sampleSize

Sample size in bits, e.g.

16 bits.

Definition at line 64 of file AudioFormat.java.

◆ signed

final boolean com.jogamp.common.av.AudioFormat.signed

Signed PCM values if true, otherwise unsigned values.

Definition at line 68 of file AudioFormat.java.


The documentation for this class was generated from the following file: