Commit 8cbee45a authored by Pierre Donat-Bouillud's avatar Pierre Donat-Bouillud
Browse files

Experiment script for Puredata

parent c07cba4b
Pipeline #995 passed with stage
in 3 minutes and 30 seconds
python3 --draw -z --tikz -n 4 --dir puredata-graphs-2/
......@@ -17,26 +17,47 @@ import glob
from pyparsing import *
def trim(s, l, tokens):
print("tok:", tokens[0])
#print("tok:", tokens[0])
return [tokens[0].strip()]
insideBlock = CharsNotIn("{}").setParseAction(trim)
#insideBlock = CharsNotIn("{}").setParseAction(trim)
insideBlock = CharsNotIn("{}")
block_parser = nestedExpr('{','}', content=insideBlock)
def extension(path):
return os.path.splitext(path)[1]
def without_ext(path):
return os.path.splitext(os.path.basename(path))[0]
def show_tokens(s):
tokens = block_parser.lex(s)
for tok in tokens:
print(tok.type, "(", tok, ")")
# Convert faust files to rust
def convert_file(filename):
proc =["faust", "-lang", "rust", filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
def convert_file(filename, struct_name):
proc =["faust", "-lang", "rust", filename, "-cn", struct_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
return proc.stdout#This is the rust content
def to_audioeffect(parse_tree):
"""Generate the audio effect"""
#Filter out what we don't need
i = 0
nb_uplevel_tok = len(parse_tree)
tok = parse_tree
while i < nb_uplevel_tok:
if "fn metadata" in tok[i] or "fn buildUserInterface" in tok[i] or "fn instanceResetUserInterface" in tok[i]:
del tok[i]
del tok[i+1]
i = i + 2
elif isinstance(tok[i], list):
def process(filename):
struct_name = without_ext(filename)
rust_file = convert_file(filename)
parse_tree = block_parser.parseString("{" + rust_file + "}")
......@@ -70,6 +91,5 @@ if __name__ == "__main__":
print(, " does not exist")
# Extract the relevant rust code (parsing with lark)
# Generate the audio effect
......@@ -176,7 +176,7 @@ def process_all_graphs(nb_nodes, dirname, random=False, from_graphs=False):
#./main.native -dewx -n 5 --node-file ../
command = [graph_enum]
if random:
command.extend(["-l", "--edge-prob", "0.3"])
command.extend(["-l", "--edge-prob", "0.3", "--nb-samples", "100"])
elif from_graphs:
command.extend(["-z", "--connect-subpatches"])
command.extend(["-ewxr", "-n", str(nb_nodes), "--node-file="+nodes_dic])
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment