Class OpusSound

java.lang.Object
io.github.kosmx.emotes.common.opus.OpusSound

public class OpusSound extends Object
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).
  • Field Details

  • Constructor Details

  • Method Details

    • read

      public static OpusSound read(Path file) throws IOException
      Throws:
      IOException
    • read

      public static OpusSound read(InputStream input) throws IOException
      Reads without closing the stream, for sounds that come from somewhere other than a file.
      Throws:
      IOException
    • write

      public void write(Path file) throws IOException
      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()