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.

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