src/music.ts 703 B raw
1
export interface MusicParams {
2
	bucketB1: number;
3
	bucketB2: number;
4
	bucketB3: number;
5
	bucketB4: number;
6
	sepAccentThreshold: number;
7
	accentCooldownMs: number;
8
	accentRateCap: number;
9
	padDurMs: number;
10
	accentDurMs: number;
11
	flashMs: number;
12
}
13
14
export const DEFAULT_MUSIC_PARAMS: MusicParams = {
15
	bucketB1: 1,
16
	bucketB2: 3,
17
	bucketB3: 6,
18
	bucketB4: 12,
19
	sepAccentThreshold: 0.04,
20
	accentCooldownMs: 350,
21
	accentRateCap: 6,
22
	padDurMs: 600,
23
	accentDurMs: 90,
24
	flashMs: 320,
25
};
26
27
export function bucketOf(count: number, p: MusicParams): number {
28
	if (count >= p.bucketB4) return 4;
29
	if (count >= p.bucketB3) return 3;
30
	if (count >= p.bucketB2) return 2;
31
	if (count >= p.bucketB1) return 1;
32
	return 0;
33
}