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

Method extendMidi

packages/playground/src/apps/RecorderApp.ts:300–323  ·  view source on GitHub ↗
(midi: alphaTab.midi.MidiFile)

Source from the content-addressed store, hash-verified

298 }
299
300 private extendMidi(midi: alphaTab.midi.MidiFile): void {
301 let rest: alphaTab.midi.AlphaTabRestEvent | undefined;
302 const events = midi.tracks[0].events;
303 for (let i = events.length - 1; i >= 0; i--) {
304 const e = events[i];
305 if (e instanceof alphaTab.midi.AlphaTabRestEvent) {
306 rest = e;
307 break;
308 }
309 }
310 if (!rest) {
311 return;
312 }
313 const desiredMs = 60 * 30 * 1000; // 30 min
314 const tempo = this.api.tickCache!.masterBars[0].tempoChanges[0].tempo;
315 const desiredTicks = (desiredMs / (60000.0 / (tempo * MIDI_QUARTER_TIME))) | 0;
316 const endOfTrack = events.pop()! as alphaTab.midi.EndOfTrackEvent;
317 let tick = rest.tick + MIDI_QUARTER_TIME;
318 while (tick < desiredTicks) {
319 events.push(new alphaTab.midi.AlphaTabRestEvent(rest.track, tick, rest.channel));
320 tick += MIDI_QUARTER_TIME;
321 }
322 endOfTrack.tick = tick;
323 }
324
325 dispose(): void {
326 for (const u of this.subscriptions) {

Callers 1

constructorMethod · 0.95

Calls 2

popMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected