Spaces:
Running
Running
| import click | |
| from midi_convert import convert_midi_to_scad, SCAD_TEMPLATE, InternalStructureType | |
| def get_default_output_filename() -> str: | |
| click_context = click.get_current_context() | |
| midi_file = click_context.params.get('midi_file') | |
| if midi_file is not None: | |
| return f'{midi_file.name}.scad' | |
| return 'out.scad' | |
| def deactivate_prompts(ctx, _, value): | |
| if value: | |
| for p in ctx.command.params: | |
| if isinstance(p, click.Option) and p.prompt is not None: | |
| p.prompt = None | |
| return value | |
| def run(midi_file, output_file, notes_file, template, internal_structure) -> None: | |
| scad_file_contents = convert_midi_to_scad( | |
| midi_file=midi_file, | |
| available_notes_string=notes_file.read(), | |
| template=template, | |
| internal_structure_type=internal_structure, | |
| ) | |
| output_file.write(scad_file_contents) | |
| if __name__ == "__main__": | |
| run() | |