UNPKG

vgm-conv

Version:
53 lines (52 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VGMClockConverter = exports.VGMConverter = void 0; class VGMConverter { from; to; _sink = null; constructor(from, to) { this.from = from; this.to = to; } getInitialCommands() { return []; } getLoopCommands() { return []; } get convertedChipInfo() { const clock = this.to.relativeClock ? this.from.clock * this.to.clock : this.to.clock; return { chip: this.to.chip, index: this.to.index, clock }; } pipeTo(target) { this._sink = target; } convert(cmd) { const tmp = this.convertCommand(cmd); if (this._sink) { let res = new Array(); for (const cmd of tmp) { res = res.concat(this._sink.convert(cmd)); } return res; } return tmp; } } exports.VGMConverter = VGMConverter; class VGMClockConverter extends VGMConverter { _defaultClock; constructor(from, toClock, defaultClock) { super(from, { ...from, clock: toClock || defaultClock }); this._defaultClock = defaultClock; } get defaultClock() { return this._defaultClock; } } exports.VGMClockConverter = VGMClockConverter;