Last active
November 30, 2024 02:38
-
-
Save matthewryanscott/060cdbaef9491f5e4d55ef31bff82013 to your computer and use it in GitHub Desktop.
Using Radiant Voices to create a simple arpeggiator MetaModule for SunVox
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 pathlib import Path | |
from rv.api import m, Note, NOTE, Pattern, Project, Synth | |
if __name__ == "__main__": | |
# Metamodules contain a project. | |
project = Project() | |
# Simple routing of a multisynth to a generator to output. | |
project += (multisynth := m.MultiSynth()) | |
project += (generator := m.AnalogGenerator()) | |
multisynth >> generator >> project.output | |
# Keep them from being visually stacked. | |
project.layout() | |
# Create an arpeggiator pattern. | |
project += (pattern := Pattern("arp", tracks=1, lines=3, x=0)) | |
# (Setting `module` could use a nicer API) | |
pattern.data[0][0] = Note(note=NOTE.C5, module=multisynth.index + 1) | |
pattern.data[1][0] = Note(note=NOTE.E5, module=multisynth.index + 1) | |
pattern.data[2][0] = Note(note=NOTE.G5, module=multisynth.index + 1) | |
# Wrap the project in a metamodule, configured to play the arpeggiator. | |
metamodule = m.MetaModule(project=project) | |
metamodule.input_module = 256 # prevent incoming notes from directly triggering the MultiSynth | |
metamodule.play_patterns = metamodule.PlayPatterns.on_repeat | |
metamodule.arpeggiator = True | |
# Expose the relative-note controller of the multisynth. | |
# (This part could use a nicer API with fewer footguns.) | |
# | |
# Set the number of user-defined controllers. | |
metamodule.user_defined_controllers = 1 | |
# Set the label of the first user-defined controller. | |
controller = metamodule.user_defined[0] | |
controller.label = "Relative Note" | |
# Map the user-defined controller to the actual controller. | |
mapping: m.MetaModule.Mapping = metamodule.mappings.values[0] | |
mapping.module = multisynth.index | |
mapping.controller = multisynth.controllers["transpose"].number - 1 | |
# Wrap the metamodule in a synth. | |
synth = Synth(metamodule) | |
# Save to a file. | |
with Path("simple_mm.sunsynth").open("wb") as f: | |
synth.write_to(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment