Patch reusability--patch as a "class?"
  • I have found patches to be a great way to encapsulate some functionality in Adulus that I'd like to reuse. For instance, I made one that takes an input frequency and translates it up or down by half-steps, over some range, for harmonizing by a fixed interval. I used five copies of it with one recent synth project.

    The word "copy" points to my problem.

    The problem I have is that should I decide to modify that patch, I have to manually replace all instances of it in my project, or else edit each in the same way. very time-consuming and prone to errors.

    Am I missing something?

    I have some experience (not recently, believe me!) with "object-oriented programming," where I'd write some code for a "class" and "instantiate" it wherever I needed it. If I found a problem with the code or wanted to change how it operated in some way, I could just make my changes to the code for that class and all instances that point to that class would be changed.

    is there a similar mechanism in Adults?
  • You aren't missing something, that is how Audulus works and not how max and pd work.

    It's a trade-off. You don't have to import libraries of sub-patches like with max or pd to use other people's sub-patches when you download from the forum. You can copy and paste the part you want to use and open it up and see how it works, which doesn't always work with the alternate approach. Audulus files don't reference anything other than their own file and the node library when constructing the patch. With the system max and pd use, you have to maintain a local file structure where the platonic version of the some sub-patch resides, make a change there and you could mess up some other patch which used the old version (which i regularly did). Audulus already has a big learning curve, so having people sort out their local file structures would likely be more effort than many would put with. Another benefit of the current implementation of Audulus is that older patches with antiquated versions of your sub patch don't stop working when you update sub-patches in your collection.

    Working together with people on the forum is how I learned to patch in Audulus, and there are lots of useful bits that I have stashed over the years, as well as conventions I picked up, like using 1/octave instead of hz for sequencing. Feel free to post anything you like and you can probably get some advice on how to patch a little easier.
  • I was thinking about this lately. We might be able to have both options: copy and reference. I would propose:

    Copy should be the default because it's a good option for keeping things from breaking.

    Referencing would work at load time. So a Patch node could reference another file. Audulus would do a cut & paste internally of the file's contents into the sub-patch. If you open a reference, it would open the other file, probably in a new window on macOS.

    This way advanced users could build complex multi-file projects.

    What do you guys think?
  • @Taylor that sounds like a good option to me.
  • What could go wrong?
  • I'm not sure that the added complexity of an #include mechanism would be worth it. While it would eliminate some redundancy, it would not provide any benefit from a performance perspective. The sub-patch mechanism already provides a way to modularize code and effectively hides the internal details. The existing mechanism (at least in macOS) allowing you to add items to the build menu works pretty well for me. I can see some issues with file location involved with a reference scheme. Would there be a "well known" directory for referenced files, or would the path be embedded in the link? Either approach would potentially cause portability problems, particularly with respect to a mixed macOS/iOS/Windows environment. Sharing patches would also become more difficult. Without some dependency mechanism and versioning, you could never be sure that a given patch would function. I've found version control to be one of the more challenging aspects of programming in Audulus for me. At least now when I fix a bug, I don't have to worry about whether I've broken any older patches. Overall, I think I prefer the existing approach, although referencing might prove useful for some people's programming style. If you do include it, an option to create a file with all of the referenced content embedded would be useful for patch sharing. It's all somewhat moot in any case, without some kind of online user library. I think an effective online library coupled with the ability to add items to the build menu on iOS would ultimately prove more useful than referencing.