class Yuno::VgmDecompressor

Overview

Detects and decompresses VGM streams. This is designed so that external libraries can extend the functionality of this class without needing to reopen it.

Defined in:

yunosynth/vgmdecompressor.cr

Class Method Summary

Class Method Detail

def self.funcs #

The set of all FuncSets that can be used to check for compressed data, and decompress it.


def self.getHint(filename : String | Path) : Symbol | Nil #

Looks at the extension of filename and attempts to guess the compression method (if any). This will return a Symbol if it was able to guess, or nil otherwise.

The symbol return will reference one of the known compression methods in #funcs. This symbol can then be passed to #maybeDecompress.

This returns nil if it thinks that filename is an uncompressed VGM.


def self.isGz?(io : IO) : Bool #

Returns true if io contains GZipped data, or false otherwise. This requires io to support IO#pos=.


def self.maybeDecompress(io : IO, hint : Symbol | Nil = nil) : IO #

Checks to see if io needs to be decompressed. If it does, this decompresses the stream into RAM. This then returns an IO that can be used to read uncompressed data, which may be the original IO if it was not compressed. io must support IO#pos.

If hint is provided and is a known decompression scheme found in #funcs, then that scheme will be tried first to offer a speedup in load times. You can get a hint by using #getHint.


def self.registerFunctions(ident : Symbol, extensions : Array(String), checkFn : CheckerFn, decompFn : DecompFn) : Nil #

Registers a new method for checking for compressed data, and decompressing that data. ident can be used to reference the FuncSet from #funcs after registering. extension is a set of file extensions that can be used by #getHint for this compression scheme. The extension should include the period and should be entirely lowercase, e.g. ".vgz".

Note that ident cannot be :none.


def self.ungz(io : IO) : IO::Memory #

Decompresses io into an IO::Memory, then returns the new IO.