1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
  
     | 
    
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 2008 (1.71)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>Entry Points</TITLE>
<META NAME="description" CONTENT="Entry Points">
<META NAME="keywords" CONTENT="mma-plugins">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="LaTeX2HTML v2008">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
<LINK REL="STYLESHEET" HREF="mma-plugins.css">
<LINK REL="next" HREF="node3.html">
<LINK REL="previous" HREF="node1.html">
<LINK REL="up" HREF="mma-plugins.html">
<LINK REL="next" HREF="node3.html">
</HEAD>
<BODY  bgcolor="#ffffff">
<DIV CLASS="navigation"><!--Navigation Panel-->
<A NAME="tex2html36"
  HREF="node3.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html34"
  HREF="mma-plugins.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html28"
  HREF="node1.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>   
<BR>
<B> Next:</B> <A NAME="tex2html37"
  HREF="node3.html">Preset Values</A>
<B> Up:</B> <A NAME="tex2html35"
  HREF="mma-plugins.html">Plugins</A>
<B> Previous:</B> <A NAME="tex2html29"
  HREF="node1.html">Easy Guide</A>
<BR>
<BR></DIV>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL CLASS="ChildLinks">
<LI><A NAME="tex2html38"
  HREF="node2.html#SECTION00210000000000000000">run(param-list):</A>
<LI><A NAME="tex2html39"
  HREF="node2.html#SECTION00220000000000000000">trackRun():</A>
<LI><A NAME="tex2html40"
  HREF="node2.html#SECTION00230000000000000000">printUsage():</A>
</UL>
<!--End of Table of Child-Links-->
<HR>
<H1><A NAME="SECTION00200000000000000000">
Entry Points</A>
</H1>
<P>
Following are simple examples for each entry point recognized by
<FONT Face="Serif"  Color="Navy"><I>MMA</I></FONT> .
<P>
<H1><A NAME="SECTION00210000000000000000">
run(param-list):</A>
</H1>
<P>
The <SMALL>RUN()</SMALL> function is executed when a 
<FONT Face="Serif"  Color="Navy"><I>MMA</I></FONT>  script encounters
the plugin's keyword in a non-track context. following is a simple bit
of Python code we used in the <TT><SPAN  CLASS="textbf">hello</SPAN></TT> example shipped with
<FONT Face="Serif"  Color="Navy"><I>MMA</I></FONT> .
<P>
<DL COMPACT>
<DT></DT>
<DD><PRE>
def run(l):
    print("Hello. This is the run() function in the MMA plugin.")
    print("We are at line %s in the MMA file %s." % (gbl.lineno, gbl.infile))
    if l:
        print("Args passed are:")
        for i in l:
            print(i)
</PRE>
</DD>
</DL>
<P>
In the first line we pass the parameter ``l''. This is set by the
main 
<FONT Face="Serif"  Color="Navy"><I>MMA</I></FONT>  parser and contains a list of any parameters passed to the
@H<SMALL>ELLO</SMALL> function. 
<P>
We leave the rest of the program as an exercise.
<P>
<H1><A NAME="SECTION00220000000000000000">
trackRun():</A>
</H1>
<P>
The next entry point is the <SMALL>TRACK</SMALL>R<SMALL>UN()</SMALL> function. This is
executed when the parser finds the plugin's keyword in a track
context. For example:
<P>
      <Table Hspace="40%" CellSpacing=0 CellPadding=10 BGColor="OldLace" Border=3>
        <tr><td>
    <B>Plectrum-Main  @Hello My command params  </B> 
   
	    </td></tr>
      </Table>
<P>
The difference between the simple and track versions is that
trackRun() is also passed the ``name'' of the track. For example,
the above example will have the first parameter set to the string
``PLECTRUM-MAIN''. Using the following code you can set a variable
(in this case ``self'') to point to the Plectrum-Main class.
<P>
<DL COMPACT>
<DT></DT>
<DD><PRE>
    self = gbl.tnames[name]
</PRE>
</DD>
</DL>
<P>
For this to work, you will need to import 
<FONT Face="Serif"  Color="Navy"><I>MMA</I></FONT> 's global module into
the namespace. We suggest you do that at the top of your plugin.py
module:
<P>
<DL COMPACT>
<DT></DT>
<DD><PRE>
    import MMA.gbl as gbl
</PRE>
</DD>
</DL>
<P>
Using the ``self'' variable you now have access to all of the
variables associated with the track. You'll have to dig though the
code a bit, but a few examples (most of the settings are in the form
of a list with a value for every sequence point in your song):
<P>
<DL COMPACT>
<DT></DT>
<DD><PRE>
  self.volume  -- track specific volume 
  self.articulate -- track specifc articulations
  self.sticky -- a True/False setting
</PRE>
</DD>
</DL>
<P>
For more variables we suggest you examine the pat.py module.
<P>
Yes, you can change these values from your plugin. Is that a good
idea? Probably not! For an alternate method to change settings read
the ``returning values'' chapter, below.
<P>
<H1><A NAME="SECTION00230000000000000000">
printUsage():</A>
</H1>
<P>
The final entry point is the <SMALL>PRINT</SMALL>U<SMALL>SAGE()</SMALL> command. It receives
no parameters and is only called when 
<FONT Face="Serif"  Color="Navy"><I>MMA</I></FONT>  finds a <SPAN  CLASS="textbf">-I
  plugin-name</SPAN> command line argument. This code is then interpreted
and the program ends.
<P>
<SMALL>PRINT</SMALL>U<SMALL>SAGE()</SMALL> should print a simple usage message. 
<P>
<DIV CLASS="navigation"><HR>
<!--Navigation Panel-->
<A NAME="tex2html36"
  HREF="node3.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html34"
  HREF="mma-plugins.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html28"
  HREF="node1.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>   
<BR>
<B> Next:</B> <A NAME="tex2html37"
  HREF="node3.html">Preset Values</A>
<B> Up:</B> <A NAME="tex2html35"
  HREF="mma-plugins.html">Plugins</A>
<B> Previous:</B> <A NAME="tex2html29"
  HREF="node1.html">Easy Guide</A></DIV>
<!--End of Navigation Panel-->
<ADDRESS>
Bob van der Poel
2016-06-11
</ADDRESS>
</BODY>
</HTML>
 
     |