Hi Jonathan,
Yes, yes! I'd love a good web-based editor! And I have looked into this for a while, but being not a priority, I had put it aside for now... How are your experiments doing? You should definitely keep me updated on this.
> Is there some way for webpd to look inside one of the page's DOM
elements for patch file data (perhaps a <pre> with a
particular id)?
Indeed, to load a patch you just pass as string to "Pd.loadPatch" function. That string is the whole contents of a Pd patch. So in the examples, I load the patch with AJAX :
https://github.com/sebpiq/WebPd/blob/master/examples/phasor/index.html#L10 but you could definitely do something like this :
<script id="patch" type="text/x-puredata">
#N canvas 51 96 762 387 10;
#X obj 127 161 dac~;
</script>
<script>
var patch = Pd.loadPatch(document.getElementById('patch').innerHTML)
Pd.start()
</script>
Or even something like this :
<script>
var patch = Pd.loadPatch('#N canvas 51 96 762 387 10;\n#X obj 127 161 dac~;')
Pd.start()
</script>
So basically WebPd just takes a Pd file. How you obtain that file is then up to you : AJAX, embedded in the HTML page, etc ...
> Could the data received from the AJAX call be inserted into the
same DOM element? That way you could save the html file and the
patch data would get saved with it.
Yes you could do that. It is trivial with JavaScript. Even easier if you use a DOM manipulation library such as jQuery!
>
Can I add nodes after the patch has loaded?
I like the idea to add a scripting layer to Pd. That way you could do something that no other sound programming language has achieved yet, and put together graphical programming and scripting using each method when most appropriate (Graphical programming is great for a DSP graph, but a pain in the ass for control flow and states, scripting is much more powerful for that). So yeah you can already do that with WebPd, though it is not fully tested yet so use with caution.