MIDIThruConnection.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. {
  2. File: CoreMIDI/MIDIThruConnection.h
  3. Contains: Routines for creating MIDI play-through connections.
  4. Copyright: (c) 2000-2008 by Apple Inc., all rights reserved.
  5. Bugs?: For bug reports, consult the following page on
  6. the World Wide Web:
  7. http://bugs.freepascal.org
  8. }
  9. { Pascal Translation: Gorazd Krosl <[email protected]>, October 2009 }
  10. { Pascal Translation Update: Jonas Maebe <[email protected]>, October 2012 }
  11. {
  12. Modified for use with Free Pascal
  13. Version 308
  14. Please report any bugs to <[email protected]>
  15. }
  16. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  17. {$mode macpas}
  18. {$modeswitch cblocks}
  19. {$packenum 1}
  20. {$macro on}
  21. {$inline on}
  22. {$calling mwpascal}
  23. {$IFNDEF FPC_DOTTEDUNITS}
  24. unit MIDIThruConnection;
  25. {$ENDIF FPC_DOTTEDUNITS}
  26. interface
  27. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  28. {$setc GAP_INTERFACES_VERSION := $0308}
  29. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  30. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  31. {$endc}
  32. {$ifc defined CPUPOWERPC and defined CPUI386}
  33. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  34. {$endc}
  35. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  36. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  37. {$endc}
  38. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  39. {$setc __ppc__ := 1}
  40. {$elsec}
  41. {$setc __ppc__ := 0}
  42. {$endc}
  43. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  44. {$setc __ppc64__ := 1}
  45. {$elsec}
  46. {$setc __ppc64__ := 0}
  47. {$endc}
  48. {$ifc not defined __i386__ and defined CPUI386}
  49. {$setc __i386__ := 1}
  50. {$elsec}
  51. {$setc __i386__ := 0}
  52. {$endc}
  53. {$ifc not defined __x86_64__ and defined CPUX86_64}
  54. {$setc __x86_64__ := 1}
  55. {$elsec}
  56. {$setc __x86_64__ := 0}
  57. {$endc}
  58. {$ifc not defined __arm__ and defined CPUARM}
  59. {$setc __arm__ := 1}
  60. {$elsec}
  61. {$setc __arm__ := 0}
  62. {$endc}
  63. {$ifc not defined __arm64__ and defined CPUAARCH64}
  64. {$setc __arm64__ := 1}
  65. {$elsec}
  66. {$setc __arm64__ := 0}
  67. {$endc}
  68. {$ifc defined cpu64}
  69. {$setc __LP64__ := 1}
  70. {$elsec}
  71. {$setc __LP64__ := 0}
  72. {$endc}
  73. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  74. {$error Conflicting definitions for __ppc__ and __i386__}
  75. {$endc}
  76. {$ifc defined __ppc__ and __ppc__}
  77. {$setc TARGET_CPU_PPC := TRUE}
  78. {$setc TARGET_CPU_PPC64 := FALSE}
  79. {$setc TARGET_CPU_X86 := FALSE}
  80. {$setc TARGET_CPU_X86_64 := FALSE}
  81. {$setc TARGET_CPU_ARM := FALSE}
  82. {$setc TARGET_CPU_ARM64 := FALSE}
  83. {$setc TARGET_OS_MAC := TRUE}
  84. {$setc TARGET_OS_IPHONE := FALSE}
  85. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  86. {$setc TARGET_OS_EMBEDDED := FALSE}
  87. {$elifc defined __ppc64__ and __ppc64__}
  88. {$setc TARGET_CPU_PPC := FALSE}
  89. {$setc TARGET_CPU_PPC64 := TRUE}
  90. {$setc TARGET_CPU_X86 := FALSE}
  91. {$setc TARGET_CPU_X86_64 := FALSE}
  92. {$setc TARGET_CPU_ARM := FALSE}
  93. {$setc TARGET_CPU_ARM64 := FALSE}
  94. {$setc TARGET_OS_MAC := TRUE}
  95. {$setc TARGET_OS_IPHONE := FALSE}
  96. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  97. {$setc TARGET_OS_EMBEDDED := FALSE}
  98. {$elifc defined __i386__ and __i386__}
  99. {$setc TARGET_CPU_PPC := FALSE}
  100. {$setc TARGET_CPU_PPC64 := FALSE}
  101. {$setc TARGET_CPU_X86 := TRUE}
  102. {$setc TARGET_CPU_X86_64 := FALSE}
  103. {$setc TARGET_CPU_ARM := FALSE}
  104. {$setc TARGET_CPU_ARM64 := FALSE}
  105. {$ifc defined iphonesim}
  106. {$setc TARGET_OS_MAC := FALSE}
  107. {$setc TARGET_OS_IPHONE := TRUE}
  108. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  109. {$elsec}
  110. {$setc TARGET_OS_MAC := TRUE}
  111. {$setc TARGET_OS_IPHONE := FALSE}
  112. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  113. {$endc}
  114. {$setc TARGET_OS_EMBEDDED := FALSE}
  115. {$elifc defined __x86_64__ and __x86_64__}
  116. {$setc TARGET_CPU_PPC := FALSE}
  117. {$setc TARGET_CPU_PPC64 := FALSE}
  118. {$setc TARGET_CPU_X86 := FALSE}
  119. {$setc TARGET_CPU_X86_64 := TRUE}
  120. {$setc TARGET_CPU_ARM := FALSE}
  121. {$setc TARGET_CPU_ARM64 := FALSE}
  122. {$ifc defined iphonesim}
  123. {$setc TARGET_OS_MAC := FALSE}
  124. {$setc TARGET_OS_IPHONE := TRUE}
  125. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  126. {$elsec}
  127. {$setc TARGET_OS_MAC := TRUE}
  128. {$setc TARGET_OS_IPHONE := FALSE}
  129. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  130. {$endc}
  131. {$setc TARGET_OS_EMBEDDED := FALSE}
  132. {$elifc defined __arm__ and __arm__}
  133. {$setc TARGET_CPU_PPC := FALSE}
  134. {$setc TARGET_CPU_PPC64 := FALSE}
  135. {$setc TARGET_CPU_X86 := FALSE}
  136. {$setc TARGET_CPU_X86_64 := FALSE}
  137. {$setc TARGET_CPU_ARM := TRUE}
  138. {$setc TARGET_CPU_ARM64 := FALSE}
  139. {$setc TARGET_OS_MAC := FALSE}
  140. {$setc TARGET_OS_IPHONE := TRUE}
  141. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  142. {$setc TARGET_OS_EMBEDDED := TRUE}
  143. {$elifc defined __arm64__ and __arm64__}
  144. {$setc TARGET_CPU_PPC := FALSE}
  145. {$setc TARGET_CPU_PPC64 := FALSE}
  146. {$setc TARGET_CPU_X86 := FALSE}
  147. {$setc TARGET_CPU_X86_64 := FALSE}
  148. {$setc TARGET_CPU_ARM := FALSE}
  149. {$setc TARGET_CPU_ARM64 := TRUE}
  150. {$ifc defined ios}
  151. {$setc TARGET_OS_MAC := FALSE}
  152. {$setc TARGET_OS_IPHONE := TRUE}
  153. {$setc TARGET_OS_EMBEDDED := TRUE}
  154. {$elsec}
  155. {$setc TARGET_OS_MAC := TRUE}
  156. {$setc TARGET_OS_IPHONE := FALSE}
  157. {$setc TARGET_OS_EMBEDDED := FALSE}
  158. {$endc}
  159. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  160. {$elsec}
  161. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  162. {$endc}
  163. {$ifc defined __LP64__ and __LP64__ }
  164. {$setc TARGET_CPU_64 := TRUE}
  165. {$elsec}
  166. {$setc TARGET_CPU_64 := FALSE}
  167. {$endc}
  168. {$ifc defined FPC_BIG_ENDIAN}
  169. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  170. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  171. {$elifc defined FPC_LITTLE_ENDIAN}
  172. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  173. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  174. {$elsec}
  175. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  176. {$endc}
  177. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  178. {$setc CALL_NOT_IN_CARBON := FALSE}
  179. {$setc OLDROUTINENAMES := FALSE}
  180. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  181. {$setc OPAQUE_UPP_TYPES := TRUE}
  182. {$setc OTCARBONAPPLICATION := TRUE}
  183. {$setc OTKERNEL := FALSE}
  184. {$setc PM_USE_SESSION_APIS := TRUE}
  185. {$setc TARGET_API_MAC_CARBON := TRUE}
  186. {$setc TARGET_API_MAC_OS8 := FALSE}
  187. {$setc TARGET_API_MAC_OSX := TRUE}
  188. {$setc TARGET_CARBON := TRUE}
  189. {$setc TARGET_CPU_68K := FALSE}
  190. {$setc TARGET_CPU_MIPS := FALSE}
  191. {$setc TARGET_CPU_SPARC := FALSE}
  192. {$setc TARGET_OS_UNIX := FALSE}
  193. {$setc TARGET_OS_WIN32 := FALSE}
  194. {$setc TARGET_RT_MAC_68881 := FALSE}
  195. {$setc TARGET_RT_MAC_CFM := FALSE}
  196. {$setc TARGET_RT_MAC_MACHO := TRUE}
  197. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  198. {$setc TYPE_BOOL := FALSE}
  199. {$setc TYPE_EXTENDED := FALSE}
  200. {$setc TYPE_LONGLONG := TRUE}
  201. {$IFDEF FPC_DOTTEDUNITS}
  202. uses MacOsApi.MacTypes,MacOsApi.CFBase,MacOsApi.CFData,MacOsApi.MIDIServices;
  203. {$ELSE FPC_DOTTEDUNITS}
  204. uses MacTypes,CFBase,CFData,MIDIServices;
  205. {$ENDIF FPC_DOTTEDUNITS}
  206. {$endc} {not MACOSALLINCLUDE}
  207. {$ifc TARGET_OS_MAC}
  208. {$ALIGN POWER}
  209. // -----------------------------------------------------------------------------
  210. {!
  211. @header MIDIThruConnection.h
  212. This header defines functions to create MIDI play-through connections
  213. between the MIDI sources and destinations. These connections may be
  214. persistent or transitory, owned by a client.
  215. By using connections instead of doing MIDI Thru operations themselves,
  216. the overhead of moving MIDI messages between the server and the client
  217. for thru-ing is reduced.
  218. The aim of these functions is to permit as flexible a set of transformations
  219. as possible while keeping the API and data structures relatively simple.
  220. }
  221. // -----------------------------------------------------------------------------
  222. {!
  223. @typedef MIDIThruConnectionRef
  224. @discussion An opaque reference to a play-through connection.
  225. }
  226. //#if __LP64__
  227. {$ifc TARGET_CPU_64}
  228. type
  229. MIDIThruConnectionRef = MIDIObjectRef;
  230. {$elsec}
  231. type
  232. MIDIThruConnectionRef = ^OpaqueMIDIThruConnection; { an opaque type }
  233. OpaqueMIDIThruConnection = record end;
  234. {$endc}
  235. {!
  236. @struct MIDIValueMap
  237. @discussion A custom mapping function to transform MIDI 7-bit values,
  238. as contained in note numbers, velocities, control values,
  239. etc. y = value[x], where x is the input MIDI value, y the
  240. output.
  241. }
  242. type
  243. MIDIValueMap = record
  244. value: packed array [0..127] of UInt8;
  245. end;
  246. {!
  247. @enum MIDITransformType
  248. @discussion Values specifying a type of MIDI transformation, as found in the transform member of MIDITransform.
  249. @constant kMIDITransform_None
  250. no transformation (param unused)
  251. @constant kMIDITransform_FilterOut
  252. filter out the specified event type (param unused)
  253. @constant kMIDITransform_MapControl
  254. transform one control number to another; param is destination control number
  255. @constant kMIDITransform_Add
  256. add param to values
  257. @constant kMIDITransform_Scale
  258. multiple value by the fixed point number in param, which is in fixed point: bbbb.bbbb bbbb bbbb
  259. @constant kMIDITransform_MinValue
  260. the value's minimum value is param
  261. @constant kMIDITransform_MaxValue
  262. the value's maximum value is param
  263. @constant kMIDITransform_MapValue
  264. transform the value using a map; param is the index of the map in the connection's array of maps.
  265. }
  266. const
  267. // MIDITransformType
  268. kMIDITransform_None = 0;
  269. kMIDITransform_FilterOut = 1;
  270. kMIDITransform_MapControl = 2;
  271. kMIDITransform_Add = 8;
  272. kMIDITransform_Scale = 9;
  273. kMIDITransform_MinValue = 10;
  274. kMIDITransform_MaxValue = 11;
  275. kMIDITransform_MapValue = 12;
  276. type
  277. MIDITransformType = UInt16;
  278. const
  279. kMIDIThruConnection_MaxEndpoints = 8;
  280. {!
  281. @enum MIDITransformControlType
  282. @discussion Specifies how control numbers are interpreted.
  283. @constant kMIDIControlType_7Bit
  284. control numbers may be 0-127
  285. @constant kMIDIControlType_14Bit
  286. control numbers may be 0-31
  287. @constant kMIDIControlType_7BitRPN
  288. control numbers may be 0-16383
  289. @constant kMIDIControlType_14BitRPN
  290. @constant kMIDIControlType_7BitNRPN
  291. @constant kMIDIControlType_14BitNRPN
  292. }
  293. const
  294. // MIDITransformControlType
  295. kMIDIControlType_7Bit = 0;
  296. kMIDIControlType_14Bit = 1;
  297. kMIDIControlType_7BitRPN = 2;
  298. kMIDIControlType_14BitRPN = 3;
  299. kMIDIControlType_7BitNRPN = 4;
  300. kMIDIControlType_14BitNRPN = 5;
  301. type
  302. MIDITransformControlType = UInt8;
  303. {!
  304. @struct MIDITransform
  305. @abstract Describes how a single type of MIDI event is transformed.
  306. @discussion This structure controls the transformation of various MIDI events other than control changes.
  307. @field transform The type of transformation to be applied to the event values.
  308. @field param An argument to the transformation method (see description of MIDITransformType).
  309. }
  310. type
  311. MIDITransform = record
  312. transform: MIDITransformType;
  313. param: SInt16;
  314. end;
  315. {!
  316. @struct MIDIControlTransform
  317. @abstract Describes a transformation of MIDI control change events.
  318. @discussion
  319. A single MIDIThruConnectionParams may describe any number of transformations to control
  320. events. It is important that multiple transformations are ordered correctly: filter out,
  321. remap, then alter values.
  322. All transformations are done internally using 14-bit values, so for example, when doing
  323. an add/min/max transform on a 7-bit control value, the parameter must be a 14-bit value.
  324. For example, to add 10 to a control value, param must be (10 << 7) = 1280.
  325. @field controlType The type of control specified by controlNumber
  326. @field remappedControlType If transform is kMIDITransform_MapControl, the output control type
  327. @field controlNumber The control number to be affected.
  328. @field transform The type of transformation to be applied to the event values.
  329. @field param An argument to the transformation method (see description of MIDITransformType).
  330. }
  331. type
  332. MIDIControlTransform = record
  333. controlType: MIDITransformControlType;
  334. remappedControlType: MIDITransformControlType;
  335. controlNumber: UInt16;
  336. transform: MIDITransformType;
  337. param: SInt16;
  338. end;
  339. {!
  340. @struct MIDIThruConnectionEndpoint
  341. @abstract Describes a source or destination in a MIDIThruConnection.
  342. @field endpointRef The endpoint specified as a MIDIEndpointRef.
  343. @field uniqueID The endpoint specified by its uniqueID.
  344. @discussion
  345. When creating one of these, you can leave uniqueID 0 if the endpoint exists and you are passing
  346. its MIDIEndpointRef.
  347. When obtaining one of these from CoreMIDI, endpointRef may be NULL if it doesn't exist, but the
  348. uniqueID will always be non-zero.
  349. }
  350. type
  351. MIDIThruConnectionEndpoint = record
  352. endpointRef: MIDIEndpointRef;
  353. uniqueID: MIDIUniqueID;
  354. end;
  355. {!
  356. @struct MIDIThruConnectionParams
  357. @abstract Describes a set of MIDI routings and transformations.
  358. @field version Version of this structure; must be 0.
  359. @field numSources The number of valid sources in the following array.
  360. @field sources All MIDI generated by these sources is routed into this connection for processing
  361. and distribution to destinations.
  362. @field numDestinations The number of valid destinations in the following array.
  363. @field destinations All MIDI output from the connection is routed to these destinations.
  364. @field channelMap Maps each of the source 16 MIDI channels to channel 0-15 (1-16) or 0xFF when
  365. MIDI from a channel is to be filtered out.
  366. @field lowVelocity Note events with a velocity less than this value are filtered out.
  367. @field highVelocity Note events with a velocity greater than this, if it is not 0, are filtered out.
  368. @field lowNote See highNote.
  369. @field highNote If highNote >= lowNote, then notes outside this range are filtered out.
  370. If lowNote > highNote, then notes <i>inside</i> this range are filtered out.
  371. This applies to note and polyphonic key pressure events.
  372. These fields are ignored if a there is a MIDIValueMap applying to noteNumber.
  373. @field noteNumber Specifies how MIDI note numbers are transformed.
  374. @field velocity Specifies how MIDI note velocities are transformed.
  375. @field keyPressure Specifies how MIDI polyphonic key pressure events are transformed.
  376. @field channelPressure Specifies how MIDI monophonic (channel) pressure events are transformed.
  377. @field programChange Specifies how MIDI program change events are transformed.
  378. @field pitchBend Specifies how MIDI pitch bend events are transformed.
  379. @field filterOutSysEx If 1, specifies that system-exclusive messages are to be filtered out.
  380. @field filterOutMTC If 1, specifies that MIDI Time Code messages are to be filtered out.
  381. @field filterOutBeatClock If 1, specifies the MIDI clock, play, stop, and resume messages are to
  382. be filtered out.
  383. @field filterOutTuneRequest If 1, specifies that MIDI Tune Request messages are to be filtered out.
  384. @field reserved2 Must be 0.
  385. @field filterOutAllControls If 1, specifies that all MIDI continuous control messages are to be filtered out.
  386. @field numControlTransforms The number of control transformations in the variable-length portion of the struct.
  387. @field numMaps The number of MIDIValueMaps in the variable-length portion of the struct.
  388. @field reserved3 Must be 0.
  389. @discussion
  390. The remainder of the structure is variably-sized. It contains numControlTransform instances of
  391. MIDIControlTransform, followed by numMaps instances of MIDIValueMap.
  392. }
  393. type
  394. MIDIThruConnectionParams = record
  395. version: UInt32;
  396. numSources: UInt32;
  397. sources: array[0..kMIDIThruConnection_MaxEndpoints-1] of MIDIThruConnectionEndpoint;
  398. numDestinations: UInt32;
  399. destinations: array[0..kMIDIThruConnection_MaxEndpoints-1] of MIDIThruConnectionEndpoint;
  400. channelMap: packed array[0..15] of UInt8;
  401. lowVelocity, highVelocity: UInt8;
  402. lowNote, highNote: UInt8;
  403. noteNumber: MIDITransform;
  404. velocity: MIDITransform;
  405. keyPressure: MIDITransform;
  406. channelPressure: MIDITransform;
  407. programChange: MIDITransform;
  408. pitchBend: MIDITransform;
  409. filterOutSysEx: UInt8;
  410. filterOutMTC: UInt8;
  411. filterOutBeatClock: UInt8;
  412. filterOutTuneRequest: UInt8;
  413. reserved2: packed array[0..2] of UInt8;
  414. filterOutAllControls: UInt8;
  415. numControlTransforms: UInt16;
  416. numMaps: UInt16;
  417. reserved3: array[0..3] of UInt16;
  418. // remainder of structure is variable-length:
  419. // MIDIControlTransform controls[];
  420. // MIDIValueMap maps[];
  421. end;
  422. MIDIThruConnectionParamsPtr = ^MIDIThruConnectionParams;
  423. {!
  424. @defined MIDIThruConnectionParamsSize
  425. @abstract Returns the size of a MIDIThruConnectionParams.
  426. @discussion Accounts for the variable-length elements in the structure and returns its true
  427. size in bytes.
  428. }
  429. function MIDIThruConnectionParamsSize(ptr : MIDIThruConnectionParamsPtr) : size_t; inline;
  430. {!
  431. @function MIDIThruConnectionParamsInitialize
  432. @abstract Fills a MIDIThruConnectionParams with default values.
  433. @param inConnectionParams The struct to be initialized.
  434. @result An OSStatus result code.
  435. @discussion
  436. This convenience function fills the connection structure with default values:
  437. no endpoints, no transformations (mostly zeroes except for the channel map).
  438. Then, just filling in the source and adding one destination will create a simple,
  439. unmodified thru connection.
  440. }
  441. procedure MIDIThruConnectionParamsInitialize( var inConnectionParams: MIDIThruConnectionParams ); external name '_MIDIThruConnectionParamsInitialize';
  442. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  443. {!
  444. @function MIDIThruConnectionCreate
  445. @abstract Creates a thru connection.
  446. @param inPersistentOwnerID
  447. If null, then the connection is marked as owned by the client
  448. and will be automatically disposed with the client. if it is non-null, then it
  449. should be a unique identifier, e.g. "com.mycompany.MyCoolProgram".
  450. @param inConnectionParams
  451. A MIDIThruConnectionParams contained in a CFDataRef.
  452. @param outConnection
  453. On successful return, a reference to the newly-created connection.
  454. @result An OSStatus result code.
  455. @discussion
  456. }
  457. function MIDIThruConnectionCreate( inPersistentOwnerID: CFStringRef; inConnectionParams: CFDataRef; var outConnection: MIDIThruConnectionRef ): OSStatus; external name '_MIDIThruConnectionCreate';
  458. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  459. {!
  460. @function MIDIThruConnectionDispose
  461. @abstract Disposes a thru connection.
  462. @param connection
  463. The connection to be disposed
  464. @result An OSStatus result code.
  465. @discussion
  466. }
  467. function MIDIThruConnectionDispose( connection: MIDIThruConnectionRef ): OSStatus; external name '_MIDIThruConnectionDispose';
  468. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  469. {!
  470. @function MIDIThruConnectionGetParams
  471. @abstract Obtains a thru connection's MIDIThruConnectionParams.
  472. @param connection
  473. The connection to be disposed.
  474. @param outConnectionParams
  475. On successful return, the connection's MIDIThruConnectionParams in a CFDataRef
  476. @result An OSStatus result code.
  477. @discussion
  478. The returned CFDataRef contains a MIDIThruConnectionParams structure. The caller is responsible
  479. for releasing it.
  480. }
  481. function MIDIThruConnectionGetParams( connection: MIDIThruConnectionRef; var outConnectionParams: CFDataRef ): OSStatus; external name '_MIDIThruConnectionGetParams';
  482. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  483. {!
  484. @function MIDIThruConnectionSetParams
  485. @abstract Alters a thru connection's MIDIThruConnectionParams.
  486. @param connection
  487. The connection to be modified.
  488. @param inConnectionParams
  489. The connection's new MIDIThruConnectionParams in a CFDataRef
  490. @result An OSStatus result code.
  491. @discussion
  492. }
  493. function MIDIThruConnectionSetParams( connection: MIDIThruConnectionRef; inConnectionParams: CFDataRef ): OSStatus; external name '_MIDIThruConnectionSetParams';
  494. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  495. {!
  496. @function MIDIThruConnectionFind
  497. @abstract Returns all of the persistent thru connections created by a client.
  498. @param inPersistentOwnerID
  499. The ID of the owner whose connections are to be returned.
  500. @param outConnectionList
  501. On successful return, a CFDataRef containing an array of MIDIThruConnectionRef's.
  502. @result An OSStatus result code.
  503. @discussion
  504. }
  505. function MIDIThruConnectionFind( inPersistentOwnerID: CFStringRef; var outConnectionList: CFDataRef ): OSStatus; external name '_MIDIThruConnectionFind';
  506. (* __OSX_AVAILABLE_STARTING(__MAC_10_2, __IPHONE_NA) *)
  507. {$endc} { TARGET_OS_MAC }
  508. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  509. implementation
  510. {$ifc TARGET_OS_MAC}
  511. function MIDIThruConnectionParamsSize(ptr : MIDIThruConnectionParamsPtr) : size_t; inline;
  512. begin
  513. MIDIThruConnectionParamsSize := sizeof(MIDIThruConnectionParams) +
  514. (ptr^.numControlTransforms * sizeof(MIDIControlTransform)) +
  515. (ptr^.numMaps * sizeof(MIDIValueMap))
  516. end;
  517. {$endc} { TARGET_OS_MAC }
  518. end.
  519. {$endc} {not MACOSALLINCLUDE}