diff options
Diffstat (limited to 'src/java/com/jogamp/common/av/AudioSink.java')
-rw-r--r-- | src/java/com/jogamp/common/av/AudioSink.java | 150 |
1 files changed, 0 insertions, 150 deletions
diff --git a/src/java/com/jogamp/common/av/AudioSink.java b/src/java/com/jogamp/common/av/AudioSink.java index d41e05b..317b0ac 100644 --- a/src/java/com/jogamp/common/av/AudioSink.java +++ b/src/java/com/jogamp/common/av/AudioSink.java @@ -46,156 +46,6 @@ public interface AudioSink { /** Audio queue limit w/o video in milliseconds. {@value} ms, i.e. 32 frames per 32 ms. See {@link #init(AudioFormat, float, int, int, int)}.*/ public static final int DefaultQueueLimitAudioOnly = 32 * 32; // 1024 ms - /** - * Specifies the linear audio PCM format. - */ - public static class AudioFormat { - /** - * @param sampleRate sample rate in Hz (1/s) - * @param sampleSize sample size in bits - * @param channelCount number of channels - * @param signed true if signed number, false for unsigned - * @param fixedP true for fixed point value, false for unsigned floating point value with a sampleSize of 32 (float) or 64 (double) - * @param planar true for planar data package (each channel in own data buffer), false for packed data channels interleaved in one buffer. - * @param littleEndian true for little-endian, false for big endian - */ - public AudioFormat(final int sampleRate, final int sampleSize, final int channelCount, final boolean signed, final boolean fixedP, final boolean planar, final boolean littleEndian) { - this.sampleRate = sampleRate; - this.sampleSize = sampleSize; - this.channelCount = channelCount; - this.signed = signed; - this.fixedP = fixedP; - this.planar = planar; - this.littleEndian = littleEndian; - if( !fixedP ) { - if( sampleSize != 32 && sampleSize != 64 ) { - throw new IllegalArgumentException("Floating point: sampleSize "+sampleSize+" bits"); - } - if( !signed ) { - throw new IllegalArgumentException("Floating point: unsigned"); - } - } - } - - /** Sample rate in Hz (1/s). */ - public final int sampleRate; - /** Sample size in bits. */ - public final int sampleSize; - /** Number of channels. */ - public final int channelCount; - public final boolean signed; - /** Fixed or floating point values. Floating point 'float' has {@link #sampleSize} 32, 'double' has {@link #sampleSize} 64. */ - public final boolean fixedP; - /** Planar or packed samples. If planar, each channel has their own data buffer. If packed, channel data is interleaved in one buffer. */ - public final boolean planar; - public final boolean littleEndian; - - - // - // Time <-> Bytes - // - - /** - * Returns the byte size of the given milliseconds - * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. - * <p> - * Time -> Byte Count - * </p> - */ - public final int getDurationsByteSize(final int millisecs) { - final int bytesPerSample = sampleSize >>> 3; // /8 - return millisecs * ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); - } - - /** - * Returns the duration in milliseconds of the given byte count - * according to {@link #sampleSize}, {@link #channelCount} and {@link #sampleRate}. - * <p> - * Byte Count -> Time - * </p> - */ - public final int getBytesDuration(final int byteCount) { - final int bytesPerSample = sampleSize >>> 3; // /8 - return byteCount / ( channelCount * bytesPerSample * ( sampleRate / 1000 ) ); - } - - /** - * Returns the duration in milliseconds of the given sample count per frame and channel - * according to the {@link #sampleRate}, i.e. - * <pre> - * ( 1000f * sampleCount ) / sampleRate - * </pre> - * <p> - * Sample Count -> Time - * </p> - * @param sampleCount sample count per frame and channel - */ - public final float getSamplesDuration(final int sampleCount) { - return ( 1000f * sampleCount ) / sampleRate; - } - - /** - * Returns the rounded frame count of the given milliseconds and frame duration. - * <pre> - * Math.max( 1, millisecs / frameDuration + 0.5f ) - * </pre> - * <p> - * Note: <code>frameDuration</code> can be derived by <i>sample count per frame and channel</i> - * via {@link #getSamplesDuration(int)}. - * </p> - * <p> - * Frame Time -> Frame Count - * </p> - * @param millisecs time in milliseconds - * @param frameDuration duration per frame in milliseconds. - */ - public final int getFrameCount(final int millisecs, final float frameDuration) { - return Math.max(1, (int) ( millisecs / frameDuration + 0.5f )); - } - - /** - * Returns the byte size of given sample count - * according to the {@link #sampleSize}, i.e.: - * <pre> - * sampleCount * ( sampleSize / 8 ) - * </pre> - * <p> - * Note: To retrieve the byte size for all channels, - * you need to pre-multiply <code>sampleCount</code> with {@link #channelCount}. - * </p> - * <p> - * Sample Count -> Byte Count - * </p> - * @param sampleCount sample count - */ - public final int getSamplesByteCount(final int sampleCount) { - return sampleCount * ( sampleSize >>> 3 ); - } - - /** - * Returns the sample count of given byte count - * according to the {@link #sampleSize}, i.e.: - * <pre> - * ( byteCount * 8 ) / sampleSize - * </pre> - * <p> - * Note: If <code>byteCount</code> covers all channels and you request the sample size per channel, - * you need to divide the result by <code>sampleCount</code> by {@link #channelCount}. - * </p> - * <p> - * Byte Count -> Sample Count - * </p> - * @param byteCount number of bytes - */ - public final int getBytesSampleCount(final int byteCount) { - return ( byteCount << 3 ) / sampleSize; - } - - @Override - public String toString() { - return "AudioDataFormat[sampleRate "+sampleRate+", sampleSize "+sampleSize+", channelCount "+channelCount+ - ", signed "+signed+", fixedP "+fixedP+", "+(planar?"planar":"packed")+", "+(littleEndian?"little":"big")+"-endian]"; } - } /** Default {@link AudioFormat}, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, fixedP, !planar, littleEndian]. */ public static final AudioFormat DefaultFormat = new AudioFormat(44100, 16, 2, true /* signed */, true /* fixed point */, false /* planar */, true /* littleEndian */); |