Skip to content

bindings.format

Melchor Garau Madrigal edited this page Apr 2, 2019 · 6 revisions

Contains all the functions and objects for FLAC/format interface. Don't think this documentation is a full replacement of the FLAC's one. Only tells all available functions, and the relation to the FLAC API, with a short description.

Read carefully this Wiki page because contains all the mappings between the C structs and Javascript objects.

Mappings C <=> Javascript

This structs has different forms depending on its type. Each type will be mapped to a JS class, whose base is always Metadata. Will contain the same attributes for its type:

They will contain these three attributes:

  • Number type: Indicates the type as a Number
  • Boolean isLast: Indicates if this block is the last
  • Number length: Indicates the length in bytes of the data block

And this methods:

clone(): Metadata

FLAC__metadata_clone()

Tryies to clone the metadata object into a new one.

isEqual(other: Metadata): boolean

FLAC__metadata_is_equal()

Returns true if both metadata objects are equals.

Metadata objects have associated the C counterpart inside the this object (V8 thing). You cannot access to the raw pointer directly, but rather you have access to each field which will then access (or modify) the C struct directly. The object will always be updated.

NOTE: Any operation of add or delete an item to all attributes that returns an Array won't affect the internal data. You must call their special methods for alter them.

  • Number minBlocksize
  • Number maxBlocksize
  • Number minFramesize
  • Number maxFramesize
  • Number channels
  • Number bitsPerSample
  • Number sampleRate
  • Number totalSamples
  • Array md5sum buffer of 16 bytes, modify the buffer, modifies the underlying struct

Has nothing inside it. It's only a padding block :)

  • Buffer id contains the 4 byte in the buffer. Any modifications on this will affect the real one. If you change the buffer, you will lost the access to the array.
  • Buffer data contains the data, its length is determined by the length attribute in the StreamMetadata object. You can also change the buffer, in this case the ...set_data function will be called for you
  • Number | BigInt sampleNumber
  • Number | BigInt streamOffset
  • Number frameSamples
  • Array points an array of FLAC__StreamMetadata_SeekPoints. Adding or deleting elements on this array won't affect the C struct, but modifying the items inside will affect the internal data. Use the bindings.metadata functions to modify them. Modifications in the elements inside will, instead, modify the C struct.

resizePoints(newSize: number): boolean

FLAC__metadata_seektable_resize_points()

Changes the size of the seek points to the new one.

setPoint(pos: number, point: SeekTablePoint): boolean

FLAC__metadata_seektable_set_point()

insertPoint(pos: number, point: SeekTablePoint): boolean

FLAC__metadata_seektable_insert_point()

deletePoint(pos: number): boolean

FLAC__metadata_seektable_delete_point()

Deletes a point in the position pos.

isLegal(): boolean

FLAC__metadata_seektable_is_legal()

Checks wether the Seek Table is valid or not.

templateAppendPlaceholders(num: number): boolean

FLAC__metadata_seektable_template_append_placeholders()

Appends a number of placeholders points into the Seek Table.

templateAppendPoint(samplePoint: number | bigint): boolean

FLAC__metadata_seektable_template_append_point()

Append a specific seek point to the end of the table.

templateAppendPoints(samplePoints: Array<number | bigint>): boolean

FLAC__metadata_seektable_template_append_points()

Append some seek points to the end of the table.

templateAppendSpacedPoints(num: number, totalSamples: number | bigint): boolean

FLAC__metadata_seektable_template_append_spaced_points()

Append a set of evenly-spaced seek point templates to the end of a seek table.

templateAppendSpacedPointsBySamples(num: number, totalSamples: number | bigint): boolean

FLAC__metadata_seektable_template_append_spaced_points_by_samples()

Append a set of evenly-spaced seek point templates to the end of a seek table.

templateSort(compact?: boolean)

FLAC__metadata_seektable_template_sort()

Sort a seek table's seek points according to the format specification, removing duplicates. After all calls of seektable_template_* methods, you must call this one to make the table valid.

This is really a String. But is special. Has a format that follows this specification, but without the framing bit. Modify this String won't affect the C version of it. Never will do.

  • String vendorString this really is a VorbisComment_Entry?
  • Array comments an array of VorbisComment_Entry, so an array of Strings. All changes to the items or the array must be done using the bindings.metadata. Changes to the array or its items will not affect the internal data.

See VorbisComment functions.

  • Number offset if the node version has no support for bigint, then values will be truncated to 48 bit
  • Number number only can store values from 0 to 255
  • Number offset if the node version has no support for bigint, then values will be truncated to 48 bit
  • Number number only can store values from 0 to 255
  • Number type only can store 0 or 1
  • Number preEmphasis only can store 0 or 1
  • String isrc always 12 alpha-numeric characters
  • Array indices an array of FLAC__StreamMetadata_CueSheet_Index. Adding or deleting elements on this array won't affect the internal data. Use the bindings.metadata functions to modify them. Modifications in inside items will, instead, modify the internal data.

See CueSheet functions.

  • String mediaCatalogNumber a string from 0 to 128 bytes (not chars)
  • Number leadIn if the node version has no support for bigint, then values will be truncated to 48 bit
  • Boolean is_cd
  • Array tracks an array of FLAC__StreamMetadata_CueSheet_Track. Adding or deleting elements on this array won't affect the internal data, but will modify the elements inside if are modified. Use the bindings.metadata functions to modify them. Modifications in inside items will, instead, modify the internal data.

See CueSheet functions.

See Picture functions.

  • Buffer data length is determined in the StreamMetadata block. You are free to modify its contents, but you cannot change the pointer.

Functions

Boolean sample_rate_is_valid(Number samplerate)

FLAC__format_sample_rate_is_valid()

Boolean blocksize_is_subset(Number blocksize, Number samplerate)

FLAC__format_blocksize_is_subset()

Boolean sample_rate_is_subset(Number samplerate)

FLAC__format_sample_rate_is_subset()

Boolean vorbiscomment_entry_name_is_legal(String name)

FLAC__format_vorbiscomment_entry_name_is_legal()

Boolean vorbiscomment_entry_value_is_legal(String value)

FLAC__format_vorbiscomment_entry_value_is_legal()

Only pass the value, the bindings will get the length for you.

Boolean vorbiscomment_entry_is_legal(String entry)

FLAC__format_vorbiscomment_entry_is_legal()

Only pass the entry NAME=Value and it will get the length for you.

Boolean seektable_is_legal(Object seektable)

FLAC__format_seektable_is_legal()

The object seektable must be created using the Metadata API.

Object seektable_sort(Object seektable)

FLAC__format_seektable_sort()

The object seektable must be created using the Metadata API. Returns the object reordered.

Boolean or String cuesheet_is_legal(Object cuesheet, Boolean check)

FLAC__format_cuesheet_is_legal()

The object cuesheet must be created using the Metadata API. Returns true if its OK, or returns a String with an error message.

Boolean or String picture_is_legal(Object picture)

FLAC__format_picture_is_legal()

The object picutre must be created using the Metadata API. Returns true if its OK, or returns a String with an error message.

Enums

get Number MetadataType[]

FLAC__MetadataType

{
    STREAMINFO: 0, PADDING: 1, APPLICATION: 2, SEEKTABLE: 3,
    VORBIS_COMMENT: 4, CUESHEET: 5, PICTURE: 6, UNDEFINED: 7
}

get Number EntropyCodingMethodType[]

FLAC__EntropyCodingMethodType

{
    PARTITIONED_RICE: 0, PARTITIONED_RICE2: 1
}

get Number SubframeType[]

FLAC__SubframeType

{
    CONSTANT: 0, VERBATIM: 1, FIXED: 2, LPC: 3
}

get Number ChannelAssignment[]

FLAC__ChannelAssignment

{
    INDEPENDENT: 0, LEFT_SIDE: 1, RIGHT_SIDE: 2, MID_SIDE: 3
}

get Number StreamMetadata_Picture_Type[]

FLAC__StreamMetadata_Picture_Type

{
    OTHER: 0,
    FILE_ICON_STANDARD: 1,
    FILE_ICON: 2,
    FRONT_COVER: 3,
    BACK_COVER: 4,
    LEAFLET_PAGE: 5,
    MEDIA: 6,
    LEAD_ARTIST: 7,
    ARTIST: 8,
    CONDUCTOR: 9,
    BAND: 10,
    COMPOSER: 11,
    LYRICIST: 12,
    RECORDING_LOCATION: 13,
    DURING_RECORDING: 14,
    DURING_PERFORMANCE: 15,
    VIDEO_SCREEN_CAPTURE: 16,
    FISH: 17,
    ILLUSTRATION: 18,
    BAND_LOGOTYPE: 19,
    PUBLISHER_LOGOTYPE: 20,
    UNDEFINED: ?,
}

get Number FrameNumberType[]

FLAC__FrameNuberType

{
    FRAME_NUMBER: 0, SAMPLE_NUMBER: 1
}

get String MetadataTypeString[]

FLAC__MetadataTypeString

get String EntropyCodingMethodTypeString[]

FLAC__EntropyCodingMethodTypeString

get String SubframeTypeString[]

FLAC__SubframeTypeString

get String ChannelAssignmentString[]

FLAC__ChannelAssignmentString

get String FrameNumberTypeString[]

FLAC__FrameNumberTypeString

get String StreamMetadata_Picture_TypeString[]

FLAC__StreamMetadata_Picture_TypeString

Clone this wiki locally