Menu

Class FlipnoteParserBase

Base Flipnote parser class

This doesn't implement any parsing functionality itself, it just provides a consistent API for every format parser to implement.

Hierarchy

Index

Constructors

constructor

Properties

[Symbol.toStringTag]

[Symbol.toStringTag]: string = "Flipnote"

Custom object tag

aspect

aspect: number

Animation frame aspect ratio (height / width), reflects FlipnoteParserBase.aspect

audioClipRatio

audioClipRatio: number

Get the amount of clipping in the master audio track, useful for determining if a Flipnote's audio is corrupted. Closer to 1.0 = more clipping. Only available after getAudioMasterPcm has been called

audioTracks

audioTracks: FlipnoteAudioTrack[]

Which audio tracks are available in this format, reflects FlipnoteParserBase.audioTracks

bgmSpeed

bgmSpeed: number

In-app animation playback speed when the BGM track was recorded

bgmrate

bgmrate: number

Animation framerate when the BGM track was recorded, measured as frames per second

buffer

buffer: ArrayBuffer

data

data: DataView

duration

duration: number

Animation duration, in seconds

format

File format type, reflects FlipnoteParserBase.format

frameCount

frameCount: number

Animation frame count

frameSpeed

frameSpeed: number

In-app animation playback speed

framerate

framerate: number

Animation framerate, measured as frames per second

globalPalette

globalPalette: FlipnotePaletteColor[]

Global animation frame color palette, reflects FlipnoteParserBase.globalPalette

imageHeight

imageHeight: number

Animation frame height, reflects FlipnoteParserBase.height

imageOffsetX

imageOffsetX: number

X offset for the top-left corner of the animation frame

imageOffsetY

imageOffsetY: number

Y offset for the top-left corner of the animation frame

imageWidth

imageWidth: number

Animation frame width, reflects FlipnoteParserBase.width

isComment

isComment: boolean = false

(KWZ only) Indicates whether or not this file is a handwritten comment from Flipnote Gallery World

isDsiLibraryNote

isDsiLibraryNote: boolean = false

(KWZ only) Indicates whether or not this Flipnote is a PPM to KWZ conversion from Flipnote Studio 3D's DSi Library service

isFolderIcon

isFolderIcon: boolean = false

(KWZ only) Indicates whether or not this file is a Flipnote Studio 3D folder icon

isSpinoff

isSpinoff: boolean

Spinoffs are remixes of another user's Flipnote

meta

File metadata, see FlipnoteMeta for structure

numLayerColors

numLayerColors: number

Number of colors per layer (aside from transparent), reflects FlipnoteParserBase.numLayerColors

numLayers

numLayers: number

Number of animation frame layers, reflects FlipnoteParserBase.numLayers

palette

Flipnote palette

pointer

pointer: number

publicKey

publicKey: string

key used for Flipnote verification, in PEM format

rawSampleRate

rawSampleRate: number

Audio track base sample rate, reflects FlipnoteParserBase.rawSampleRate

sampleRate

sampleRate: number

Audio output sample rate, reflects FlipnoteParserBase.sampleRate

soundEffectTracks

soundEffectTracks: FlipnoteSoundEffectTrack[]

Which sound effect tracks are available in this format, reflects FlipnoteParserBase.soundEffectTracks

soundMeta

soundMeta: Map<FlipnoteAudioTrack, FlipnoteAudioTrackInfo> = new Map()

File audio track info, see FlipnoteAudioTrackInfo

thumbFrameIndex

thumbFrameIndex: number

Index of the animation frame used as the Flipnote's thumbnail image

Static aspect

aspect: number

Animation frame aspect ratio (height / width)

Static audioTracks

audioTracks: FlipnoteAudioTrack[]

Which audio tracks are available in this format

Static format

File format type

Static globalPalette

globalPalette: FlipnotePaletteColor[]

Global animation frame color palette

Static height

height: number

Animation frame height

Static numLayerColors

numLayerColors: number

Number of colors per layer (aside from transparent)

Static numLayers

numLayers: number

Number of animation frame layers

Static publicKey

publicKey: string

key used for Flipnote verification, in PEM format

Static rawSampleRate

rawSampleRate: number

Audio track base sample rate

Static sampleRate

sampleRate: number

Audio output sample rate

Static soundEffectTracks

soundEffectTracks: FlipnoteSoundEffectTrack[]

Which sound effect tracks are available in this format

Static width

width: number

Animation frame width

Accessors

byteLength

  • get byteLength(): number

bytes

  • get bytes(): Uint8Array

