-
Notifications
You must be signed in to change notification settings - Fork 202
/
Copy pathBeatTickLookup.ts
52 lines (43 loc) · 1.4 KB
/
BeatTickLookup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Beat } from '@src/model/Beat';
import { MasterBarTickLookup } from '@src/midi/MasterBarTickLookup';
/**
* Represents the time period, for which a {@link Beat} is played.
*/
export class BeatTickLookup {
private _highlightedBeats: Map<number, boolean> = new Map();
/**
* Gets or sets the index of the lookup within the parent MasterBarTickLookup.
*/
public index: number = 0;
/**
* Gets or sets the parent MasterBarTickLookup to which this beat lookup belongs to.
*/
public masterBar!: MasterBarTickLookup;
/**
* Gets or sets the start time in midi ticks at which the given beat is played.
*/
public start: number = 0;
/**
* Gets or sets the end time in midi ticks at which the given beat is played.
*/
public end: number = 0;
/**
* Gets or sets the beat which is played.
*/
public beat!: Beat;
/**
* Gets or sets whether the beat is the placeholder beat for an empty bar.
*/
public isEmptyBar: boolean = false;
/**
* Gets or sets a list of all beats that should be highlighted when
* the beat of this lookup starts playing.
*/
public beatsToHighlight: Beat[] = [];
public highlightBeat(beat: Beat): void {
if (!this._highlightedBeats.has(beat.id)) {
this._highlightedBeats.set(beat.id, true);
this.beatsToHighlight.push(beat);
}
}
}