writeHeaderChunk

void
writeHeaderChunk
(
T
)
(
ref T output
,
ref const HeaderChunk chunk
)
if (
isOutputRange!(T, ubyte)
)

Examples

This test demonstrates header chunk writing.

import mididi.def : TrackFormat;

auto chunk = HeaderChunk(
    TrackFormat.sequential,
    ushort.max,
    TimeDivision.fromFormat1(-25, 64),
);
auto result = "";
auto range = DelegateSink((scope const bytes) {
    result ~= bytes;
});
range.writeHeaderChunk(chunk);
assert(result == [
    'M', 'T', 'h', 'd', // chunk: header
    0, 0, 0, 6, // length: 6
    0, 2, // format: 2
    0xFF, 0xFF, // nTracks: ushort.max
    0b1_1100111, 64, // division: format 1; -25; 64
]);

Meta