class Yuno::VgmFile
- Yuno::VgmFile
- Reference
- Object
Overview
A virtual representation of a VGM file.
Defined in:
yunosynth/vgmfile.crConstant Summary
-
VGM_MAGIC =
"Vgm " -
The magic four bytes at the start of a VGM file.
Constructors
-
.fromIO(io : IO) : VgmFile
Loads a VGM file from
io, returning a newVgmFileinstance. -
.load(path : Path | String) : VgmFile
Loads a VGM file from
path, returning a newVgmFileinstance. -
.new(io : IO)
Creates a new
VgmFileinstance by reading data fromio.
Class Method Summary
-
.pcmSampleToVgmSample(sampleNum : Int64, sampleRateDiv : Int64, sampleRateMul : Int64) : UInt32
Converts a playback sample index number into a VGM sample index number.
-
.validVgmFile?(io : IO) : Bool
Reads the first four bytes from
ioto check for the magic bytes that indicate a VGM file. -
.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.
-
.vgmSampleToPcmSample(sampleNum : Int64, sampleRateDiv : Int64, sampleRateMul : Int64) : UInt32
Converts a VGM sample index number into a playback sample index number.
Instance Method Summary
-
#chipsUsed : Hash(ChipType, Int32)
Returns the list of all chips that are used in this VGM.
-
#chipUsed?(chip : ChipType) : Bool
Returns
trueifchipis used at least once in this VGM, orfalseotherwise. -
#data : Bytes
Returns the data (that is, the stream of instructions and data bytes) associated with this VGM.
-
#extraHeader : ExtraHeader | Nil
The extra header, if any, in this VGM file.
-
#gd3Tag : Gd3Tag
Returns the GD3 tag associated with this VGM.
-
#getAlternateChipClock(chipNum : Int32, chipType : ChipType) : UInt32 | Nil
Checks to see if a chip has an alternate clock value within the extra header.
-
#getChipClock(chip : ChipType) : UInt32
Returns the current clock rate for a given
ChipType. -
#getChipVolume(chip : AbstractChip, chipType : ChipType, chipCount : Int32, paired : ChipType | Nil = nil) : UInt16
Retrieves a volume for
chipgiven achipTypeand the number of chips ofchipType. -
#hasLoopInfo? : Bool
Returns
trueif this VGM file contains loop information, orfalseotherwise. -
#header : Header
Returns the header associated with this VGM.
-
#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.
-
#validateChips : Bool
Returns
trueif all chips used by this VGM file are supported by YunoSynth as far as playback is concerned, orfalseotherwise.
Constructor Detail
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.
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.
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.
Class Method Detail
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.
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.
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.
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.
Instance Method Detail
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.
Returns true if chip is used at least once in this VGM, or false
otherwise.
Returns the data (that is, the stream of instructions and data bytes) associated with this VGM.
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.
Returns the current clock rate for a given ChipType.
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.
Returns true if this VGM file contains loop information, or false
otherwise.
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.
Returns true if all chips used by this VGM file are supported by
YunoSynth as far as playback is concerned, or false otherwise.