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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Mastering Preset System
|
| 3 |
+
Contains professional presets for different genres and use cases
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from dataclasses import dataclass, asdict
|
| 7 |
+
from typing import List, Dict, Optional
|
| 8 |
+
import json
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@dataclass
|
| 13 |
+
class EQBand:
|
| 14 |
+
"""Single EQ band parameters"""
|
| 15 |
+
frequency: float # Hz
|
| 16 |
+
gain: float # dB
|
| 17 |
+
q: float # Q factor (bandwidth)
|
| 18 |
+
type: str = 'peak' # peak, lowshelf, highshelf, lowpass, highpass
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@dataclass
|
| 22 |
+
class MasteringPreset:
|
| 23 |
+
"""
|
| 24 |
+
Complete mastering preset with all parameters
|
| 25 |
+
"""
|
| 26 |
+
# Metadata
|
| 27 |
+
name: str
|
| 28 |
+
category: str
|
| 29 |
+
description: str
|
| 30 |
+
author: str = "System"
|
| 31 |
+
tags: List[str] = None
|
| 32 |
+
|
| 33 |
+
# Target loudness
|
| 34 |
+
target_lufs: float = -9.0
|
| 35 |
+
|
| 36 |
+
# EQ
|
| 37 |
+
eq_bands: List[EQBand] = None
|
| 38 |
+
|
| 39 |
+
# Compression
|
| 40 |
+
comp_threshold_db: float = -12.0
|
| 41 |
+
comp_ratio: float = 3.0
|
| 42 |
+
comp_attack_ms: float = 10.0
|
| 43 |
+
comp_release_ms: float = 100.0
|
| 44 |
+
comp_knee_db: float = 3.0
|
| 45 |
+
|
| 46 |
+
# Multiband Compression (3 bands)
|
| 47 |
+
mb_low_threshold: float = -15.0
|
| 48 |
+
mb_low_ratio: float = 2.5
|
| 49 |
+
mb_mid_threshold: float = -12.0
|
| 50 |
+
mb_mid_ratio: float = 3.0
|
| 51 |
+
mb_high_threshold: float = -10.0
|
| 52 |
+
mb_high_ratio: float = 2.0
|
| 53 |
+
|
| 54 |
+
# Stereo Imaging
|
| 55 |
+
stereo_width: float = 1.0 # 0.5-1.5
|
| 56 |
+
stereo_bass_mono_below_hz: float = 120.0
|
| 57 |
+
|
| 58 |
+
# Saturation/Warmth
|
| 59 |
+
saturation_amount: float = 0.0 # 0-1
|
| 60 |
+
saturation_type: str = "tape" # tape, tube, transistor
|
| 61 |
+
|
| 62 |
+
# Exciter (harmonic enhancement)
|
| 63 |
+
exciter_amount: float = 0.0 # 0-1
|
| 64 |
+
exciter_frequency: float = 3000.0 # Hz
|
| 65 |
+
|
| 66 |
+
# Limiter
|
| 67 |
+
limiter_threshold_db: float = -1.0
|
| 68 |
+
limiter_ceiling_db: float = -0.3
|
| 69 |
+
limiter_release_ms: float = 50.0
|
| 70 |
+
|
| 71 |
+
def __post_init__(self):
|
| 72 |
+
if self.tags is None:
|
| 73 |
+
self.tags = []
|
| 74 |
+
if self.eq_bands is None:
|
| 75 |
+
self.eq_bands = []
|
| 76 |
+
|
| 77 |
+
def to_dict(self) -> Dict:
|
| 78 |
+
"""Convert to dictionary"""
|
| 79 |
+
d = asdict(self)
|
| 80 |
+
# Convert EQBand objects to dicts
|
| 81 |
+
d['eq_bands'] = [asdict(band) for band in self.eq_bands]
|
| 82 |
+
return d
|
| 83 |
+
|
| 84 |
+
@classmethod
|
| 85 |
+
def from_dict(cls, data: Dict):
|
| 86 |
+
"""Create from dictionary"""
|
| 87 |
+
# Convert eq_bands back to EQBand objects
|
| 88 |
+
if 'eq_bands' in data and data['eq_bands']:
|
| 89 |
+
data['eq_bands'] = [EQBand(**band) for band in data['eq_bands']]
|
| 90 |
+
return cls(**data)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
class PresetLibrary:
|
| 94 |
+
"""
|
| 95 |
+
Library of mastering presets
|
| 96 |
+
"""
|
| 97 |
+
|
| 98 |
+
def __init__(self):
|
| 99 |
+
self.presets: Dict[str, MasteringPreset] = {}
|
| 100 |
+
self._load_default_presets()
|
| 101 |
+
|
| 102 |
+
def _load_default_presets(self):
|
| 103 |
+
"""Load built-in presets"""
|
| 104 |
+
|
| 105 |
+
# ==================== EDM PRESETS ====================
|
| 106 |
+
|
| 107 |
+
self.presets['edm_club_master'] = MasteringPreset(
|
| 108 |
+
name="EDM Club Master",
|
| 109 |
+
category="edm",
|
| 110 |
+
description="Loud, punchy, wide. Perfect for club and festival tracks.",
|
| 111 |
+
tags=['edm', 'loud', 'club', 'festival', 'wide'],
|
| 112 |
+
target_lufs=-8.0,
|
| 113 |
+
eq_bands=[
|
| 114 |
+
EQBand(frequency=30, gain=0, q=0.7, type='highpass'),
|
| 115 |
+
EQBand(frequency=60, gain=1.5, q=0.7),
|
| 116 |
+
EQBand(frequency=200, gain=-1.0, q=1.0),
|
| 117 |
+
EQBand(frequency=3000, gain=1.0, q=1.2),
|
| 118 |
+
EQBand(frequency=10000, gain=2.0, q=0.7),
|
| 119 |
+
],
|
| 120 |
+
comp_threshold_db=-12,
|
| 121 |
+
comp_ratio=3.0,
|
| 122 |
+
comp_attack_ms=10,
|
| 123 |
+
comp_release_ms=100,
|
| 124 |
+
mb_low_threshold=-15,
|
| 125 |
+
mb_low_ratio=2.5,
|
| 126 |
+
mb_mid_threshold=-12,
|
| 127 |
+
mb_mid_ratio=3.0,
|
| 128 |
+
mb_high_threshold=-10,
|
| 129 |
+
mb_high_ratio=2.0,
|
| 130 |
+
stereo_width=1.3,
|
| 131 |
+
stereo_bass_mono_below_hz=150,
|
| 132 |
+
saturation_amount=0.3,
|
| 133 |
+
exciter_amount=0.4,
|
| 134 |
+
exciter_frequency=3000,
|
| 135 |
+
limiter_threshold_db=-1.0,
|
| 136 |
+
limiter_ceiling_db=-0.3,
|
| 137 |
+
)
|
| 138 |
+
|
| 139 |
+
self.presets['edm_melodic'] = MasteringPreset(
|
| 140 |
+
name="Melodic House",
|
| 141 |
+
category="edm",
|
| 142 |
+
description="Balanced, musical, less aggressive. For melodic electronic music.",
|
| 143 |
+
tags=['edm', 'melodic', 'house', 'balanced'],
|
| 144 |
+
target_lufs=-9.5,
|
| 145 |
+
eq_bands=[
|
| 146 |
+
EQBand(frequency=30, gain=0, q=0.7, type='highpass'),
|
| 147 |
+
EQBand(frequency=50, gain=0.5, q=0.7),
|
| 148 |
+
EQBand(frequency=250, gain=-0.5, q=1.0),
|
| 149 |
+
EQBand(frequency=2500, gain=0.8, q=1.0),
|
| 150 |
+
EQBand(frequency=8000, gain=1.2, q=0.8),
|
| 151 |
+
],
|
| 152 |
+
comp_threshold_db=-14,
|
| 153 |
+
comp_ratio=2.5,
|
| 154 |
+
comp_attack_ms=15,
|
| 155 |
+
comp_release_ms=120,
|
| 156 |
+
stereo_width=1.2,
|
| 157 |
+
saturation_amount=0.2,
|
| 158 |
+
exciter_amount=0.3,
|
| 159 |
+
limiter_threshold_db=-1.5,
|
| 160 |
+
limiter_ceiling_db=-0.5,
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
# ==================== HIP-HOP PRESETS ====================
|
| 164 |
+
|
| 165 |
+
self.presets['hiphop_808_punch'] = MasteringPreset(
|
| 166 |
+
name="Hip-Hop 808 Punch",
|
| 167 |
+
category="hiphop",
|
| 168 |
+
description="Powerful low-end, clear vocals. Modern trap/hip-hop sound.",
|
| 169 |
+
tags=['hiphop', 'trap', '808', 'bass', 'modern'],
|
| 170 |
+
target_lufs=-9.0,
|
| 171 |
+
eq_bands=[
|
| 172 |
+
EQBand(frequency=25, gain=0, q=0.7, type='highpass'),
|
| 173 |
+
EQBand(frequency=40, gain=2.0, q=0.5), # Sub boost
|
| 174 |
+
EQBand(frequency=80, gain=1.5, q=0.8), # 808 fundamental
|
| 175 |
+
EQBand(frequency=300, gain=-1.5, q=1.2), # Mud cut
|
| 176 |
+
EQBand(frequency=2000, gain=1.5, q=0.9), # Vocal clarity
|
| 177 |
+
EQBand(frequency=12000, gain=1.0, q=0.7), # Air
|
| 178 |
+
],
|
| 179 |
+
comp_threshold_db=-13,
|
| 180 |
+
comp_ratio=2.8,
|
| 181 |
+
comp_attack_ms=20,
|
| 182 |
+
comp_release_ms=150,
|
| 183 |
+
mb_low_threshold=-14,
|
| 184 |
+
mb_low_ratio=3.0, # Control bass heavily
|
| 185 |
+
mb_mid_threshold=-12,
|
| 186 |
+
mb_mid_ratio=2.5,
|
| 187 |
+
mb_high_threshold=-10,
|
| 188 |
+
mb_high_ratio=2.0,
|
| 189 |
+
stereo_width=1.0, # Less width for punch
|
| 190 |
+
stereo_bass_mono_below_hz=180, # Mono bass critical
|
| 191 |
+
saturation_amount=0.4, # Warmth
|
| 192 |
+
exciter_amount=0.2,
|
| 193 |
+
limiter_threshold_db=-1.0,
|
| 194 |
+
limiter_ceiling_db=-0.3,
|
| 195 |
+
)
|
| 196 |
+
|
| 197 |
+
self.presets['hiphop_boom_bap'] = MasteringPreset(
|
| 198 |
+
name="Boom Bap Classic",
|
| 199 |
+
category="hiphop",
|
| 200 |
+
description="Classic 90s hip-hop sound. Warm, punchy, less loud.",
|
| 201 |
+
tags=['hiphop', 'boom bap', 'classic', '90s', 'vintage'],
|
| 202 |
+
target_lufs=-11.0,
|
| 203 |
+
eq_bands=[
|
| 204 |
+
EQBand(frequency=30, gain=0, q=0.7, type='highpass'),
|
| 205 |
+
EQBand(frequency=80, gain=1.0, q=0.8),
|
| 206 |
+
EQBand(frequency=250, gain=-0.8, q=1.0),
|
| 207 |
+
EQBand(frequency=1500, gain=1.2, q=1.0),
|
| 208 |
+
EQBand(frequency=6000, gain=0.8, q=0.8),
|
| 209 |
+
],
|
| 210 |
+
comp_threshold_db=-15,
|
| 211 |
+
comp_ratio=2.5,
|
| 212 |
+
saturation_amount=0.5, # Analog warmth
|
| 213 |
+
saturation_type="tape",
|
| 214 |
+
limiter_threshold_db=-2.0,
|
| 215 |
+
limiter_ceiling_db=-0.8,
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
# ==================== ROCK PRESETS ====================
|
| 219 |
+
|
| 220 |
+
self.presets['rock_live'] = MasteringPreset(
|
| 221 |
+
name="Rock Live Energy",
|
| 222 |
+
category="rock",
|
| 223 |
+
description="Dynamic, punchy. Preserves live band energy.",
|
| 224 |
+
tags=['rock', 'live', 'dynamic', 'band'],
|
| 225 |
+
target_lufs=-11.0,
|
| 226 |
+
eq_bands=[
|
| 227 |
+
EQBand(frequency=40, gain=0, q=0.7, type='highpass'),
|
| 228 |
+
EQBand(frequency=80, gain=0.5, q=0.7),
|
| 229 |
+
EQBand(frequency=400, gain=-1.0, q=1.5), # Guitar mud
|
| 230 |
+
EQBand(frequency=1500, gain=1.0, q=1.0),
|
| 231 |
+
EQBand(frequency=5000, gain=1.5, q=0.8), # Snare crack
|
| 232 |
+
EQBand(frequency=10000, gain=0.8, q=0.7),
|
| 233 |
+
],
|
| 234 |
+
comp_threshold_db=-16,
|
| 235 |
+
comp_ratio=2.0, # Gentle
|
| 236 |
+
comp_attack_ms=30, # Slower for punch
|
| 237 |
+
comp_release_ms=200,
|
| 238 |
+
stereo_width=1.1,
|
| 239 |
+
saturation_amount=0.5,
|
| 240 |
+
saturation_type="tape",
|
| 241 |
+
limiter_threshold_db=-2.0,
|
| 242 |
+
limiter_ceiling_db=-0.8,
|
| 243 |
+
)
|
| 244 |
+
|
| 245 |
+
# ==================== POP PRESETS ====================
|
| 246 |
+
|
| 247 |
+
self.presets['pop_radio'] = MasteringPreset(
|
| 248 |
+
name="Pop Radio Ready",
|
| 249 |
+
category="pop",
|
| 250 |
+
description="Bright, loud, competitive. Modern pop sound.",
|
| 251 |
+
tags=['pop', 'radio', 'modern', 'bright'],
|
| 252 |
+
target_lufs=-9.0,
|
| 253 |
+
eq_bands=[
|
| 254 |
+
EQBand(frequency=30, gain=0, q=0.7, type='highpass'),
|
| 255 |
+
EQBand(frequency=100, gain=0.8, q=0.8),
|
| 256 |
+
EQBand(frequency=300, gain=-0.8, q=1.2),
|
| 257 |
+
EQBand(frequency=2500, gain=1.2, q=1.0),
|
| 258 |
+
EQBand(frequency=8000, gain=1.5, q=0.8),
|
| 259 |
+
],
|
| 260 |
+
comp_threshold_db=-12,
|
| 261 |
+
comp_ratio=3.5,
|
| 262 |
+
stereo_width=1.2,
|
| 263 |
+
exciter_amount=0.4,
|
| 264 |
+
limiter_threshold_db=-1.0,
|
| 265 |
+
limiter_ceiling_db=-0.3,
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# ==================== JAZZ PRESETS ====================
|
| 269 |
+
|
| 270 |
+
self.presets['jazz_acoustic'] = MasteringPreset(
|
| 271 |
+
name="Jazz Acoustic",
|
| 272 |
+
category="jazz",
|
| 273 |
+
description="Natural, dynamic. Preserves acoustic instrument detail.",
|
| 274 |
+
tags=['jazz', 'acoustic', 'dynamic', 'natural'],
|
| 275 |
+
target_lufs=-14.0,
|
| 276 |
+
eq_bands=[
|
| 277 |
+
EQBand(frequency=40, gain=0, q=0.7, type='highpass'),
|
| 278 |
+
EQBand(frequency=200, gain=-0.5, q=1.0),
|
| 279 |
+
EQBand(frequency=3000, gain=0.8, q=1.0),
|
| 280 |
+
EQBand(frequency=10000, gain=0.5, q=0.7),
|
| 281 |
+
],
|
| 282 |
+
comp_threshold_db=-18,
|
| 283 |
+
comp_ratio=1.5, # Very gentle
|
| 284 |
+
comp_attack_ms=50,
|
| 285 |
+
comp_release_ms=250,
|
| 286 |
+
stereo_width=1.0,
|
| 287 |
+
saturation_amount=0.1,
|
| 288 |
+
limiter_threshold_db=-3.0,
|
| 289 |
+
limiter_ceiling_db=-1.5,
|
| 290 |
+
)
|
| 291 |
+
|
| 292 |
+
# ==================== PODCAST PRESETS ====================
|
| 293 |
+
|
| 294 |
+
self.presets['podcast_voice'] = MasteringPreset(
|
| 295 |
+
name="Podcast Voice Clarity",
|
| 296 |
+
category="podcast",
|
| 297 |
+
description="Clear speech, controlled dynamics. Broadcast safe.",
|
| 298 |
+
tags=['podcast', 'voice', 'speech', 'broadcast'],
|
| 299 |
+
target_lufs=-16.0, # Broadcast standard
|
| 300 |
+
eq_bands=[
|
| 301 |
+
EQBand(frequency=80, gain=0, q=0.5, type='highpass'), # Remove rumble
|
| 302 |
+
EQBand(frequency=250, gain=-1.0, q=1.0), # Mud
|
| 303 |
+
EQBand(frequency=3000, gain=2.0, q=1.2), # Presence
|
| 304 |
+
EQBand(frequency=8000, gain=1.0, q=0.8), # Clarity
|
| 305 |
+
],
|
| 306 |
+
comp_threshold_db=-18,
|
| 307 |
+
comp_ratio=4.0, # Heavy for consistency
|
| 308 |
+
comp_attack_ms=5, # Fast for speech
|
| 309 |
+
comp_release_ms=80,
|
| 310 |
+
stereo_width=0.8, # Narrow for voice
|
| 311 |
+
limiter_threshold_db=-3.0,
|
| 312 |
+
limiter_ceiling_db=-1.0, # True peak safe
|
| 313 |
+
)
|
| 314 |
+
|
| 315 |
+
# ==================== LO-FI PRESETS ====================
|
| 316 |
+
|
| 317 |
+
self.presets['lofi_chill'] = MasteringPreset(
|
| 318 |
+
name="Lo-Fi Chill",
|
| 319 |
+
category="lofi",
|
| 320 |
+
description="Warm, relaxed. Vintage lo-fi aesthetic.",
|
| 321 |
+
tags=['lofi', 'chill', 'vintage', 'warm'],
|
| 322 |
+
target_lufs=-12.0,
|
| 323 |
+
eq_bands=[
|
| 324 |
+
EQBand(frequency=50, gain=0, q=0.7, type='highpass'),
|
| 325 |
+
EQBand(frequency=120, gain=1.0, q=0.8),
|
| 326 |
+
EQBand(frequency=2000, gain=-0.5, q=1.0),
|
| 327 |
+
EQBand(frequency=8000, gain=-1.0, q=0.7), # Roll off highs
|
| 328 |
+
],
|
| 329 |
+
comp_threshold_db=-15,
|
| 330 |
+
comp_ratio=2.0,
|
| 331 |
+
saturation_amount=0.6, # Heavy saturation
|
| 332 |
+
saturation_type="tape",
|
| 333 |
+
limiter_threshold_db=-2.5,
|
| 334 |
+
limiter_ceiling_db=-1.0,
|
| 335 |
+
)
|
| 336 |
+
|
| 337 |
+
def get_preset(self, name: str) -> Optional[MasteringPreset]:
|
| 338 |
+
"""Get preset by name"""
|
| 339 |
+
return self.presets.get(name)
|
| 340 |
+
|
| 341 |
+
def get_presets_by_category(self, category: str) -> List[MasteringPreset]:
|
| 342 |
+
"""Get all presets in a category"""
|
| 343 |
+
return [p for p in self.presets.values() if p.category == category]
|
| 344 |
+
|
| 345 |
+
def get_presets_by_tags(self, tags: List[str]) -> List[MasteringPreset]:
|
| 346 |
+
"""Get presets matching any of the tags"""
|
| 347 |
+
results = []
|
| 348 |
+
for preset in self.presets.values():
|
| 349 |
+
if any(tag in preset.tags for tag in tags):
|
| 350 |
+
results.append(preset)
|
| 351 |
+
return results
|
| 352 |
+
|
| 353 |
+
def list_all_presets(self) -> List[str]:
|
| 354 |
+
"""List all preset names"""
|
| 355 |
+
return list(self.presets.keys())
|
| 356 |
+
|
| 357 |
+
def add_preset(self, preset: MasteringPreset):
|
| 358 |
+
"""Add custom preset"""
|
| 359 |
+
self.presets[preset.name.lower().replace(' ', '_')] = preset
|
| 360 |
+
|
| 361 |
+
def save_to_file(self, filepath: str):
|
| 362 |
+
"""Save all presets to JSON file"""
|
| 363 |
+
data = {
|
| 364 |
+
name: preset.to_dict()
|
| 365 |
+
for name, preset in self.presets.items()
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
Path(filepath).parent.mkdir(parents=True, exist_ok=True)
|
| 369 |
+
with open(filepath, 'w') as f:
|
| 370 |
+
json.dump(data, f, indent=2)
|
| 371 |
+
|
| 372 |
+
print(f"๐พ Presets saved to {filepath}")
|
| 373 |
+
|
| 374 |
+
def load_from_file(self, filepath: str):
|
| 375 |
+
"""Load presets from JSON file"""
|
| 376 |
+
with open(filepath, 'r') as f:
|
| 377 |
+
data = json.load(f)
|
| 378 |
+
|
| 379 |
+
for name, preset_dict in data.items():
|
| 380 |
+
self.presets[name] = MasteringPreset.from_dict(preset_dict)
|
| 381 |
+
|
| 382 |
+
print(f"๐ Loaded {len(data)} presets from {filepath}")
|
| 383 |
+
|
| 384 |
+
def print_preset_info(self, preset_name: str):
|
| 385 |
+
"""Print detailed preset information"""
|
| 386 |
+
preset = self.get_preset(preset_name)
|
| 387 |
+
if not preset:
|
| 388 |
+
print(f"โ Preset '{preset_name}' not found")
|
| 389 |
+
return
|
| 390 |
+
|
| 391 |
+
print("\n" + "="*60)
|
| 392 |
+
print(f"๐๏ธ PRESET: {preset.name}")
|
| 393 |
+
print("="*60)
|
| 394 |
+
print(f"Category: {preset.category}")
|
| 395 |
+
print(f"Description: {preset.description}")
|
| 396 |
+
print(f"Tags: {', '.join(preset.tags)}")
|
| 397 |
+
|
| 398 |
+
print(f"\n๐ฏ TARGET:")
|
| 399 |
+
print(f" Loudness: {preset.target_lufs} LUFS")
|
| 400 |
+
|
| 401 |
+
print(f"\n๐๏ธ EQ ({len(preset.eq_bands)} bands):")
|
| 402 |
+
for i, band in enumerate(preset.eq_bands, 1):
|
| 403 |
+
print(f" Band {i}: {band.frequency}Hz {band.gain:+.1f}dB Q:{band.q}")
|
| 404 |
+
|
| 405 |
+
print(f"\n๐ COMPRESSION:")
|
| 406 |
+
print(f" Threshold: {preset.comp_threshold_db} dB")
|
| 407 |
+
print(f" Ratio: {preset.comp_ratio}:1")
|
| 408 |
+
print(f" Attack: {preset.comp_attack_ms} ms")
|
| 409 |
+
print(f" Release: {preset.comp_release_ms} ms")
|
| 410 |
+
|
| 411 |
+
print(f"\n๐ก STEREO:")
|
| 412 |
+
print(f" Width: {preset.stereo_width}")
|
| 413 |
+
print(f" Bass Mono Below: {preset.stereo_bass_mono_below_hz} Hz")
|
| 414 |
+
|
| 415 |
+
print(f"\n๐ฅ SATURATION:")
|
| 416 |
+
print(f" Amount: {preset.saturation_amount*100:.0f}%")
|
| 417 |
+
print(f" Type: {preset.saturation_type}")
|
| 418 |
+
|
| 419 |
+
print(f"\n๐ธ EXCITER:")
|
| 420 |
+
print(f" Amount: {preset.exciter_amount*100:.0f}%")
|
| 421 |
+
print(f" Frequency: {preset.exciter_frequency} Hz")
|
| 422 |
+
|
| 423 |
+
print(f"\nโก LIMITER:")
|
| 424 |
+
print(f" Threshold: {preset.limiter_threshold_db} dB")
|
| 425 |
+
print(f" Ceiling: {preset.limiter_ceiling_db} dB")
|
| 426 |
+
print(f" Release: {preset.limiter_release_ms} ms")
|
| 427 |
+
|
| 428 |
+
print("\n" + "="*60 + "\n")
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
if __name__ == "__main__":
|
| 432 |
+
# Example usage
|
| 433 |
+
library = PresetLibrary()
|
| 434 |
+
|
| 435 |
+
# List all presets
|
| 436 |
+
print("๐ Available Presets:")
|
| 437 |
+
for name in library.list_all_presets():
|
| 438 |
+
preset = library.get_preset(name)
|
| 439 |
+
print(f" โข {preset.name} ({preset.category})")
|
| 440 |
+
|
| 441 |
+
# Show detailed info
|
| 442 |
+
library.print_preset_info('edm_club_master')
|
| 443 |
+
|
| 444 |
+
# Save to file
|
| 445 |
+
library.save_to_file('data/presets/default_presets.json')
|