Class EmbeddedAudioSource
-
- All Implemented Interfaces:
public class EmbeddedAudioSource
Represents a source of audio data that can be embedded inside a SoundAnnotation.
-
-
Field Summary
Fields Modifier and Type Field Description public final static int
DURATION_UNKNOWN
public final DataProvider
dataProvider
public final AudioEncoding
audioEncoding
public final int
sampleRate
public final int
sampleSize
public final int
channels
-
Constructor Summary
Constructors Constructor Description 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(Array<byte> audioData, AudioEncoding audioEncoding, int sampleRate, int sampleSize, int channels, String description)
Constructs an embedded audio source with data served from memory.
-
Method Summary
Modifier and Type Method Description DataProvider
getDataProvider()
Returns data provider with audio data in ENCODING_PCM_16BIT format. AudioEncoding
getAudioEncoding()
Audio samples encoding. int
getSampleRate()
The sampling rate, in samples per second. int
getSampleSize()
The number of bits per sample value per channel. int
getChannels()
The number of audio channels. String
getDescription()
Returns audio data description. long
getDuration()
Audio duration in millisecond. -
-
Constructor Detail
-
EmbeddedAudioSource
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.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.
-
EmbeddedAudioSource
EmbeddedAudioSource(Array<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.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.
-
-
Method Detail
-
getDataProvider
@NonNull() 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:
An instance of DataProvider which serves the audio data.
-
getAudioEncoding
@NonNull() AudioEncoding getAudioEncoding()
Audio samples encoding.
- Returns:
Encoding used for audio data samples.
-
getSampleRate
int getSampleRate()
The sampling rate, in samples per second.
- Returns:
Sampling rate of the audio data.
-
getSampleSize
int getSampleSize()
The number of bits per sample value per channel.
- Returns:
Number of bits per sample value in the audio data.
-
getChannels
int getChannels()
The number of audio channels.
- Returns:
Number of audio channels.
-
getDescription
@Nullable() String getDescription()
Returns audio data description.
- Returns:
Audio data description or
null
if not set.
-
getDuration
long getDuration()
Audio duration in millisecond.
- Returns:
Audio clip duration in milliseconds, or DURATION_UNKNOWN if duration is unknown.
-
-
-
-