Package 

Class Avatar

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public final class Avatar
     implements AutoCloseable
                        

    High-level Essence avatar facade.

    Owns a single fixture + a single runtime. For multi-conversation scenarios (one shared fixture, N independent histories), use Fixture and Runtime directly.

    Typical use:

    Avatar.load("/sdcard/Android/data/.../files/sample-avatar.imx").use { a ->
        a.composeAsBitmaps(pcm).forEach { bmp -> imageView.setImageBitmap(bmp) }
    }

    Not thread-safe: confine calls (and the Sequence iteration) to one thread.

    • Method Detail

      • getSampleRate

         final Integer getSampleRate()

        PCM input sample rate the runtime expects (always 16000 Hz).

      • composeFromFile

         final Sequence<ComposedFrame> composeFromFile(String audioPath)

        Decodes audioPath (WAV or anything MediaExtractor understands — MP3, M4A, OGG, FLAC) to 16 kHz mono PCM and streams composed frames.

        Uses platform MediaExtractor + MediaCodec. Channel-mix and resample are handled by the codec via output-format reconfiguration where supported; otherwise we resample with a naive linear pass — fine for voice but not music.

      • recordMp4

        @JvmOverloads() final Unit recordMp4(String audioPath, String outputPath, Integer targetWidth, Integer targetHeight, Avatar.EncoderQuality quality)

        One-shot session record: decode the audio file, drive the compose loop, encode H.264 + AAC, mux into an MP4 — all inside libessence.

        Replaces the per-binding decodeToMono16k + manual frame loop orchestration. Encoder dispatch is automatic: h264_mediacodec on Android (hardware), libx264 as fallback.

        Parameters:
        audioPath - any libavformat-supported audio source.
        outputPath - destination .mp4 path.
        targetWidth - target canvas width (0 = native fixture frame size).
        targetHeight - target canvas height (0 = native).
        quality - encoder preset.
      • recordMp4

        @JvmOverloads() final Unit recordMp4(String audioPath, String outputPath, Integer targetWidth, Integer targetHeight)

        One-shot session record: decode the audio file, drive the compose loop, encode H.264 + AAC, mux into an MP4 — all inside libessence.

        Replaces the per-binding decodeToMono16k + manual frame loop orchestration. Encoder dispatch is automatic: h264_mediacodec on Android (hardware), libx264 as fallback.

        Parameters:
        audioPath - any libavformat-supported audio source.
        outputPath - destination .mp4 path.
        targetWidth - target canvas width (0 = native fixture frame size).
        targetHeight - target canvas height (0 = native).
      • recordMp4

        @JvmOverloads() final Unit recordMp4(String audioPath, String outputPath, Integer targetWidth)

        One-shot session record: decode the audio file, drive the compose loop, encode H.264 + AAC, mux into an MP4 — all inside libessence.

        Replaces the per-binding decodeToMono16k + manual frame loop orchestration. Encoder dispatch is automatic: h264_mediacodec on Android (hardware), libx264 as fallback.

        Parameters:
        audioPath - any libavformat-supported audio source.
        outputPath - destination .mp4 path.
        targetWidth - target canvas width (0 = native fixture frame size).
      • recordMp4

        @JvmOverloads() final Unit recordMp4(String audioPath, String outputPath)

        One-shot session record: decode the audio file, drive the compose loop, encode H.264 + AAC, mux into an MP4 — all inside libessence.

        Replaces the per-binding decodeToMono16k + manual frame loop orchestration. Encoder dispatch is automatic: h264_mediacodec on Android (hardware), libx264 as fallback.

        Parameters:
        audioPath - any libavformat-supported audio source.
        outputPath - destination .mp4 path.