Code Editor for GENEXP
Dear all,
I am currently writing a lot of gen code (> 500 lines of code) and I am looking therefore for a external code editor that can be linked to max 7. In the forum I found that some people used sublime text for this and I personally like it. Here are my questions:
- as Sublime is a text editor how can I integrate it into max? I found only some instructions which are not comprehensible ...
Currently i copy the gen expo code to sublime text, then write additional code there, copy the whole code in sublime text and then paste it back to max7. There (hopefully) must be a better way.
If there are any other solutions out there I am also happy to hear :-)
Best regards
jo
Sublime is currently the best alternative.
My workflow is saving the gen code to a genexpr file and edit the file in external editor directly. Always copy codes from external editor to gen codebox and never copy codes from codebox to external editor.
BTW if you use VS Code you can find the converted (from sublime text version) plugin here: https://github.com/larme/GenExprForVSCode
Thanks guys!
Copying text shouldn't be necessary. If, for example, the genexpr defines a function "main", e.g.:
// save as mycode.genexpr
main(input) {
return 74;
}
And the gen patcher is a codebox like this:
require "mycode.genexpr"
out1 = main(in1);
Then whenever you edit mycode.genexpr, and save the file, it should be automatically reloaded in the gen~ patcher. Try it!
(Plus, when gen~ reloads, it remembers param, history, data etc. values, which should keep things smooth)
Thanks Graham. Will try this out!
BR
Jo
Graham, tried it out but need another advice.
As I understood your solution works in a way to "outsource" function code to an external text file that can be edited in sublime and is automatically reloaded into the gen world. Fine.
As I am already having over 800 Lines of code I would like to be able to edit all my code in sublime. This would then mean (please correct me if I am wrong) that in the Codebox there is only one line of code (e.g require "mycode.genexpr"). The rest of the code would reside in a separate textfile that can be edited outside of max7.
I see a problem as non of my patches worked on the first run. I always had some errors and needed to debug the code. As the code will not be visible within the codebox any more I would then also not get the high lite of specific lines of code where an error occurred. So this would mean I still would need to copy the code over to the code box.
Is my assumption right?
BR
Jo
a) you would still need to declare global param/buffer/etc. and the `out1 =` lines in the gen patcher's codebox; my example just made those as simple as possible so that the rest can be in the genexpr file.
b) there's no reasonable way at present to route error/warning messages through to an external editor for highlighting there. You'd still need to keep the Max window present in view while editing code, and identify line numbers manually.
There *is* a way to avoid (a) using a bit of javascript (see example below), but no way to avoid (b).
Hello Graham,
thanks the clarification.
BR
Jo
Hey all! In case anyone is prefers Atom, I've ported a syntax highlighting package for GenExpr from Sublime to Atom . It can be found here: https://github.com/okhick/language-GenExpr
Enjoy!
Has anyone found a way to get the patch, or Gen~, to update?
You can change the Max patch code in a text editor (the formatting isn't very friendly though) then restart the patch and the changes will be there. Really if you're doing synthesis in Gen then you need the audio 'feedback' to be instant from saving. If there is a more responsive method (aside from copy paste) then a VS code extension could be made. I'm not suggesting OP makes an extension though, it would just be a very useful tool.