MusicDevice.pas 23 KB

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