Spaces:
Sleeping
Sleeping
v4: no double-kicks (5kHz split+sneak), xcorr beat align, pre-drop mix-in (structure.py)
Browse files- structure.py +13 -9
structure.py
CHANGED
|
@@ -207,17 +207,21 @@ def find_mix_points(analysis) -> dict:
|
|
| 207 |
intros = [s for s in segments if get(s, 'label') == 'intro']
|
| 208 |
outros = [s for s in segments if get(s, 'label') == 'outro']
|
| 209 |
|
| 210 |
-
# Mix-in:
|
| 211 |
-
#
|
| 212 |
-
# If no buildup, use 16 bars
|
| 213 |
-
if
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
| 217 |
bars_16 = 16 * 4 * 60.0 / max(analysis.bpm, 60)
|
| 218 |
-
mix_in_time = max(0,
|
| 219 |
else:
|
| 220 |
-
|
|
|
|
| 221 |
|
| 222 |
# First drop
|
| 223 |
if drops:
|
|
|
|
| 207 |
intros = [s for s in segments if get(s, 'label') == 'intro']
|
| 208 |
outros = [s for s in segments if get(s, 'label') == 'outro']
|
| 209 |
|
| 210 |
+
# Mix-in: where the audience first hears this track.
|
| 211 |
+
# Prefer: buildup BEFORE the first drop (the energy ramp into the drop).
|
| 212 |
+
# If no buildup before the drop, use the last 16 bars of the intro.
|
| 213 |
+
first_drop_time = get(drops[0], 'start') if drops else duration * 0.3
|
| 214 |
+
|
| 215 |
+
pre_drop_buildups = [s for s in buildups if get(s, 'start') < first_drop_time]
|
| 216 |
+
if pre_drop_buildups:
|
| 217 |
+
mix_in_time = get(pre_drop_buildups[-1], 'start')
|
| 218 |
+
elif intros:
|
| 219 |
+
# No buildup detected — use intro, 16 bars before the drop
|
| 220 |
bars_16 = 16 * 4 * 60.0 / max(analysis.bpm, 60)
|
| 221 |
+
mix_in_time = max(0, first_drop_time - bars_16)
|
| 222 |
else:
|
| 223 |
+
bars_16 = 16 * 4 * 60.0 / max(analysis.bpm, 60)
|
| 224 |
+
mix_in_time = max(0, first_drop_time - bars_16)
|
| 225 |
|
| 226 |
# First drop
|
| 227 |
if drops:
|