Custom block global section

Issue #70 new
Poindexter Frink created an issue

A user could add tables and other static data through a <globals> block element.

The C code contained therein could be placed at the top of the dynamic code section in the global scope.

This feature would permit static data (like samples), shared data (like inter-block communication without wires e.g.: singleton master/slave)) or custom functions.

Comments (5)

  1. Poindexter Frink reporter

    Static data is actually possible by using a static variable inside the inlined function body. I did not know this about inlined functions!

    So a global section would only add custom functions and wireless inter-block communication.

  2. snoozee

    Added !

        <global>
        <![CDATA[
    
        struct {
            int32_t a;
            int32_t b;
            int32_t c;
        } customData ;
    
    static inline int32_t someMethod(int32_t num){
           return num + num;
    }
    
        ]]>
        </global>   
    
  3. Poindexter Frink reporter

    It occurs to me that if several different blocks all had an identical global element, that they will need to be deduplicated.

    For example, look at the envelopes. They all have a small array that contains the logarithmic curve data. They could all use the same instance of a global array.

    Perhaps the global section needs some sort of identifier to indicate that the data is common. Maybe a name attribute. So like:

    <global name="log_curve">
        <![CDATA[
        static const uint8_t log_curve[8] = { 0, 61, 111, 152, 186, 213, 236, 255 };
        ]]>
    </global>
    

    That way, if the user includes more than one envelope, the data would not be duplicated.

    Also, it allows a sort of "library function". Block designers could include pre-defined global sections that have some function. Patches could include multiple blocks that include the same functions without each having to define a unique method name.

  4. snoozee

    yeah I've addressed that too, so there should be no problem with duplicates. However your suggestion about using name attribute would make it more convenient than code/string check up. Will look into that !

  5. Log in to comment