Example #1
0
 def bynder(self, instrument):
     instrument = find_instrument(instrument)
     with self.path.open("rb") as f:
         s = f.read()
         g = LyeGrammar(s)
         ast = g.lye()
         if instrument == "drums":
             return Drumlyne(simplify_ast(ast))
         else:
             return Bynder(simplify_ast(ast), instrument)
Example #2
0
def melody_from_ly(s):
    """
    Make a `Melody` from a ly string.
    """

    g = LyeGrammar(s)
    ast = g.exprs()
    ast = simplify_ast(ast)
    melody = Melody(ast, 120, data=s)
    return melody
Example #3
0
from lye.combyne import Bynder
from lye.grammar import LyeGrammar
from lye.pretty import pretty
from lye.utilities import find_instrument
from lye.visitors import simplify_ast

if len(sys.argv) < 2:
    print "Usage:", sys.argv[0], "<snippet> [<instrument>]"
    sys.exit(0)

instrument = None

if len(sys.argv) >= 3:
    instrument = find_instrument(" ".join(sys.argv[2:]))

with open(sys.argv[1], "rb") as f:
    s = f.read()

g = LyeGrammar(s)
ast = g.lye()
bound = Bynder(simplify_ast(ast), instrument)

print "AST:"
print pretty(bound)

print "AST (%s):" % instrument
print pretty(bound.specialized())

print "Scheduled:"
print pretty(bound.schedule())