1 // ****************************************************************************
5 // Include file for interfacing with the CMtcSync class.
7 // This class manages syncing to MIDI time code.
9 // Set editor tabs to 3 for your viewing pleasure.
11 // ----------------------------------------------------------------------------
13 // This file is part of Echo Digital Audio's generic driver library.
14 // Copyright Echo Digital Audio Corporation (c) 1998 - 2005
15 // All rights reserved
18 // This library is free software; you can redistribute it and/or
19 // modify it under the terms of the GNU Lesser General Public
20 // License as published by the Free Software Foundation; either
21 // version 2.1 of the License, or (at your option) any later version.
23 // This library is distributed in the hope that it will be useful,
24 // but WITHOUT ANY WARRANTY; without even the implied warranty of
25 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 // Lesser General Public License for more details.
28 // You should have received a copy of the GNU Lesser General Public
29 // License along with this library; if not, write to the Free Software
30 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 // ****************************************************************************
34 // Prevent problems with multiple includes
35 #ifndef _MTCQUEUEOBJECT_
36 #define _MTCQUEUEOBJECT_
38 typedef struct tMTC_DATA
40 DWORD dwData
; // DWORD here wastes memory, but is easier to debug...
41 DWORD dwTimestamp
; // Timestamp in terms of the DSP sample count
52 // Construction/destruction
54 CMtcSync( CEchoGals
*pEG
);
58 // Methods used to store MTC data & timestamps
60 void StoreTimestampHigh(DWORD dwData
);
61 void StoreTimestampLow(DWORD dwData
);
62 void StoreMtcData(DWORD dwData
);
65 // Call this to process the MTC data and adjust the sample rate
70 // Reset the state of things
75 // Overload new & delete so memory for this object is allocated from non-paged memory.
77 PVOID
operator new( size_t Size
);
78 VOID
operator delete( PVOID pVoid
);
82 enum // Quarter-frame message types
94 MTC_DAMPING
= 98 * 0x1000 / 100, // 95% in 12 bit fixed point
96 MAX_DFRAME_SYNC_COUNT
= 4096,
98 DAMPING_RATIO_LIMIT_LOW
= 4096 - 16,
99 DAMPING_RATIO_LIMIT_HIGH
= 4096 + 16
103 // Midi buffer management
105 MTC_DATA m_Buffer
[ ECHO_MTC_QUEUE_SZ
];
112 DWORD m_dwBaseSampleRate
;
114 DWORD m_dwLastDframeTimestamp
; // Timestamp of last double frame
115 // in units of samples
117 DWORD m_iSamplesPerDframe
;
118 DWORD m_dwFramesPerSec
;
120 DWORD m_dwLastDframe
; // Last doubleframe number
121 DWORD m_dwCurrentDframe
; // Doubleframe number currently being assembled
122 // from MTC data bytes
124 DWORD m_iNumDframesSynced
; // How many frames have elapsed since the
125 // last sample rate adjustment
127 INT32 m_iNumSamplesSynced
; // Sum of all actual timestamp deltas since
128 // last sample rate adjustment
129 DWORD m_dwNextQfType
;
138 friend class CMidiInQ
;
142 typedef CMtcSync
* PCMtcSync
;
146 // *** CMtcSync.H ***