00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __MK__Conductor_H___
00014 #define __MK__Conductor_H___
00015
00016 #import "MKConductor.h"
00017 #import <Foundation/Foundation.h>
00018
00019 #define _MK_ONLY_ONE_MTC_SUPPORTED 1
00020 #define _MK_DEFAULT_MTC_POLL_PERIOD (1/30.0)
00021
00022 #define DELEGATE_RESPONDS_TO(_self,_msgBit) ((_self)->delegateFlags & _msgBit)
00023 #define BEAT_TO_CLOCK 1
00024 #define CLOCK_TO_BEAT 2
00025
00026
00027 #define MK_FOREVER (6307200000.0)
00028
00029 #define ENDOFLIST (MK_FOREVER)
00030 #define PAUSETIME (MK_ENDOFTIME - 2.0)
00031
00032
00033 #define ISENDOFLIST(_x) (_x > (ENDOFLIST - 1.0))
00034 #define ISENDOFTIME(_x) (_x > (MK_ENDOFTIME - 1.0))
00035
00036 #define TARGETFREES NO
00037 #define CONDUCTORFREES YES
00038
00039 #define NOTIMEDENTRY nil
00040
00041 #define PEEKTIME(pq) (pq)->_timeOfMsg
00042
00043 typedef enum _backgroundThreadAction {
00044 exitThread,
00045 pauseThread
00046 } backgroundThreadAction;
00047
00048 extern void _MKLock(void) ;
00049
00050 extern void _MKUnlock(void) ;
00051
00052
00053 extern void _MKAddPort(NSPort *aPort,
00054 id handlerObj,
00055 unsigned max_msg_size,
00056 void *anArg,
00057 NSString *priority);
00058 extern void _MKRemovePort(NSPort *aPort);
00059
00060 extern void _MKSendVMMsgToApplicationThread(id self,
00061 short *data,
00062 int dataCount,
00063 int vmCount);
00064
00065
00066 extern double _MKTheTimeToWait(double nextMsgTime);
00067
00068 @interface MKConductor(Private)
00069
00070 +(MKMsgStruct *)_afterPerformanceSel:(SEL)aSelector
00071 to:(id)toObject
00072 argCount:(int)argCount, ...;
00073 +(MKMsgStruct *)_afterPerformanceSel:(SEL)aSelector
00074 to:(id)toObject
00075 argCount:(int)argCount
00076 arg1:(id)arg1 retain:(BOOL)retainArg1
00077 arg2:(id)arg2 retain:(BOOL)retainArg2;
00078 +(MKMsgStruct *)_newMsgRequestAtTime:(double)timeOfMsg
00079 sel:(SEL)whichSelector to:(id)destinationObject
00080 argCount:(int)argCount, ...;
00081 +(MKMsgStruct *)_newMsgRequestAtTime:(double)timeOfMsg
00082 sel:(SEL)whichSelector to:(id)destinationObject
00083 argCount:(int)argCount arg1:(id)arg1 retain:(BOOL)retainArg1
00084 arg2:(id)arg2 retain:(BOOL)retainArg2;
00085 +(void)_scheduleMsgRequest:(MKMsgStruct *)aMsgStructPtr;
00086 +(MKMsgStruct *)_cancelMsgRequest:(MKMsgStruct *)aMsgStructPtr;
00087 +(double)_adjustTimeNoTE:(double)desiredTime ;
00088 +(double)_getLastTime;
00089 +_adjustDeltaTThresholds;
00090 -(void)_scheduleMsgRequest:(MKMsgStruct *)aMsgStructPtr;
00091 -(MKMsgStruct *)_rescheduleMsgRequest:(MKMsgStruct *)aMsgStructPtr
00092 atTime:(double)timeOfNewMsg sel:(SEL)whichSelector
00093 to:(id)destinationObject argCount:(int)argCount, ...;
00094 -(MKMsgStruct *)_rescheduleMsgRequestWithObjectArgs:(MKMsgStruct *)aMsgStructPtr
00095 atTime:(double)timeOfNewMsg sel:(SEL)whichSelector
00096 to:(id)destinationObject argCount:(int)argCount
00097 arg1:(id)arg1 retain:(BOOL)retainArg1
00098 arg2:(id)arg2 retain:(BOOL)retainArg2;
00099 + (void) masterConductorBody:(NSTimer *) unusedTimer;
00100 - _error: (NSString *) errorMsg;
00101 -_pause;
00102 -_resume;
00103
00104 @end
00105
00106 @interface MKConductor(MTCPrivate)
00107
00108 -_adjustPauseOffset:(double)v;
00109 -_MTCException:(int)exception;
00110 -_addActivePerformer:perf;
00111 -_removeActivePerformer:perf;
00112 -_runMTC:(double)requestedTime :(double)actualTime;
00113 -(double) _setMTCTime:(double)desiredTime;
00114 -(double)_MTCPerformerActivateOffset: (id) sender;
00115 - _setMTCSynch: (MKMidi *) aMidiObj;
00116
00117 void setupMTC(void);
00118 void resetMTCTime(void);
00119 BOOL weGotMTC(void);
00120 BOOL mtcEndOfTime(void);
00121 void adjustTime();
00122 BOOL checkForEndOfTime();
00123 void repositionCond(MKConductor *cond, double nextMsgTime);
00124 double beatToClock(MKConductor *self, double newBeat);
00125
00126 @end
00127
00128 #endif