home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 066.lha / MidiDev / func.doc < prev    next >
Encoding:
Text File  |  1986-11-20  |  19.3 KB  |  672 lines

  1. TABLE OF CONTENTS
  2.  
  3. midi.library/CreateMDest
  4. midi.library/CreateMRoute
  5. midi.library/CreateMSource
  6. midi.library/DeleteMDest
  7. midi.library/DeleteMRoute
  8. midi.library/DeleteMSource
  9. midi.library/FindMDest
  10. midi.library/FindMSource
  11. midi.library/FreeMidiMsg
  12. midi.library/GetMidiMsg
  13. midi.library/LockMidiBase
  14. midi.library/MidiMsgLength
  15. midi.library/MidiMsgType
  16. midi.library/ModifyMRoute
  17. midi.library/MRouteDest
  18. midi.library/MRoutePublic
  19. midi.library/MRouteSource
  20. midi.library/PutMidiMsg
  21. midi.library/PutMidiStream
  22. midi.library/UnlockMidiBase
  23. midi.library/CreateMDest
  24.  
  25. NAME
  26.      CreateMDest -- Create a MIDI destination node
  27.  
  28. SYNOPSIS
  29.      dest = CreateMDest (name,image)
  30.      d0                  a0   a1
  31.      struct MDest *dest;
  32.      char *name;
  33.      struct Image *image;
  34.  
  35. FUNCTION
  36.      Creates a new MIDI destination node.  A MsgPort is created and 
  37.      linked into the new MDest that will signal you when this MDest gets 
  38.      a message (see msg routines for more info).  If a name is given, 
  39.      this node will be placed in the library's public destination list 
  40.      (so it can be located with FindMDest()).  If name is NULL a private 
  41.      node is created.  The image supplied can be used by graphics-based 
  42.      patch bay applications and will only be used for public nodes.  
  43.      image may be NULL if no image is to be supplied.  You are 
  44.      responsible for deleting any nodes you create when you are done with 
  45.      them.
  46.  
  47. INPUTS
  48.      name - pointer to a null-terminated string or NULL
  49.      image - pointer to an Intuition Image structure or NULL
  50.  
  51. RESULTS
  52.      dest - pointer to the new MDest node or NULL on failure.
  53.  
  54. SEE ALSO
  55.      DeleteMDest, FindMDest
  56.  
  57. midi.library/CreateMRoute
  58.  
  59. NAME
  60.      CreateMRoute -- Create an MRoute
  61.  
  62. SYNOPSIS
  63.      route = CreateMRoute (source,dest,routeinfo)
  64.      d0                    a0     a1   a2
  65.      struct MRoute *route;
  66.      struct MSource *source;
  67.      struct MDest *dest;
  68.      struct MRouteInfo *routeinfo;
  69.  
  70. FUNCTION
  71.      Creates and links a new MRoute into a MIDI Source node and a MIDI 
  72.      Dest node.  This routine assumes that both source and dest are 
  73.      private nodes that you created.  To route to public nodes use one of 
  74.      the other MRoute creation routines.  The MRouteInfo structure 
  75.      defines the new connection.  You need not preserve the MRouteInfo 
  76.      structure after calling this routine since it is copied into the 
  77.      newly created MRoute structure.  You are responsible for deleting 
  78.      any MRoute's you create.
  79.  
  80. INPUT
  81.      source - pointer to an MSource node
  82.      dest - pointer to an MDest node
  83.      routeinfo - pointer to an MRouteInfo structure defining this MRoute
  84.  
  85. RESULTS
  86.      route - a pointer to a new MRoute structure or NULL on failure.
  87.  
  88. SEE ALSO
  89.      MRouteSource, MRouteDest, MRoutePublic, ModifyMRoute, DeleteMRoute
  90.  
  91. midi.library/CreateMSource
  92.  
  93. NAME
  94.      CreateMSource -- Create a MIDI source node
  95.  
  96. SYNOPSIS
  97.      source = CreateMSource (name,image)
  98.      d0                      a0   a1
  99.      struct MSource *source;
  100.      char *name;
  101.      struct Image *image;
  102.  
  103. FUNCTION
  104.      Creates a new MIDI source node.  If a name is given, this node will 
  105.      be placed in the library's public source list (so it can be located 
  106.      with FindMSource()).  If name is NULL a private node is created.  
  107.      The image supplied can be used by graphics-based patch bay 
  108.      applications and will only be used for public nodes.  image may be 
  109.      NULL if no image is to be supplied.  You are responsible for 
  110.      deleting any nodes you create when you are done with them.
  111.  
  112. INPUTS
  113.      name - pointer to a null-terminated string or NULL
  114.      image - pointer to an Intuition Image structure or NULL
  115.  
  116. RESULTS
  117.      source - pointer to the new MSource node or NULL on failure.
  118.  
  119. SEE ALSO
  120.      DeleteMSource, FindMSource
  121.  
  122. midi.library/DeleteMDest
  123.  
  124. NAME
  125.      DeleteMDest -- Delete a MIDI destination node
  126.  
  127. SYNOPSIS
  128.      DeleteMDest (dest)
  129.                   a0
  130.      struct MDest *dest;
  131.  
  132. FUNCTION
  133.      Removes and frees an MDest created by CreateMDest().  Any MRoute's 
  134.      connected to this MDest will be unlinked.  Any messages waiting at 
  135.      this MDest will be freed.  You should only delete nodes that you 
  136.      created.
  137.  
  138. INPUTS
  139.      dest - pointer to the MDest node to delete
  140.  
  141. RESULTS
  142.      none
  143.  
  144. SEE ALSO
  145.      CreateMDest, FindMDest
  146.  
  147. midi.library/DeleteMRoute
  148.  
  149. NAME
  150.      DeleteMRoute -- Delete an MRoute
  151.  
  152. SYNOPSIS
  153.      DeleteMRoute (route)
  154.                    a0
  155.      struct MRoute *route;
  156.  
  157. FUNCTION
  158.      Unlinks and frees a route previously created with one of the routing 
  159.      functions.  You should only delete routes that you created.  You 
  160.      will still need to do this even if both the source and dest have 
  161.      been deleted in order to free up the memory allocated to the route.
  162.  
  163. INPUTS
  164.      route - pointer to the MRoute to delete
  165.  
  166. RESULTS
  167.      none
  168.  
  169. SEE ALSO
  170.      CreateMRoute, MRouteSource, MRouteDest, MRoutePublic, ModifyMRoute
  171.  
  172. midi.library/DeleteMSource
  173.  
  174. NAME
  175.      DeleteMSource -- Delete a MIDI source node
  176.  
  177. SYNOPSIS
  178.      DeleteMSource (source)
  179.                     a0
  180.      struct MSource *source;
  181.  
  182. FUNCTION
  183.      Removes and frees an MSource created by CreateMSource().  Any 
  184.      MRoute's connected to this MSource will be unlinked.  You should 
  185.      only delete nodes that you created.
  186.  
  187. INPUTS
  188.      source - pointer to the MSource node to delete
  189.  
  190. RESULTS
  191.      none
  192.  
  193. SEE ALSO
  194.      CreateMSource, FindMSource
  195.  
  196. midi.library/FindMDest
  197.  
  198. NAME
  199.      FindMDest -- Find a public MIDI destination node
  200.  
  201. SYNOPSIS
  202.      dest = FindMDest (name)
  203.      d0                a0
  204.      struct MDest *dest;
  205.      char *name;
  206.  
  207. FUNCTION
  208.      Finds a public MIDI destination node by name if it exists.  In order 
  209.      to ensure that this node remains valid you should call 
  210.      LockMidiBase() prior to calling this routine.
  211.  
  212. INPUTS
  213.      name - pointer to the null-terminated name to find
  214.  
  215. RESULTS
  216.      dest - pointer to the requested MDest node or NULL if not found.
  217.  
  218. SEE ALSO
  219.      CreateMDest, DeleteMDest, LockMidiBase, UnlockMidiBase
  220.  
  221. midi.library/FindMSource
  222.  
  223. NAME
  224.      FindMSource -- Find a public MIDI source node
  225.  
  226. SYNOPSIS
  227.      source = FindMSource (name)
  228.      d0                    a0
  229.      struct MSource *source;
  230.      char *name;
  231.  
  232. FUNCTION
  233.      Finds a public MIDI source node by name if it exists.  In order to 
  234.      ensure that this node remains valid you should call LockMidiBase() 
  235.      prior to calling this routine.
  236.  
  237. INPUTS
  238.      name - pointer to the null-terminated name to find
  239.  
  240. RESULTS
  241.      source - pointer to the requested MSource node or NULL if not found.
  242.  
  243. SEE ALSO
  244.      CreateMSource, DeleteMSource, LockMidiBase, UnlockMidiBase
  245.  
  246. midi.library/FreeMidiMsg
  247.  
  248. NAME
  249.      FreeMidiMsg -- Free a MIDI message returned by GetMidiMsg
  250.  
  251. SYNOPSIS
  252.      FreeMidiMsg (msg)
  253.                   a0
  254.      UBYTE *msg;
  255.  
  256. FUNCTION
  257.      Frees a message returned by GetMidiMsg().
  258.  
  259. INPUTS
  260.      msg - pointer to a UBYTE array containing one MIDI message
  261.  
  262. RESULTS
  263.      none
  264.  
  265. SEE ALSO
  266.      GetMidiMsg()
  267.  
  268. midi.library/GetMidiMsg
  269.  
  270. NAME
  271.      GetMidiMsg -- Get the next MIDI message from an MDest
  272.  
  273. SYNOPSIS
  274.      msg = GetMidiMsg (dest)
  275.      d0                a0
  276.      UBYTE *msg;
  277.      struct MDest *dest;
  278.  
  279. FUNCTION
  280.      Returns the next message received at a MIDI destination or NULL if 
  281.      no more messages are present.  This is the preferred method of 
  282.      receiving MIDI messages from an MDest since it strips off and frees 
  283.      the packet that carried this message to the MDest's MsgPort 
  284.      (dest->DestPort).  This routine will not wait around for the next 
  285.      message since you might want to do something else between messages.  
  286.      If you want to wait, just Wait for the signal allocated to the 
  287.      MDest's MsgPort:
  288.  
  289.           Wait (1L << dest->DestPort->mp_SigBit);
  290.  
  291.      Once you have dealt with the messages you have received you should 
  292.      dispose of them by calling FreeMidiMsg().  Unlike Intuition, 
  293.      midi.library is not halted until you free these messages so you can 
  294.      hang on to them as long as you like.  Just free them when you are 
  295.      done with them.
  296.  
  297.      Be aware that the more messages you keep without freeing the more 
  298.      fragmented the Amiga's memory will become.  If you plan to keep a 
  299.      large number of messages you are probably better off allocating a 
  300.      buffer and copying the messages to it.
  301.  
  302. INPUTS
  303.      dest - pointer to the MDest node to receive from
  304.  
  305. RESULTS
  306.      msg - pointer to a UBYTE array containing one MIDI message or NULL
  307.              if there are no more messages at this MDest
  308.  
  309. SEE ALSO
  310.      FreeMidiMsg, MidiMsgType, MidiMsgLength, PutMidiMsg
  311.  
  312. midi.library/LockMidiBase
  313.  
  314. NAME
  315.      LockMidiBase -- lock the lists in the library base
  316.  
  317. SYNOPSIS
  318.      LockMidiBase()
  319.  
  320. FUNCTION
  321.      Gains exclusive access to the Source and Dest lists in the library 
  322.      base.  This will block any other tasks attempts to Create, Delete, 
  323.      or Find MSource and MDest nodes.  Use this if you wish to examine a 
  324.      public node.  The route linkages within the nodes are not protected 
  325.      by this.  Currently you need to Forbid() to prevent them from 
  326.      changing.
  327.  
  328.      Calls to LockMidiBase() may be nested, but each call must be matched 
  329.      with a call to UnlockMidiBase().
  330.  
  331. INPUTS
  332.      none
  333.  
  334. RESULTS
  335.      none
  336.  
  337. SEE ALSO
  338.      UnlockMidiBase
  339.  
  340. midi.library/MidiMsgLength
  341.  
  342. NAME
  343.      MidiMsgLength -- Determine the length of a MIDI message
  344.  
  345. SYNOPSIS
  346.      length = MidiMsgLength(msg)
  347.      d0                     a0
  348.      ULONG length;
  349.      UBYTE *msg;
  350.  
  351. FUNCTION
  352.      Returns the length in bytes of a MIDI message.  The message length 
  353.      includes the status byte.  For system exclusive messages the EOX 
  354.      status byte at the end is also included.
  355.  
  356. INPUTS
  357.      msg - pointer to a UBYTE array containing one MIDI message
  358.  
  359. RESULTS
  360.      length - length of the message in bytes.  For valid messages this
  361.                 will be at least 1.  0 is returned for invalid messages.
  362.  
  363. SEE ALSO
  364.      MidiMsgType
  365.  
  366. midi.library/MidiMsgType
  367.  
  368. NAME
  369.      MidiMsgType -- Determine the type of a MIDI message
  370.  
  371. SYNOPSIS
  372.      type = MidiMsgType(msg)
  373.      d0                 a0
  374.      UWORD type;
  375.      UBYTE *msg;
  376.  
  377. FUNCTION
  378.      Returns the type a MIDI message.  The flags are defined in 
  379.      midi/midi.h (or midi/midi.i) and are the same ones used in 
  380.      MRouteInfo.MsgFlags.  Other than the obvious, some special message 
  381.      handling takes place:
  382.  
  383.           Controller changes for ctrl # 122 - 127 return MMF_MODE.
  384.  
  385.           Note On messages with velocity == 0 return MMF_NOTEOFF.
  386.  
  387.           EOX and all invalid messages return 0 (an EOX by itself is not 
  388.           considered a valid message)
  389.  
  390. INPUTS
  391.      msg - pointer to a UBYTE array containing one MIDI message
  392.  
  393. RESULTS
  394.      type - message type
  395.  
  396. SEE ALSO
  397.      MidiMsgLength
  398.  
  399. midi.library/ModifyMRoute
  400.  
  401. NAME
  402.      ModifyMRoute -- Modify an existing an MRoute
  403.  
  404. SYNOPSIS
  405.      ModifyMRoute (route,newrouteinfo)
  406.                    a0    a1
  407.      struct MRoute *route;
  408.      struct MRouteInfo *newrouteinfo;
  409.  
  410. FUNCTION
  411.      Modifies the MRouteInfo structure in an existing route.  Any 
  412.      messages already delivered to this MRoute's MDest, whether received 
  413.      or not, are not affected.  As with CreateMRoute, the supplied 
  414.      MRouteInfo structure need not be kept after calling this routine:  
  415.      it is merely a template that is copied to the MRoute.
  416.  
  417. INPUT
  418.      route - pointer to an MRoute to modify
  419.      routeinfo - pointer to the new MRouteInfo for this MRoute
  420.  
  421. RESULTS
  422.      none
  423.  
  424. SEE ALSO
  425.      CreateMRoute, MRouteSource, MRouteDest, MRoutePublic, DeleteMRoute
  426.  
  427. midi.library/MRouteDest
  428.  
  429. NAME
  430.      MRouteDest -- Create an MRoute from a public MSource to a private 
  431.      MDest
  432.  
  433. SYNOPSIS
  434.      route = MRouteDest (sourcename,dest,routeinfo)
  435.      d0                  a0         a1   a2
  436.      struct MRoute *route;
  437.      char *sourcename;
  438.      struct MDest *dest;
  439.      struct MRouteInfo *routeinfo;
  440.  
  441. FUNCTION
  442.      Routes an MDest to a public MSource.  This is shorthand for:
  443.  
  444.           LockMidiBase();
  445.           if (source = FindMSource(sourcename))
  446.                route = CreateMRoute(source,dest,routeinfo);
  447.           UnlockMidiBase();
  448.  
  449. INPUT
  450.      sourcename - pointer to null-terminated name of a public MSource
  451.      dest - pointer to an MDest node
  452.      routeinfo - pointer to an MRouteInfo structure defining this MRoute
  453.  
  454. RESULTS
  455.      route - a pointer to a new MRoute structure or NULL on failure.
  456.  
  457. SEE ALSO
  458.      CreateMRoute, MRouteSource, MRoutePublic, ModifyMRoute, DeleteMRoute
  459.  
  460. midi.library/MRoutePublic
  461.  
  462. NAME
  463.      MRoutePublic -- Create an MRoute from a public MSource to a public 
  464. MDest
  465.  
  466. SYNOPSIS
  467.      route = MRoutePublic (sourcename,destname,routeinfo)
  468.      d0                    a0         a1       a2
  469.      struct MRoute *route;
  470.      char *sourcename;
  471.      char *destname;
  472.      struct MRouteInfo *routeinfo;
  473.  
  474. FUNCTION
  475.      Routes a public MSource to a public MDest.  This is shorthand for:
  476.  
  477.           LockMidiBase();
  478.           if ( (source = FindMSource(sourcename) &&
  479.                (dest = FindMDest(destname)) )
  480.                route = CreateMRoute(source,dest,routeinfo);
  481.           UnlockMidiBase();
  482.  
  483. INPUT
  484.      sourcename - pointer to null-terminated name of a public MSource
  485.      destname - pointer to null-terminated name of a public MDest
  486.      routeinfo - pointer to an MRouteInfo structure defining this MRoute
  487.  
  488. RESULTS
  489.      route - a pointer to a new MRoute structure or NULL on failure.
  490.  
  491. SEE ALSO
  492.      CreateMRoute, MRouteSource, MRouteDest, ModifyMRoute, DeleteMRoute
  493.  
  494. midi.library/MRouteSource
  495.  
  496. NAME
  497.      MRouteSource -- Create an MRoute from a private MSource to a public 
  498.      MDest
  499.  
  500. SYNOPSIS
  501.      route = MRouteSource (source,destname,routeinfo)
  502.      d0                    a0     a1       a2
  503.      struct MRoute *route;
  504.      struct MSource *source;
  505.      char *destname;
  506.      struct MRouteInfo *routeinfo;
  507.  
  508. FUNCTION
  509.      Routes an MSource to a public MDest.  This is shorthand for:
  510.  
  511.           LockMidiBase();
  512.           if (dest = FindMDest(destname))
  513.                route = CreateMRoute(source,dest,routeinfo);
  514.           UnlockMidiBase();
  515.  
  516. INPUT
  517.      source - pointer to an MSource node
  518.      destname - pointer to null-terminated name of a public MDest
  519.      routeinfo - pointer to an MRouteInfo structure defining this MRoute
  520.  
  521. RESULTS
  522.      route - a pointer to a new MRoute structure or NULL on failure.
  523.  
  524. SEE ALSO
  525.      CreateMRoute, MRouteDest, MRoutePublic, ModifyMRoute, DeleteMRoute
  526.  
  527. midi.library/PutMidiMsg
  528.  
  529. NAME
  530.      PutMidiMsg -- Place a MIDI message at an MSource
  531.  
  532. SYNOPSIS
  533.      PutMidiMsg (source,msg)
  534.                  a0     a1
  535.      struct MSource *source;
  536.      UBYTE *msg;
  537.  
  538. FUNCTION
  539.      Sends a MIDI message off to an MSource to be distributed to any 
  540.      MDest's that are routed to this source.  Once sent the message 
  541.      buffer can be recycled since copies are made of it as necessary.  
  542.      This routine assumes that it is getting a valid message.  If you 
  543.      wish to send data that is not necessarily valid (and don't wish to 
  544.      process it yourself) or your message buffer contains more than one 
  545.      message you should consider using PutMidiStream() instead.
  546.  
  547. INPUTS
  548.      source - pointer to the MSource node to place the message at
  549.      msg - pointer to a UBYTE array containing one MIDI message
  550.  
  551. RESULTS
  552.      none
  553.  
  554. SEE ALSO
  555.      PutMidiStream, MidiMsgLength, MidiMsgType, GetMidiMsg
  556.  
  557. midi.library/PutMidiStream
  558.  
  559. NAME
  560.      PutMidiStream -- Send an unformatted stream
  561.  
  562. SYNOPSIS
  563.      PutMidiStream (source,fillbuffer,buf,bufsize,cursize)
  564.                     a0     a1         a2  d0      d1
  565.      struct MSource *source;
  566.      ULONG (*fillbuffer)();
  567.      UBYTE *buf;
  568.      ULONG bufsize,cursize;
  569.  
  570. FUNCTION
  571.      Converts an unformatted stream into MIDI messages and calls 
  572.      PutMidiMsg() to the specified MSource for each one.
  573.  
  574.      The user supplied fillbuffer routine is called to place data in the 
  575.      user supplied buffer.  It can be written in C, assembly or whatever 
  576.      as long as it abides by the rules:
  577.  
  578.           On entry the following registers will be set:
  579.  
  580.                A0 - points to the user supplied buffer
  581.                D0 - indicates the size of user supplied buffer
  582.                (these are the same values the user supplied in the 
  583.                function call)
  584.  
  585.           On return D0 should be set to the number of bytes placed in the 
  586.           buffer.  A value of 0 indicates the end of the stream has been 
  587.           reached and that PutMidiStream() should return.
  588.  
  589.           Any registers that the PutMidiStream() needs are preserved 
  590.           before calling the user's fillbuffer routine so fillbuffer need 
  591.           not preserve any registers.
  592.  
  593.      In C the routine should be declared something like:
  594.  
  595.           long fillbuffer()
  596.           {
  597.                long len;
  598.  
  599.                geta4();            /* necessary for aztec C small data */
  600.                  .
  601.                  .                 /* whatever it takes to fill up */
  602.                  .                 /* buffer and set len */
  603.                  .
  604.                return len;         /* sets D0 accordingly */
  605.           }
  606.  
  607.      There are two basic ways of using calling PutMidiStream:
  608.  
  609.      1.  The stream length is unknown or just simply too large to put 
  610.          into a single buffer (like transferring from a file to an 
  611.          MSource).
  612.  
  613.           Assuming that the buffer is initially empty you would use a 
  614.           call similar to:
  615.  
  616.           PutMidiStream (source,fillmybuf,mybuf,(long)sizeof mybuf,0L);
  617.  
  618.           fillmybuf() will be called immediately to put some data into 
  619.           the buffer (mybuf).  Processing will continue until fillmybuf() 
  620.           indicates that it's time to quit by returning a 0.
  621.  
  622.      2.  The stream length is known and it is small enough to place in 
  623.          the buffer.
  624.  
  625.           PutMidiStream (source,NULL,mybuf,(long)sizeof mybuf,
  626.                                            (long)sizeof mybuf);
  627.  
  628.           The NULL fillbuffer routine indicates that the buffer contains 
  629.           all it's ever going to.  The current size is set to the size of 
  630.           the buffer to indicate that the buffer is full of data to be 
  631.           processed.  Once the buffer is exhausted, PutMidiStream will 
  632.           return.
  633.  
  634. INPUTS
  635.      source - pointer to the MSource to send messages to
  636.      fillbuffer - user supplied routine to fill the user supplied buffer
  637.                     can be NULL if no buffer filling is to be done
  638.      buf - user supplied buffer
  639.      bufsize - size of user supplied buffer
  640.      cursize - amount of data currently in the buffer upon entry to this
  641.                  function.  If non-zero this data will be processed before
  642.                  trying to call (*fillbuffer)()
  643.  
  644. RESULTS
  645.      none
  646.  
  647. SEE ALSO
  648.      PutMidiMsg
  649.  
  650. midi.library/UnlockMidiBase
  651.  
  652. NAME
  653.      UnlockMidiBase -- unlock the lists in the library base
  654.  
  655. SYNOPSIS
  656.      UnlockMidiBase()
  657.  
  658. FUNCTION
  659.      Releases exclusive access to the Source and Dest lists in the 
  660.      library base.  Each call to this must be matched with a call to 
  661.      LockMidiBase().
  662.  
  663. INPUTS
  664.      none
  665.  
  666. RESULTS
  667.      none
  668.  
  669. SEE ALSO
  670.      LockMidiBase
  671.  
  672.