Depends on nymphes_osc
.
Last active
March 30, 2025 15:01
-
-
Save SuperSonicHub1/9ce667c28070c26e4698a372ccdd93a1 to your computer and use it in GitHub Desktop.
Random patch generator for the Nymphes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint, uniform | |
from nymphes_midi.NymphesPreset import NymphesPreset | |
from datetime import datetime | |
def rand(ty: type, min, max): | |
if ty == float: | |
return uniform(min, max) | |
elif ty == int: | |
return randint(min, max) | |
else: | |
raise ValueError(f"Unexpected type {ty}.") | |
def set(preset: NymphesPreset, ty: type, name: str, value): | |
if ty == float: | |
preset.set_float(name, value) | |
elif ty == int: | |
preset.set_int(name, value) | |
else: | |
raise ValueError(f"Unexpected type {ty}.") | |
def random_preset() -> NymphesPreset: | |
preset = NymphesPreset() | |
for name in NymphesPreset.all_param_names(): | |
ty = NymphesPreset.type_for_param_name(name) | |
set( | |
preset, | |
ty, | |
name, | |
rand( | |
ty, | |
NymphesPreset.min_val_for_param_name(name), | |
NymphesPreset.max_val_for_param_name(name), | |
), | |
) | |
return preset | |
randomized = random_preset() | |
timestamp = datetime.now().strftime("%Y-%M-%d-%H-%M-%S") | |
randomized.save_preset_file(f"preset-{timestamp}.txt") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment