70 lines
2.9 KiB
Python
70 lines
2.9 KiB
Python
"""장르별 음악 파라미터 랜덤 풀 — 음악적으로 어울리는 결과 유도."""
|
|
import random
|
|
|
|
POOLS = {
|
|
"lo-fi": {
|
|
"moods": ["chill", "relaxing", "dreamy", "melancholic", "mellow", "nostalgic", "peaceful"],
|
|
"instruments_pool": ["piano", "synth", "drums", "vinyl", "rhodes", "soft bass", "ambient pads"],
|
|
"instruments_count": (3, 4),
|
|
"bpm": (70, 90),
|
|
"keys": ["C", "D", "F", "G", "A"],
|
|
"scales": ["minor", "major"],
|
|
"prompt_modifiers": ["cozy bedroom vibes", "rainy night", "late night study", "cafe ambience"],
|
|
},
|
|
"phonk": {
|
|
"moods": ["dark", "aggressive", "moody", "intense", "hypnotic"],
|
|
"instruments_pool": ["808 bass", "hi-hat", "synth lead", "vocal chops", "bass drops", "trap drums"],
|
|
"instruments_count": (3, 4),
|
|
"bpm": (130, 160),
|
|
"keys": ["C", "D", "F", "G"],
|
|
"scales": ["minor"],
|
|
"prompt_modifiers": ["drift atmosphere", "dark neon", "midnight drive"],
|
|
},
|
|
"ambient": {
|
|
"moods": ["peaceful", "meditative", "ethereal", "spacious", "dreamy"],
|
|
"instruments_pool": ["pad synths", "atmospheric guitar", "soft strings", "field recordings", "drone bass"],
|
|
"instruments_count": (2, 3),
|
|
"bpm": (50, 75),
|
|
"keys": ["C", "D", "E", "G", "A"],
|
|
"scales": ["major", "minor"],
|
|
"prompt_modifiers": ["misty mountain morning", "deep space", "still water", "forest dawn"],
|
|
},
|
|
"pop": {
|
|
"moods": ["uplifting", "happy", "energetic", "romantic", "catchy"],
|
|
"instruments_pool": ["acoustic guitar", "piano", "drums", "bass", "synth", "vocals harmonies"],
|
|
"instruments_count": (3, 5),
|
|
"bpm": (95, 130),
|
|
"keys": ["C", "D", "E", "F", "G", "A"],
|
|
"scales": ["major"],
|
|
"prompt_modifiers": ["radio-ready", "summer vibe", "feel-good"],
|
|
},
|
|
"default": {
|
|
"moods": ["chill", "relaxing", "uplifting", "mellow"],
|
|
"instruments_pool": ["piano", "synth", "drums", "guitar", "bass", "strings"],
|
|
"instruments_count": (3, 4),
|
|
"bpm": (80, 110),
|
|
"keys": ["C", "D", "F", "G", "A"],
|
|
"scales": ["minor", "major"],
|
|
"prompt_modifiers": [""],
|
|
},
|
|
}
|
|
|
|
|
|
def randomize(genre: str, rng=None) -> dict:
|
|
"""장르 → 랜덤 음악 파라미터 1세트.
|
|
|
|
반환: {moods, instruments, bpm, key, scale, prompt_modifier}
|
|
"""
|
|
rng = rng or random.Random()
|
|
pool = POOLS.get(genre.lower(), POOLS["default"])
|
|
n_instr = rng.randint(*pool["instruments_count"])
|
|
instruments = rng.sample(pool["instruments_pool"], min(n_instr, len(pool["instruments_pool"])))
|
|
return {
|
|
"moods": [rng.choice(pool["moods"])],
|
|
"instruments": instruments,
|
|
"bpm": rng.randint(*pool["bpm"]),
|
|
"key": rng.choice(pool["keys"]),
|
|
"scale": rng.choice(pool["scales"]),
|
|
"prompt_modifier": rng.choice(pool["prompt_modifiers"]),
|
|
}
|