Node Definitions Manager
Hi,
This post will be in three parts:
1. background information.
2. how the "Node definitions manager" works + technical info.
3. future plans.
I have now made it possible to create/import custom Audio object types,
without touching the original set of objects provided by the tool.
Node-addons is saved to the "project".
Audio Object "documentation" if available is saved to browser indexedDB,
(documentaion is only possible using the html format).
It all started when Bob Larkin contacted me and asked about
how to use custom Audio Objects in the tool.
Specially the
https://github.com/chipaudette/OpenAudio_ArduinoLibrary
as he was working on to implement for teensy 4+ as well.
And since I think it's better to just have one tool instead
of many spawns each containing their own set of objects
I started together with Bob to create the structure changes needed.
First I thought to do the node def. list myself, but then I created the
https://github.com/manicken/manicken.github.io/blob/master/DesignToolNodes.html
which is a kind of template for new Audio object types
that i asked Bod to fill in while I did the required programming.
Meanwhile I did also notice that chipaudette had done some
special tagging of the audio class files.
//GUI: inputs:2, outputs:1 //this line used for automatic generation of GUI node
//GUI: shortName: AnalyzePhase
which I find to be a very nice addon to the audio class files,
because it make it easier to understand how the objects are meant to be used.
from that I did think of a "easier to parse" format (in JSON):
/*GUI_NODE_DEF "AudioConvert_I16toF32":
{
"shortName":"I16toF32",
"category":"converters",
"inputTypes":{"0":"i16"},
"outputTypes":{"0":"f32"},
"color":"#E6E0F8",
"boards":["teensy36", "teensy40", "teensy41"]
}
GUI_NODE_DEF*/
where both inputTypes and outputTypes
can used as follows (to make it easier to write for multi-input/output objects):
{"x1":"i16","x2":"f32","x2":"i16"}
which will result in the following
{"0":"i16","1":"f32","2":"f32","3":"i16","4":"i16" }
there is also the n type variant:
{"n":"i16"}
which means that it's i16 for every (inputs and/or outputs) pins
note. when using the n type it wont matter if there is others defined:
{"n":"i16", "x4":"f32"}
will result in
{"n":"i16"}
I have also planned a audio object file doc tag:
/*GUI_NODE_DOC "AudioConvert_I16toF32"
<h3>Summary</h3>
<div class=tooltipinfo>
<p>(summary text)</p>
</div>
<h3>Audio Connections</h3>
<table class=doc align=center cellpadding=3>
<tr class=top><th>Port</th><th>Purpose</th></tr>
<tr class=odd><td align=center>In n</td><td>Input signal #n</td></tr>
<tr class=odd><td align=center>Out 0</td><td>Sum of all inputs</td></tr>
</table>
<h3>Functions</h3>
<p class=func><span class=keyword>gain</span>(channel, level);</p>
<p class=desc>function description goes here</p>
<h3>Notes</h3>
GUI_NODE_DOC*/
that can be included and automatically parsed by the tool import.
The inputTypes and outputTypes are used in the tool to match the wires when they are connected
so that non matching IO types cannot be connected.
If the data type are not defined then the default i16 is used, which is the case for all official Audio Objects.
To make it easier to import and use the nodeAddons saved with the project-JSON
I had to change the "project" structure from:
to:
which is a thing I have been wanted to do for a long time anyway,
because it makes it easier/faster to export to cpp code/classes. (specially for extremely huge and complex designs)
Also the internal structure/usage could benefit from this as it would make it little faster.
Even if it's allready optimized to only render objects that are selected/moved.
OK that was all the background information.
Node definitions manager "manual"
Is opened from the tool "main menu" found in the (top right) side of the save button.
It consist of three parts
1. Left panel:
Tree view of the nodetypes grouped into groups.
The first two are readonly (embedded into the tool)
the 3:rd is autogenerated readonly and contains the "tab"-classes
2. Right panel:
contains either the selected group or node def in json format,
this can be edited and saved for "non readonly" items.
3. Menu Toolbar
add:
single add new group/node def.
only add new group is having a form to fill in,
the add new node def. is using json to edit the data.
new group dialog:
new node def. type dialog:
import:
from url: downloads the node def. from a internet url
(server need to allow CORS, best is to use Github)
from file: not implemented yet (should work just like the above)
refresh: not implemented yet (should update the current addon from the url given)
remove: removes current selected group/node def. (only for "non readonly" items)
note. using a confirm dialog
export: exports all current groups and node def. to a json file
(can only be imported by uploading it to Github in a html file using the DesignToolNodes.html format above)
this is only intented for debugging but can be used to export node def. when creating own libraries
apply: saves and applying the current edited item ("non readonly" can only be saved)
How to use import from URL dialog (and how it works)
the URL:s can be in the following formats:
if it ends with html
and starts with "https://github.com" then the url is changed into the raw file url format,
("https://raw.githubusercontent.com")
else the url is not changed
note. the NodeDefinitions format can either be "classic" format
or the new group based format.
else if it starts with either
"https://github.com" or "https://api.github.com"
and is a url to a folder
then all the .h files in the folder is downloaded and
scanned for the chipaudette //GUI: tags described above.
this is shown in a new form dialog
after the correct supported url is given
it shows what format it's in
and enables the download button
if the old NodeDefinitions html format is used
then both the Mode and UID fields are shown so
that the user can input the UID needed.
When everyting is filled in and the download is completed the OK button is enabled,
which will when pressed, import the downloaded node defs.
Maybe future features:
* download required files required by the node addons
usable when exporting as class based zip file,
which will then include all files required for the "project"
* import from local html file (maybe not used anyway)
* import from local zip file
which will also contain all required lib code files
Please feel free to post if there is something that you don't understand or if something is missing.
note.
the above formats is not set in stone, and suggestions are welcome .