public class

EmbeddedAudioSource

extends Object
java.lang.Object
   ↳ com.pspdfkit.annotations.sound.EmbeddedAudioSource

Class Overview

Represents a source of audio data that can be embedded inside a SoundAnnotation.

Summary

Constants
int DURATION_UNKNOWN Constant value returned from getDuration() to signal an error during retrieval of the actual audio clip duration.
Public Constructors
EmbeddedAudioSource(DataProvider audioDataProvider, AudioEncoding audioEncoding, int sampleRate, int sampleSize, int channels, String description)
Constructs an embedded audio source with data served from a DataProvider.
EmbeddedAudioSource(byte[] audioData, AudioEncoding audioEncoding, int sampleRate, int sampleSize, int channels, String description)
Constructs an embedded audio source with data served from memory.
Public Methods
AudioEncoding getAudioEncoding()
Audio samples encoding.
int getChannels()
The number of audio channels.
DataProvider getDataProvider()
Returns data provider with audio data in ENCODING_PCM_16BIT format.
String getDescription()
Returns audio data description.
long getDuration()
Audio duration in millisecond.
int getSampleRate()
The sampling rate, in samples per second.
int getSampleSize()
The number of bits per sample value per channel.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DURATION_UNKNOWN

Constant value returned from getDuration() to signal an error during retrieval of the actual audio clip duration.

Constant Value: -1 (0xffffffff)

Public Constructors

public EmbeddedAudioSource (DataProvider audioDataProvider, AudioEncoding audioEncoding, int sampleRate, int sampleSize, int channels, String description)

Constructs an embedded audio source with data served from a DataProvider.

Parameters
audioDataProvider Provider for audio data that should be saved in the document. Expects audio data stored in Big-endian with interleaved channels.
sampleRate Sample rate of the audio data in Hz.
channels Number of channels in the audio data.
description The optional description of the audio data. If set, this will be set as Contents on the created sound annotation (setContents(String)).

public EmbeddedAudioSource (byte[] audioData, AudioEncoding audioEncoding, int sampleRate, int sampleSize, int channels, String description)

Constructs an embedded audio source with data served from memory.

Parameters
audioData Audio data that should be saved in the document. Expects audio data stored in Big-endian with interleaved channels.
sampleRate Sample rate of the audio data in Hz.
channels Number of channels in the audio data.
description The optional description of the audio data. If set, this will be set as Contents on the created sound annotation (setContents(String)).

Public Methods

public AudioEncoding getAudioEncoding ()

Audio samples encoding.

Returns
  • Encoding used for audio data samples.

public int getChannels ()

The number of audio channels.

Returns
  • Number of audio channels.

public DataProvider getDataProvider ()

Returns data provider with audio data in ENCODING_PCM_16BIT format.

This will always return non-null even if sound source was created from in-memory data - wrapping the in-memory audio data in MemoryDataProvider.

Returns

public String getDescription ()

Returns audio data description.

Returns
  • Audio data description or null if not set.

public long getDuration ()

Audio duration in millisecond.

Returns
  • Audio clip duration in milliseconds, or DURATION_UNKNOWN if duration is unknown.

public int getSampleRate ()

The sampling rate, in samples per second.

Returns
  • Sampling rate of the audio data.

public int getSampleSize ()

The number of bits per sample value per channel.

Returns
  • Number of bits per sample value in the audio data.