summaryrefslogtreecommitdiff
path: root/Settings/Distribution.go
diff options
context:
space:
mode:
authorPhysick <96335032+DegustatorPonos@users.noreply.github.com>2025-12-13 12:32:15 +0500
committerPhysick <96335032+DegustatorPonos@users.noreply.github.com>2025-12-13 12:32:15 +0500
commitae11ed555cb350ea4c11fc1625f4a56229969ddd (patch)
tree1d02b84131b713a2eed9a332ffac51997b0ec285 /Settings/Distribution.go
parent4b8ef84059e772ef7636c451356680ec5b0983c4 (diff)
Tracks meta
Diffstat (limited to 'Settings/Distribution.go')
-rw-r--r--Settings/Distribution.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/Settings/Distribution.go b/Settings/Distribution.go
new file mode 100644
index 0000000..fc8ae13
--- /dev/null
+++ b/Settings/Distribution.go
@@ -0,0 +1,28 @@
+package settings
+
+import "math/rand"
+
+type distributionOptions struct {
+ // The chance of a value to be defaulted by zero
+ RandomisationChance float64
+ // The song start point will be between [0; len(song) * MaxPointPercent]
+ MaxPointPercent float64
+ // All the values less than this param will be defaulted to zero
+
+ StartSnapPercent float64
+}
+
+func (base distributionOptions) GetDistributedInt(dur int) int {
+ if rand.Float64() < base.RandomisationChance {
+ return 0
+ }
+ var random = rand.Float64() * base.MaxPointPercent
+ if random >= 1 {
+ panic("Random is greater than 1")
+ }
+ var randomDur = int(random * float64(dur))
+ if randomDur <= int(base.StartSnapPercent * float64(dur)) {
+ return 0
+ }
+ return randomDur
+}