GitHub - rottytooth/VelatoPy

Velato Interpreter

A Python implementation of the Velato programming language, where code is inscribed as music. Each program is a MIDI file; the sequence of music notes determine the program's commands and logic.

This interpreter is based on the reference Velato compiler written in C# (2009).

Components

1. Velato Interpreter (velato.py)

Usage:

python velato.py <midi_file.mid> [-v]

Options:

  • -v, --verbose: Print notes as they are processed

Example:

python velato.py Programs/Programs_print_hello_world.mid
# Output: Hello, World!

2. Velato Note Suggestion Tool (velato_note_suggestion_tool.py)

A tool to convert pseudocode commands into Velato MIDI note sequences.

Usage:

from velato_note_suggestion_tool import VelatoNoteSuggestionTool

converter = VelatoNoteSuggestionTool(root_note='C4')

# Get note suggestions for a command
notes = converter.suggest_notes('Print ["H"]')
print(notes)  # e.g., "C4 E4 A4 D5 E5 B5"

# Generate a complete MIDI file
commands = [
    'Print ["H"]',
    'Print ["i"]',
    'While ["!"]'
]
converter.convert_to_midi(commands, 'output.mid')

Example Scripts

1. Generate Example Program from PseudoCode and Generate MIDI file (Scripts/generate_from_converter.py)

Demonstrates how to use velato_note_suggestion_tool to create a complete "Hello, World!" program.

2. Generate MIDI and Sheet Music from list of notes (Scripts/lilypond_mid_and_pdf.py)

Uses music21 to create both MIDI files and sheet music (PDF) from Velato programs.

Testing

This proj uses pytest. There is the beginning of a suite of tests for both the interpreter and the converter.

Resources