Audio Methods

Abstract decodeAudioTrack

Abstract decodeSoundFlags

  • decodeSoundFlags(): boolean[][]

Abstract getAudioMasterPcm

  • getAudioMasterPcm(sampleRate?: number): Int16Array
  • Get the full mixed audio for the Flipnote, using the specified samplerate

    Parameters

    • Optional sampleRate: number

    Returns Int16Array

    Signed 16-bit PCM audio

Abstract getAudioTrackPcm

Abstract getAudioTrackRaw

Abstract getFrameSoundEffectFlags

Abstract getSoundEffectFlags

getSoundEffectFlagsForTrack

hasAudioTrack

isSoundEffectUsedOnFrame

Image Methods

Abstract decodeFrame

  • decodeFrame(frameIndex: number): Uint8Array[]

Abstract getFrameCameraFlags

  • getFrameCameraFlags(frameIndex: number): boolean[]
  • Get the camera flags for a given frame, if there are any

    Parameters

    • frameIndex: number

    Returns boolean[]

    Array of booleans, indicating whether each layer uses a photo or not

Abstract getFrameLayerDepths

  • getFrameLayerDepths(frameIndex: number): number[]

Abstract getFrameLayerOrder

  • getFrameLayerOrder(frameIndex: number): number[]

Abstract getFramePalette

Abstract getFramePaletteIndices

  • getFramePaletteIndices(frameIndex: number): number[]

getFramePaletteUint32

  • getFramePaletteUint32(frameIndex: number, paletteBuffer?: Uint32Array): Uint32Array
  • Get the color palette for a given frame, as an uint32 array

    Parameters

    • frameIndex: number
    • Default value paletteBuffer: Uint32Array = new Uint32Array(16)

    Returns Uint32Array

getFramePixels

  • getFramePixels(frameIndex: number, imageBuffer?: Uint8Array, depthStrength?: number, depthEye?: FlipnoteStereoscopicEye): Uint8Array
  • Get the image for a given frame, as palette indices

    Parameters

    • frameIndex: number
    • Default value imageBuffer: Uint8Array = new Uint8Array(this.imageWidth * this.imageHeight)
    • Default value depthStrength: number = 0
    • Default value depthEye: FlipnoteStereoscopicEye = FlipnoteStereoscopicEye.Left

    Returns Uint8Array

getFramePixelsRgba

  • getFramePixelsRgba(frameIndex: number, imageBuffer?: Uint32Array, paletteBuffer?: Uint32Array, depthStrength?: number, depthEye?: FlipnoteStereoscopicEye): Uint32Array
  • Get the image for a given frame as an uint32 array of RGBA pixels

    Parameters

    • frameIndex: number
    • Default value imageBuffer: Uint32Array = new Uint32Array(this.imageWidth * this.imageHeight)
    • Default value paletteBuffer: Uint32Array = new Uint32Array(16)
    • Default value depthStrength: number = 0
    • Default value depthEye: FlipnoteStereoscopicEye = FlipnoteStereoscopicEye.Left

    Returns Uint32Array

Abstract getIsKeyFrame

  • getIsKeyFrame(frameIndex: number): boolean[]
  • Determines if a given frame is a video key frame or not. This returns an array of booleans for each layer, since keyframe encoding is done on a per-layer basis.

    Parameters

    • frameIndex: number

    Returns boolean[]

getLayerPixels

  • getLayerPixels(frameIndex: number, layerIndex: number, imageBuffer?: Uint8Array, depthStrength?: number, depthEye?: FlipnoteStereoscopicEye): Uint8Array
  • Get the pixels for a given frame layer, as palette indices NOTE: layerIndex are not guaranteed to be sorted by 3D depth in KWZs, use getFrameLayerOrder to get the correct sort order first NOTE: if the visibility flag for this layer is turned off, the result will be empty

    Parameters

    • frameIndex: number
    • layerIndex: number
    • Default value imageBuffer: Uint8Array = new Uint8Array(this.imageWidth * this.imageHeight)
    • Default value depthStrength: number = 0
    • Default value depthEye: FlipnoteStereoscopicEye = FlipnoteStereoscopicEye.Left

    Returns Uint8Array

getLayerPixelsRgba

  • getLayerPixelsRgba(frameIndex: number, layerIndex: number, imageBuffer?: Uint32Array, paletteBuffer?: Uint32Array, depthStrength?: number, depthEye?: FlipnoteStereoscopicEye): Uint32Array
  • Get the pixels for a given frame layer, as RGBA pixels NOTE: layerIndex are not guaranteed to be sorted by 3D depth in KWZs, use getFrameLayerOrder to get the correct sort order first NOTE: if the visibility flag for this layer is turned off, the result will be empty

    Parameters

    • frameIndex: number
    • layerIndex: number
    • Default value imageBuffer: Uint32Array = new Uint32Array(this.imageWidth * this.imageHeight)
    • Default value paletteBuffer: Uint32Array = new Uint32Array(16)
    • Default value depthStrength: number = 0
    • Default value depthEye: FlipnoteStereoscopicEye = FlipnoteStereoscopicEye.Left

    Returns Uint32Array

Meta Methods

Abstract getFrameAuthor

  • getFrameAuthor(frameIndex: number): string

Abstract getThumbnailImage

Other Methods

readBytes

  • readBytes(count: number): Uint8Array

readChars

  • readChars(count: number): string

readHex

  • readHex(count: number, reverse?: boolean): string
  • Parameters

    • count: number
    • Default value reverse: boolean = false

    Returns string

readInt16

  • readInt16(littleEndian?: boolean): number
  • Parameters

    • Default value littleEndian: boolean = true

    Returns number

readInt32

  • readInt32(littleEndian?: boolean): number
  • Parameters

    • Default value littleEndian: boolean = true

    Returns number

readInt8

  • readInt8(): number

readUint16

  • readUint16(littleEndian?: boolean): number
  • Parameters

    • Default value littleEndian: boolean = true

    Returns number

readUint32

  • readUint32(littleEndian?: boolean): number
  • Parameters

    • Default value littleEndian: boolean = true

    Returns number

readUint8

  • readUint8(): number

readWideChars

  • readWideChars(count: number): string

seek

  • seek(offset: number, whence?: SeekOrigin): void
  • Parameters

    • offset: number
    • Optional whence: SeekOrigin

    Returns void

writeBytes

  • writeBytes(bytes: number[] | Uint8Array): void

writeChars

  • writeChars(string: string): void

writeInt16

  • writeInt16(value: number, littleEndian?: boolean): void
  • Parameters

    • value: number
    • Default value littleEndian: boolean = true

    Returns void

writeInt32

  • writeInt32(value: number, littleEndian?: boolean): void
  • Parameters

    • value: number
    • Default value littleEndian: boolean = true

    Returns void

writeInt8

  • writeInt8(value: number): void

writeUint16

  • writeUint16(value: number, littleEndian?: boolean): void
  • Parameters

    • value: number
    • Default value littleEndian: boolean = true

    Returns void

writeUint32

  • writeUint32(value: number, littleEndian?: boolean): void
  • Parameters

    • value: number
    • Default value littleEndian: boolean = true

    Returns void

writeUint8

  • writeUint8(value: number): void

Utility Methods

[Symbol.iterator]

  • [Symbol.iterator](): Generator<number, void, unknown>
  • Allows for frame index iteration when using the parser instance as a for..of iterator

    for (const frameIndex of note) {
      // do something with frameIndex...
    }
    

    Returns Generator<number, void, unknown>

getTitle

  • getTitle(formats?: { COMMENT: string; FLIPNOTE: string; ICON: string }): string
  • Get file default title - e.g. "Flipnote by Y", "Comment by X", etc. A format object can be passed for localization, where $USERNAME gets replaced by author name:

    {
     COMMENT: 'Comment by $USERNAME',
     FLIPNOTE: 'Flipnote by $USERNAME',
     ICON: 'Folder icon'
    }
    

    Parameters

    • Default value formats: { COMMENT: string; FLIPNOTE: string; ICON: string } = this.titleFormats
      • COMMENT: string
      • FLIPNOTE: string
      • ICON: string

    Returns string

toString

  • toString(): string
  • Returns the Flipnote title when casting a parser instance to a string

    const str = 'Title: ' + note;
    // str === 'Title: Flipnote by username'
    

    Returns string

Verification Methods

Abstract getBody

  • getBody(): Uint8Array

Abstract getSignature

  • getSignature(): Uint8Array

Abstract verify

  • verify(): Promise<boolean>

Object literals

layerVisibility

layerVisibility: object

Animation frame global layer visibility

1

1: true = true

2

2: true = true

3

3: true = true

titleFormats

titleFormats: object

Default formats used for {@link getTitle()}

COMMENT

COMMENT: string = "Comment by $USERNAME"

FLIPNOTE

FLIPNOTE: string = "Flipnote by $USERNAME"

ICON

ICON: string = "Folder icon"