the output range type
the MIDI object that is encoded into output
the output range object
import mididi.def : MetaEventType, SystemMessageType, TrackFormat; const(ubyte)[] result; auto sink = DelegateSink((scope const bytes) { result ~= bytes; }); auto midi = MIDI( HeaderChunk(TrackFormat.single, 1, TimeDivision.fromFormat0(1000)), [ TrackChunk([ TrackEvent( 0xFF, MIDIEvent(cast(ubyte) SystemMessageType.songSelect, [123, 0]), ), TrackEvent( 0x0F, MetaEvent(MetaEventType.endOfTrack, []), ), ]), ] ); sink.writeMIDI(midi); assert(result == cast(const(ubyte)[]) [ 'M', 'T', 'h', 'd', 0, 0, 0, 6, 0, 0, 0, 1, 0x03, 0xE8, 'M', 'T', 'r', 'k', 0, 0, 0, 8, 0x81, 0x7F, cast(ubyte) SystemMessageType.songSelect, 123, 0x0F, 0xFF, cast(ubyte) MetaEventType.endOfTrack, 0x00, ]);
writeMIDI encodes a MIDI data object (mididi.types.MIDI) to binary data.
The template parameter T must be an output range type defining the put(ubyte) method. In addition, it can define the putMultiple(scope const ubyte[]) method if there is a more efficient method to put several bytes at once. (This info applies to all write* functions in this module.)