MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / writeTo

Method writeTo

packages/alphatab/src/midi/MidiFile.ts:152–168  ·  view source on GitHub ↗

* Writes the midi file as binary into the given stream. * @returns The stream to write to.

(s: IWriteable)

Source from the content-addressed store, hash-verified

150 * @returns The stream to write to.
151 */
152 public writeTo(s: IWriteable): void {
153 // magic number "MThd" (0x4D546864)
154 const b: Uint8Array = new Uint8Array([0x4d, 0x54, 0x68, 0x64]);
155 s.write(b, 0, b.length);
156 // Header Length 6 (0x00000006)
157 IOHelper.writeInt32BE(s, 6);
158 // format (single multi channel track)
159 IOHelper.writeInt16BE(s, this.format as number);
160 // number of tracks (1)
161 IOHelper.writeInt16BE(s, this.tracks.length);
162 // division
163 IOHelper.writeInt16BE(s, this.division);
164
165 for (const track of this.tracks) {
166 track.writeTo(s);
167 }
168 }
169
170 public static writeVariableInt(s: IWriteable, value: number): void {
171 const array: Uint8Array = new Uint8Array(4);

Callers 2

toBinaryMethod · 0.95
writeToMethod · 0.45

Calls 3

writeInt32BEMethod · 0.80
writeInt16BEMethod · 0.80
writeMethod · 0.65

Tested by

no test coverage detected