SoundFontInfoLib
2.21.6
Library for parsing and rendering SF2 files
|
Represents a tagged chunk of a file. More...
#include <Chunk.hpp>
Inherited by SF2::IO::ChunkList.
Public Member Functions | |
Chunk (Tag tag, uint32_t size, Pos pos) | |
Constructor. More... | |
Tag | tag () const |
Obtain the Tag type for the chunk. More... | |
size_t | size () const |
Obtain the size of the chunk data. More... | |
Pos | begin () const |
Obtain the location of the first byte of the chunk data. More... | |
Pos | end () const |
Obtain the location right after the last byte of chunk data. More... | |
Pos | advance () const |
Obtain the file position of the next chunk in the file after this one. More... | |
std::string | extract () const |
Treat the chunk data as a string of ASCII characters with a max length of 256 characters. More... | |
std::shared_ptr< int16_t > | extractSamples () const |
Read samples into a new buffer. More... | |
Represents a tagged chunk of a file.
A chunk starts with a 4-byte value that is taken as 4 ASCII characters. The 4-byte value uniquely identifies the type of data held in the chunk. The next entry in the chunk layout is an unsigned 4-byte value indicating the number of bytes in the chunk. The chunk records the position of its data in the file. It does not hold any internal data apart from the chunk tag and size.
Constructor.
tag | the chunk's Tag type |
size | the number of bytes held by the chunk |
pos | the file position where the contents of the chunk is to be found |
|
inline |
Obtain the file position of the next chunk in the file after this one.
References SF2::IO::Pos::advance().
|
inline |
Obtain the location of the first byte of the chunk data.
Referenced by extract(), and extractSamples().
|
inline |
Obtain the location right after the last byte of chunk data.
References SF2::IO::Pos::advance().
|
inline |
Treat the chunk data as a string of ASCII characters with a max length of 256 characters.
The result is sanitized: leading/trailing spaces are removed, non-ASCII characters are converted to '_' (the SF2 spec is pre-Unicode).
References begin(), SF2::IO::Pos::readInto(), size(), and SF2::IO::trim_property().
|
inline |
Read samples into a new buffer.
References begin(), SF2::IO::Pos::readInto(), and size().
|
inline |
|
inline |
Obtain the Tag type for the chunk.