DeepSeekOracle commited on
Commit
98b074a
·
verified ·
1 Parent(s): 62a9905

Upload ldq_genre_manifold.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. ldq_genre_manifold.py +62 -0
ldq_genre_manifold.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ LDQ Genre Manifold Projection
4
+ Deterministic parameter warping for genre-specific sounds
5
+ """
6
+
7
+ from typing import Dict, Any
8
+
9
+ # Genre manifolds as parameter vectors
10
+ GENRE_MANIFOLDS = {
11
+ "Dubstep": {
12
+ "swing_amount": 0.25,
13
+ "half_time_factor": 0.5,
14
+ "spectral_centroid_target": 0.6,
15
+ "clap_density": 0.3,
16
+ "sub_bass_boost": 1.5,
17
+ },
18
+ "Phonk": {
19
+ "swing_amount": 0.33,
20
+ "half_time_factor": 1.0,
21
+ "spectral_centroid_target": 0.4,
22
+ "clap_density": 0.7,
23
+ "sub_bass_boost": 1.2,
24
+ },
25
+ "Industrial": {
26
+ "swing_amount": 0.15,
27
+ "half_time_factor": 0.75,
28
+ "spectral_centroid_target": 0.8,
29
+ "clap_density": 0.1,
30
+ "sub_bass_boost": 1.8,
31
+ },
32
+ }
33
+
34
+ def project_to_genre(features: Dict[str, Any], genre: str) -> Dict[str, float]:
35
+ """
36
+ Project image features onto a genre manifold.
37
+ Returns a dictionary of synthesis parameters.
38
+ """
39
+ if genre not in GENRE_MANIFOLDS:
40
+ return {}
41
+
42
+ base = GENRE_MANIFOLDS[genre].copy()
43
+
44
+ # Modulate parameters based on image features
45
+ edge_density = features.get("edge_density", 0.02)
46
+ chaos_index = features.get("chaos_keypoints", 0)
47
+ brightness = features.get("average_brightness", 0.5)
48
+
49
+ # Swing modifier: more edges = more swing
50
+ base["swing_amount"] = min(0.5, base["swing_amount"] + edge_density * 1.5)
51
+
52
+ # Half-time factor: dark images = more half-time
53
+ base["half_time_factor"] = max(0.3, base["half_time_factor"] - (1.0 - brightness) * 0.3)
54
+
55
+ # Spectral centroid: chaos pushes it higher
56
+ base["spectral_centroid_target"] = min(1.0, base["spectral_centroid_target"] + (chaos_index / 1000) * 0.3)
57
+
58
+ # Clap density: edge density controls it
59
+ base["clap_density"] = min(1.0, base["clap_density"] + edge_density * 2.0)
60
+
61
+ return base
62
+