Initial project sync
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
class_name TimeAnchorFrequencyProfile
|
||||
extends Resource
|
||||
|
||||
@export var streak_thresholds: Array[int] = [0, 8, 16]
|
||||
@export var anchors_per_window: Array[int] = [1, 2, 4]
|
||||
@export var window_beats := 4
|
||||
|
||||
|
||||
func interval_for_streak(streak: int) -> int:
|
||||
var anchors := anchors_per_window_for_streak(streak)
|
||||
return maxi(1, int(ceil(float(window_beats) / float(maxi(1, anchors)))))
|
||||
|
||||
|
||||
func anchors_per_window_for_streak(streak: int) -> int:
|
||||
var count := 1
|
||||
for index: int in range(streak_thresholds.size()):
|
||||
if index >= anchors_per_window.size():
|
||||
break
|
||||
if streak >= streak_thresholds[index]:
|
||||
count = clampi(anchors_per_window[index], 1, maxi(1, window_beats))
|
||||
return count
|
||||
|
||||
|
||||
func anchor_offsets_for_streak(streak: int) -> Array[int]:
|
||||
var safe_window := maxi(1, window_beats)
|
||||
var count := anchors_per_window_for_streak(streak)
|
||||
if count <= 1:
|
||||
return [safe_window]
|
||||
if count == 2:
|
||||
return [maxi(1, int(ceil(float(safe_window) * 0.5))), safe_window]
|
||||
var offsets: Array[int] = []
|
||||
for beat_offset: int in range(1, safe_window + 1):
|
||||
offsets.append(beat_offset)
|
||||
return offsets
|
||||
Reference in New Issue
Block a user