class Yuno::VgmFile

Overview

A virtual representation of a VGM file.

Defined in:

yunosynth/vgmfile.cr

Constant Summary

VGM_MAGIC = "Vgm "

The magic four bytes at the start of a VGM file.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.fromIO(io : IO) : VgmFile #

Loads a VGM file from io, returning a new VgmFile instance. The data in IO may be compressed. The IO must be able to seek.


[View source]
def self.load(path : Path | String) : VgmFile #

Loads a VGM file from path, returning a new VgmFile instance. If the VGM is compressed using a supported compression scheme, it will first be decompressed into RAM.


[View source]
def self.new(io : IO) #

Creates a new VgmFile instance by reading data from io. The data in io cannot be compressed. If you need to read possibly compressed data from an ::IO, then use VgmFile.fromIO instead. The IO must be able to seek.


[View source]

Class Method Detail

def self.pcmSampleToVgmSample(sampleNum : Int64, sampleRateDiv : Int64, sampleRateMul : Int64) : UInt32 #

Converts a playback sample index number into a VGM sample index number. That is, this converts a PCM sample position into a VGM sample position.


[View source]
def self.validVgmFile?(io : IO) : Bool #

Reads the first four bytes from io to check for the magic bytes that indicate a VGM file. If they're found, this returns true, otherwise it returns false. The IO must be seekable.


[View source]
def self.validVgmFile?(path : Path | String) : Bool #

Reads the first four bytes from the given file to check for the magic bytes that indicate a VGM file. If they're found, this returns true, otherwise it returns false.


[View source]
def self.vgmSampleToPcmSample(sampleNum : Int64, sampleRateDiv : Int64, sampleRateMul : Int64) : UInt32 #

Converts a VGM sample index number into a playback sample index number. That is, this converts a VGM sample position into a PCM sample position.


[View source]

Instance Method Detail

def chipsUsed : Hash(ChipType, Int32) #

Returns the list of all chips that are used in this VGM. The keys of the Hash that is returned are the types of chips, while the values dictate whether the chip is solo (1) or paired (2).

Note that VgmPlayer#chipNamesUsed and VgmPlayer#chipsUsed is the preferred way to get a list of chips that are used since these return more information, such as the number of each chip. This can still be used as a quick way to get a list of ChipTypes, however.


[View source]
def chipUsed?(chip : ChipType) : Bool #

Returns true if chip is used at least once in this VGM, or false otherwise.


[View source]
def data : Bytes #

Returns the data (that is, the stream of instructions and data bytes) associated with this VGM.


[View source]
def extraHeader : ExtraHeader | Nil #

The extra header, if any, in this VGM file.


[View source]
def gd3Tag : Gd3Tag #

Returns the GD3 tag associated with this VGM.


[View source]
def getAlternateChipClock(chipNum : Int32, chipType : ChipType) : UInt32 | Nil #

Checks to see if a chip has an alternate clock value within the extra header. This can only happen if an extra header exists within the VGM. If a value is found, this returns the new clock value, otherwise it returns nil.

An alternate header clock value is always for the second (or higher) chip, never for the first chip.


[View source]
def getChipClock(chip : ChipType) : UInt32 #

Returns the current clock rate for a given ChipType.


[View source]
def getChipVolume(chip : AbstractChip, chipType : ChipType, chipCount : Int32, paired : ChipType | Nil = nil) : UInt16 #

Retrieves a volume for chip given a chipType and the number of chips of chipType. If paired is nonNil, then the volume is retrieved for chip's internal paired chip of type paired.


[View source]
def hasLoopInfo? : Bool #

Returns true if this VGM file contains loop information, or false otherwise.


[View source]
def header : Header #

Returns the header associated with this VGM.


[View source]
def unsupportedChips : Array(ChipType) #

Returns the list of all chips that are used in this VGM that are currently not supported by YunoSynth as far as playback is concerned.


[View source]
def validateChips : Bool #

Returns true if all chips used by this VGM file are supported by YunoSynth as far as playback is concerned, or false otherwise.


[View source]