MusicDevice.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. {
  2. File: MusicDevice.h
  3. Contains: MusicDevice Interfaces
  4. Copyright: © 2000-2011 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. {$packenum 1}
  19. {$macro on}
  20. {$inline on}
  21. {$calling mwpascal}
  22. unit MusicDevice;
  23. interface
  24. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  25. {$setc GAP_INTERFACES_VERSION := $0308}
  26. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  27. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  28. {$endc}
  29. {$ifc defined CPUPOWERPC and defined CPUI386}
  30. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  31. {$endc}
  32. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  33. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  34. {$endc}
  35. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  36. {$setc __ppc__ := 1}
  37. {$elsec}
  38. {$setc __ppc__ := 0}
  39. {$endc}
  40. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  41. {$setc __ppc64__ := 1}
  42. {$elsec}
  43. {$setc __ppc64__ := 0}
  44. {$endc}
  45. {$ifc not defined __i386__ and defined CPUI386}
  46. {$setc __i386__ := 1}
  47. {$elsec}
  48. {$setc __i386__ := 0}
  49. {$endc}
  50. {$ifc not defined __x86_64__ and defined CPUX86_64}
  51. {$setc __x86_64__ := 1}
  52. {$elsec}
  53. {$setc __x86_64__ := 0}
  54. {$endc}
  55. {$ifc not defined __arm__ and defined CPUARM}
  56. {$setc __arm__ := 1}
  57. {$elsec}
  58. {$setc __arm__ := 0}
  59. {$endc}
  60. {$ifc not defined __arm64__ and defined CPUAARCH64}
  61. {$setc __arm64__ := 1}
  62. {$elsec}
  63. {$setc __arm64__ := 0}
  64. {$endc}
  65. {$ifc defined cpu64}
  66. {$setc __LP64__ := 1}
  67. {$elsec}
  68. {$setc __LP64__ := 0}
  69. {$endc}
  70. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  71. {$error Conflicting definitions for __ppc__ and __i386__}
  72. {$endc}
  73. {$ifc defined __ppc__ and __ppc__}
  74. {$setc TARGET_CPU_PPC := TRUE}
  75. {$setc TARGET_CPU_PPC64 := FALSE}
  76. {$setc TARGET_CPU_X86 := FALSE}
  77. {$setc TARGET_CPU_X86_64 := FALSE}
  78. {$setc TARGET_CPU_ARM := FALSE}
  79. {$setc TARGET_CPU_ARM64 := FALSE}
  80. {$setc TARGET_OS_MAC := TRUE}
  81. {$setc TARGET_OS_IPHONE := FALSE}
  82. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  83. {$setc TARGET_OS_EMBEDDED := FALSE}
  84. {$elifc defined __ppc64__ and __ppc64__}
  85. {$setc TARGET_CPU_PPC := FALSE}
  86. {$setc TARGET_CPU_PPC64 := TRUE}
  87. {$setc TARGET_CPU_X86 := FALSE}
  88. {$setc TARGET_CPU_X86_64 := FALSE}
  89. {$setc TARGET_CPU_ARM := FALSE}
  90. {$setc TARGET_CPU_ARM64 := FALSE}
  91. {$setc TARGET_OS_MAC := TRUE}
  92. {$setc TARGET_OS_IPHONE := FALSE}
  93. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  94. {$setc TARGET_OS_EMBEDDED := FALSE}
  95. {$elifc defined __i386__ and __i386__}
  96. {$setc TARGET_CPU_PPC := FALSE}
  97. {$setc TARGET_CPU_PPC64 := FALSE}
  98. {$setc TARGET_CPU_X86 := TRUE}
  99. {$setc TARGET_CPU_X86_64 := FALSE}
  100. {$setc TARGET_CPU_ARM := FALSE}
  101. {$setc TARGET_CPU_ARM64 := FALSE}
  102. {$ifc defined(iphonesim)}
  103. {$setc TARGET_OS_MAC := FALSE}
  104. {$setc TARGET_OS_IPHONE := TRUE}
  105. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  106. {$elsec}
  107. {$setc TARGET_OS_MAC := TRUE}
  108. {$setc TARGET_OS_IPHONE := FALSE}
  109. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  110. {$endc}
  111. {$setc TARGET_OS_EMBEDDED := FALSE}
  112. {$elifc defined __x86_64__ and __x86_64__}
  113. {$setc TARGET_CPU_PPC := FALSE}
  114. {$setc TARGET_CPU_PPC64 := FALSE}
  115. {$setc TARGET_CPU_X86 := FALSE}
  116. {$setc TARGET_CPU_X86_64 := TRUE}
  117. {$setc TARGET_CPU_ARM := FALSE}
  118. {$setc TARGET_CPU_ARM64 := FALSE}
  119. {$ifc defined(iphonesim)}
  120. {$setc TARGET_OS_MAC := FALSE}
  121. {$setc TARGET_OS_IPHONE := TRUE}
  122. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  123. {$elsec}
  124. {$setc TARGET_OS_MAC := TRUE}
  125. {$setc TARGET_OS_IPHONE := FALSE}
  126. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  127. {$endc}
  128. {$setc TARGET_OS_EMBEDDED := FALSE}
  129. {$elifc defined __arm__ and __arm__}
  130. {$setc TARGET_CPU_PPC := FALSE}
  131. {$setc TARGET_CPU_PPC64 := FALSE}
  132. {$setc TARGET_CPU_X86 := FALSE}
  133. {$setc TARGET_CPU_X86_64 := FALSE}
  134. {$setc TARGET_CPU_ARM := TRUE}
  135. {$setc TARGET_CPU_ARM64 := FALSE}
  136. { will require compiler define when/if other Apple devices with ARM cpus ship }
  137. {$setc TARGET_OS_MAC := FALSE}
  138. {$setc TARGET_OS_IPHONE := TRUE}
  139. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  140. {$setc TARGET_OS_EMBEDDED := TRUE}
  141. {$elifc defined __arm64__ and __arm64__}
  142. {$setc TARGET_CPU_PPC := FALSE}
  143. {$setc TARGET_CPU_PPC64 := FALSE}
  144. {$setc TARGET_CPU_X86 := FALSE}
  145. {$setc TARGET_CPU_X86_64 := FALSE}
  146. {$setc TARGET_CPU_ARM := FALSE}
  147. {$setc TARGET_CPU_ARM64 := TRUE}
  148. { will require compiler define when/if other Apple devices with ARM cpus ship }
  149. {$setc TARGET_OS_MAC := FALSE}
  150. {$setc TARGET_OS_IPHONE := TRUE}
  151. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  152. {$setc TARGET_OS_EMBEDDED := TRUE}
  153. {$elsec}
  154. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  155. {$endc}
  156. {$ifc defined __LP64__ and __LP64__ }
  157. {$setc TARGET_CPU_64 := TRUE}
  158. {$elsec}
  159. {$setc TARGET_CPU_64 := FALSE}
  160. {$endc}
  161. {$ifc defined FPC_BIG_ENDIAN}
  162. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  163. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  164. {$elifc defined FPC_LITTLE_ENDIAN}
  165. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  166. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  167. {$elsec}
  168. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  169. {$endc}
  170. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  171. {$setc CALL_NOT_IN_CARBON := FALSE}
  172. {$setc OLDROUTINENAMES := FALSE}
  173. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  174. {$setc OPAQUE_UPP_TYPES := TRUE}
  175. {$setc OTCARBONAPPLICATION := TRUE}
  176. {$setc OTKERNEL := FALSE}
  177. {$setc PM_USE_SESSION_APIS := TRUE}
  178. {$setc TARGET_API_MAC_CARBON := TRUE}
  179. {$setc TARGET_API_MAC_OS8 := FALSE}
  180. {$setc TARGET_API_MAC_OSX := TRUE}
  181. {$setc TARGET_CARBON := TRUE}
  182. {$setc TARGET_CPU_68K := FALSE}
  183. {$setc TARGET_CPU_MIPS := FALSE}
  184. {$setc TARGET_CPU_SPARC := FALSE}
  185. {$setc TARGET_OS_UNIX := FALSE}
  186. {$setc TARGET_OS_WIN32 := FALSE}
  187. {$setc TARGET_RT_MAC_68881 := FALSE}
  188. {$setc TARGET_RT_MAC_CFM := FALSE}
  189. {$setc TARGET_RT_MAC_MACHO := TRUE}
  190. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  191. {$setc TYPE_BOOL := FALSE}
  192. {$setc TYPE_EXTENDED := FALSE}
  193. {$setc TYPE_LONGLONG := TRUE}
  194. uses MacTypes,AUComponent,AudioComponents,CoreAudioTypes;
  195. {$endc} {not MACOSALLINCLUDE}
  196. {$ifc TARGET_OS_MAC}
  197. {$ALIGN POWER}
  198. {$ifc not TARGET_CPU_64}
  199. {$ALIGN MAC68K}
  200. {$endc}
  201. //=====================================================================================================================
  202. //#pragma mark -
  203. //#pragma mark Overview
  204. {!
  205. @header MusicDevice
  206. @discussion
  207. A music device audio unit - what is commonly referred to as a music instrument - is used to render notes.
  208. A note is a sound, usually pitched, that is started and stopped with a note number or pitch specifier.
  209. A note is played on a group (in MIDI this is called a MIDI Channel) and the various state values of a
  210. group (such as pitch bend, after-touch, etc) is inherited and controlled by every playing note on a given group.
  211. A note can be individually stopped (which is the common case), or stopped with the "All Notes Off" message that
  212. is sent to a specific group.
  213. A music instrument can be multi-timbral - that is, each group can have a particular patch (or sound) associated with
  214. it, and different groups can have different patches. This is a common case for music instruments that implement
  215. the General MIDI specification. In this case, the music instrument should return the number of available
  216. patches at a given time as the value for the _InstrumentCount property.
  217. It is also common for instruments to be mono-timbral - that is, they are only capable of producing notes using a
  218. single patch/sound and typically only respond to commands on one group. In this case, the music instrument
  219. should return 0 as the value for the _InstrumentCount property.
  220. Parameters can be defined in Group Scope, and these parameter IDs within the range of 0 < 1024, are equivalent
  221. to the standard definitions of control in the MIDI specification (up to the ID of). Parameters in group scope
  222. above 1024 are audio unit defined.
  223. Notes can be created/started with one of two methods. To stop a note it must be stopped with the same API group
  224. as was used to start it (MIDI or the extended Start/Stop note API.
  225. (1) the MIDI Note on event (MusicDeviceMIDIEvent)
  226. - notes must be stopped with the MIDI note off event (MusicDeviceMIDIEvent)
  227. The MIDI Note number is used to turn the note off for the specified channel
  228. (2) the extended Note API (MusicDeviceStartNote). This API returns a note instance ID.
  229. This is unique and can be used with the kAudioUnitScope_Note.
  230. It is also used to turn the note off with MusicDeviceStopNote
  231. }
  232. //=====================================================================================================================
  233. //#pragma mark -
  234. //#pragma mark Types
  235. {!
  236. @typedef MusicDeviceInstrumentID
  237. @abstract type for instrument identifiers
  238. }
  239. type
  240. MusicDeviceInstrumentID = UInt32;
  241. {!
  242. @typedef MusicDeviceStdNoteParams
  243. @abstract convenience struct for specifying a note and velocity
  244. @discussion This struct is the common usage for MusicDeviceStartNote, as most synths that implement this functionality
  245. will only allow for the specification of a note number and velocity when starting a new note.
  246. @param argCount
  247. Should be set to 2
  248. @param mPitch
  249. The pitch of the new note, typically specified using a MIDI note number (and a fractional pitch) within the
  250. range of 0 < 128. So 60 is middle C, 60.5 is middle C + 50 cents.
  251. @param mVelocity
  252. The velocity of the new note - this can be a fractional value - specified as MIDI (within the range of 0 < 128)
  253. }
  254. type
  255. MusicDeviceStdNoteParams = record
  256. argCount: UInt32; { should be 2}
  257. mPitch: Float32;
  258. mVelocity: Float32;
  259. end;
  260. MusicDeviceStdNoteParamsPtr = ^MusicDeviceStdNoteParams;
  261. {!
  262. @typedef NoteParamsControlValue
  263. @abstract used to describe a control and value
  264. @discussion This struct is used to describe a parameterID (a control in MIDI terminology, though it is not limited to
  265. MIDI CC specifications) and the value of this parameter.
  266. @param mID
  267. The parameter ID
  268. @param mValue
  269. The value of that parameter
  270. }
  271. type
  272. NoteParamsControlValue = record
  273. mID: AudioUnitParameterID;
  274. mValue: AudioUnitParameterValue;
  275. end;
  276. NoteParamsControlValuePtr = ^NoteParamsControlValue;
  277. {!
  278. @typedef MusicDeviceNoteParams
  279. @abstract Used to hold the value of the inParams parameter for the MusicDeviceStartNote function.
  280. @discussion The generic version of this structure describes an arg count (which is the number of mControls values
  281. + 1 for mPitch and 1 for mVelocity). So, argCount should at least be two. See MusicDeviceStdNoteParams
  282. for the common use case, as many audio unit instruments will not respond to control values provided
  283. in the start note function
  284. @param argCount
  285. The number of controls + 2 (for mPitch and mVelocity)
  286. @param mPitch
  287. The pitch of the new note, typically specified using a MIDI note number (and a fractional pitch) within the
  288. range of 0 < 128. So 60 is middle C, 60.5 is middle C + 50 cents.
  289. @param mVelocity
  290. The velocity of the new note - this can be a fractional value - specified as MIDI (within the range of 0 < 128)
  291. @param mControls
  292. A variable length array with the number of elements: argCount - 2.
  293. }
  294. type
  295. MusicDeviceNoteParams = record
  296. argCount: UInt32;
  297. mPitch: Float32;
  298. mVelocity: Float32;
  299. mControls: array[0..0] of NoteParamsControlValue; { arbitrary length }
  300. end;
  301. MusicDeviceNoteParamsPtr = ^MusicDeviceNoteParams;
  302. {!
  303. @enum MusicNoteEvent
  304. @discussion This is used to signify that the patch used to start a note (its sound) is defined by the current
  305. selection for the group ID; this is the normal usage in MIDI as any notes started on a given channel
  306. (group ID) use the sound (patch) defined for that channel. See MusicDeviceStartNote
  307. @constant kMusicNoteEvent_UseGroupInstrument
  308. Use the patch (instrument number) assigned to the new notes group ID
  309. @constant kMusicNoteEvent_Unused
  310. The instrument ID is not specified
  311. }
  312. const
  313. kMusicNoteEvent_UseGroupInstrument = $FFFFFFFF;
  314. kMusicNoteEvent_Unused = $FFFFFFFF;
  315. {!
  316. @typedef MusicDeviceGroupID
  317. @discussion The type used to specify which group (channel number in MIDI) is used with a given command (new note,
  318. control or parameter value change)
  319. }
  320. type
  321. MusicDeviceGroupID = UInt32;
  322. {!
  323. @typedef NoteInstanceID
  324. @discussion The type used to hold an unique identifier returned by MusicDeviceStartNote that is used to then address
  325. that note (typically to turn the note off). An ID must be used for notes, because notes can be specified
  326. by fractional pitches, and so using the MIDI note number is not sufficient to identify the note to turn
  327. it off (or to apply polyphonic after touch).
  328. }
  329. type
  330. NoteInstanceID = UInt32;
  331. {!
  332. @typedef MusicDeviceComponent
  333. @discussion The unique type of a MusicDevice audio unit (which is an AudioComponentInstance)
  334. }
  335. type
  336. MusicDeviceComponent = AudioComponentInstance;
  337. //=====================================================================================================================
  338. //#pragma mark -
  339. //#pragma mark Functions
  340. {!
  341. @function MusicDeviceMIDIEvent
  342. @abstract Used to sent MIDI channel messages to an audio unit
  343. @discussion This is the API used to send MIDI channel messages to an audio unit. The status and data parameters
  344. are used exactly as described by the MIDI specification, including the combination of channel and
  345. command in the status byte.
  346. @param inUnit
  347. The audio unit
  348. @param inStatus
  349. The MIDI status byte
  350. @param inData1
  351. The first MIDI data byte (value is in the range 0 < 128)
  352. @param inData2
  353. The second MIDI data byte (value is in the range 0 < 128). If the MIDI status byte only has one
  354. data byte, this should be set to zero.
  355. @param inOffsetSampleFrame
  356. If you are scheduling the MIDI Event from the audio unit's render thread, then you can supply a
  357. sample offset that the audio unit may apply when applying that event in its next audio unit render.
  358. This allows you to schedule to the sample, the time when a MIDI command is applied and is particularly
  359. important when starting new notes. If you are not scheduling in the audio unit's render thread,
  360. then you should set this value to 0
  361. @result noErr, or an audio unit error code
  362. }
  363. function MusicDeviceMIDIEvent( inUnit: MusicDeviceComponent; inStatus: UInt32; inData1: UInt32; inData2: UInt32; inOffsetSampleFrame: UInt32 ): OSStatus; external name '_MusicDeviceMIDIEvent';
  364. (* __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_NA) *)
  365. {!
  366. @function MusicDeviceSysEx
  367. @abstract used to send any non-channel MIDI event to an audio unit
  368. @discussion This is used to send any non-channel MIDI event to an audio unit. In practise this is a System Exclusive
  369. (SysEx) MIDI message
  370. @param inUnit
  371. The audio unit
  372. @param inData
  373. The complete MIDI SysEx message including the F0 and F7 start and termination bytes
  374. @param inLength
  375. The size, in bytes, of the data
  376. @result noErr, or an audio unit error code
  377. }
  378. function MusicDeviceSysEx( inUnit: MusicDeviceComponent; const inData: UnivPtr; inLength: UInt32 ): OSStatus; external name '_MusicDeviceSysEx';
  379. (* __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_NA) *)
  380. {!
  381. @function MusicDeviceStartNote
  382. @abstract used to start a note
  383. @discussion This function is used to start a note. The caller must provide a NoteInstanceID to receive a
  384. token that is then used to stop the note. The MusicDeviceStopNote call should be used to stop
  385. notes started with this API. The token can also be used to address individual notes on the
  386. kAudioUnitScope_Note if the audio unit supports it. The instrumentID is no longer used and the
  387. kMusicNoteEvent_Unused constant should be specified (this takes the current patch for the
  388. specifed group as the sound to use for the note).
  389. The Audio unit must provide an unique ID for the note instance ID. This ID must be non-zero and not
  390. 0xFFFFFFFF (any other UInt32 value is valid).
  391. Not all Music Device audio units implement the semantics of this API (though it is strongly recommended
  392. that they do). A host application shoudl query the kMusicDeviceProperty_SupportsStartStopNote to
  393. check that this is supported.
  394. @param inUnit
  395. The audio unit
  396. @param inInstrument
  397. The instrumentID is no longer used and the kMusicNoteEvent_Unused constant should be specified (this takes
  398. the current patch for the specifed group as the sound to use for the note)
  399. @param inGroupID
  400. The group ID that this note will be attached too. As with MIDI, all notes sounding on a groupID can be
  401. controlled through the various parameters (such as pitch bend, etc) that can be specified on the Group
  402. Scope
  403. @param outNoteInstanceID
  404. A pointer to receive the token that is used to identify the note. This parameter must be specified
  405. @param inOffsetSampleFrame
  406. If you are scheduling the MIDI Event from the audio unit's render thread, then you can supply a sample offset
  407. that the audio unit may apply when starting the note in its next audio unit render. This allows you to
  408. schedule to the sample and is particularly important when starting new notes. If you are not scheduling
  409. in the audio unit's render thread, then you should set this value to 0
  410. @param inParams
  411. The parameters to be used when starting the note - pitch and velocity must be specified
  412. @result noErr, or an audio unit error code
  413. }
  414. function MusicDeviceStartNote( inUnit: MusicDeviceComponent; inInstrument: MusicDeviceInstrumentID; inGroupID: MusicDeviceGroupID; var outNoteInstanceID: NoteInstanceID; inOffsetSampleFrame: UInt32; const (*var*) inParams: MusicDeviceNoteParams ): OSStatus; external name '_MusicDeviceStartNote';
  415. (* __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_NA) *)
  416. {!
  417. @function MusicDeviceStopNote
  418. @abstract used to stop notes started with the MusicDeviceStartNote call
  419. @discussion This call is used to stop notes that have been started with the MusicDeviceStartNote call; both the group ID
  420. that the note was started on and the noteInstanceID should be specified.
  421. @param inUnit
  422. The audio unit
  423. @param inGroupID
  424. the group ID
  425. @param inNoteInstanceID
  426. the note instance ID
  427. @param inOffsetSampleFrame
  428. the sample offset within the next buffer rendered that the note should be turned off at
  429. @result noErr, or an audio unit error code
  430. }
  431. function MusicDeviceStopNote( inUnit: MusicDeviceComponent; inGroupID: MusicDeviceGroupID; inNoteInstanceID: NoteInstanceID; inOffsetSampleFrame: UInt32 ): OSStatus; external name '_MusicDeviceStopNote';
  432. (* __OSX_AVAILABLE_STARTING(__MAC_10_0,__IPHONE_NA) *)
  433. {!
  434. @enum Music Device range
  435. @constant kMusicDeviceRange
  436. delineates the start of the selector ranges for music devices
  437. @constant kMusicDeviceMIDIEventSelect
  438. @constant kMusicDeviceSysExSelect
  439. @constant kMusicDevicePrepareInstrumentSelect
  440. @constant kMusicDeviceReleaseInstrumentSelect
  441. @constant kMusicDeviceStartNoteSelect
  442. @constant kMusicDeviceStopNoteSelect
  443. }
  444. const
  445. kMusicDeviceRange = $0100;
  446. kMusicDeviceMIDIEventSelect = $0101;
  447. kMusicDeviceSysExSelect = $0102;
  448. kMusicDevicePrepareInstrumentSelect = $0103;
  449. kMusicDeviceReleaseInstrumentSelect = $0104;
  450. kMusicDeviceStartNoteSelect = $0105;
  451. kMusicDeviceStopNoteSelect = $0106;
  452. //=====================================================================================================================
  453. //#pragma mark -
  454. //#pragma mark Fast-dispatch function prototypes
  455. {!
  456. @typedef MusicDeviceMIDIEventProc
  457. @discussion This proc can be exported through the FastDispatch property or is used as the prototype for
  458. an audio component dispatch for this selector.
  459. The arguments are the same as are provided to the corresponding API call
  460. @param inComponentStorage
  461. For a component manager component, this is the component instance storage pointer
  462. @param inStatus
  463. @param inData1
  464. @param inData2
  465. @param inOffsetSampleFrame
  466. @result noErr, or an audio unit error code
  467. }
  468. type
  469. MusicDeviceMIDIEventProc = function( inComponentStorage: UnivPtr; inStatus: UInt32; inData1: UInt32; inData2: UInt32; inOffsetSampleFrame: UInt32 ): OSStatus;
  470. {!
  471. @typedef MusicDeviceSysExProc
  472. @discussion This proc can be exported through the FastDispatch property or is used as the prototype for
  473. an audio component dispatch for this selector.
  474. The arguments are the same as are provided to the corresponding API call
  475. @param inComponentStorage
  476. For a component manager component, this is the component instance storage pointer
  477. @param inData
  478. @param inLength
  479. @result noErr, or an audio unit error code
  480. }
  481. type
  482. MusicDeviceSysExProc = function( inComponentStorage: UnivPtr; (*const*) inData: UnivPtr; inLength: UInt32 ): OSStatus;
  483. {!
  484. @typedef MusicDeviceStartNoteProc
  485. @discussion This proc can be exported through the FastDispatch property or is used as the prototype for
  486. an audio component dispatch for this selector.
  487. The arguments are the same as are provided to the corresponding API call
  488. @param inComponentStorage
  489. For a component manager component, this is the component instance storage pointer
  490. @param inInstrument
  491. @param inGroupID
  492. @param outNoteInstanceID
  493. @param inOffsetSampleFrame
  494. @param inParams
  495. @result noErr, or an audio unit error code
  496. }
  497. type
  498. MusicDeviceStartNoteProc = function( inComponentStorage: UnivPtr; inInstrument: MusicDeviceInstrumentID; inGroupID: MusicDeviceGroupID; var outNoteInstanceID: NoteInstanceID; inOffsetSampleFrame: UInt32; const (*var*) inParams: MusicDeviceNoteParams ): OSStatus;
  499. {!
  500. @typedef MusicDeviceStopNoteProc
  501. @discussion This proc can be exported through the FastDispatch property or is used as the prototype for
  502. an audio component dispatch for this selector.
  503. The arguments are the same as are provided to the corresponding API call
  504. @param inComponentStorage
  505. For a component manager component, this is the component instance storage pointer
  506. @param inGroupID
  507. @param inNoteInstanceID
  508. @param inOffsetSampleFrame
  509. @result noErr, or an audio unit error code
  510. }
  511. type
  512. MusicDeviceStopNoteProc = function( inComponentStorage: UnivPtr; inGroupID: MusicDeviceGroupID; inNoteInstanceID: NoteInstanceID; inOffsetSampleFrame: UInt32 ): OSStatus;
  513. //=====================================================================================================================
  514. //#pragma mark -
  515. //#pragma mark Deprecated
  516. {
  517. The notion of instruments (separate voices assigned to different control groups) is a deprecated concept.
  518. Going forward, multitimbral synths are implemented using Part Scopes.
  519. Thus, the Prepare and Release Instrument API calls are deprecated (see also MusicDeviceStartNote)
  520. }
  521. function MusicDevicePrepareInstrument( inUnit: MusicDeviceComponent; inInstrument: MusicDeviceInstrumentID ): OSStatus; external name '_MusicDevicePrepareInstrument';
  522. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5, __IPHONE_NA, __IPHONE_NA) *)
  523. function MusicDeviceReleaseInstrument( inUnit: MusicDeviceComponent; inInstrument: MusicDeviceInstrumentID ): OSStatus; external name '_MusicDeviceReleaseInstrument';
  524. (* __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0,__MAC_10_5, __IPHONE_NA, __IPHONE_NA) *)
  525. {$endc} { TARGET_OS_MAC }
  526. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  527. end.
  528. {$endc} {not MACOSALLINCLUDE}