home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / CAMD / include / midi / realtime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-30  |  5.3 KB  |  148 lines

  1. #ifndef MIDI_REALTIME_H
  2. #define MIDI_REALTIME_H
  3. /************************************************************************
  4. *     RealTime Library (timing & syncing system)                        *
  5. *************************************************************************
  6. *                                                                       *
  7. * Design & Development  - Talin & Joe Pearce                            *
  8. *                                                                       *
  9. * Copyright 1992 by Commodore Business Machines                         *
  10. *************************************************************************
  11. *
  12. * realtime.h  - RealTime conductor/player include file.
  13. *
  14. ************************************************************************/
  15.  
  16. #ifndef EXEC_LISTS_H
  17.   #include <exec/lists.h>
  18. #endif
  19.  
  20. #ifndef EXEC_TYPES_H
  21.   #include <exec/types.h>
  22. #endif
  23.  
  24. #ifndef UTILITY_TAGITEM_H
  25.   #include <utility/tagitem.h>
  26. #endif
  27.  
  28. #ifndef UTILITY_HOOKS_H
  29.   #include <utility/hooks.h>
  30. #endif
  31.  
  32. /* Each Conductor represents a group of applications which wish to remain
  33.  * synchronized together. 
  34.  */
  35.  
  36. struct Conductor {
  37.     struct Node        cdt_Node;        /* conductor list node        */
  38.     UWORD        cdt_nodepad;
  39.     struct MinList    cdt_Players;        /* list of players        */
  40.     ULONG        cdt_ClockTime,        /* current time of this sequence*/
  41.             cdt_StartTime,        /* start time of this sequence    */
  42.             cdt_ExternalTime,    /* time from external unit    */
  43.             cdt_MaxExternalTime,    /* upper limit on sync'd time    */
  44.             cdt_Metronome;        /* MetricTime highest pri node  */
  45.     UWORD        cdt_PlayersNotReady;    /* count of players not ready    */
  46.     UWORD        cdt_Flags;        /* clock flags            */
  47.     UBYTE        cdt_State;        /* playing or stopped        */
  48.     UBYTE        cdt_Stopped;        /* quick stopped check        */
  49. };
  50.  
  51. #define CONDUCTF_EXTERNAL    (1<<0)        /* clock is externally driven    */
  52. #define CONDUCTF_GOTTICK    (1<<1)        /* received 1st external tick    */
  53. #define CONDUCTF_METROSET    (1<<2)        /* Metroname filled in        */
  54.  
  55. enum time_states {
  56.     CLOCKSTATE_STOPPED=0,            /* clock is stopped        */
  57.     CLOCKSTATE_PAUSED,                /* clock is paused        */
  58.     CLOCKSTATE_LOCATE,                /* go to 'running' when ready    */
  59.     CLOCKSTATE_RUNNING,                /* run clock NOW        */
  60.     CLOCKSTATE_METRIC=-1,            /* ask high node to locate    */
  61.     CLOCKSTATE_SHUTTLE=-2            /* time changing but not running*/
  62.                         /* SetConductorState only    */
  63. };
  64.  
  65. #define CONDSTOPF_STOPPED    (1<<0)        /* not running state        */
  66. #define CONDSTOPF_NOTICK    (1<<1)        /* extsync & not gottick    */
  67.  
  68. /* The PlayerInfo is the connetion between a Conductor and an application.
  69.  */
  70.  
  71. struct PlayerInfo {
  72.     struct Node        pi_Node;        /* callback for player        */
  73.     UWORD        pi_nodepad;
  74.     struct Hook        *pi_Hook;        /* callback for player        */
  75.     struct Conductor     *pi_Source;        /* pointer to parent context    */
  76.     struct Task        *pi_Task;        /* task to signal for alarm    */
  77.     LONG        pi_MetricTime;        /* current time in app's metric    */
  78.     LONG        pi_AlarmTime;        /* time to wake up        */
  79.     void        *pi_UserData;        /* for application use        */
  80.     UWORD        pi_PlayerID;        /* for application use        */
  81.     UWORD        pi_Flags;        /* general PlayerInfo flags    */
  82.     ULONG        pi_Reserved[2];        /* internal use            */
  83.     BYTE        pi_AlarmSigBit;        /* signal to send for alarms    */
  84. };
  85.  
  86. #define PLAYERF_READY    (1<<0)            /* player is ready to go!    */
  87. #define PLAYERF_ALARMSET (1<<1)            /* alarm is set            */
  88. #define PLAYERF_QUIET    (1<<2)            /* a dummy player, used for sync*/
  89. #define PLAYERF_CONDUCTED (1<<3)        /* give me metered time        */
  90. #define PLAYERF_EXTSYNC (1<<4)            /* granted external sync    */
  91.  
  92. #define PLAYER_Base    (TAG_USER+64)
  93. #define PLAYER_Hook    (PLAYER_Base+1)        /* set address of hook function    */
  94. #define PLAYER_Name    (PLAYER_Base+2)        /* name of player        */
  95. #define PLAYER_Priority    (PLAYER_Base+3)        /* priority of player        */
  96. #define PLAYER_Conductor (PLAYER_Base+4)    /* set conductor for player    */
  97.                         /* if ~0, create private conductor */
  98. #define PLAYER_Ready    (PLAYER_Base+5)        /* the "ready" flag        */
  99. #define PLAYER_SignalTask (PLAYER_Base+6)    /* task to signal for alarm/notify */
  100. #define PLAYER_Conducted (PLAYER_Base+7)    /* sets/clears CONDUCTED flag    */
  101. #define PLAYER_AlarmSigBit (PLAYER_Base+8)    /* signal bit for alarm (or -1) */
  102. #define PLAYER_Quiet    (PLAYER_Base+9)        /* don't process time thru this */
  103. #define PLAYER_UserData    (PLAYER_Base+10)
  104. #define PLAYER_ID    (PLAYER_Base+11)
  105. #define PLAYER_AlarmTime (PLAYER_Base+12)    /* alarm time (sets PLAYERF_ALARMSET) */
  106. #define PLAYER_AlarmOn (PLAYER_Base+13)        /* sets/clears ALARMSET flag    */
  107. #define PLAYER_ExtSync (PLAYER_Base+14)        /* attempt/release to ext sync    */
  108.  
  109. #define PLAYER_ErrorCode (PLAYER_Base+15)    /* error return value        */
  110.  
  111. /* Mesages sent via PlayerInfo hook.
  112.  */
  113.  
  114. enum player_methods {
  115.     PM_TICK=0,
  116.     PM_STATE,
  117.     PM_POSITION,
  118.     PM_SHUTTLE
  119. };
  120.  
  121. struct pmTime {        /* used for PM_TICK, PM_POSITION and PM_SHUTTLE */
  122.     ULONG        pmt_Method;
  123.     ULONG        pmt_Time;
  124. };
  125.  
  126. struct pmState {    /* used for PM_STATE */
  127.     ULONG        pms_Method;
  128.     ULONG        pms_OldState;
  129. };
  130.  
  131. enum {
  132.     RT_Conductors,                              /* conductor list */
  133.     RT_NLocks
  134. };
  135.  
  136. /***************************************************************
  137. *
  138. *   RealTime Error Codes
  139. *
  140. ***************************************************************/
  141.  
  142. #define RTE_NoMem     801       /* memory allocation failed */
  143. #define RTE_NoSignals 802       /* signal allocation failed */
  144. #define RTE_NoTimer   803       /* timer (CIA) allocation failed */
  145. #define RTE_Playing   804        /* Can't shuttle while playing */
  146.  
  147. #endif /* MIDI_REALTIME_H */
  148.