Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

716 lines
22 KiB

  1. /****************************************************************************
  2. MODULE: HAU_MIDI.HPP
  3. Tab settings: 5 9
  4. Copyright 1995, 1996, Microsoft Corporation, All Rights Reserved.
  5. PURPOSE: Header for HAU_MIDI.CPP
  6. Author(s): Name:
  7. ---------- ----------------
  8. MEA Manolito E. Adan
  9. Revision History:
  10. -----------------
  11. Version Date Author Comments
  12. 1.0 03-Apr-96 MEA original
  13. 21-Mar-99 waltw Removed unreferenced ModifyEnvelopeParams,
  14. ModifyEffectParams, MapEnvelope, CMD_ModifyParamByIndex,
  15. CMD_Download_RTCSpring
  16. ****************************************************************************/
  17. #ifndef _HAU_MIDI_SEEN
  18. #define _HAU_MIDI_SEEN
  19. #include "DX_MAP.hpp"
  20. #define MAX_EFFECT_IDS 32
  21. #define NEW_EFFECT_ID 0x7f
  22. #define SYSTEM_EFFECT_ID 0x7f
  23. #define SYSTEM_RTCSPRING_ID 0
  24. #define SYSTEM_FRICTIONCANCEL_ID 1
  25. #define SYSTEM_RTCSPRING_ALIAS_ID 0x7e // Due to internal ID=0 means create new
  26. #define MAX_MIDI_CHANNEL 16
  27. #define DEFAULT_MIDI_CHANNEL 5
  28. #define DEFAULT_MIDI_PORTIO 0x330
  29. #define COMM_WINMM 0x01
  30. #define COMM_MIDI_BACKDOOR 0x02
  31. #define COMM_SERIAL_BACKDOOR 0x03
  32. #define COMM_SERIAL_FILE 0x04
  33. #define MASK_OVERRIDE_MIDI_PATH 0x80000000
  34. #define MASK_SERIAL_BACKDOOR 0x40000000
  35. #define COMM_SERIAL1 1 // COMM Port 1
  36. #define MIN_COMMSERIAL 1
  37. #define MAX_COMMSERIAL 4
  38. #define DEFAULT_JOLT_FORCE_RATE 100
  39. #define DEFAULT_PERCENT 10000
  40. #define MAX_SYS_EX_BUFFER_SIZE 1024 // Maximum Primary buffer size
  41. #define DIFFERENCE_THRESHOLD 32 // Threshold to using absolute data
  42. #define DIFFERENCE_BIT 0x40 // Bit to set for Difference data
  43. #define MAX_MIDI_WAVEFORM_PACKET_SIZE (256-20) // Midi SYS_EX packet size
  44. #define MAX_MIDI_WAVEFORM_DATA_SIZE 100 // Midi SYS_EX Data sample window size
  45. #define MAX_PLIST_EFFECT_SIZE 8 // 8 effects in a PList
  46. #define MAX_PLIST_EFFECT 8 // 8 PLists allowed
  47. #define MAX_INDEX 15
  48. #define MAX_SIZE_SNAME 64
  49. #define MS_MANUFACTURER_ID 0x0a01
  50. #define JOLT_PRODUCT_ID 0x01 // REVIEW: Is this correct?
  51. #define DRIVER_ERROR_NO_MIDI_INPUT 0x100 // No open Midi input device
  52. #define DRIVER_ERROR_MIDI_OUTPUT 0x101 // Error outputing to Midi output
  53. //
  54. // --- RTC Spring defaults
  55. //
  56. #define DEFAULT_RTC_KX 80
  57. #define DEFAULT_RTC_KY 80
  58. #define DEFAULT_RTC_X0 0
  59. #define DEFAULT_RTC_Y0 0
  60. #define DEFAULT_RTC_XSAT 96
  61. #define DEFAULT_RTC_YSAT 96
  62. #define DEFAULT_RTC_XDBAND 16
  63. #define DEFAULT_RTC_YDBAND 16
  64. //
  65. // --- Effect status code from Device
  66. //
  67. #define SWDEV_STS_EFFECT_STOPPED 0x01
  68. #define SWDEV_STS_EFFECT_RUNNING 0x02
  69. //
  70. // --- Bitmasks for Device Status
  71. //
  72. #define BANDWIDTH_MASK 0x200 // Bandwidth bit
  73. #define COMM_MODE_MASK 0x100 // 0 = MIDI, 1 = Serial
  74. #define AC_FAULT_MASK 0x80 // 1= AC brick fault
  75. #define HOTS_MASK 0x20 // Hands on Throttle Sensor
  76. #define RESET_MASK 0x10 // 1 = Power On Reset detected
  77. #define SHUTDOWN_MASK 0x08 // 0 = normal Shutdown, else 1 = Soft Reset
  78. #define MINIMUM_BANDWIDTH 1
  79. #define MAXIMUM_BANDWIDTH 100 // in %
  80. //
  81. // --- ERROR CODES from Device
  82. //
  83. #define DEV_ERR_SUCCESS 0x00 // Success
  84. #define DEV_ERR_INVALID_ID 0x01 // Effect ID is invalid or not found
  85. #define DEV_ERR_INVALID_PARAM 0x02 // Invalid parameter in data structure
  86. #define DEV_ERR_CHECKSUM 0x03 // Invalid checksum
  87. #define DEV_ERR_TYPE_FULL 0x04 // No more room for specified Effect
  88. #define DEV_ERR_UNKNOWN_CMD 0x05 // Unrecognized command
  89. #define DEV_ERR_PLAYLIST_FULL 0x06 // Play List is full, cannot play any
  90. // more effects
  91. #define DEV_ERR_PROCESS_LIST_FULL 0x07 // Process List is full
  92. //
  93. // --- MIDI Command codes
  94. //
  95. #define MODIFY_CMD 0xA0
  96. #define EFFECT_CMD 0xB0
  97. #define SYSTEM_CMD 0xC0
  98. #define STATUS_CMD 0xD0
  99. #define RESPONSE_CMD 0xE0 // Device to Host
  100. #define SYS_EX_CMD 0xF0
  101. #define ASSIGN_CMD 0xF0
  102. #define DNLOAD_CMD 0xF0
  103. #define UPLOAD_CMD 0xF0
  104. #define PROCESS_CMD 0xF0
  105. #define MIDI_EOX 0xF7
  106. //
  107. // --- Second byte sub-commands
  108. //
  109. // --- MIDI_CMD_EFFECT second byte sub-command
  110. #define NO_OVERRIDE 0x00
  111. #define DESTINATION_X 0x01
  112. #define DESTINATION_Y 0x02
  113. #define DESTINATION_XY 0x03
  114. #define PUT_FORCE_X 0x01
  115. #define PUT_FORCE_Y 0x02
  116. #define PUT_FORCE_XY 0x03
  117. #define PLAY_EFFECT_SOLO 0x00
  118. #define DESTROY_EFFECT 0x10
  119. #define PLAY_EFFECT_SUPERIMPOSE 0x20
  120. #define STOP_EFFECT 0x30
  121. #define SET_INDEX 0x40
  122. // --- MIDI_CMD_SYSTEM second byte sub-command
  123. #define SWDEV_SHUTDOWN 1L // All Effects destroyed, Motors disabled
  124. #define SWDEV_FORCE_ON 2L // Motors enabled. "Un-Mute"
  125. #define SWDEV_FORCE_OFF 3L // Motors disabled. "Mute"
  126. #define SWDEV_CONTINUE 4L // All "Paused" Effects are allow to continue
  127. #define SWDEV_PAUSE 5L // All Effects are "Paused"
  128. #define SWDEV_STOP_ALL 6L // Stops all Effects.
  129. #define SWDEV_KILL_MIDI 7L // Kills (tri-states) MIDI
  130. // Remap for dinput modes
  131. #define DEV_RESET SWDEV_SHUTDOWN
  132. #define DEV_FORCE_ON SWDEV_FORCE_ON
  133. #define DEV_FORCE_OFF SWDEV_FORCE_OFF
  134. #define DEV_CONTINUE SWDEV_CONTINUE
  135. #define DEV_PAUSE SWDEV_PAUSE
  136. #define DEV_STOP_ALL SWDEV_STOP_ALL
  137. //
  138. // --- ACK and NACK 2nd byte from RESPONSE_CMD
  139. //
  140. #define ACK 0x00
  141. #define NACK 0x7f
  142. #define ACKNACK_TIMEOUT 50 // 50*1msec timeout = 50msecs
  143. #define ACKNACK_EFFECT_STATUS_TIMEOUT 1 // 1ms Timeout
  144. #define MAX_RETRY_COUNT 10 // Retry count for comm NACKS
  145. //#define MAX_GET_STATUS_PACKET_RETRY_COUNT 30
  146. #define MAX_GET_STATUS_PACKET_RETRY_COUNT 10
  147. #define SHORT_MSG_TIMEOUT 1
  148. #define LONG_MSG_TIMEOUT 2
  149. #define POWER_ON_MSG 0x007F00E5UL
  150. #define RESPONSE_NACK 0x007FE0UL // Example for MIDI channel 0.
  151. #define RESPONSE_ACK 0x0000E0UL // " "
  152. // timing delays, in mS
  153. /*
  154. #define DEFAULT_SHORT_MSG_DELAY 1
  155. #define DEFAULT_LONG_MSG_DELAY 1
  156. #define DEFAULT_DIGITAL_OVERDRIVE_PRECHARGE_CMD_DELAY 1
  157. #define DEFAULT_SHUTDOWN_DELAY 10
  158. #define DEFAULT_HWRESET_DELAY 20
  159. #define DEFAULT_POST_SET_DEVICE_STATE_DELAY 1
  160. #define DEFAULT_GET_EFFECT_STATUS_DELAY 1
  161. #define DEFAULT_GET_DATA_PACKET_DELAY 1
  162. #define DEFAULT_GET_STATUS_PACKET_DELAY 0
  163. #define DEFAULT_GET_ID_PACKET_DELAY 1
  164. #define DEFAULT_GET_STATUS_GATE_DATA_DELAY 0
  165. #define DEFAULT_SET_INDEX_DELAY 0
  166. #define DEFAULT_MODIFY_PARAM_DELAY 0
  167. #define DEFAULT_FORCE_OUT_DELAY 1
  168. #define DEFAULT_DESTROY_EFFECT_DELAY 1
  169. #define DEFAULT_FORCE_OUT_MOD 1
  170. */
  171. // Changes of above for Zep
  172. #define DEFAULT_SHORT_MSG_DELAY 0
  173. #define DEFAULT_LONG_MSG_DELAY 0
  174. #define DEFAULT_DIGITAL_OVERDRIVE_PRECHARGE_CMD_DELAY 0
  175. #define DEFAULT_SHUTDOWN_DELAY 0
  176. #define DEFAULT_HWRESET_DELAY 0
  177. #define DEFAULT_POST_SET_DEVICE_STATE_DELAY 0
  178. #define DEFAULT_GET_EFFECT_STATUS_DELAY 0
  179. #define DEFAULT_GET_DATA_PACKET_DELAY 0
  180. #define DEFAULT_GET_STATUS_PACKET_DELAY 0
  181. #define DEFAULT_GET_ID_PACKET_DELAY 0
  182. #define DEFAULT_GET_STATUS_GATE_DATA_DELAY 0
  183. #define DEFAULT_SET_INDEX_DELAY 0
  184. #define DEFAULT_MODIFY_PARAM_DELAY 0
  185. #define DEFAULT_FORCE_OUT_DELAY 0
  186. #define DEFAULT_DESTROY_EFFECT_DELAY 0
  187. #define DEFAULT_FORCE_OUT_MOD 0
  188. typedef struct _DELAY_PARAMS
  189. {
  190. DWORD dwBytes;
  191. DWORD dwDigitalOverdrivePrechargeCmdDelay;
  192. DWORD dwShutdownDelay;
  193. DWORD dwHWResetDelay;
  194. DWORD dwPostSetDeviceStateDelay;
  195. DWORD dwGetEffectStatusDelay;
  196. DWORD dwGetDataPacketDelay;
  197. DWORD dwGetStatusPacketDelay;
  198. DWORD dwGetIDPacketDelay;
  199. DWORD dwGetStatusGateDataDelay;
  200. DWORD dwSetIndexDelay;
  201. DWORD dwModifyParamDelay;
  202. DWORD dwForceOutDelay;
  203. DWORD dwShortMsgDelay;
  204. DWORD dwLongMsgDelay;
  205. DWORD dwDestroyEffectDelay;
  206. DWORD dwForceOutMod;
  207. } DELAY_PARAMS, *PDELAY_PARAMS;
  208. void GetDelayParams(UINT nJoystickID, PDELAY_PARAMS pDelayParams);
  209. //
  210. // --- Format of Download command
  211. // Bytes in SYS EX body (starting from Byte 5 to (n-1)
  212. //
  213. // Byte Contents
  214. // ----- ---------
  215. // 0 bOpCode - see detail on OPCODE below
  216. // 1 bSubType - e.g. ET_UD_WAVEFORM, etc.
  217. // 2 bEffectID - Effect ID, 0x7f = Create New
  218. // 3 bDurationL - Low 7 bits duration in 2ms ticks, 0=Forever
  219. // 4 bDurationH - High 7 bits
  220. // 5 bAngleL - Low 7 bits Direction Angle
  221. // 7 bAngleH - High 2 bits Direction Angle
  222. // 8 bGain - 7 bits Gain 1 - 100%
  223. // 9 bButtonPlayL - Low 7 bits button mask
  224. // 10 bButtonPlayH - High 2 bits button mask
  225. // 11 bForceOutRateL - Low 7 bits, 1 to 500 Hz
  226. // 12 bForceOutRateH - High 2 bits
  227. // 13 bLoopCountL - Low 7 bits Loop Count, Normally 1
  228. // 14 bLoopCountH - High 7 bits Loop count
  229. //
  230. //
  231. // The next block is optional and starts at Byte 15
  232. // 15 bAttack - %tage
  233. // 16 bSustain; - %tage
  234. // 17 bDecay; - %tage
  235. //
  236. // Otherwise, Type specific Parameters start at either Byte 15 or 18
  237. // 18 Type specific parameter bytes here
  238. //
  239. //
  240. // ...
  241. // n 7 bits Checksum of bytes 0 to n
  242. //
  243. //
  244. //
  245. // --- MIDI_CMD_ASSIGN, MIDI_CMD_DNLOAD, MIDI_CMD_PROCESS
  246. // second byte sub-command
  247. // Opcode is defined as follows:
  248. // 7 6 5 4 3 2 1 0
  249. // - - - - - - - -
  250. // 0 c c c a a d d
  251. //
  252. // where:
  253. // c c c
  254. // - - -
  255. // 0 0 0 - EXTEND_ESCAPE
  256. // 0 0 1 - MIDI_ASSIGN
  257. // 0 1 0 - DNLOAD_DATA
  258. // 0 1 1 - UPLOAD_DATA
  259. // 1 0 0 - PROCESS_DATA
  260. // 1 0 1 - reserved
  261. // 1 1 0 - reserved
  262. // 1 1 1 - reserved
  263. //
  264. // and:
  265. // a a
  266. // - -
  267. // 0 0 - DL_PLAY_STORE only after download
  268. // 0 1 - DL_PLAY_SUPERIMPOSE right after download
  269. // 1 0 - DL_PLAY_SOLO right after download
  270. // 1 1 - reserved
  271. // and:
  272. // d d
  273. // - -
  274. // 0 0 - reserved
  275. // 0 1 - X-Axis
  276. // 1 0 - Y-Axis
  277. // 1 1 - X and Y-Axis
  278. //
  279. #define EXTEND_ESCAPE 0x00
  280. #define MIDI_ASSIGN 0x10
  281. #define DNLOAD_DATA 0x20
  282. #define UPLOAD_DATA 0x30
  283. #define PROCESS_DATA 0x40
  284. #define GET_FORCE_EFFECT_VALUE 0x50
  285. // --- Download sub-commands
  286. //
  287. #define DL_PLAY_STORE 0x00
  288. #define DL_PLAY_SUPERIMPOSE 0x04
  289. #define DL_PLAY_SOLO 0x08
  290. //
  291. // --- Process List sub-commands
  292. //
  293. #define PLIST_CONCATENATE 0x01 //0x11 // Temp. s/b 0x01
  294. #define PLIST_SUPERIMPOSE 0x02 //0x12 // Temp. s/b 0x02
  295. //
  296. // --- Special UD_EFFECT parameters
  297. //
  298. #define UD_DIFFERENCE_DATA 0x40
  299. //
  300. // --- Bitmap Indexes into Parameter storage array
  301. //
  302. #define INDEX0_MASK 0x00000001L
  303. #define INDEX1_MASK 0x00000002L
  304. #define INDEX2_MASK 0x00000004L
  305. #define INDEX3_MASK 0x00000008L
  306. #define INDEX4_MASK 0x00000010L
  307. #define INDEX5_MASK 0x00000020L
  308. #define INDEX6_MASK 0x00000040L
  309. #define INDEX7_MASK 0x00000080L
  310. #define INDEX8_MASK 0x00000100L
  311. #define INDEX9_MASK 0x00000200L
  312. #define INDEX10_MASK 0x00000400L
  313. #define INDEX11_MASK 0x00000800L
  314. #define INDEX12_MASK 0x00001000L
  315. #define INDEX13_MASK 0x00002000L
  316. #define INDEX14_MASK 0x00004000L
  317. #define INDEX15_MASK 0x00008000L
  318. #define INDEX_DURATION 0
  319. #define INDEX_TRIGGERBUTTONMASK 1
  320. #define INDEX_X_COEEFICIENT 2
  321. #define INDEX_Y_COEEFICIENT 3
  322. #define INDEX_X_CENTER 4
  323. #define INDEX_Y_CENTER 5
  324. // Indexes for 1XX RTCSpring Parms
  325. #define INDEX_RTC_COEEFICIENT_X (BYTE)0
  326. #define INDEX_RTC_COEEFICIENT_Y (BYTE)1
  327. #define INDEX_RTC_CENTER_X (BYTE)2
  328. #define INDEX_RTC_CENTER_Y (BYTE)3
  329. #define INDEX_RTC_SATURATION_X (BYTE)4
  330. #define INDEX_RTC_SATURATION_Y (BYTE)5
  331. #define INDEX_RTC_DEADBAND_X (BYTE)6
  332. #define INDEX_RTC_DEADBAND_Y (BYTE)7
  333. #define INDEX0 (BYTE)0
  334. #define INDEX1 (BYTE)1
  335. #define INDEX2 (BYTE)2
  336. #define INDEX3 (BYTE)3
  337. #define INDEX4 (BYTE)4
  338. #define INDEX5 (BYTE)5
  339. #define INDEX6 (BYTE)6
  340. #define INDEX7 (BYTE)7
  341. #define INDEX8 (BYTE)8
  342. #define INDEX9 (BYTE)9
  343. #define INDEX10 (BYTE)10
  344. #define INDEX11 (BYTE)11
  345. #define INDEX12 (BYTE)12
  346. #define INDEX13 (BYTE)13
  347. #define INDEX14 (BYTE)14
  348. #define INDEX15 (BYTE)15
  349. //
  350. // --- Effect types
  351. //
  352. #define ET_UD_WAVEFORM 1 // User Defined Waveform
  353. #define ET_SE_SINE 2 // Sinusoidal
  354. #define ET_SE_COSINE 3 // Cosine
  355. #define ET_SE_SQUARELOW 4 // Square starting Low
  356. #define ET_SE_SQUAREHIGH 5 // Square starting High
  357. #define ET_SE_RAMPUP 6 // Ramp UP
  358. #define ET_SE_RAMPDOWN 7 // Ramp Down
  359. #define ET_SE_TRIANGLEUP 8 // Triangle rising
  360. #define ET_SE_TRIANGLEDOWN 9 // Triangle falling
  361. #define ET_SE_SAWTOOTHUP 10 // Sawtooth rising
  362. #define ET_SE_SAWTOOTHDOWN 11 // Sawtooth falling
  363. #define ET_BE_DELAY 12 // NOP delay
  364. #define ET_BE_SPRING 13 // Springs
  365. #define ET_BE_DAMPER 14 // Dampers
  366. #define ET_BE_INERTIA 15 // Gravity
  367. #define ET_BE_FRICTION 16 // Friction
  368. #define ET_BE_WALL 17 // Wall (bumper)
  369. #define ET_SE_CONSTANT_FORCE 18 // Constant Force
  370. #define ET_PL_CONCATENATE 19 // Concatenate process list
  371. #define ET_PL_SUPERIMPOSE 20 // Superimpose process list
  372. // ROM Effect IDS
  373. #define ET_RE_ROMID1 32
  374. #define ET_RE_ROMID2 33
  375. #define ET_RE_ROMID3 34
  376. #define ET_RE_ROMID4 35
  377. #define ET_RE_ROMID5 36
  378. #define ET_RE_ROMID6 37
  379. #define ET_RE_ROMID7 38
  380. #define ET_RE_ROMID8 39
  381. #define ET_RE_ROMID9 40
  382. #define ET_RE_ROMID10 41
  383. #define ET_RE_ROMID11 42
  384. #define ET_RE_ROMID12 43
  385. #define ET_RE_ROMID13 44
  386. #define ET_RE_ROMID14 45
  387. #define ET_RE_ROMID15 46
  388. #define ET_RE_ROMID16 47
  389. #define ET_RE_ROMID17 48
  390. #define ET_RE_ROMID18 49
  391. #define ET_RE_ROMID19 50
  392. #define ET_RE_ROMID20 51
  393. #define ET_RE_ROMID21 52
  394. #define ET_RE_ROMID22 53
  395. #define ET_RE_ROMID23 54
  396. #define ET_RE_ROMID24 55
  397. #define ET_RE_ROMID25 56
  398. #define ET_RE_ROMID26 57
  399. #define ET_RE_ROMID27 58
  400. #define ET_RE_ROMID28 59
  401. #define ET_RE_ROMID29 60
  402. #define ET_RE_ROMID30 61
  403. #define ET_RE_ROMID31 62
  404. #define ET_RE_ROMID32 63
  405. #define ET_RE_ROMID33 64
  406. #define ET_RE_ROMID34 65
  407. #define ET_RE_ROMID35 66
  408. #define ET_RE_ROMID36 67
  409. #define ET_RE_ROMID37 68
  410. // more to be defined....
  411. //
  412. // Effect IDs as defined in Jolt device
  413. //
  414. #define EFFECT_ID_RTC_SPRING 0 // Built-in Return To Center Virtual Spring
  415. #define EFFECT_ID_FRICTIONCANCEL 1 // Friction cancellation
  416. //
  417. // --- Process List Structure
  418. //
  419. typedef struct _PLIST {
  420. ULONG ulNumEffects;
  421. ULONG ulProcessMode; // PLIST_SUPERIMPOSE or PLIST_CONCATENATE
  422. PDNHANDLE pEffectArray; // Effect ID[0} . . .
  423. ULONG ulAction;
  424. ULONG ulDuration;
  425. } PLIST, *PPLIST;
  426. //
  427. // --- Behavioral Effects Structure
  428. //
  429. typedef struct _BE_XXX {
  430. LONG m_XConstant; //(KX/BX/MX/FX/Wall type)
  431. LONG m_YConstant; //(KY/BY/MY/FY/KWall)
  432. LONG m_Param3; //(CX/VX/AX/Wall angle)
  433. LONG m_Param4; //(CY/VYO/AY/Wall distance)
  434. } BE_XXX, *PBE_XXX;
  435. //
  436. // --- SysEx Messages
  437. //
  438. typedef struct _SYS_EX_HDR {
  439. BYTE m_bSysExCmd; // SysEx Fx command
  440. BYTE m_bEscManufID; // Escape to long Manufac. ID, s/b 0
  441. BYTE m_bManufIDL; // Low byte
  442. BYTE m_bManufIDH; // High byte
  443. BYTE m_bProdID; // Product ID
  444. } SYS_EX_HDR, *PSYS_EX_HDR;
  445. // --- Common Effect parameters
  446. typedef struct _MIDI_EFFECT {
  447. BYTE bDurationL; // Low 7 bits duration in 2ms ticks, 0=Forever
  448. BYTE bDurationH; // High 7 bits
  449. BYTE bButtonPlayL; // Low 7 bits button mask
  450. BYTE bButtonPlayH; // High 2 bits button mask
  451. BYTE bAngleL; // Low 7 bits Direction Angle
  452. BYTE bAngleH; // High 2 bits Direction Angle
  453. BYTE bGain; // 7 bits Gain 1 - 100%
  454. BYTE bForceOutRateL; // Low 7 bits, 1 to 500 Hz
  455. BYTE bForceOutRateH; // High 2 bits
  456. BYTE bPercentL; // Low 7 bits Percent of waveform 1 to 10000
  457. BYTE bPercentH; // High 7 bits Loop Count
  458. } MIDI_EFFECT, *PMIDI_EFFECT;
  459. // --- Envelope
  460. typedef struct MIDI_ENVELOPE {
  461. BYTE bAttackLevel; // Initial Attack amplitude 0 to +127
  462. BYTE bSustainL; // time to Sustain in 2ms ticks
  463. BYTE bSustainH; //
  464. BYTE bSustainLevel; // Amplitude level to sustain
  465. BYTE bDecayL; // time to Decay in 2ms ticks
  466. BYTE bDecayH;
  467. BYTE bDecayLevel; // Amplitude level to decay
  468. } MIDI_ENVELOPE, *PMIDI_ENVELOPE;
  469. // --- Midi Assign
  470. typedef struct _MIDI_ASSIGN_SYS_EX {
  471. SYS_EX_HDR SysExHdr;
  472. BYTE bOpCode; // Sub-command opcode: MIDI_ASSIGN
  473. BYTE bChannel; // Midi channel 1-16
  474. BYTE bChecksum;
  475. BYTE bEOX;
  476. } MIDI_ASSIGN_SYS_EX, *PMIDI_ASSIGN_SYS_EX;
  477. // --- Get Effect Force Value at a tick sample time
  478. typedef struct _MIDI_GET_EFFECT_FORCE_VALUE_SYS_EX {
  479. SYS_EX_HDR SysExHdr;
  480. BYTE bOpCode; // Sub-command opcode: GET_EFFECT_FORCE_VALUE
  481. BYTE bEffectID; // Effect ID
  482. BYTE bSampleTimeL; // Low 7 bits in 2ms ticks
  483. BYTE bSampleTimeH; // High 7 bits in 2ms ticks
  484. BYTE bChecksum;
  485. BYTE bEOX;
  486. } MIDI_GET_EFFECT_FORCE_VALUE_SYS_EX, *PMIDI_GET_EFFECT_FORCE_VALUE_SYS_EX;
  487. // --- Note: For the following, if bEffectID = 0x7f, then New, else Modify
  488. // --- Download Data - Synthesized Waveform
  489. typedef struct _SE_WAVEFORM_SYS_EX {
  490. SYS_EX_HDR SysExHdr;
  491. BYTE bOpCode; // Sub-command opcode: DNLOAD_DATA
  492. BYTE bSubType; // ex: ET_SE_SINE
  493. BYTE bEffectID; // Downloaded Effect ID
  494. MIDI_EFFECT Effect;
  495. MIDI_ENVELOPE Envelope;
  496. // SE Parameters
  497. BYTE bFreqL; // Low 7 bits Frequency 1-2048Hz
  498. BYTE bFreqH; // High 4 bits
  499. BYTE bMaxAmpL; // Low 7 bits Maximum Amplitude +/- 100%
  500. BYTE bMaxAmpH; // High 1 bit
  501. BYTE bMinAmpL; // Low 7 bits Minimum Amplitude +/- 100%
  502. BYTE bMinAmpH; // High 1 bit
  503. BYTE bChecksum;
  504. BYTE bEOX;
  505. } SE_WAVEFORM_SYS_EX, *PSE_WAVEFORM_SYS_EX;
  506. // --- Download Data - NOP Delay
  507. typedef struct _NOP_SYS_EX {
  508. SYS_EX_HDR SysExHdr;
  509. BYTE bOpCode; // Sub-command opcode: DNLOAD_DATA
  510. BYTE bSubType; // Behavioral Effect Type: BE_FRICTION
  511. BYTE bEffectID; // Downloaded Effect ID, 0x7F = Create NEw
  512. BYTE bDurationL; // Low 7 bits duration in 2ms ticks, 0=Forever
  513. BYTE bDurationH; // High 7 bits
  514. BYTE bChecksum;
  515. BYTE bEOX;
  516. } NOP_SYS_EX, *PNOP_SYS_EX;
  517. // --- Download Data - Behavioral SysEx
  518. typedef struct _BEHAVIORAL_SYS_EX {
  519. SYS_EX_HDR SysExHdr;
  520. BYTE bOpCode; // Sub-command opcode: DNLOAD_DATA
  521. BYTE bSubType; // Behavioral Effect Type: BE_SPRING
  522. BYTE bEffectID; // Downloaded Effect ID
  523. // Effects params
  524. BYTE bDurationL; // Low 7 bits duration in 2ms ticks, 0=Forever
  525. BYTE bDurationH; // High 7 bits
  526. BYTE bButtonPlayL; // Low 7 bits button mask
  527. BYTE bButtonPlayH; // High 2 bits button mask
  528. // BE_XXX Parameters
  529. BYTE bXConstantL; // Low 7 bits K (in +/- 100%) X-Axis
  530. BYTE bXConstantH; // High 1 bit K
  531. BYTE bYConstantL; // Low 7 bits K (in +/- 100%) Y-Axis
  532. BYTE bYConstantH; // High 1 bit K
  533. BYTE bParam3L; // Low 7 bits Axis center (in +/- 100%) X-Axis
  534. BYTE bParam3H; // High 1 bit
  535. BYTE bParam4L; // Low 7 bits Axis center (in +/- 100%) Y-Axis
  536. BYTE bParam4H; // High 1 bit
  537. BYTE bChecksum;
  538. BYTE bEOX;
  539. } BEHAVIORAL_SYS_EX, *PBEHAVIORAL_SYS_EX;
  540. // --- Download Data - Friction SysEx
  541. typedef struct _FRICTION_SYS_EX {
  542. SYS_EX_HDR SysExHdr;
  543. BYTE bOpCode; // Sub-command opcode: DNLOAD_DATA
  544. BYTE bSubType; // Behavioral Effect Type: BE_FRICTION
  545. BYTE bEffectID; // Downloaded Effect ID
  546. // Effects params
  547. BYTE bDurationL; // Low 7 bits duration in 2ms ticks, 0=Forever
  548. BYTE bDurationH; // High 7 bits
  549. BYTE bButtonPlayL; // Low 7 bits button mask
  550. BYTE bButtonPlayH; // High 2 bits button mask
  551. // BE_FRICTION Parameters
  552. BYTE bXFConstantL; // Low 7 bits F (in +/- 100%) X-Axis
  553. BYTE bXFConstantH; // High 1 bit F
  554. BYTE bYFConstantL; // Low 7 bits F (in +/- 100%) Y-Axis
  555. BYTE bYFConstantH; // High 1 bit F
  556. BYTE bChecksum;
  557. BYTE bEOX;
  558. } FRICTION_SYS_EX, *PFRICTION_SYS_EX;
  559. // --- Download Data - WALL SysEx
  560. #define INNER_WALL 0 // Wall face to center
  561. #define OUTER_WALL 1 // Wall face away from center
  562. typedef struct _WALL_SYS_EX {
  563. SYS_EX_HDR SysExHdr;
  564. BYTE bOpCode; // Sub-command opcode: DNLOAD_DATA
  565. BYTE bSubType; // Behavioral Effect Type: e.g. EF_BE_WALL
  566. BYTE bEffectID; // Downloaded Effect ID
  567. // Effects params
  568. BYTE bDurationL; // Low 7 bits duration in 2ms ticks, 0=Forever
  569. BYTE bDurationH; // High 7 bits
  570. BYTE bButtonPlayL; // Low 7 bits button mask
  571. BYTE bButtonPlayH; // High 2 bits button mask
  572. // BE_SPRING Parameters
  573. BYTE bWallType; // INNER_WALL or OUTER_WALL
  574. BYTE bWallConstantL; // Low 7 bits: Similar to Spring Constant.
  575. // Value is from +/- 100%.
  576. BYTE bWallConstantH; // High 1 bit
  577. BYTE bWallAngleL; // Low 7 bits: 0 to 359 degrees
  578. // For simple vertical and horizontal walls,
  579. // this value should be set to 0, 90, 180, 270
  580. BYTE bWallAngleH; // Low 2 bit
  581. BYTE bWallDistance; // 7 bits: Distance from Center of stick 0 to 100
  582. BYTE bChecksum;
  583. BYTE bEOX;
  584. } WALL_SYS_EX, *PWALL_SYS_EX;
  585. // --- Download Data - User Defined Waveform SysEx
  586. typedef struct _UD_WAVEFORM_SYS_EX {
  587. SYS_EX_HDR SysExHdr;
  588. BYTE bOpCode; // Sub-command opcode: PROCESS_DATA
  589. BYTE bSubType; // Process List: PL_SUPERIMPOSE/PL_CONCATENATE
  590. BYTE bEffectID; // Downloaded Effect ID
  591. MIDI_EFFECT Effect;
  592. // BYTE bWaveformArray; // Force Data . . .
  593. // BYTE bChecksum;
  594. // BYTE bEOX;
  595. } UD_WAVEFORM_SYS_EX, *PUD_WAVEFORM_SYS_EX;
  596. #define UD_WAVEFORM_START_OFFSET (sizeof(UD_WAVEFORM_SYS_EX))
  597. // --- Download Data - Process List SysEx
  598. typedef struct _PROCESS_LIST_SYS_EX {
  599. SYS_EX_HDR SysExHdr;
  600. BYTE bOpCode; // Sub-command opcode: PROCESS_DATA
  601. BYTE bSubType; // Process List: PL_SUPERIMPOSE/PL_CONCATENATE
  602. BYTE bEffectID; // Downloaded Effect ID
  603. BYTE bButtonPlayL; // Low 7 bits button mask
  604. BYTE bButtonPlayH; // High 2 bits button mask
  605. BYTE bEffectArrayID; // Effect ID[0] . . .
  606. // BYTE bChecksum;
  607. // BYTE bEOX;
  608. } PROCESS_LIST_SYS_EX, *PPROCESS_LIST_SYS_EX;
  609. #define PROCESS_LIST_EFFECT_START_OFFSET (sizeof(PROCESS_LIST_SYS_EX))
  610. //
  611. // --- Function Prototypes
  612. //
  613. BOOL DetectMidiDevice(
  614. IN OUT UINT *pDeviceOutID);
  615. HRESULT CMD_SetIndex(
  616. IN int nIndex,
  617. IN DNHANDLE DnloadID);
  618. HRESULT CMD_ModifyParam(
  619. IN WORD wNewParam);
  620. HRESULT CMD_Download_VFX(
  621. IN PEFFECT pEffect,
  622. IN PENVELOPE pEnvelope,
  623. IN PVFX_PARAM pVFX_Param,
  624. IN ULONG ulAction,
  625. IN OUT PDNHANDLE pDnloadID,
  626. IN DWORD dwFlags);
  627. HRESULT CMD_Download_BE_XXX(
  628. IN PEFFECT pEffect,
  629. IN PENVELOPE pEnvelope,
  630. IN PBE_XXX pBE_XXX,
  631. IN OUT PDNHANDLE pDnloadID,
  632. IN DWORD dwFlags);
  633. class CMidiSynthesized;
  634. #endif // of ifdef _HAU_MIDI_SEEN