aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-03-18 02:11:51 +0000
committerDavid Robillard <d@drobilla.net>2007-03-18 02:11:51 +0000
commit47f59aaad7a5ab8c189905544a761940ae9f8509 (patch)
tree67b6ec9ad915de327cda5007c8c1708a1e256c87 /util
parenta716b2c0571f5bdcd817835cecb30cb7a4c745e0 (diff)
downloadmachina-47f59aaad7a5ab8c189905544a761940ae9f8509.tar.gz
machina-47f59aaad7a5ab8c189905544a761940ae9f8509.tar.bz2
machina-47f59aaad7a5ab8c189905544a761940ae9f8509.zip
Improved automata diagram drawing (include notes, use standard initial note notation).
Made compilation without Jack possible. git-svn-id: http://svn.drobilla.net/lad/machina@363 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'util')
-rwxr-xr-xutil/machina2dot (renamed from util/machina2dot.py)16
1 files changed, 11 insertions, 5 deletions
diff --git a/util/machina2dot.py b/util/machina2dot
index cb704ef..e3e420c 100755
--- a/util/machina2dot.py
+++ b/util/machina2dot
@@ -12,7 +12,6 @@ if len(sys.argv) != 2:
parser.parse_into_model(model, "file:" + sys.argv[1])
-
print """
digraph finite_state_machine {
rankdir=LR;
@@ -23,10 +22,12 @@ node_durations = { }
initial_nodes_query = RDF.SPARQLQuery("""
PREFIX machina: <http://drobilla.net/ns/machina#>
-SELECT DISTINCT ?n ?dur WHERE {
+SELECT DISTINCT ?n ?dur ?note WHERE {
?m machina:initialNode ?n .
?n a machina:Node ;
machina:duration ?dur .
+ OPTIONAL { ?n machina:enterAction ?a .
+ ?a machina:midiNote ?note }
}
""")
@@ -45,10 +46,12 @@ for result in initial_nodes_query.execute(model):
nodes_query = RDF.SPARQLQuery("""
PREFIX machina: <http://drobilla.net/ns/machina#>
-SELECT DISTINCT ?n ?dur WHERE {
+SELECT DISTINCT ?n ?dur ?note WHERE {
?m machina:node ?n .
?n a machina:Node ;
machina:duration ?dur .
+ OPTIONAL { ?n machina:enterAction ?a .
+ ?a machina:midiNote ?note }
}
""")
@@ -56,7 +59,10 @@ for result in nodes_query.execute(model):
node_id = result['n'].blank_identifier
duration = float(result['dur'].literal_value['string'])
node_durations[node_id] = duration
- print '\t', node_id, "[ label = \"d =", "%.2f" % duration, "\"]; "
+ label = "d=%.2f" % duration
+ if result['note']:
+ label += "\\nn=%s" % result['note'].literal_value['string']
+ print '\t', node_id, "[ label=\"%s\" ]" % label
edge_query = RDF.SPARQLQuery("""
@@ -72,7 +78,7 @@ SELECT DISTINCT ?tail ?head ?prob WHERE {
for edge in edge_query.execute(model):
print '\t', edge['tail'].blank_identifier, ' -> ',
print edge['head'].blank_identifier, ' ',
- print "[ label = \"", "%1.2f" % float(edge['prob'].literal_value['string']), "\" ",
+ print "[ label = \"%1.2f\"" % float(edge['prob'].literal_value['string']),
print "minlen = ", node_durations[edge['tail'].blank_identifier] * 2, " ];"
print "}"