Javascript Argument library
The following standardised library for handling argument setup is being implemented using the new #include mechanism. This library provides the same argument and attribute parsing as non-javascript patchers. Arguments are read in order, and associated with the correct variable. Attributes (named @ATTRIBUTE/value pairs) are properly named and declared, and behave the same way as patcher attributes. Syntax example
Note : the nature of argument and attribute handling requires |
Javascript Inlet/Outlet library
The following standardised library for handling inlet and outlet setup is being implemented using the new #include mechanism. Syntax example
|
Javascript Includes Part2
Having implemented an include mechanism, and a main javascript code template, it made sense to develop a standard include-file template as well. When starting to do so, I took the time to tidy up the original code template, including standardising a certain amount of descriptive documentation. One thing that became clear was that the amount of comments et.c. added significantly to the size of an included file. As a result, I decided to provide a method for removing this overhead, in the form of a 'cleaned' include file, stripped of comments and extraneous whitespace. A 'clean' include file would be file-suffixed '.h.js', and the 'full' version, used for code maintenance would retain the '.js' suffix. The original include code was modified to use a 'clean' include file first, if present, or, in its absence, the 'full' version. To simplify the process of 'cleaning' header files, a simple perl utility, called strippa was written capable of generating a 'clean' include file from every javascript file in directory. The utility is also capable of modifying the self-reporting 'post' messages in include files. The revised requirements for an include file are thus: Requirements:
|
Javascript Includes
A basic #include type functionality was implemented to allow the easier and more modular development of Javascript within MAX/MSP. This would allow the use of reusable Javascript code in a clean and straightforward fashion, The #include functionality was modelled after the C preprocessor, allowing the inclusion of local Javascript files as well as those in a central 'library' location (chosen to be %MAXROOT%/Cycling '74/jsincludes) Requirements:
The use of this mechanism is as follows
This code should have been fairly straightforward, but issues with line-end characters caused a certain amount of
headscratching. The current code, which grabs lines one at a time, might be slower, but it more forgiving
of EOL issues. The implementation reads all the included module code into a single buffer then |
Javascript in MAX/MSP
Having decided there were numerous advantages in using Javascript within MAX/MSP for the development process, it became important to consider the development process. After carrying out some brief tests to ensure that the jsui was indeed capable of handling the kind of UI interactivity required, I concentrated on structuring my Javascript development in a more convenient and rationalised manner. One of the first stages was sidestepping the very limited coding envirinment included in MAX (a very primitive text editor) in favour of the Komodo IDE, and use of the command
which causes MAX/MSP to reload a js or jsui object when it has been modified. This combination
meant that I could edit documents in a fully-fledged IDE, with minimal overhead.
:: maxmsp :: javascript
|
Javascript Standardised IO methods
The following functionality was developed to allow a consistent approach to MAX/MSP IO from a js/jsui object:
(*)not fully implemented as yet :: maxmsp :: javascript
|
Javascript standardised code
The following public functions have been or will be implemented in the template as 'hardcoded' methods, or stubs, providing handling of a standardised MAX message set. (hardcoded public functions)
(stubs for public functions)
The following private functions are implemented in the template as 'hardcoded' methods, or stubs, to support the implementation of the standardised MAX message set. (hardcoded private functions)
(stubs for private functions)
Some of these methods are implemented using 'eval', which is known to be inefficient.
All of this usage of eval currently occurs at the initialisation stage, but a method for avoiding repeated calls to
eval is required. This may be resoved by my intention to try and implement :: maxmsp :: javascript
|
Javascript : template js document
Javascript maps slightly awkwardly to the MAX/MSP paradigm, but much has been provided to provide a framework which 'hooks in' to the MAX box/patcher model. However, I realised that much of the code required to handle this would be duplicated from one js/jsui object to the next, so one of the first taks I undertook was to develop a 'template' javascript document, which was (a) well structured and (b) contained as much useful reusable io functionality as possible. The current implementation of this template provides a consistent framework for the development of new javascript objects, with the folllwing advantages
:: maxmsp :: javascript
|
Reboot...
June 2012
|