Skip to content

Instantly share code, notes, and snippets.

@urswilke
Created November 19, 2020 13:25
Show Gist options
  • Save urswilke/9176fb739147c835f5d99aa01da7ee96 to your computer and use it in GitHub Desktop.
Save urswilke/9176fb739147c835f5d99aa01da7ee96 to your computer and use it in GitHub Desktop.
graphviz file
digraph workflow {
ranksep=.5;
graph [
fontname = "helvetica",
#splines=ortho,
concentrate=true
];
node [
fontname = "helvetica",
style = "rounded,filled,radial",
gradientangle=60,
#fillcolor="#dddddd99:#7777772f",
# gradients dont work on observable...:
fillcolor="#dddddd99",
penwidth=4,
color = "#ffffff55",
];
edge [
fontname = "helvetica",
penwidth=3,
color="#37373766"
];
penwidth=5;
style=rounded
subgraph cluster_arduino {
label = < <B>arduino</B> >;
bgcolor = "#a8feff";
color = "#3e979d";
fontcolor = "#3e979d";
fontsize = 30;
Thermometers -> mc;
sketch -> mc;
Thermometers [shape=box];
sketch [
label = "send_temp.ino",
shape=box,
URL="https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/arduino/send_temp/send_temp.ino",
tooltip = "arduino sketch to read multiple DS18B20 thermometers and then print the information to the serial connection"
];
{rank=same; mc; sketch}
}
sc -> python;
subgraph cluster_main {
label = < <B>python</B> >;
bgcolor = "#fffb4b";
color = "#4f93ba";
fontcolor = "#4f93ba";
fontsize = 30;
penwidth=5;
#graph[style=dotted];
"functions.py" [
shape=box,
tooltip = "functions that are imported in the temperatures_to_midi notebook",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/functions.py"
]
python [
shape=box,
tooltip = "python real-time loop to
* read serial string, extract temperatures
* calculate temperature differences
* translate differences to midi notes according to a specified musical scale
* send the note events to a midi port in real time
During the loop the data is recorded in lists and when it has finished the data is written to a midi and csv files. ",
label = "temperatures_to_midi.ipynb",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/temperatures_to_midi.ipynb"
];
"functions.py" -> python
mc [
shape=box,
label="micro-controller",
tooltip="the micro-controller is connected to the PC via USB",
];
{rank = same; "functions.py" python}
}
# subgraph cluster_main_to_R_connectors {
# label = "main workflow";
# }
subgraph cluster_fluidsynth {
label = <<B>fluidsynth </B>>;
fontsize = 30;
bgcolor = "#ffd030";
color = "#f07531";
fontcolor = "#f07531";
penwidth=5;
sf2 [shape = cylinder, label = "sound\nfont"];
fluidsynth [
shape=box,
tooltip = "* Fluidsynth can be easily started via the GUI QSynth.\n* An sf2 soundfont file has to be used.\n* A midi port can be synthesized in real time, or\n* A midi file can be rendered to an audio file."
];
sf2 -> fluidsynth;
{rank=same; fluidsynth sf2}
}
subgraph cluster_output_files {
label = < <B>output files</B> >;
fontsize = 30;
bgcolor = "#ffd080"
color = "#b25605"
fontcolor = "#b25605"
midifile [
shape = cylinder,
label = "live_record.mid",
tooltip = "midi file written by temperatures_to_midi.ipynb",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/recorded_data/"
];
prelim_mp3 [
label = "test.mp3"
shape = cylinder;
tooltip = "resulting mp3 file, when the midifile test.mid is rendered by fluidsynth with the specified soundfont",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/R/preliminary_study/"
];
mp3 [
label = "live_record.mp3"
shape = cylinder;
tooltip = "resulting mp3 file, when the midifile live_record.mid (written by temperatures_to_midi.ipynb) is rendered by fluidsynth with the specified soundfont"
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/recorded_data/"
];
csv [shape = cylinder];
prelim_audio [
shape=cylinder,
label="test.mid",
tooltip = "midi file written by preliminary_study.Rmd",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/R/preliminary_study/"
]
prelim_audio -> prelim_mp3
midifile -> mp3
{rank=same;prelim_audio, midifile}
}
python -> csv [color = "#4f93ba"];
python -> midifile [color = "#4f93ba"];
fluidsynth -> mp3 [style = dashed, color = "#f07531"]
fluidsynth -> prelim_mp3 [style = dashed, color = "#f07531"]
mp -> fluidsynth;
mc -> sc [
arrowhead=none,
tooltip = "setup serial connection in arduino",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/arduino/send_temp/send_temp.ino#L24"
];
python -> mp [arrowhead=none];
sc [
label="serial\nconnection",
color=grey,
shape=diamond,
tooltip = "The serial string sent from the arduino is of the following format:
S: 1, ID: 40255662332332138251, T: 23.12; S: 2, ID: 402552102282332138209, T: 23.25; S: 3, ID: 402551932392332138119, T: 22.75; S: 4, ID: 4025514153413227192, T: 23.38; S: 5, ID: 402552272422332138169, T: 23.12",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/recorded_data/serial_string.txt"
];
mp [
label = "midi\nport",
shape=diamond,
color=grey,
tooltip = "The midi port to fluidsynth is set up by the python code in temperatures_to_midi.ipynb",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/temperatures_to_midi.ipynb#Setup_fluidsynth_connection"
];
#mc -> sc -> python -> mp -> fluidsynth[ style = invis, weight= 10 ];
fluidsynth -> speakers
subgraph cluster_speaker {
label = < <B>speaker</B> >;
fontsize = 30;
# bgcolor="#FFD700:#CCA600";
# gradients dont work on observable...:
bgcolor="#CCA600";
speakers [label="🔊🎶"];
}
subgraph cluster_R {
# https://stackoverflow.com/questions/6824431/placing-clusters-on-the-same-rank-in-graphviz
label = < <B>R</B> >;
fontsize = 30;
bgcolor = "#87d5ff"
color = "#217ca3"
fontcolor = "#217ca3"
newrank=true;
csv -> "plot_csv_data.R";
"plot_midifile.Rmd" [
shape=box,
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/R/plot_midifile/plot_midifile.md"
tooltip = "In this document, a piano roll visualization is produced of the midifile written at the end of the python notebook. And I will promote the two packages I wrote:
* The python package [miditapyr](https://github.com/urswilke/miditapyr/) can tabulate midifile data (read in by [mido](github.com/mido/mido)) in dataframes.
* The R package [pyramidi](https://github.com/urswilke/pyramidi/) can transform these dataframes to a wide format that allows for an easy way to plot piano roll plots."
]
"plot_csv_data.R" [
shape=box,
tooltip = "script to plot the data in the csv files written in python/temperatures_to_midi.ipynb"
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/R/plot_csv_data/plot_csv_data.md"
]
plotter [
label = "live_plotter.R",
shape=box,
tooltip = "script to plot the serial data in real time",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/R/live_plotter/live_plotter.R"
]
#&#8226; after the real-time loop, csv, midi and mp3 files are generated<br ALIGN = "LEFT"/>
prelim [
shape=box,
label="preliminary_study.Rmd",
URL="https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/R/preliminary_study/preliminary_study.md"
tooltip="This is a preliminary study to translate temperature measurements into sound.
* Fake temperaure curves are generated
* pairwise differences are calculated
* these differnces are mapped to midi notes
* this information is saved to a midi file
* which is synthesized to an audiofile"
];
# {rank=same; midifile [group = g3] csv [group = g3] }
edge[style=invis];
python -> plotter;
plotter -> prelim;
prelim -> "plot_midifile.Rmd";
"plot_midifile.Rmd" -> "plot_csv_data.R";
"plot_midifile.Rmd" -> "plot_csv_data.R";
}
{rank=same; python plotter}
#{rank=same; prelim prelim_audio}
sc -> plotter;
midifile -> "plot_midifile.Rmd"
prelim -> prelim_audio
edge[style=invis];
midifile -> csv;
mc -> sc [ weight = 100, style=invis]
sc -> python [
weight = 100,
style=invis,
tooltip = "setup serial connection in arduino",
URL = "https://gitlab.com/urswilke/chaos_machine_code/-/tree/master/python/temperatures_to_midi.ipynb#Arduino"
]
python -> mp [ weight = 100, style=invis]
mp -> fluidsynth [ weight = 100, style=invis]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment