HCA Audio Codec

class PyCriCodecsEx.hca.HCA(stream: str | BinaryIO, key: int = 0, subkey: int = 0)[source]

Bases: object

HCA class for decoding and encoding HCA files

NOTE: Direct usage of this class is not recommended, use the HCACodec wrapper instead.

__init__(stream: str | BinaryIO, key: int = 0, subkey: int = 0) None[source]

Initializes the HCA encoder/decoder

Parameters:
  • stream (str | BinaryIO) – Path to the HCA or WAV file, or a BinaryIO stream.

  • key (int, optional) – HCA key. Defaults to 0.

  • subkey (int, optional) – HCA subkey. Defaults to 0.

decode() bytes[source]

Decodes the HCA or WAV file to WAV bytes.

encode(force_not_looping: bool = False, encrypt: bool = False, keyless: bool = False, quality_level: CriHcaQuality = CriHcaQuality.High) bytes[source]

Encodes the WAV file to HCA bytes.

get_frames()[source]

Generator function to yield Frame number, and Frame data.

get_hca() bytes[source]

Get the HCA file bytes after encrypting or decrypting.

get_header() bytes[source]

Get the HCA Header.

info() dict[source]

Returns info related to the input file.

class PyCriCodecsEx.hca.HCACodec(stream: str | bytes, filename: str = 'default.hca', quality: CriHcaQuality = CriHcaQuality.High, key=0, subkey=0, **kwargs)[source]

Bases: HCA

Use this class for encoding and decoding HCA files, from and to WAV.

__init__(stream: str | bytes, filename: str = 'default.hca', quality: CriHcaQuality = CriHcaQuality.High, key=0, subkey=0, **kwargs)[source]

Initializes the HCA encoder/decoder

Parameters:
  • stream (str | bytes) – Path to the HCA or WAV file, or a BinaryIO stream. WAV files will be automatically encoded with the given settings first.

  • filename (str, optional) – USM filename. Defaults to “default.hca”.

  • quality (CriHcaQuality, optional) – Encoding quality. Defaults to CriHcaQuality.High.

  • key (int, optional) – HCA key. Defaults to 0.

  • subkey (int, optional) – HCA subkey. Defaults to 0.

get_encoded() bytes[source]

Gets the encoded HCA audio data.

save(filepath: str | BinaryIO)[source]

Saves the decoded WAV audio to filepath or a writable stream