Class OpusSound
java.lang.Object
io.github.kosmx.emotes.common.opus.OpusSound
A validated mono Opus stream: its packets, and the PCM they decode to once someone asks.
The packets live back to back in one array, indexed by
offset(int) and length(int).-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()decoded()decoded(BooleanSupplier cancelled) The cancellation predicate is also read on the decoder thread.intintendTrim()booleanfailed()intlength(int index) intfloatintoffset(int index) intintintplayable()intpreSkip()static OpusSoundread(InputStream input) Reads without closing the stream, for sounds that come from somewhere other than a file.static OpusSoundvoid
-
Field Details
-
NO_LOOP
public static final int NO_LOOP- See Also:
-
-
Constructor Details
-
OpusSound
public OpusSound(int preSkip, int endTrim, int outputGain, @Nullable @Nullable Integer trackGain, @Nullable @Nullable Integer loopStart, byte[] data, int[] offsets) throws OpusFormatException - Throws:
OpusFormatException
-
-
Method Details
-
read
- Throws:
IOException
-
read
Reads without closing the stream, for sounds that come from somewhere other than a file.- Throws:
IOException
-
write
- Throws:
IOException
-
preSkip
public int preSkip() -
outputGain
public int outputGain() -
endTrim
public int endTrim()- Returns:
- the padding at the end, in samples
-
loopStart
public int loopStart()- Returns:
- where a repeat starts, in samples, or
NO_LOOP
-
packetCount
public int packetCount() -
data
public byte[] data() -
offset
public int offset(int index) -
length
public int length(int index) -
durationMs
public int durationMs() -
playable
public int playable()- Returns:
- how many samples are left once both ends are trimmed
-
normalization
public float normalization()- Returns:
- what a decode measured the track at, or zero while its PCM is not in memory
-
decoded
- Returns:
- the PCM, decoded in the background if that has not happened yet or was reclaimed
-
decoded
The cancellation predicate is also read on the decoder thread. -
failed
public boolean failed()
-