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

Function lookupTest

packages/alphatab/test/audio/MidiTickLookup.test.ts:666–747  ·  view source on GitHub ↗
(
        tex: string,
        ticks: number[],
        trackIndexes: number[],
        durations: number[],
        currentBeatIds: number[],
        nextBeatIds: number[],
        expectedCursorModes: MidiTickLookupFindBeatResultCursorMode[] | null = null,
        skipClean: boolean = false,
        prepareLookup: ((lookup: MidiTickLookup) => void) | null = null
    )

Source from the content-addressed store, hash-verified

664 });
665
666 function lookupTest(
667 tex: string,
668 ticks: number[],
669 trackIndexes: number[],
670 durations: number[],
671 currentBeatIds: number[],
672 nextBeatIds: number[],
673 expectedCursorModes: MidiTickLookupFindBeatResultCursorMode[] | null = null,
674 skipClean: boolean = false,
675 prepareLookup: ((lookup: MidiTickLookup) => void) | null = null
676 ) {
677 const buffer = ByteBuffer.fromString(tex);
678 const settings = new Settings();
679 Beat.resetIds();
680 const score = ScoreLoader.loadScoreFromBytes(buffer.getBuffer(), settings);
681 const lookup = buildLookup(score, settings);
682
683 const tracks = new Set<number>(trackIndexes);
684
685 if (
686 (trackIndexes.length === 1 &&
687 score.stylesheet.perTrackMultiBarRest &&
688 score.stylesheet.perTrackMultiBarRest!.has(trackIndexes[0])) ||
689 score.stylesheet.multiTrackMultiBarRest
690 ) {
691 lookup.multiBarRestInfo = ModelUtils.buildMultiBarRestInfo(
692 score.tracks.filter(t => tracks.has(t.index)),
693 0,
694 score.masterBars.length - 1
695 );
696 }
697
698 if (prepareLookup) {
699 prepareLookup(lookup);
700 }
701
702 let currentLookup: MidiTickLookupFindBeatResult | null = null;
703
704 const actualIncrementalIds: number[] = [];
705 const actualIncrementalNextIds: number[] = [];
706 const actualIncrementalTickDurations: number[] = [];
707
708 const actualCleanIds: number[] = [];
709 const actualCleanNextIds: number[] = [];
710 const actualCleanTickDurations: number[] = [];
711 const actualCursorModes: MidiTickLookupFindBeatResultCursorMode[] = [];
712
713 for (let i = 0; i < ticks.length; i++) {
714 currentLookup = lookup.findBeat(tracks, ticks[i], currentLookup);
715
716 Logger.info('Test', `Checking index ${i} with tick ${ticks[i]}`);
717 expect(currentLookup).toBeTruthy();
718 actualIncrementalIds.push(idOfBeat(currentLookup!.beat));
719 actualIncrementalNextIds.push(idOfBeat(currentLookup!.nextBeat?.beat ?? null));
720 actualIncrementalTickDurations.push(currentLookup!.tickDuration);
721 actualCursorModes.push(currentLookup!.cursorMode);
722
723 if (!skipClean) {

Callers 2

nextBeatSearchTestFunction · 0.85

Calls 15

hasMethod · 0.95
buildLookupFunction · 0.85
idOfBeatFunction · 0.85
fromStringMethod · 0.80
loadScoreFromBytesMethod · 0.80
getBufferMethod · 0.80
buildMultiBarRestInfoMethod · 0.80
filterMethod · 0.80
infoMethod · 0.65
resetIdsMethod · 0.45
hasMethod · 0.45
findBeatMethod · 0.45

Tested by

no test coverage detected