ARAInterface.h 215 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677
  1. //------------------------------------------------------------------------------
  2. //! \file ARAInterface.h
  3. //! definition of the ARA application programming interface
  4. //! \project ARA API Specification
  5. //! \copyright Copyright (c) 2012-2021, Celemony Software GmbH, All Rights Reserved.
  6. //! Developed in cooperation with PreSonus Software Ltd.
  7. //! \license Licensed under the Apache License, Version 2.0 (the "License");
  8. //! you may not use this file except in compliance with the License.
  9. //! You may obtain a copy of the License at
  10. //!
  11. //! http://www.apache.org/licenses/LICENSE-2.0
  12. //!
  13. //! Unless required by applicable law or agreed to in writing, software
  14. //! distributed under the License is distributed on an "AS IS" BASIS,
  15. //! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. //! See the License for the specific language governing permissions and
  17. //! limitations under the License.
  18. //------------------------------------------------------------------------------
  19. /***************************************************************************************************/
  20. // IMPORTANT:
  21. // Please read ARA_API.pdf for general documentation before studying this header!
  22. /***************************************************************************************************/
  23. #ifndef ARAInterface_h
  24. #define ARAInterface_h
  25. /***************************************************************************************************/
  26. #if defined(__clang__)
  27. #pragma mark General configuration
  28. #endif
  29. /***************************************************************************************************/
  30. /***************************************************************************************************/
  31. // C99 standard includes for the basic data types
  32. #include <stddef.h>
  33. #include <stdint.h>
  34. /***************************************************************************************************/
  35. // Auxiliary defines for Doxygen code generation, must evaluate to 0 for actual code compilation
  36. // Enable this when building Doxygen documentation
  37. #if !defined(ARA_DOXYGEN_BUILD)
  38. #define ARA_DOXYGEN_BUILD 0
  39. #endif
  40. /***************************************************************************************************/
  41. // Various configurations/decorations to ensure binary compatibility across compilers:
  42. // struct packing and alignment, calling conventions, etc.
  43. #if defined(__cplusplus) && !(ARA_DOXYGEN_BUILD)
  44. namespace ARA
  45. {
  46. extern "C"
  47. {
  48. #endif
  49. // define CPU architecture
  50. #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
  51. #define ARA_CPU_X86 1
  52. #define ARA_CPU_ARM 0
  53. #elif defined(__aarch64__) || defined(__arm64__) || defined(__arm64e__) || defined(_M_ARM64)
  54. #define ARA_CPU_X86 0
  55. #define ARA_CPU_ARM 1
  56. //#elif defined(__ppc__) || defined(__ppc64__)
  57. // #define ARA_CPU_PPC 1
  58. #else
  59. #error "unsupported CPU architecture"
  60. #endif
  61. // To prevent any alignment/padding settings from the surrounding code to modify the ARA data layout,
  62. // we need to explicitly define the layout here. Ideally, we would stick with the C standard
  63. // alignment/padding (struct alignment defined by largest member, each member aligned by its size),
  64. // but at the time when ARA 1 was developed there was no way to achieve this in code.
  65. // As a workaround, ARA started using 1-byte packing. However, this causes some members in some of
  66. // the ARA structs to be not naturally aligned on 64 bit systems. But moreover, this also affects
  67. // the possible alignment of all ARA structs in some compilers. Thus developers that directly use
  68. // the C API must carefully align any struct that they pass across the API boundary in order to avoid
  69. // performance penalties. When using the ARA library C++ dispatch code, the SizedStruct<> template
  70. // which is used as central low-level wrapper for any data crossing the API takes care of this issue.
  71. #if defined(_MSC_VER) || defined(__GNUC__)
  72. #if ARA_CPU_X86
  73. // This is for historical reason only - current MSVC defaults are 8 on x86 and 16 on x64.
  74. #pragma pack(push, 1)
  75. #elif ARA_CPU_ARM
  76. // MSVC default for ARM64 is 8, this also fits the standard packing by member size for
  77. // the vast majority of the structs in the ARA API on 64 bit processors.
  78. #pragma pack(push, 8)
  79. #else
  80. #error "struct packing and alignment not yet defined for this architecture"
  81. #endif
  82. #else
  83. #error "struct packing and alignment not yet defined for this compiler"
  84. #endif
  85. // Override any custom calling conventions, enforce the C standard calling convention.
  86. #if defined(_MSC_VER)
  87. #define ARA_CALL __cdecl
  88. #else
  89. #define ARA_CALL
  90. #endif
  91. /***************************************************************************************************/
  92. //! @addtogroup API_generations API Generations
  93. // Macros to mark API added or deprecated as the API evolves - see ARAAPIGeneration.
  94. //! @{
  95. // Internal macro to trigger deprecation warnings (not fully supported by all compilers).
  96. #if defined(__cplusplus) && defined(__has_cpp_attribute)
  97. #if __has_cpp_attribute(deprecated)
  98. // C++14 standard
  99. #define ARA_WARN_DEPRECATED(generation) [[deprecated("deprecated as of kARAAPIGeneration_"#generation)]]
  100. #endif
  101. #endif
  102. #if !defined(ARA_WARN_DEPRECATED) && defined(__GNUC__)
  103. // Vendor-specific: gcc & clang.
  104. #define ARA_WARN_DEPRECATED(generation) __attribute__((deprecated))
  105. #endif
  106. #if !defined(ARA_WARN_DEPRECATED) && defined(_MSC_VER)
  107. // Vendor-specific: Visual Studio.
  108. #define ARA_WARN_DEPRECATED(generation) __declspec(deprecated("deprecated as of kARAAPIGeneration_"#generation))
  109. #endif
  110. //! Markup for outdated API that should no longer be used in future development, but can still
  111. //! be supported for backwards compatibility with older plug-ins/hosts if desired. \br
  112. //! By defining ARA_ENABLE_DEPRECATION_WARNINGS as non-zero value it is possible to get deprecation
  113. //! warnings in the most common compilers, for inspecting deprecated API usage in a given project.
  114. //! These warnings are disabled by default in order to not interfere with code that supports older APIs.
  115. #define ARA_DEPRECATED(generation)
  116. #if defined(ARA_ENABLE_DEPRECATION_WARNINGS) && (ARA_ENABLE_DEPRECATION_WARNINGS)
  117. #if !defined(ARA_WARN_DEPRECATED)
  118. #warning ARA_ENABLE_DEPRECATION_WARNINGS is not supported for this compiler - no deprecation warnings will be shown!
  119. #endif
  120. #undef ARA_DEPRECATED
  121. #define ARA_DEPRECATED(generation) ARA_WARN_DEPRECATED(generation)
  122. #endif
  123. //! Markup for struct elements which were added in later revisions of the API and may be omitted
  124. //! from the struct when dealing with older plug-ins/hosts.
  125. #define ARA_ADDENDUM(generation)
  126. //! Markup for draft API that is still under active development and not yet properly versioned -
  127. //! when using those struct elements, host and plug-in must agree on a specific draft header version! \br
  128. //! All uses of this macro will be replaced by ARA_ADDENDUM() upon final release.
  129. //! To quickly find all places in your project that use draft API, it's possible to temporarily
  130. //! redefine ARA_DRAFT to ARA_WARN_DEPRECATED(...).
  131. #define ARA_DRAFT ARA_ADDENDUM(2_X_Draft)
  132. // use this alternate definition to trigger a "deprecation" warning for every location draft API is used
  133. //#undef ARA_DRAFT
  134. //#define ARA_DRAFT ARA_WARN_DEPRECATED(2_X_Draft)
  135. //! @}
  136. /***************************************************************************************************/
  137. #if defined(__clang__)
  138. #pragma mark Basic constants and data types
  139. #endif
  140. //! @defgroup Basic_Types Basic Types
  141. //! Pre-defined types to ensure binary compatibility between plug-in and host.
  142. //! These types must be used when crossing the API boundary, but intermediate types can be used internally.
  143. //! For example, you can use your own struct representing color, but when defining color for ARA operations
  144. //! your internal color struct must be converted to ARAColor.
  145. //! @{
  146. /***************************************************************************************************/
  147. /***************************************************************************************************/
  148. //! @defgroup Fixed-size_integers Fixed-size Integers
  149. //! ARA defines platform-independent signed integers with fixed size of 32 or 64 bits
  150. //! and for a pointer-sized signed integer.
  151. //! @{
  152. //! Byte: 8 bits wide unsigned integer.
  153. typedef uint8_t ARAByte;
  154. //! 32 bits wide signed integer.
  155. typedef int32_t ARAInt32;
  156. //! 64 bits wide signed integer.
  157. typedef int64_t ARAInt64;
  158. //! Pointer-wide size value for ARA structs.
  159. typedef size_t ARASize;
  160. //! @}
  161. /***************************************************************************************************/
  162. //! @defgroup Boolean_values Boolean Values
  163. //! Since Microsoft still doesn't fully support C99 and fails to provide <stdbool.h>,
  164. //! we need to roll our own. On the other hand this ensures a fixed size of 32 bits, too.
  165. //! 32 bits were chosen so that ARABool is consistent with the other enum-like data types such as
  166. //! ARAContentType. Since ARABool is only used in temporary structs that are valid only for the
  167. //! duration of a call and likely passed in a register in most cases, there's no point in trying
  168. //! to optimize for size by using 8 bit boolean types.
  169. //! Note that in order to avoid conversion warnings in Visual Studio, you should not directly cast
  170. //! bool to ARABool or vice versa, but instead use a ternary operator or a comparison like this:
  171. //! \code{.c}
  172. //! araBool = (cppBool) ? kARATrue : kARAFalse;
  173. //! cppBool = (araBool != kARAFalse);
  174. //! \endcode
  175. //! Providing conversion operators for ARABool for C++ that handle this automatically is alas no
  176. //! viable option, because ARABool is only a typedef so this would lead to side-effects for all
  177. //! conversions from the integer type that ARABool is defined upon.
  178. //! @{
  179. //! Platform independent 32-bit boolean value.
  180. typedef ARAInt32 ARABool;
  181. #if defined(__cplusplus)
  182. //! "true" value for ARABool.
  183. constexpr ARABool kARATrue { 1 };
  184. //! "false" value for ARABool.
  185. constexpr ARABool kARAFalse { 0 };
  186. #else
  187. #define kARATrue ((ARABool)1)
  188. #define kARAFalse ((ARABool)0)
  189. #endif
  190. //! @}
  191. /***************************************************************************************************/
  192. //! @defgroup Enums Enums
  193. //! ARA enums can either be used to represent distinct enumerations, or to
  194. //! declare C-compatible constant integer flags that can be or'd together as bit masks.
  195. //! To ensure binary compatibility between plug-in and host, the underlying type
  196. //! of ARA enums is always ARAInt32.
  197. //! @{
  198. //! Define a 32-bit ARA enum type.
  199. //! The actual enum declaration is encapsulated in a macro to allow for adjusting it between
  200. //! C++, C and Doxygen builds.
  201. #if ARA_DOXYGEN_BUILD
  202. #define ARA_32_BIT_ENUM(name) \
  203. enum name : ARAInt32
  204. #elif defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && (_MSC_VER >= 1900)))
  205. #define ARA_32_BIT_ENUM(name) \
  206. ARAInt32 name; \
  207. enum : ARAInt32
  208. #else
  209. #define ARA_32_BIT_ENUM(name) \
  210. ARAInt32 name; \
  211. enum
  212. #endif
  213. //! @}
  214. /***************************************************************************************************/
  215. //! @defgroup Strings Strings
  216. //! User-readable texts are stored as UTF-8 encoded unicode strings.
  217. //! It's not defined if and how the string is normalized - if either side has requirements regarding
  218. //! normalization, it needs to apply these after reading the string from the other side.
  219. //! Unicode rules apply regarding normalization, comparison etc.
  220. //! Both hosts and plug-ins are required to support at least all ISO/IEC 8859-1 based characters
  221. //! (from U+0020 up to U+007E and from U+00A0 up to U+00FF) in their text display rendering.
  222. //! @{
  223. //! A single character.
  224. typedef char ARAUtf8Char;
  225. //! A string, 0-terminated.
  226. typedef const ARAUtf8Char * ARAUtf8String;
  227. //! @}
  228. /***************************************************************************************************/
  229. //! @defgroup Common_time-related_data_types Common Time-Related Data Types
  230. //! Some basic data types used in several contexts.
  231. //! @{
  232. //! A point in time in seconds.
  233. typedef double ARATimePosition;
  234. //! A duration of time in seconds - the start of the duration is part of the interval, the end is not.
  235. typedef double ARATimeDuration;
  236. //! Integer sample index, always related to a particular sample rate defined by the context it is used in.
  237. typedef ARAInt64 ARASamplePosition;
  238. //! Integer sample count, always related to a particular sample rate defined by the context this is used in.
  239. typedef ARAInt64 ARASampleCount;
  240. //! A position in musical time measured in quarter notes.
  241. typedef double ARAQuarterPosition;
  242. //! A duration in musical time measured in quarter notes - the start of the duration is part of the interval, the end is not.
  243. typedef double ARAQuarterDuration;
  244. //! @}
  245. /***************************************************************************************************/
  246. //! @defgroup Sampled_audio_data Sampled Audio Data
  247. //! The audio samples are encoded using these format descriptions.
  248. //! The data alignment and byte order always matches the machine's native layout.
  249. //! @{
  250. //! Specified in Hz.
  251. typedef double ARASampleRate;
  252. //! In the current version of ARA, no spatial positioning of the channels is defined.
  253. typedef ARAInt32 ARAChannelCount;
  254. //! @}
  255. /***************************************************************************************************/
  256. //! @defgroup Color Color
  257. //! ARA color representation.
  258. //! @{
  259. //! R/G/B color, values range from 0.0f to 1.0f.
  260. //! Does not include transparency because it must not depend on the background its drawn upon
  261. //! in order to be equally represented in both the host and plug-in UI - any transparency on
  262. //! either side must be converted depending on internal drawing before/after the ARA calls.
  263. ARA_ADDENDUM(2_0_Draft) typedef struct ARAColor
  264. {
  265. float r; //!< red
  266. float g; //!< green
  267. float b; //!< blue
  268. } ARAColor;
  269. //! @}
  270. /***************************************************************************************************/
  271. //! @defgroup Object_References Object References
  272. //! ARA uses pointer-sized unique identifiers to reference objects at runtime -
  273. //! typical C++-based implementations will use the this-pointer as ID.
  274. //! C-style code could do the same, or instead choose to use array indices as ID. \br
  275. //! Those objects that are archived by the host can be persistently identified
  276. //! by an ::ARAPersistentID that the host assigns as a property of the object.
  277. //! @{
  278. //! @name Markup Types
  279. //! Type-safe representations of the opaque refs/host refs.
  280. //! The markup types allow for overloaded custom conversion functions if using C++,
  281. //! or for re-defining the markup types to actual implementations in C like this:
  282. //! \code{.c}
  283. //! #define ARAAudioSourceRefMarkupType MyAudioFileClass
  284. //! #define ARAMusicalContextRefMarkupType MyGlobalTracksClass
  285. //! \endcode
  286. //! ... etc ...
  287. //! @{
  288. //! Plug-in reference markup type identifier. \br\br
  289. //! Examples: \br
  290. //! ::ARAMusicalContextRef \br
  291. //! ::ARARegionSequenceRef \br
  292. //! ::ARAAudioSourceRef \br
  293. //! ::ARAAudioModificationRef \br
  294. //! ::ARAPlaybackRegionRef \br
  295. //! ::ARAContentReaderRef \br
  296. //! ::ARADocumentControllerRef \br
  297. //! ::ARAPlaybackRendererRef \br
  298. //! ::ARAEditorRendererRef \br
  299. //! ::ARAEditorViewRef \br
  300. #define ARA_REF(RefType) struct RefType##MarkupType * RefType
  301. //! Host reference markup type identifier. \br\br
  302. //! Examples: \br
  303. //! ::ARAMusicalContextHostRef \br
  304. //! ::ARARegionSequenceHostRef \br
  305. //! ::ARAAudioSourceHostRef \br
  306. //! ::ARAAudioModificationHostRef \br
  307. //! ::ARAPlaybackRegionHostRef \br
  308. //! ::ARAContentReaderHostRef \br
  309. //! ::ARAAudioAccessControllerHostRef \br
  310. //! ::ARAAudioReaderHostRef \br
  311. //! ::ARAArchivingControllerHostRef \br
  312. //! ::ARAArchiveReaderHostRef \br
  313. //! ::ARAArchiveWriterHostRef \br
  314. //! ::ARAContentAccessControllerHostRef \br
  315. //! ::ARAModelUpdateControllerHostRef \br
  316. //! ::ARAPlaybackControllerHostRef \br
  317. #define ARA_HOST_REF(HostRefType) struct HostRefType##MarkupType * HostRefType
  318. //! @}
  319. //! @name Persistent IDs
  320. //! @{
  321. //! Persistent object reference representation.
  322. //! Persistent IDs are used to encode object references between plug-in and host when dealing
  323. //! with persistency. Contrary to the user-readable ARAUtf8String, ARAPersistentIDs are seven-bit
  324. //! US-ASCII-encoded strings, such as "com.manufacturerDomain.someIdentifier", and can thus be
  325. //! directly compared using strcmp() and its siblings. They can be copied using strcpy() and must
  326. //! always be compared by value, not by address.
  327. typedef const char * ARAPersistentID;
  328. //! @}
  329. //! @}
  330. //! @}
  331. /***************************************************************************************************/
  332. #if defined(__clang__)
  333. #pragma mark Versioning support
  334. #endif
  335. //! @defgroup API_versions API Versions
  336. //! ARA implements two patterns for its ongoing evolution of the API: incremental, fully-backwards
  337. //! compatible additions by appending features to it versioned structs, and major, potentially
  338. //! incompatible updates through its API generations.
  339. //! @{
  340. /***************************************************************************************************/
  341. /***************************************************************************************************/
  342. //! @defgroup API_generations API Generations
  343. //! While purely additive features can be handled through ARA's versioned structs,
  344. //! ARA API generations allow for non-backwards-compatible, fundamental API changes.
  345. //! For hosts that rely on a certain minimum ARA feature set provided by the plug-ins, it also
  346. //! offers a convenient way to filter incompatible plug-ins.
  347. //! Plug-ins on the other hand can use the API generation chosen by the host to optimize their
  348. //! feature set for the given environment, such as disabling potentially costly fallback code
  349. //! required for older hosts when running in a modern host.
  350. //! @{
  351. typedef ARA_32_BIT_ENUM(ARAAPIGeneration)
  352. {
  353. #if !ARA_CPU_ARM
  354. //! private API between Studio One and Melodyne
  355. kARAAPIGeneration_1_0_Draft = 1,
  356. //! supported by Studio One, Cakewalk/SONAR, Samplitude Pro, Mixcraft, Waveform/Tracktion, Melodyne, VocAlign, AutoTune
  357. kARAAPIGeneration_1_0_Final = 2,
  358. //! supported by Studio One, Logic Pro, Cubase/Nuendo, Cakewalk, REAPER, Melodyne, ReVoice Pro, VocAlign, Auto-Align, SpectraLayers
  359. kARAAPIGeneration_2_0_Draft = 3,
  360. #endif
  361. //! most developers supporting kARAAPIGeneration_2_0_Draft are already working on updating to kARAAPIGeneration_2_0_Final
  362. //! (this is also required for ARM builds)
  363. kARAAPIGeneration_2_0_Final = 4,
  364. //! reserved for future development
  365. kARAAPIGeneration_2_X_Draft = 5
  366. };
  367. //! @}
  368. /***************************************************************************************************/
  369. //! @defgroup Versioned_structs Versioned Structs
  370. //! In the various interface and data structs used in the ARA API, callback pointers or data fields
  371. //! may be added in later revisions of the current API generation. Each of these extensible structs
  372. //! starts with a structSize data field that describes how much data is actually contained in the
  373. //! given instance of the struct, thus allowing to determine which of the additional features are
  374. //! supported by the other side.
  375. //! All struct members that are later additions will be marked with the macro ARA_ADDENDUM.
  376. //! Members that are not marked as addendum must always be present in the struct.
  377. //! Accordingly, the minimum value of structSize is the size of the struct in the first API revision.
  378. //! When creating such a struct in your code, the maximum value is the size of the struct in the
  379. //! current API revision used at compile time. When parsing a struct received from the other side,
  380. //! the value may be even larger since the other side may use an even later API revision.
  381. //! \br
  382. //! Note that when implementing ARA, it is important not to directly use sizeof() when filling in
  383. //! the structSize values. If you later update to newer API headers, the values of sizeof() will
  384. //! change and your code thus will be broken until you've implemented all additions.
  385. //! Instead, use the ARA_IMPLEMENTED_STRUCT_SIZE macro or similar techniques added in the ARA
  386. //! C++ library dispatcher code, see \ref ARA_Library_Utility_SizedStructs "there".
  387. //! @{
  388. //! Macro that calculates the proper value for the structSize field of a versioned struct based
  389. //! on which features are actually implemented by the code that provides the struct.
  390. //! This may be different from sizeof() whenever features are added in the API, but not yet
  391. //! implemented in the current code base. Only after adding that implementation, the \p memberName
  392. //! parameter provided to ARA_IMPLEMENTED_STRUCT_SIZE should be updated accordingly.
  393. //! \br
  394. //! The ARA library C++ dispatchers implement a similar feature via templates,
  395. //! see ARA::SizedStruct<>.
  396. #if defined(__cplusplus)
  397. #define ARA_IMPLEMENTED_STRUCT_SIZE(StructType, memberName) (offsetof(ARA::StructType, memberName) + sizeof(static_cast<ARA::StructType *> (nullptr)->memberName))
  398. #else
  399. #define ARA_IMPLEMENTED_STRUCT_SIZE(StructType, memberName) (offsetof(StructType, memberName) + sizeof(((StructType *)NULL)->memberName))
  400. #endif
  401. //! Convenience macro to test if a field is present in a given struct.
  402. //! \br
  403. //! The ARA library C++ dispatchers implement a similar feature via templates,
  404. //! see ARA::SizedStructPtr::implements<>().
  405. #if defined(__cplusplus)
  406. #define ARA_IMPLEMENTS_FIELD(pointerToStruct, StructType, memberName) \
  407. ((pointerToStruct)->structSize > offsetof(ARA::StructType, memberName))
  408. #else
  409. #define ARA_IMPLEMENTS_FIELD(pointerToStruct, StructType, memberName) \
  410. ((pointerToStruct)->structSize > offsetof(StructType, memberName))
  411. #endif
  412. //! @}
  413. //! @}
  414. /***************************************************************************************************/
  415. #if defined(__clang__)
  416. #pragma mark Debugging support
  417. #endif
  418. //! @defgroup Debugging Debugging
  419. //! ARA strictly separates programming errors from runtime error conditions such as missing files,
  420. //! CPU or I/O overloads etc.
  421. //! Runtime errors occur when accessing external data and resources, which is always done on the host
  422. //! side of the ARA API. Accordingly, the host has the responsibility to detect any such errors and
  423. //! to properly communicate the issue to the user. Since ARA leverages existing technologies, host
  424. //! implementations usually already feature proper code for this.
  425. //! With the error reporting done on the host side, plug-ins do not need to know any details about
  426. //! runtime errors - a simple bool to indicate success or failure is sufficient for implementing
  427. //! normal operation or graceful error recovery. Thus, ARA does not need to define error codes for
  428. //! communicating error details across the API.
  429. //! As an example, consider audio data being read from a server across the network - if the connection
  430. //! breaks, the host will recognize the issue and bring up an according user notification. If the
  431. //! plug-in requests the now inaccessible audio data, the host simply flags that an error occurred and
  432. //! the plug-in can either retry later or use silence as fallback data.
  433. //! \br
  434. //! A different kind of errors are programming errors. If either side fails to properly follow the
  435. //! API contract, undefined behavior can occur. Tracking down such bugs from one side only can be
  436. //! difficult and very time consuming, thus ARA strives to aid developers in this process by defining
  437. //! a global assert function that both sides call whenever detecting programming errors related to
  438. //! the ARA API.
  439. //! When debugging (or when running unit tests), either side can provide the code for the assert
  440. //! function, so that no matter what side you're debugging from you can always inject your custom
  441. //! assert handling in order to be able to set proper breakpoints etc.
  442. //! The assert function is only a debug facility: it will usually be disabled on end user systems,
  443. //! and it must never be used for flow control in a shipping product. Instead, each side should
  444. //! implement graceful fallback behavior after asserting the programming error, e.g. by defining a
  445. //! special value for invalid object refs (NULL or -1, depending on the implementation) which will
  446. //! be returned as a placeholder whenever object creation fails due to a programming error on the
  447. //! other side and then filtering this value accordingly whenever objects are referenced.
  448. //! @{
  449. /***************************************************************************************************/
  450. //! Hint about the nature of the programming error.
  451. typedef ARA_32_BIT_ENUM(ARAAssertCategory)
  452. {
  453. //! Not covered by any of the following codes.
  454. kARAAssertUnspecified = 0,
  455. //! Indicate that the caller passed invalid arguments.
  456. kARAAssertInvalidArgument = -1,
  457. //! Indicate that the call is invalid in the current state.
  458. //! e.g. if a document modification is being made without guarding it properly with
  459. //! ARADocumentControllerInterface::beginEditing() and ARADocumentControllerInterface::endEditing()
  460. kARAAssertInvalidState = -2,
  461. //! Indicate that the call cannot be made on the current thread.
  462. kARAAssertInvalidThread = -3
  463. };
  464. //! Global assert function pointer.
  465. //! The assert categories passed to the global assert function are useful both for guiding developers
  466. //! when debugging and for automatic assert evaluation when building unit tests. \br
  467. //! The diagnosis text is intended solely to aid the developer debugging an issue "from the
  468. //! other side"; they must not be presented to the user (or even parsed for flow control).
  469. //! If applicable (i.e. if the category is kARAAssertInvalidArgument), the diagnosis should contain
  470. //! a hint about what problematicArgument actually points to - for example if a struct is too small,
  471. //! you'd pass the pointer to the struct along with a diagnosis message a la:
  472. //! "someExampleInterfacePointer->structSize < kExampleStructMinSize".
  473. //! Creating such appropriate texts automatically can be easily accomplished by custom assert macros. \br
  474. //! Finally, problematicArgument should point to the argument that contains the invalid data, so that
  475. //! the developer on that end can quickly identify the problem. If you can't provide a meaningful
  476. //! address for it, e.g. because the category is kARAAssertInvalidThread, pass NULL here.
  477. typedef void (ARA_CALL * ARAAssertFunction) (ARAAssertCategory category, const void * problematicArgument,
  478. const char * diagnosis);
  479. //! @}
  480. /***************************************************************************************************/
  481. #if defined(__clang__)
  482. #pragma mark Model graph objects
  483. #endif
  484. //! @defgroup ARA_Model_Graph ARA Model Graph
  485. //! @{
  486. /***************************************************************************************************/
  487. /***************************************************************************************************/
  488. //! @defgroup Model_Document Document
  489. //! The document is the root object for a model graph and typically represents a piece of music
  490. //! such as a song or an entire performance.
  491. //! It is bound to a document controller in a 1:1 relationship. The document controller is used to
  492. //! manage the entire graph it contains. Because of the 1:1 relationship, the document is never
  493. //! specified when calling into the document controller.
  494. //! Edits of the document and any of the objects it contains are done in cycles started with
  495. //! ARADocumentControllerInterface::beginEditing() and concluded with
  496. //! ARADocumentControllerInterface::endEditing().
  497. //! This allows plug-ins to deal with any render thread synchronization that may be necessary,
  498. //! as well as postponing any internal updates until the end of the cycle when the ARA graph has
  499. //! its full state available.
  500. //! A document is the root object for persistency and is the owner of any amount of associated
  501. //! audio sources, region sequences and musical contexts.
  502. //! \br
  503. //! Plug-in developers using the C++ ARA Library can use the ARA::PlugIn::Document class.
  504. //! @{
  505. //! Document properties.
  506. //! Note that like all properties, a pointer to this struct is only valid for the duration of the
  507. //! call receiving the pointer - the data must be evaluated/copied inside the call, and the pointer
  508. //! must not be stored anywhere.
  509. typedef struct ARADocumentProperties
  510. {
  511. //! @see_Versioned_Structs
  512. ARASize structSize;
  513. //! User-readable name of the document as displayed in the host.
  514. //! The plug-in must copy the name, the pointer may be only valid for the duration of the call.
  515. //! It may be NULL if the host cannot provide a name for the document.
  516. //! In that case, the host should not make up some dummy name just to satisfy the API, but
  517. //! rather let the plug-in do this if desired - this way it can distinguish between a proper
  518. //! name visible somewhere in the host and a dummy name implicitly derived from other state.
  519. ARAUtf8String name;
  520. } ARADocumentProperties;
  521. // Convenience constant for easy struct validation.
  522. enum { kARADocumentPropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARADocumentProperties, name) };
  523. //! @}
  524. /***************************************************************************************************/
  525. //! @defgroup Model_Musical_Context Musical Context
  526. //! A musical context describes both rhythmical concepts of the music such as bars and beats and
  527. //! their distribution over time, as well as harmonic structures and their distribution over time.
  528. //! A musical context is always owned by one document.
  529. //! Musical contexts are not persistent when storing documents, instead the host re-creates them
  530. //! as needed.
  531. //! \br
  532. //! Plug-in developers using the C++ ARA Library can use the ARA::PlugIn::MusicalContext class.
  533. //! @{
  534. //! Reference to the plug-in side representation of a musical context (opaque to the host).
  535. typedef ARA_REF(ARAMusicalContextRef);
  536. //! Reference to the host side representation of a musical context (opaque to the plug-in).
  537. typedef ARA_HOST_REF(ARAMusicalContextHostRef);
  538. //! Musical context properties.
  539. //! Note that like all properties, a pointer to this struct is only valid for the duration of the
  540. //! call receiving the pointer - the data must be evaluated/copied inside the call, and the pointer
  541. //! must not be stored anywhere.
  542. typedef struct ARAMusicalContextProperties
  543. {
  544. //! @see_Versioned_Structs
  545. ARASize structSize;
  546. //! User-readable name of the musical context as displayed in the host.
  547. //! The plug-in must copy the name, the pointer may be only valid for the duration of the call.
  548. //! It may be NULL if the host cannot provide a name for the musical context (which is typically
  549. //! true for all hosts that only use a single context per document.)
  550. //! In that case, the host should not make up some dummy name just to satisfy the API, but
  551. //! rather let the plug-in do this if desired - this way it can distinguish between a proper
  552. //! name visible somewhere in the host and a dummy name implicitly derived from other state.
  553. ARA_ADDENDUM(2_0_Draft) ARAUtf8String name;
  554. //! Sort order of the musical context in the host.
  555. //! The index must allow for the plug-in to order the musical contexts as shown in the host,
  556. //! but the actual index values are not shown to the user. They can be arbitrary, but must
  557. //! increase strictly monotonically.
  558. ARA_ADDENDUM(2_0_Draft) ARAInt32 orderIndex;
  559. //! Color associated with the musical context in the host.
  560. //! The plug-in must copy the color, the pointer may be only valid for the duration of the call.
  561. //! It may be NULL if the host cannot provide a color for the musical context.
  562. ARA_ADDENDUM(2_0_Draft) const ARAColor * color;
  563. } ARAMusicalContextProperties;
  564. // Convenience constant for easy struct validation.
  565. enum { kARAMusicalContextPropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAMusicalContextProperties, structSize) };
  566. //! @}
  567. /***************************************************************************************************/
  568. //! @defgroup Model_Region_Sequences Region Sequences (Added In ARA 2.0)
  569. //! Region sequences allow hosts to group playback regions, typically by "tracks" or "lanes" in
  570. //! their arrangement.
  571. //! Each sequence is associated with a musical context, and all regions in a sequence will be adapted
  572. //! to that same context.
  573. //! Further, all regions within a sequence are expected to play back through the same routing (incl.
  574. //! same latency), typically the same "mixer track" or "audio channel".
  575. //! Regions in a sequence can overlap, and such overlapping regions will sound concurrently.
  576. //! A region sequence is always owned by one document, and refers to a musical context.
  577. //! Region sequences are not persistent when storing documents, instead the host re-creates them
  578. //! as needed.
  579. //! \br
  580. //! Plug-in developers using the C++ ARA Library can use the ARA::PlugIn::RegionSequence class.
  581. //! @{
  582. //! Reference to the plug-in side representation of a region sequence (opaque to the host).
  583. ARA_ADDENDUM(2_0_Draft) typedef ARA_REF(ARARegionSequenceRef);
  584. //! Reference to the host side representation of a region sequence (opaque to the plug-in).
  585. ARA_ADDENDUM(2_0_Draft) typedef ARA_HOST_REF(ARARegionSequenceHostRef);
  586. //! Region sequence properties.
  587. //! Note that like all properties, a pointer to this struct is only valid for the duration of the
  588. //! call receiving the pointer - the data must be evaluated/copied inside the call, and the pointer
  589. //! must not be stored anywhere.
  590. ARA_ADDENDUM(2_0_Draft) typedef struct ARARegionSequenceProperties
  591. {
  592. //! @see_Versioned_Structs
  593. ARASize structSize;
  594. //! User-readable name of the region sequence as displayed in the host.
  595. //! The plug-in must copy the name, the pointer may be only valid for the duration of the call.
  596. //! It may be NULL if the host cannot provide a name for the region sequence.
  597. //! In that case, the host should not make up some dummy name just to satisfy the API, but
  598. //! rather let the plug-in do this if desired - this way it can distinguish between a proper
  599. //! name visible somewhere in the host and a dummy name implicitly derived from other state.
  600. ARAUtf8String name;
  601. //! Sort order of the region sequence in the host.
  602. //! The index must allow for the plug-in to order the region sequences as shown in the host,
  603. //! but the actual index values are not shown to the user. They can be arbitrary, but must
  604. //! increase strictly monotonically.
  605. ARAInt32 orderIndex;
  606. //! Musical context in which the playback regions of the sequence will be edited and rendered.
  607. //! Note that when rendering the playback regions via any plug-in instance, the time information
  608. //! provided for this plug-in through the companion API must match this musical context.
  609. ARAMusicalContextRef musicalContextRef;
  610. //! Color associated with the region sequence in the host.
  611. //! The plug-in must copy the color, the pointer may be only valid for the duration of the call.
  612. //! It may be NULL if the host cannot provide a color for the region sequence.
  613. ARA_ADDENDUM(2_0_Draft) const ARAColor * color;
  614. } ARARegionSequenceProperties;
  615. // Convenience constant for easy struct validation.
  616. enum ARA_ADDENDUM(2_0_Draft) { kARARegionSequencePropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARARegionSequenceProperties, musicalContextRef) };
  617. //! @}
  618. /***************************************************************************************************/
  619. //! @defgroup Model_Audio_Source Audio Source
  620. //! An audio source represents a continuous sequence of sampled audio data. Typically a host will
  621. //! create an audio source object for each audio file used with ARA plug-ins.
  622. //! Conceptually, the contents of an audio source are immutable (even though updates are possible,
  623. //! this is an expensive process, and user edits based on the modified content may get lost).
  624. //! An audio source is always owned by one document, and in turn owns any amount of associated
  625. //! audio modifications.
  626. //! Audio sources are persistent when storing documents.
  627. //! \br
  628. //! Plug-in developers using the C++ ARA Library can use the ARA::PlugIn::AudioSource class.
  629. //! @{
  630. //! Reference to the plug-in side representation of an audio source (opaque to the host).
  631. typedef ARA_REF(ARAAudioSourceRef);
  632. //! Reference to the host side representation of an audio source (opaque to the plug-in).
  633. typedef ARA_HOST_REF(ARAAudioSourceHostRef);
  634. //! Audio source properties.
  635. //! Note that like all properties, a pointer to this struct is only valid for the duration of the
  636. //! call receiving the pointer - the data must be evaluated/copied inside the call, and the pointer
  637. //! must not be stored anywhere.
  638. typedef struct ARAAudioSourceProperties
  639. {
  640. //! @see_Versioned_Structs
  641. ARASize structSize;
  642. //! User-readable name of the audio source as displayed in the host.
  643. //! The plug-in must copy the name, the pointer may be only valid for the duration of the call.
  644. //! It may be NULL if the host cannot provide a name for the audio source.
  645. //! In that case, the host should not make up some dummy name just to satisfy the API, but
  646. //! rather let the plug-in do this if desired - this way it can distinguish between a proper
  647. //! name visible somewhere in the host and a dummy name implicitly derived from other state.
  648. ARAUtf8String name;
  649. //! ID used to re-connect model graph when archiving/unarchiving.
  650. //! This ID must be unique for all audio sources within the document.
  651. //! The plug-in must copy the persistentID, the pointer may be only valid for the duration of the call.
  652. ARAPersistentID persistentID;
  653. //! Total number of samples per channel of the contained audio material.
  654. //! May only be changed while access to the audio source is disabled,
  655. //! see ARADocumentControllerInterface::enableAudioSourceSamplesAccess().
  656. ARASampleCount sampleCount;
  657. //! Sample rate of the contained audio material.
  658. //! May only be changed while access to the audio source is disabled,
  659. //! see ARADocumentControllerInterface::enableAudioSourceSamplesAccess().
  660. //! Note that the sample rate of the audio source may not match the sample rate(s) used in the
  661. //! companion plug-in instances that render playback regions based on this audio source -
  662. //! plug-ins must apply sample rate conversion as needed.
  663. //! However, if the sample rate is changed, plug-ins are not required to translate their model
  664. //! to the new sample rate, and may instead restart with a fresh analysis, causing all user
  665. //! edits applied at the previous sample rate to be lost.
  666. ARASampleRate sampleRate;
  667. //! Count of discrete channels of the contained audio material.
  668. //! May only be changed while access to the audio source is disabled,
  669. //! see ARADocumentControllerInterface::enableAudioSourceSamplesAccess().
  670. //! As with sample rate changes, plug-ins may discard all edits and start with a fresh analysis
  671. //! if the channel count is changed.
  672. ARAChannelCount channelCount;
  673. //! Flag to indicating that the data is available in a resolution that cannot be represented
  674. //! in 32 bit float samples without losing quality.
  675. //! Depending on its internal algorithms, the plug-in may or may not base its decision to
  676. //! read either 32 or 64 bit samples on this flag,
  677. //! see ARAAudioAccessControllerInterface::createAudioReaderForSource().
  678. ARABool merits64BitSamples;
  679. } ARAAudioSourceProperties;
  680. // Convenience constant for easy struct validation.
  681. enum { kARAAudioSourcePropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAAudioSourceProperties, merits64BitSamples) };
  682. //! @}
  683. /***************************************************************************************************/
  684. //! @defgroup Model_Audio_Modification Audio Modification
  685. //! An audio modification contains a set of musical edits that the user has made to transform
  686. //! the content of an audio source when rendered by the ARA plug-in.
  687. //! An audio modification is always owned by one audio source, and in turn owns any amount of
  688. //! associated playback regions.
  689. //! Audio modifications are persistent when storing documents.
  690. //! \br
  691. //! Plug-in developers using the C++ ARA Library can use the ARA::PlugIn::AudioModification class.
  692. //! @{
  693. //! Reference to the plug-in side representation of an audio modification (opaque to the host).
  694. typedef ARA_REF(ARAAudioModificationRef);
  695. //! Reference to the host side representation of an audio modification (opaque to the plug-in).
  696. typedef ARA_HOST_REF(ARAAudioModificationHostRef);
  697. //! Audio modification properties.
  698. //! Note that like all properties, a pointer to this struct is only valid for the duration of the
  699. //! call receiving the pointer - the data must be evaluated/copied inside the call, and the pointer
  700. //! must not be stored anywhere.
  701. typedef struct ARAAudioModificationProperties
  702. {
  703. //! @see_Versioned_Structs
  704. ARASize structSize;
  705. //! User-readable name of the audio modification as displayed in the host.
  706. //! The plug-in must copy the name, the pointer may be only valid for the duration of the call.
  707. //! It may be NULL if the host cannot provide a name for the audio modification.
  708. //! In that case, the host should not make up some name (e.g. derived from the audio source), but
  709. //! rather let the plug-in do this if desired - this way it can distinguish between a proper name
  710. //! visible somewhere in the host and a dummy name implicitly derived from other state.
  711. ARAUtf8String name;
  712. //! ID used to re-connect model graph when archiving/unarchiving.
  713. //! This ID must be unique for all audio modifications within the document.
  714. //! The plug-in must copy the persistentID, the pointer may be only valid for the duration of the call.
  715. ARAPersistentID persistentID;
  716. } ARAAudioModificationProperties;
  717. // Convenience constant for easy struct validation.
  718. enum { kARAAudioModificationPropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAAudioModificationProperties, persistentID) };
  719. //! @}
  720. /***************************************************************************************************/
  721. //! @defgroup Model_Playback_Region Playback Region
  722. //! A playback region is a reference to an arbitrary time section of an audio modification,
  723. //! mapped to a certain section of playback time.
  724. //! It is linked to a region sequence, which in turn is linked to a musical context.
  725. //! All playback regions that share the same audio modification play back the same musical
  726. //! content, but may adapt that content to the given section of the musical context and to the
  727. //! content of other regions in the same region sequence (see content based fades).
  728. //! Note that if a plug-in offers any user settings to control this adaptation (such as groove settings),
  729. //! then these settings should be part of the audio modification state, not of the individual
  730. //! playback regions.
  731. //! A playback is always owned by one audio modification, and refers to a region sequence.
  732. //! Playback regions are not persistent when storing documents, instead the host re-creates them
  733. //! as needed.
  734. //! \br
  735. //! Plug-in developers using the C++ ARA Library can use the ARA::PlugIn::PlaybackRegion class.
  736. //! @{
  737. //! Reference to the plug-in side representation of a playback region (opaque to the host).
  738. typedef ARA_REF(ARAPlaybackRegionRef);
  739. //! Reference to the host side representation of a playback region (opaque to the plug-in).
  740. typedef ARA_HOST_REF(ARAPlaybackRegionHostRef);
  741. //! Playback region transformations.
  742. //! Plug-ins may or may not support all transformations that can be configured in a playback region.
  743. //! They express these capabilities at factory level, and the host must respect this.
  744. //! Also used in ARAFactory::supportedPlaybackTransformationFlags.
  745. typedef ARA_32_BIT_ENUM(ARAPlaybackTransformationFlags)
  746. {
  747. //! Named constant if no flags are set.
  748. //! If no flags are set, the modification is played back "as is", without further adoption
  749. //! to the given playback situation.
  750. kARAPlaybackTransformationNoChanges = 0,
  751. //! Time-stretching enable flag.
  752. //! If time-stretching is supported by the plug-in, the host can use this flag to enable it.
  753. //! If disabled, the host must always specify the same duration in modification and playback time,
  754. //! and the plug-in should ignore ARAPlaybackRegionProperties::durationInModificationTime.
  755. kARAPlaybackTransformationTimestretch = 1 << 0,
  756. //! Time-stretching tempo configuration flag.
  757. //! If kARAPlaybackTransformationTimestretch is set, this flag allows to distinguish whether
  758. //! the stretching shall be done in a strictly linear fashion (flag is off) or whether it
  759. //! shall reflect the tempo relationship between the musical context and the content of the
  760. //! audio modification (flag is on).
  761. kARAPlaybackTransformationTimestretchReflectingTempo = 1 << 1,
  762. ARA_ADDENDUM(2_0_Draft) kARAPlaybackTransformationContentBasedFadeAtTail = 1 << 2, //!< see ::kARAPlaybackTransformationContentBasedFades
  763. ARA_ADDENDUM(2_0_Draft) kARAPlaybackTransformationContentBasedFadeAtHead = 1 << 3, //!< see ::kARAPlaybackTransformationContentBasedFades
  764. //! Content-based fades enabling flags.
  765. //! These flags are used to enable smart, content-based fades at either end of the playback region.
  766. //! If supported by the plug-in, the host no longer needs to apply its regular overall fades at
  767. //! region borders, but can instead delegate this functionality to the plug-in.
  768. //! Based on the region sequence grouping, the plug-in can determine neighboring regions and
  769. //! utilize head and tail time to calculate a smart, musical transition.
  770. //! Even when no neighboring region is found, it may be appropriate to fade in or out to avoid
  771. //! cutting off signals abruptly.
  772. //! Note that while the transformation of a playback region can be defined separately for each
  773. //! border of the region, it must be enabled for either both or neither border in the
  774. //! ARAFactory::supportedPlaybackTransformationFlags.
  775. ARA_ADDENDUM(2_0_Draft) kARAPlaybackTransformationContentBasedFades = kARAPlaybackTransformationContentBasedFadeAtHead | kARAPlaybackTransformationContentBasedFadeAtTail,
  776. };
  777. //! Playback region properties.
  778. //! Note that like all properties, a pointer to this struct is only valid for the duration of the
  779. //! call receiving the pointer - the data must be evaluated/copied inside the call, and the pointer
  780. //! must not be stored anywhere.
  781. typedef struct ARAPlaybackRegionProperties
  782. {
  783. //! @see_Versioned_Structs
  784. ARASize structSize;
  785. //! Configuration of possible transformations upon playback, i.e. time-stretching etc.
  786. //! The host may only enable flags that are listed in ARAFactory::supportedPlaybackTransformationFlags.
  787. ARAPlaybackTransformationFlags transformationFlags;
  788. //! #startInModificationTime and #durationInModificationTime define the
  789. //! audible audio modification time range. This section of the modification's audio data will
  790. //! be mapped to the song playback time range defined below as configured by the #transformationFlags,
  791. //! including optional time stretching. See @ref sec_ManipulatingTheTiming for more information.
  792. ARATimePosition startInModificationTime;
  793. //! See #startInModificationTime. \br
  794. //! Plug-ins must deal with #durationInModificationTime being 0.0.
  795. ARATimeDuration durationInModificationTime;
  796. //! #startInPlaybackTime and #durationInPlaybackTime define the relationship between the
  797. //! audible modification time range and the song playback time in seconds as communicated
  798. //! via the companion API.
  799. //! Musical context content (such as ::kARAContentTypeTempoEntries) is also expressed
  800. //! in song playback time.
  801. ARATimePosition startInPlaybackTime;
  802. //! See #startInPlaybackTime. \br
  803. //! Plug-ins must deal with #durationInPlaybackTime being 0.0.
  804. ARATimeDuration durationInPlaybackTime;
  805. //! Musical context in which the playback region will be edited and rendered.
  806. //! Note that when rendering the playback region via any plug-in instance, the time information
  807. //! provided for this plug-in through the companion API must match this musical context.
  808. //! \deprecated
  809. //! No longer used since adding region sequences in ARA 2.0, which already define the musical
  810. //! context for all their respective regions. If structSize indicates that a sequence is used
  811. //! (i.e. when using ARA 2.0 or higher), this field must be ignored by plug-ins. Hosts are
  812. //! free to additionally set a valid musical context if desired for ARA 1 backwards compatibility,
  813. //! or leave the field uninitialized otherwise.
  814. ARA_DEPRECATED(2_0_Draft) ARAMusicalContextRef musicalContextRef;
  815. //! Region sequence with which the playback region is associated in the host.
  816. ARA_ADDENDUM(2_0_Draft) ARARegionSequenceRef regionSequenceRef;
  817. //! User-readable name of the playback region as displayed in the host.
  818. //! The plug-in must copy the name, the pointer may be only valid for the duration of the call.
  819. //! It may be NULL if the host cannot provide a name for the audio modification.
  820. //! In that case, the host should not make up some name (e.g. derived from the audio source), but
  821. //! rather let the plug-in do this if desired - this way it can distinguish between a proper name
  822. //! visible somewhere in the host and a dummy name implicitly derived from other state.
  823. ARA_ADDENDUM(2_0_Draft) ARAUtf8String name;
  824. //! Color associated with the playback region in the host.
  825. //! The plug-in must copy the color, the pointer may be only valid for the duration of the call.
  826. //! It may be NULL if the host cannot provide a color for the playback region.
  827. //! In that case, the host should not make up some color (e.g. derived from the track color), but
  828. //! rather let the plug-in do this if desired - this way it can distinguish between a proper color
  829. //! visible somewhere in the host and a dummy color implicitly derived from other state.
  830. ARA_ADDENDUM(2_0_Draft) const ARAColor * color;
  831. } ARAPlaybackRegionProperties;
  832. // Convenience constant for easy struct validation.
  833. enum { kARAPlaybackRegionPropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAPlaybackRegionProperties, musicalContextRef) };
  834. //! @}
  835. //! @}
  836. /***************************************************************************************************/
  837. #if defined(__clang__)
  838. #pragma mark Content Reading
  839. #endif
  840. // Note: when reading this header for the first time, you may want to skip the topic of content
  841. // updates and content reading - proceed directly to the host controller interfaces to gain a better
  842. // overall understanding of ARA, then come back to content reading later.
  843. //! @defgroup Content_Reading Content Reading
  844. //! @{
  845. /***************************************************************************************************/
  846. /***************************************************************************************************/
  847. //! @defgroup Model_Content_Updates Content Updates
  848. //! \br
  849. //! There are several levels of abstraction when analyzing musical recordings.
  850. //! Initially, there is the signal in its "physical" form.
  851. //! On the next level, the signal interpreted as a series of musical events - the notes played when
  852. //! creating the signal.
  853. //! These notes and their relationship in time and pitch can be interpreted further, leading to
  854. //! abstractions like tempo, bar signatures, key signatures, tuning and chords.
  855. //! \br
  856. //! Updates may happen on any of these levels, both independently or concurrently.
  857. //! In the most simple but most unlikely case, the signal is completely replaced, and all the
  858. //! higher abstractions therefore also invalidated. This also means that all user edits done in an
  859. //! audio modification will be lost.
  860. //! More likely is a minor modification of the signal, such as applying a high pass filtering to
  861. //! remove rumble in the audio source. This will not change any higher abstractions (all notes etc.
  862. //! remain the same), so any edits inside the audio modification or any notation of the music based
  863. //! on the analysis will remain intact.
  864. //! Another case is the correction of the analysis by the user. The signal does not change in this
  865. //! case, but mis-detected notes are added or removed so the mid-level abstraction which is
  866. //! considered with the notes changes. Whether or not this also changes higher interpretations
  867. //! such as the detected harmonic structure depends on the case at hand.
  868. //! \br
  869. //! ARA defines a set of flags that allow to communicate the level of change, which helps to avoid
  870. //! unnecessary flushing of the user edits inside an audio modification and allows for optimizations
  871. //! of the analysis. The flags are providing a guarantee what has NOT changed.
  872. //! This may seem odd at first but if for example a given host does not know about harmonies, it
  873. //! cannot make any assumption about whether these have changed or not.
  874. //! @{
  875. //! Flags indicating the scope of a content update.
  876. //! If notifying the API partner about a content update, the caller can make guarantees about which
  877. //! abstractions of the signal are unaffected by the given change.
  878. //! The enum flags describing these abstractions are or'd together into a single ARAInt32 value.
  879. //! \br
  880. //! The C++ ARA Library encapsulates content updates in the ARA::ContentUpdateScopes class.
  881. typedef ARA_32_BIT_ENUM(ARAContentUpdateFlags)
  882. {
  883. //! No flags set means update everything.
  884. kARAContentUpdateEverythingChanged = 0,
  885. //! The actual signal is unaffected by the change.
  886. //! Note that in some cases even when the signal is considered to be unchanged, the values of
  887. //! the actual sample data may change, e.g. if the user applies a sample rate conversion.
  888. kARAContentUpdateSignalScopeRemainsUnchanged = 1<<0,
  889. //! Content information for notes, beat-markers etc. is unaffected by the change.
  890. kARAContentUpdateNoteScopeRemainsUnchanged = 1<<1,
  891. //! Content information for tempo, bar signatures etc. is unaffected by the change.
  892. kARAContentUpdateTimingScopeRemainsUnchanged = 1<<2,
  893. //! Content readers for tuning (static or dynamic) are unaffected by the change. (added in ARA 2.0)
  894. ARA_ADDENDUM(2_0_Final) kARAContentUpdateTuningScopeRemainsUnchanged = 1<<3,
  895. //! Content readers for key signatures, chords etc. are unaffected by the change. (added in ARA 2.0)
  896. ARA_ADDENDUM(2_0_Final) kARAContentUpdateHarmonicScopeRemainsUnchanged = 1<<4
  897. };
  898. //! @}
  899. /***************************************************************************************************/
  900. //! @defgroup Model_Content_Readers_and_Content_Events Content Readers And Content Events
  901. //! \br
  902. //! Reading content description follows the same pattern both from the host and from the plug-in side.
  903. //! ARA establishes iterator objects called content reader to access the data in small units called
  904. //! content events. There are several types available, each defining a certain abstract representation
  905. //! of its associated events.
  906. //! \br
  907. //! Upon creation, content readers are bound to a given content type and to an object of which the
  908. //! content shall be read. Optionally the reader can be restricted to only cover a given time range.
  909. //! Once created, its event count is queried and the individual events are read, then the reader is
  910. //! disposed of. This is all done immediately, reader objects are only temporary objects that are
  911. //! created and destroyed from the same stack frame.
  912. //! \br
  913. //! The data pointer returned when reading an event's data remains owned by the content reader and
  914. //! must remain valid until the reader is either another event is read or the reader is destroyed.
  915. //! \br
  916. //! The events returned by the reader are sorted in an order that depends on the content type, but
  917. //! generally follows their appearance on the timeline. If several events appear at the same
  918. //! (start-)time, their order is not defined and the receiver must apply further sorting if desired.
  919. //! \br
  920. //! The C++ ARA Library offers convenient content reader classes for host and plug-in developers.
  921. //! Host developers can read plug-in content using ARA::Host::ContentReader, and plug-in developers
  922. //! can use ARA::PlugIn::HostContentReader to read host content.
  923. //! @{
  924. //! Reference to the plug-in side representation of a content reader (opaque to the host).
  925. typedef ARA_REF(ARAContentReaderRef);
  926. //! Reference to the host side representation of a content reader (opaque to the plug-in).
  927. typedef ARA_HOST_REF(ARAContentReaderHostRef);
  928. //! Types of data that can be shared between host and plug-in.
  929. typedef ARA_32_BIT_ENUM(ARAContentType)
  930. {
  931. //! @name Physical scope descriptions: currently none.
  932. //! May be added in later release, e.g. for restoration plug-ins.
  933. //@{
  934. //@}
  935. //! @name Note scope descriptions.
  936. //@{
  937. //! Returns const ARAContentNote * for each note.
  938. kARAContentTypeNotes = 10,
  939. /* postponed until needed
  940. // at this point it's not sure if there really is a need for beat-markers in addition to notes, but
  941. // there is a conceptual difference between both when dealing with chords, arpeggios etc.
  942. //! Returns const ARAContentBeatmarker * for each transient.
  943. kARAContentTypeBeatmarkers = 11,
  944. */
  945. //@}
  946. //! @name Time scope descriptions.
  947. //@{
  948. //! Returns const ARAContentTempoEntry * for each tempo sync point.
  949. kARAContentTypeTempoEntries = 20,
  950. //! Returns const ARAContentBarSignature * for each bar signature change.
  951. //! In the original ARA 1 API, this value was called kARAContentTypeSignatures -
  952. //! while its name has been changed with ARA 2 to distinguish it from kARAContentTypeKeySignatures,
  953. //! its semantics and binary encoding are still the same.
  954. kARAContentTypeBarSignatures = 21,
  955. //@}
  956. //! @name Tuning, Key Signatures and Chords (added in ARA 2.0)
  957. //! pitch scope descriptions:
  958. //@{
  959. //! Returns single const ARAContentTuning *.
  960. ARA_ADDENDUM(2_0_Final) kARAContentTypeStaticTuning = 31,
  961. //@}
  962. //! @name Harmonic scope descriptions.
  963. //@{
  964. //! Returns const ARAContentKeySignature * for each key signature change.
  965. ARA_ADDENDUM(2_0_Final) kARAContentTypeKeySignatures = 42,
  966. //! Returns const ARAContentChord * for each chord in a lead-sheet-like notation.
  967. //! (i.e. the sheet chord can imply notes that are not actually played in the audio,
  968. //! or vice versa. also, sheet chords are typically quantized to integer beats or even bars.)
  969. ARA_ADDENDUM(2_0_Final) kARAContentTypeSheetChords = 45
  970. //@}
  971. };
  972. //! Content reader optional creation parameter: a range in time to filter content events.
  973. //! As an optimization hint, a content reader can be asked to restrict its data to only those events
  974. //! that intersect with the given time range. Reader implementations should strive to respect this
  975. //! request, but focus on overall performance - the events actually returned may exceed the specified
  976. //! range by any amount, and calling code must evaluate the returned event positions/event durations.
  977. //!
  978. //! Note that when calls accept a pointer to a content time range, that pointer is only valid for
  979. //! the duration of the call - the data must be evaluated/copied inside the call, and the pointer
  980. //! must not be stored anywhere.
  981. //! Further, in most of these calls the pointer to a content range may be NULL, indicating that the
  982. //! entire content range of the object should be read.
  983. typedef struct ARAContentTimeRange
  984. {
  985. //! Events at start time are considered part of the range.
  986. ARATimePosition start;
  987. //! Events at start time + duration are not considered part of the range.
  988. ARATimeDuration duration;
  989. } ARAContentTimeRange;
  990. //! Content grade: degree of reliability of the provided content information.
  991. //! The most prominent use of the content grade is to solve conflicts between data provided by the
  992. //! host and data found via analysis on the plug-in side. Another example is that when being notified
  993. //! about content changes in the plug-in, a host may choose to trigger certain automatic updates only
  994. //! if the grade of the content is above a certain reliability threshold.
  995. typedef ARA_32_BIT_ENUM(ARAContentGrade)
  996. {
  997. //! Default data used as placeholder value.
  998. //! This grade can be used when no actual content information is present, such as the widely
  999. //! used default tempo of 120 bpm. This grade will typically be encountered while the analysis
  1000. //! is still pending or still being executed. It may also be used if analysis failed to provide
  1001. //! any meaningful results.
  1002. kARAContentGradeInitial = 0,
  1003. //! Data was provided by automatic content detection without any user intervention.
  1004. //! Since the user has not reviewed the data, it may not be reliable in some cases.
  1005. kARAContentGradeDetected = 1,
  1006. //! Data was reviewed or edited by the user but not specifically approved as fully correct.
  1007. //! This is the typical state of the data in the regular studio workflow.
  1008. kARAContentGradeAdjusted = 2,
  1009. //! Data has been specifically approved by the user as fully correct, e.g. for shipping it
  1010. //! as part of a content library.
  1011. kARAContentGradeApproved = 3
  1012. };
  1013. //! @}
  1014. /***************************************************************************************************/
  1015. //! @defgroup Model_Timeline Timeline
  1016. //! \br
  1017. //! ARA expresses musical timing as a mapping between song time measured in seconds and musical
  1018. //! time measured in quarter notes. The mapping is created by dividing the timeline into sections
  1019. //! of constant musical tempo. These tempo sections are then annotated as a list of tempo sync
  1020. //! points, where each point represents both the end of one and the beginning of another section.
  1021. //! The location of a tempo sync point is specified both in song time and musical time. The actual
  1022. //! tempo of a section can be easily derived from the relationship of the duration of the section
  1023. //! in song time and the duration of the section in musical time (note that neither the quarters nor
  1024. //! the seconds must necessarily be integer values here):
  1025. //! \verbatim
  1026. //! rightTempoEntry.quarterPosition - leftTempoEntry.quarterPosition
  1027. //! sectionTempoInBpm = ----------------------------------------------------------------- * 60.0 sec
  1028. //! rightTempoEntry.timePosition - leftTempoEntry.timePosition
  1029. //! \endverbatim
  1030. //! The advantage of providing such sync points whenever the tempo changes instead of specifying
  1031. //! the tempo directly is that there are no rounding errors that sum up over time - whenever the
  1032. //! tempo changes, this happens fully in sync.
  1033. //! The disadvantage of this representation is that there is no way to express the tempo before
  1034. //! the first and after the last tempo sync point, because the initial and final tempo sections
  1035. //! stretch "forever" into the past resp. future. ARA works around this by defining that the
  1036. //! initial tempo is equal to the tempo between the first and the second tempo sync point and that
  1037. //! the final tempo is equal to the tempo between the last-but-one and the last tempo sync point.
  1038. //! This means that there must always be at least 2 sync points in a valid ARA time line definition.
  1039. //! \br
  1040. //! To ease parsing the timeline, ARA further requires that there must be a tempo sync point given
  1041. //! at quarter 0, even if there is no actual tempo change at this point in time. This allows for
  1042. //! precisely determining any offset between time 0 seconds and quarter 0 without introducing possible
  1043. //! rounding errors. (If a content range is specified, this only applies if quarter 0 is part of the
  1044. //! content range.)
  1045. //! \br
  1046. //! Musical timing is commonly not notated by simply counting quarter notes - instead bars are
  1047. //! defined that form repeating patterns. ARA expresses this by providing a list of bar signatures.
  1048. //! Like in standard musical notation, the bar signatures are expressed as a fraction of two integer
  1049. //! values: numerator/denominator.
  1050. //! The location of a bar signature is specified in musical time. To make sense musically, the
  1051. //! distance between two bar signatures must be an integer multiple of the bar length of the earlier
  1052. //! of the two signatures (even though the bar length itself may not be integer, e.g. when using a
  1053. //! measure of 7/8). Note that when implementing the translation of these values to/from your code,
  1054. //! potential rounding issues must be handled properly to ensure the desired positions are extracted.
  1055. //! @{
  1056. //! Content reader event class: tempo map provided by kARAContentTypeTempoEntries.
  1057. //! Event sort order is by timePosition.
  1058. //! As with all content readers, a pointer to this struct retrieved via getContentReaderDataForEvent()
  1059. //! is still owned by the callee and must remain valid until either getContentReaderDataForEvent()
  1060. //! is called again or the reader is destroyed via destroyContentReader().
  1061. typedef struct ARAContentTempoEntry
  1062. {
  1063. //! Time in seconds relative to the start of the song or the audio source/modification.
  1064. ARATimePosition timePosition;
  1065. //! Corresponding time in quarter notes.
  1066. ARAQuarterPosition quarterPosition;
  1067. } ARAContentTempoEntry;
  1068. //! Content reader event class: bar signatures provided by kARAContentTypeBarSignatures.
  1069. //! The event position relates to ARAContentTempoEntry, a valid tempo map must be provided
  1070. //! by any provider of ARAContentBarSignature.
  1071. //! Each bar signature is valid until the following one, and the first bar signature is assumed to
  1072. //! also be valid any time before it is actually defined.
  1073. //! The location of the first bar signature is also considered to be the location of bar 1.
  1074. //! Event sort order is by position.
  1075. //! As with all content readers, a pointer to this struct retrieved via getContentReaderDataForEvent()
  1076. //! is still owned by the callee and must remain valid until either getContentReaderDataForEvent()
  1077. //! is called again or the reader is destroyed via destroyContentReader().
  1078. typedef struct ARAContentBarSignature
  1079. {
  1080. //! Numerator of the bar signature.
  1081. ARAInt32 numerator;
  1082. //! Denominator of the bar signature.
  1083. ARAInt32 denominator;
  1084. //! Start time in quarter notes, see ARAContentTempoEntry.
  1085. ARAQuarterPosition position;
  1086. } ARAContentBarSignature;
  1087. //! @}
  1088. /***************************************************************************************************/
  1089. //! @defgroup Model_Notes Notes
  1090. //! \br
  1091. //! Notes in ARA correspond to what a composer would notate to describe the music.
  1092. //! Notes are described by their position in time, their pitch and their relative volume.
  1093. //! The pitch can be interpreted as frequency, but ARA also offers a musical description of the
  1094. //! pitch very similar to MIDI: it defines the tuning for the overall musical scale and provides
  1095. //! an integer number to identify the pitch for each note within this tuning, along with an average
  1096. //! detune for each note actually played.
  1097. //! ARA pitch numbers match MIDI note numbers, so that the note A4 has the value 69.
  1098. //! This note is also used to specify the tuning reference, commonly at 440 Hz.
  1099. //! At 440 Hz reference tuning the ARA pitch number 0 thus equals 8.1757989 Hz.
  1100. //! Some notes may not have a well-defined pitch, such as percussive notes. For such notes,
  1101. //! a frequency of kARAInvalidFrequency and a pitch number of kARAInvalidPitchNumber are used.
  1102. //! @{
  1103. //! Quantized pitch, corresponds to the MIDI note number in the range 0...127, but may exceed this range.
  1104. typedef ARAInt32 ARAPitchNumber;
  1105. //! Used if there is no pitch associated with a note (e.g. purely percussive note).
  1106. #if defined(__cplusplus)
  1107. constexpr ARAPitchNumber kARAInvalidPitchNumber { INT32_MIN };
  1108. #else
  1109. #define kARAInvalidPitchNumber INT32_MIN
  1110. #endif
  1111. //! Used if there is no pitch associated with a note (e.g. purely percussive note).
  1112. #if defined(__cplusplus)
  1113. constexpr float kARAInvalidFrequency { 0.0f };
  1114. #else
  1115. #define kARAInvalidFrequency 0.0f
  1116. #endif
  1117. //! Default tuning reference.
  1118. #if defined(__cplusplus)
  1119. constexpr float kARADefaultConcertPitchFrequency { 440.0f };
  1120. #else
  1121. #define kARADefaultConcertPitchFrequency 440.0f
  1122. #endif
  1123. //! Content reader event class: notes provided by kARAContentTypeNotes.
  1124. //! Event sort order is by startPosition.
  1125. //! As with all content readers, a pointer to this struct retrieved via getContentReaderDataForEvent()
  1126. //! is still owned by the callee and must remain valid until either getContentReaderDataForEvent()
  1127. //! is called again or the reader is destroyed via destroyContentReader().
  1128. typedef struct ARAContentNote
  1129. {
  1130. //! Average frequency in Hz, kARAInvalidFrequency if note has no defined pitch (percussive).
  1131. float frequency;
  1132. //! Index corresponding to MIDI note number (or kARAInvalidPitchNumber).
  1133. ARAPitchNumber pitchNumber;
  1134. //! Normalized level: 0.0f (weak) <= level <= 1.0f (strong).
  1135. //! This value is scaled according to human perception (i.e. closer to a dB scale than to a linear one).
  1136. float volume;
  1137. //! Time marking the beginning of the note (aka "note on" in MIDI), relative to the start of the
  1138. //! described object (audio source/playback region).
  1139. ARATimePosition startPosition;
  1140. //! Time marking the musical/quantization anchor of the note, relative to the start of the note.
  1141. ARATimeDuration attackDuration;
  1142. //! Time marking the release point of the note (aka "note off" in MIDI), relative to the start of the note.
  1143. ARATimeDuration noteDuration;
  1144. //! Time marking the end of the entire sound of the note (end of release phase), relative to the start of the note.
  1145. ARATimeDuration signalDuration;
  1146. } ARAContentNote;
  1147. //! @}
  1148. /***************************************************************************************************/
  1149. //! @defgroup Model_Tuning_Key_Signatures_and_Chords Tuning, Key Signatures and Chords (Added In ARA 2.0)
  1150. //! \br
  1151. //! ARA expresses "western standard" octave-cyclic, 12-tone scales as tunings and key signatures.
  1152. //! While some applications such as Melodyne offer a much more complex model that allows for acyclic
  1153. //! and/or micro-tonal scales, those models usually don't map well to each others, and introduce
  1154. //! a complexity that can not meaningfully be handled by applications with the "main stream" model.
  1155. //! Further, there is no standardized musical theory for expressing chords in such scales.
  1156. //! Should the actual need to deal with more complex scales arise in the future, a new content type
  1157. //! may be added to cover this.
  1158. //! @{
  1159. //! The root of a key signature or chord as an index (or angle) in the circle of fifths from 'C'.
  1160. //! Enharmonic equivalents such as Db and C# are distinguished:
  1161. //! \verbatim
  1162. //! ...
  1163. //! -5: Db
  1164. //! ...
  1165. //! -1: F
  1166. //! 0: C
  1167. //! 1: G
  1168. //! 2: D
  1169. //! ...
  1170. //! 7: C#
  1171. //! ...
  1172. //! 11: E#
  1173. //! ...
  1174. //! \endverbatim
  1175. ARA_ADDENDUM(2_0_Final) typedef ARAInt32 ARACircleOfFifthsIndex;
  1176. //! Content reader event class: periodic 12-tone tuning table provided by kARAContentTypeStaticTuning.
  1177. //! Defines the tuning of each pitch class in the octave-cyclic 12-tone pitch system.
  1178. //! Allows to import (12-tone) Scala files.
  1179. //! Stretched tunings are not supported by ARA at this point, but may be added in a future release
  1180. //! as an additional tuning stretch curve applied on top of this average tuning.
  1181. //! ARA defines a single overall tuning (i.e. there's always only one event for this reader).
  1182. //! As with all content readers, a pointer to this struct retrieved via getContentReaderDataForEvent()
  1183. //! is still owned by the callee and must remain valid until either getContentReaderDataForEvent()
  1184. //! is called again or the reader is destroyed via destroyContentReader().
  1185. ARA_ADDENDUM(2_0_Final) typedef struct ARAContentTuning
  1186. {
  1187. //! Frequency of the concert pitch 'A' in hertz, defaulting to kARADefaultConcertPitchFrequency aka 440.0f.
  1188. float concertPitchFrequency;
  1189. //! Root key for the following per-key tunings.
  1190. ARACircleOfFifthsIndex root;
  1191. //! Tuning of each note pitch as an offset from the equal temperament tuning in cent.
  1192. //! Each entry defaults to 0.0f.
  1193. //! The first entry relates to the root, increasing chromatically up to the full octave.
  1194. //! \verbatim
  1195. //! Example:
  1196. //! Arabian Rast: {0.0f, 0.0f, 0.0f, 0.0f, -50.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, -50.0f}
  1197. //! \endverbatim
  1198. float tunings[12];
  1199. //! User-readable name of the tuning as displayed in the content provider.
  1200. //! The tuning name may or may not include the root note, depending on context - for example,
  1201. //! equal temperament does not care about the root note so it is always omitted, Werckmeister
  1202. //! tunings typically imply a root note of C unless noted explicitly otherwise, etc.
  1203. //! The name is provided only for display purposes, in case the receiver wants to display the
  1204. //! tuning exactly as done in the sender instead of utilizing its built-in naming system for
  1205. //! tunings based on the above properties.
  1206. //! The receiver must copy the name, the pointer may be only valid as long as the containing
  1207. //! ARAContentTuning struct.
  1208. //! It may be NULL if the provider does not provide a name for the tuning in its UI.
  1209. ARAUtf8String name;
  1210. } ARAContentTuning;
  1211. //! The ARAKeySignatureIntervalUsage defines whether a particular interval is used
  1212. //! (kARAKeySignatureIntervalUsed) or not (kARAKeySignatureIntervalUnused).
  1213. //! Future extensions of the API could further specify the usage of a given interval, similar to the
  1214. //! chord intervals below. However since there are currently no clear-cut use cases for such a
  1215. //! distinction, this is not yet specified.
  1216. ARA_ADDENDUM(2_0_Final) typedef ARAByte ARAKeySignatureIntervalUsage;
  1217. //! @name Markup values of ARAKeySignatureIntervalUsage.
  1218. //! @{
  1219. #if defined(__cplusplus)
  1220. //! Marks an interval of the ARAContentKeySignature as unused.
  1221. ARA_ADDENDUM(2_0_Final) constexpr ARAKeySignatureIntervalUsage kARAKeySignatureIntervalUnused { 0x00 };
  1222. //! Marks an interval of the ARAContentKeySignature as used.
  1223. ARA_ADDENDUM(2_0_Final) constexpr ARAKeySignatureIntervalUsage kARAKeySignatureIntervalUsed { 0xFF };
  1224. #else
  1225. #define kARAKeySignatureIntervalUnused (ARA_ADDENDUM(2_0_Final) (ARAKeySignatureIntervalUsage)0x00)
  1226. #define kARAKeySignatureIntervalUsed (ARA_ADDENDUM(2_0_Final) (ARAKeySignatureIntervalUsage)0xFF)
  1227. #endif
  1228. //! @}
  1229. //! Content reader event class: key signature provided by kARAContentTypeKeySignatures.
  1230. //! Defines the usage of each pitch class in the octave-cyclic 12-tone pitch system.
  1231. //! This content type describes the key signatures as would be annotated in a score, not the local
  1232. //! scales (which may be using some out-of-key notes via additional per-note accidentals).
  1233. //! The event position relates to ARAContentTempoEntry, a valid tempo map must be provided
  1234. //! by any provider of ARAContentBarSignature.
  1235. //! Each key signature is valid until the following one, the first key signature is assumed to also
  1236. //! be valid any time before it is actually defined.
  1237. //! Event sort order is by position.
  1238. //! As with all content readers, a pointer to this struct retrieved via getContentReaderDataForEvent()
  1239. //! is still owned by the callee and must remain valid until either getContentReaderDataForEvent()
  1240. //! is called again or the reader is destroyed via destroyContentReader().
  1241. ARA_ADDENDUM(2_0_Final) typedef struct ARAContentKeySignature
  1242. {
  1243. //! Root key of the signature.
  1244. ARACircleOfFifthsIndex root;
  1245. //! Scales intervals (aka scale mode) of the signature.
  1246. //! The index of this arrays entry is the chromatic interval to the keys root pitch class.
  1247. //! \verbatim
  1248. //! Examples (Hex Values):
  1249. //! major {FF, 00, FF, 00, FF, FF, 00, FF, 00, FF, 00, FF}
  1250. //! natural minor {FF, 00, FF, FF, 00, FF, 00, FF, FF, 00, FF, 00}
  1251. //! \endverbatim
  1252. ARAKeySignatureIntervalUsage intervals[12];
  1253. //! Optional user-readable name of the key signature as displayed in the content provider
  1254. //! (including the root note name).
  1255. //! Typically, the receiver has a built-in system to generate a suitable name for a key
  1256. //! signature based on its internal abstractions. However, this internal model might cover all
  1257. //! states that the ARA model can provide, or vice versa. If there is such a mismatch, the
  1258. //! internal name generation algorithm will likely fail - in which case the receiver may fall
  1259. //! back to the string provided here.
  1260. //! Note that the utility library that ships with the ARA SDK contains C++ code that can create
  1261. //! a proper name for the most common key signatures, otherwise falling back to this name.
  1262. //! The receiver must copy the name, the pointer may be only valid as long as the containing
  1263. //! ARAContentKeySignature struct.
  1264. //! It may be NULL if the provider does not provide a name for the key signature in its UI.
  1265. //! When encoding the string to send it across the ARA API, flat and sharp symbols must be
  1266. //! represented with the Unicodes 0x266D "MUSIC FLAT SIGN" and 0x266F "MUSIC SHARP SIGN"
  1267. //! respectively (as also required for ARAContentChord::name).
  1268. ARAUtf8String name;
  1269. //! Start time in quarter notes, see ARAContentTempoEntry.
  1270. ARAQuarterPosition position;
  1271. } ARAContentKeySignature;
  1272. //! The ARAChordIntervalUsage defines whether a particular interval is used
  1273. //! (kARAChordIntervalUsed) or not (kARAChordIntervalUnused), or if used may instead further
  1274. //! specify the function of the interval in the chord by specifying its diatonic degree:
  1275. //! 1 = unison, 3 = third, up to 13 = thirteenth
  1276. //! Note that the bass note of a chord is treated separately, see below.
  1277. typedef ARAByte ARAChordIntervalUsage;
  1278. //! @name Markup values of ARAChordIntervalUsage.
  1279. //! \verbatim
  1280. //! common degrees per note if root is C:
  1281. //! C D E F G A B
  1282. //! 1 b9 2/9 #9/3 3 4/11 #11/b5 5 #5/b6/b13 6/7/13 7/#13 7
  1283. //! (7 only if dim)
  1284. //! \endverbatim
  1285. //! @{
  1286. #if defined(__cplusplus)
  1287. //! ARAChordIntervalUsage value when the corresponding chromatic interval is used with the given diatonic function.
  1288. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree1 { 0x01 };
  1289. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree2 { 0x02 };
  1290. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree3 { 0x03 };
  1291. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree4 { 0x04 };
  1292. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree5 { 0x05 };
  1293. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree6 { 0x06 };
  1294. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree7 { 0x07 };
  1295. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree9 { 0x09 };
  1296. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree11 { 0x0B };
  1297. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordDiatonicDegree13 { 0x0D };
  1298. //! ARAChordIntervalUsage value when the corresponding chromatic interval is used, but its diatonic function is unknown.
  1299. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordIntervalUsed { 0xFF };
  1300. //! ARAChordIntervalUsage value when the corresponding chromatic interval is not used.
  1301. ARA_ADDENDUM(2_0_Final) constexpr ARAChordIntervalUsage kARAChordIntervalUnused { 0x00 };
  1302. #else
  1303. #define kARAChordDiatonicDegree1 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x01)
  1304. #define kARAChordDiatonicDegree2 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x02)
  1305. #define kARAChordDiatonicDegree3 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x03)
  1306. #define kARAChordDiatonicDegree4 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x04)
  1307. #define kARAChordDiatonicDegree5 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x05)
  1308. #define kARAChordDiatonicDegree6 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x06)
  1309. #define kARAChordDiatonicDegree7 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x07)
  1310. #define kARAChordDiatonicDegree9 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x09)
  1311. #define kARAChordDiatonicDegree11 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x0B)
  1312. #define kARAChordDiatonicDegree13 (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x0D)
  1313. #define kARAChordIntervalUsed (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0xFF)
  1314. #define kARAChordIntervalUnused (ARA_ADDENDUM(2_0_Final) (ARAChordIntervalUsage)0x00)
  1315. #endif
  1316. //! @}
  1317. //! Content reader event class: chords provided by kARAContentTypeSheetChords.
  1318. //! The event position relates to ARAContentTempoEntry, a valid tempo map must be provided
  1319. //! by any provider of ARAContentBarSignature.
  1320. //! Each chord is valid until the following one, and the first chord is assumed to also be valid
  1321. //! any time before it is actually defined (i.e. its position is effectively ignored).
  1322. //! The "undefined chord" markup (all intervals unused) can be used to express a range where no
  1323. //! chord is applicable. Such gaps may appear between "regular" chords, or they can be used
  1324. //! to limit the otherwise infinite duration of the first and last "regular" chord if desired.
  1325. //! Event sort order is by position.
  1326. //! As with all content readers, a pointer to this struct retrieved via getContentReaderDataForEvent()
  1327. //! is still owned by the callee and must remain valid until either getContentReaderDataForEvent()
  1328. //! is called again or the reader is destroyed via destroyContentReader().
  1329. ARA_ADDENDUM(2_0_Final) typedef struct ARAContentChord
  1330. {
  1331. //! Root note of the chord.
  1332. //! \br
  1333. //! Examples: F: root = -1 C/E: root = 0 G/D: root = 1
  1334. ARACircleOfFifthsIndex root;
  1335. //! Bass note of the chord.
  1336. //! Usually identical to the root, but may be different from root,
  1337. //! or even different from any other note represented by the intervals below.
  1338. //! \br
  1339. //! Examples: F: bass = -1 C/E: bass = 4 G/D: bass = 2
  1340. ARACircleOfFifthsIndex bass;
  1341. //! Chords intervals, defining gender, suspensions and extensions.
  1342. //! The index of this array's entry is the chromatic interval to
  1343. //! the chords root pitch class.
  1344. //! Depending on the chord's musical interpretation, the interval
  1345. //! corresponding to the bass note may or may not be included in here.
  1346. //! If all intervals are unused, this chord represents an "undefined chord",
  1347. //! which is used as a markup for gaps in the chord progression.
  1348. //! \verbatim
  1349. //! Examples (hexadecimal values):
  1350. //! major {FF, 00, 00, 00, FF, 00, 00, FF, 00, 00, 00, 00}
  1351. //! major {01, 00, 00, 00, 03, 00, 00, 05, 00, 00, 00, 00}
  1352. //! minor {01, 00, 00, 03, 00, 00, 00, 05, 00, 00, 00, 00}
  1353. //! major 13 {01, 00, 09, 00, 03, 00, 00, 05, 00, 0D, 07, 00}
  1354. //! major add13 {01, 00, 00, 00, 03, 00, 00, 05, 00, 0D, 00, 00}
  1355. //! major 6 {01, 00, 00, 00, 03, 00, 00, 05, 00, 06, 00, 00}
  1356. //! \endverbatim
  1357. ARAChordIntervalUsage intervals[12];
  1358. //! Optional user-readable name of the chord as displayed in the content provider
  1359. //! (including the root note name).
  1360. //! Typically, the receiver has a built-in system to generate a suitable name for a chord
  1361. //! based on its internal abstractions. However, this internal model might cover all
  1362. //! states that the ARA model can provide, or vice versa. If there is such a mismatch, the
  1363. //! internal name generation algorithm will likely fail - in which case the receiver may fall
  1364. //! back to the string provided here.
  1365. //! Note that the utility library that ships with the ARA SDK contains C++ code that can create
  1366. //! a proper name for any ARA chord, completely avoiding the necessity to use this name string.
  1367. //! The receiver must copy the name, the pointer may be only valid as long as the containing
  1368. //! ARAContentChord struct.
  1369. //! It may be NULL if the provider does not provide a name for the chord in its UI.
  1370. //! \br
  1371. //! Chord annotation systems often use symbols in addition to Latin letters and Arabic numbers.
  1372. //! Depending on UI considerations such as the font in use, different applications may use
  1373. //! different Unicode codes to represent the same symbols internally.
  1374. //! In order to send strings containing such symbol across the ARA API without ambiguities,
  1375. //! they must be mapped to the following Unicode codes:
  1376. //! - flat symbol:
  1377. //! 0x266D "MUSIC FLAT SIGN"
  1378. //! - sharp symbol:
  1379. //! 0x266F "MUSIC SHARP SIGN"
  1380. //! - upward-pointing triangle used to annotate major 7 chords:
  1381. //! 0x2206 "INCREMENT"
  1382. //! - minus sign used to annotate minor chords:
  1383. //! 0x002D "HYPHEN-MINUS"
  1384. //! - circle with slash used to annotate half-diminished chords:
  1385. //! 0x00F8 "LATIN SMALL LETTER O WITH STROKE"
  1386. //! - circle used to annotate diminished chords:
  1387. //! 0x00B0 "DEGREE SIGN"
  1388. //! - plus sign used to annotate augmented chords:
  1389. //! 0x002B "PLUS SIGN"
  1390. ARAUtf8String name;
  1391. //! Start time in quarter notes, see ARAContentTempoEntry.
  1392. ARAQuarterPosition position;
  1393. } ARAContentChord;
  1394. //! @}
  1395. //! @}
  1396. /***************************************************************************************************/
  1397. #if defined(__clang__)
  1398. #pragma mark Host side controller interfaces
  1399. #endif
  1400. //! @defgroup Host_Interfaces Host Interfaces
  1401. //! @{
  1402. /***************************************************************************************************/
  1403. /***************************************************************************************************/
  1404. //! @defgroup Host_Audio_Access_Controller Audio Access Controller
  1405. //! This interface allows plug-ins to read the audio data from the host in a random access order.
  1406. //! It is used from multiple threads, both host and plug-in need to carefully observe the threading
  1407. //! rules for each function. The basic design idea is that each audio reader is used single-threaded,
  1408. //! but multiple audio readers can work concurrently (even on the same audio source).
  1409. //! Audio readers can be considered random access iterators, and like most iterators operate on
  1410. //! conceptually constant data structures. If the host changes sample rate, channel count or other
  1411. //! audio source properties that the reader relies upon, the plug-in must discard any existing
  1412. //! audio readers for the source and later re-create them based on the new configuration.
  1413. //! The host can temporarily disable access to the audio source in order to control the exact timing
  1414. //! of stopping the readers from accessing the source.
  1415. //! Whenever an audio reader is destroyed, the plug-in is responsible for thread safety - it may
  1416. //! need to block until a concurrent read operation on the I/O thread has finished. Hosts must take
  1417. //! care in their audio reader implementation to avoid potential deadlocks in this situation.
  1418. //! Note that when rendering, the audio source will often not be read in a consecutive order -
  1419. //! depending on the edits the user applied at audio modification level, the access may jump back
  1420. //! and forth quite often. The reader implementation should be optimized accordingly.
  1421. //! \br
  1422. //! Host developer using C++ ARA Library can implement the ARA::Host::AudioAccessControllerInterface.
  1423. //! For plug-in developers this interface is wrapped by the ARA::PlugIn::HostAudioAccessController.
  1424. //! @{
  1425. //! Reference to the host side representation of an audio access controller (opaque to the plug-in).
  1426. typedef ARA_HOST_REF(ARAAudioAccessControllerHostRef);
  1427. //! Reference to the host side representation of an audio reader (opaque to the plug-in).
  1428. typedef ARA_HOST_REF(ARAAudioReaderHostRef);
  1429. //! Host interface: audio access controller.
  1430. //! As with all host interfaces, the function pointers in this struct must remain valid until
  1431. //! all document controllers on the plug-in side that use it have been destroyed.
  1432. typedef struct ARAAudioAccessControllerInterface
  1433. {
  1434. //! @see_Versioned_Structs_
  1435. ARASize structSize;
  1436. //! @name Synchronous reading: blocking until data is available
  1437. //@{
  1438. //! Create audio reader instance to access sample data in an audio source.
  1439. //! The format of the data is matching the format of the audio source, with a choice of reading
  1440. //! samples as 32 bit or 64 bit (hosts must support both formats).
  1441. //! Similar to the rules for creating content readers, the plug-in may call these functions only
  1442. //! from calls in the "Audio Source Management" section of ARADocumentControllerInterface for
  1443. //! the particular audio source the call is referring to, or from
  1444. //! ARADocumentControllerInterface::endEditing() for any audio source.
  1445. //! Contrary to content readers, audio readers are long-living objects that are not bound to a
  1446. //! certain stack frame.
  1447. ARAAudioReaderHostRef (ARA_CALL *createAudioReaderForSource) (ARAAudioAccessControllerHostRef controllerHostRef,
  1448. ARAAudioSourceHostRef audioSourceHostRef, ARABool use64BitSamples);
  1449. //! Read audio samples.
  1450. //! The samples are provided in non-interleaved buffers of double or float data, depending on
  1451. //! whether use64BitSamples was set when creating the reader. The channel count equals the
  1452. //! channel count of the audio source. The data alignment and byte order always matches the
  1453. //! machine's native layout.
  1454. //! If the requested sample range extends beyond the start or end of the audio source, the
  1455. //! out-of-range samples should be filled with silence. This should not be treated as an error.
  1456. //! This potentially blocking function may be called from any non-realtime thread (including
  1457. //! threads for offline rendering), but not from more than one thread per reader at the same time.
  1458. //! The host may decide to let the thread sleep until the requested data is available, the
  1459. //! plug-in must be designed to deal with this without triggering priority inversion.
  1460. //! The target buffer(s) are provided by the caller.
  1461. //! Result is kARATrue upon success, or kARAFalse when there is a critical, nonrecoverable
  1462. //! I/O error, such as a network failure while the file is being read from a server.
  1463. //! In case of failing in this call, the buffers must be filled with silence and the host must
  1464. //! notify the user about the problem in an appropriate way. The plug-in must deal gracefully
  1465. //! with any such I/O errors, both during analysis and rendering.
  1466. ARABool (ARA_CALL *readAudioSamples) (ARAAudioAccessControllerHostRef controllerHostRef, ARAAudioReaderHostRef audioReaderHostRef,
  1467. ARASamplePosition samplePosition, ARASampleCount samplesPerChannel, void * const buffers[]);
  1468. //! Destroy given audio reader created by the host.
  1469. //! The caller must guarantee that the reader is currently not in use in some other thread.
  1470. //! See ARAAudioAccessControllerInterface::createAudioReaderForSource() about the restrictions when to call this.
  1471. void (ARA_CALL *destroyAudioReader) (ARAAudioAccessControllerHostRef controllerHostRef, ARAAudioReaderHostRef audioReaderHostRef);
  1472. //@}
  1473. } ARAAudioAccessControllerInterface;
  1474. // Convenience constant for easy struct validation.
  1475. enum { kARAAudioAccessControllerInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAAudioAccessControllerInterface, destroyAudioReader) };
  1476. //! @}
  1477. /***************************************************************************************************/
  1478. //! @defgroup Host_Archiving_Controller Archiving Controller
  1479. //! This interface allows plug-ins to read and write archives with minimal memory impact.
  1480. //! It also allows for displaying progress when archiving or unarchiving model graphs.
  1481. //! Its functions may only be called during the archiving/unarchiving process.
  1482. //! \br
  1483. //! Because of the potentially large size of the archives, ARA does not use simple monolithic memory
  1484. //! blocks as known from many companion APIs. Instead, it establishes a stream-like archive format
  1485. //! so that copying large blocks of memory can be avoided.
  1486. //! Plug-ins that create large archives should use any mean of data reduction that is appropriate
  1487. //! to reduce the archive size. For example, they may implement gzip compression. Since it has good
  1488. //! knowledge of the characteristics of the data, it can configure the compression algorithms so
  1489. //! that optimal results are achieved. Consequently, there's no point for host to try to compress
  1490. //! the data any further with generic algorithms.
  1491. //! \br
  1492. //! Hosts that support both 32 and 64 bit architectures shall be aware of the fact that ARA archive
  1493. //! sizes are pointer-sized data types, so they will differ in bit width between these architectures.
  1494. //! This must be taken into account when storing the archive size in the host's document structure.
  1495. //! Also, when importing documents from 64 bit into 32 bit, the host must check whether the archive
  1496. //! is small enough to be loaded at all (i.e. its size fits into 32 bits). If not, it shall refuse
  1497. //! to load the archive and provide a proper error message.
  1498. //! This may seem like a restriction, but the reasoning behind this is that if the archive already
  1499. //! exceeds the available address space, the resulting unarchived graph will do so too.
  1500. //! \br
  1501. //! There's no creation or destruction call for the archive readers/writers because they are provided
  1502. //! by the host for the duration of the (un-)archiving process, so the lifetime is implicitly defined.
  1503. //! \br
  1504. //! When using API generation 1 or older and loading an archive through the deprecated functions
  1505. //! begin-/endRestoringDocumentFromArchive(), plug-ins may choose to access the associated archive reader
  1506. //! upon either begin- or endRestoringDocumentFromArchive() or even upon both calls, as suitable for their
  1507. //! implementation - hosts must be able to provide the requested data during the duration of both calls.
  1508. //! \br
  1509. //! Host developer using C++ ARA Library can implement the ARA::Host::ArchivingControllerInterface.
  1510. //! For plug-in developers this interface is wrapped by the ARA::PlugIn::HostArchivingController.
  1511. //! @{
  1512. //! Reference to the host side representation of an archiving controller (opaque to the plug-in).
  1513. typedef ARA_HOST_REF(ARAArchivingControllerHostRef);
  1514. //! Reference to the host side representation of an archive reader (opaque to the plug-in).
  1515. typedef ARA_HOST_REF(ARAArchiveReaderHostRef);
  1516. //! Reference to the host side representation of an archive writer (opaque to the plug-in).
  1517. typedef ARA_HOST_REF(ARAArchiveWriterHostRef);
  1518. //! Host interface: archive controller.
  1519. //! As with all host interfaces, the function pointers in this struct must remain valid until
  1520. //! all document controllers on the plug-in side that use it have been destroyed.
  1521. typedef struct ARAArchivingControllerInterface
  1522. {
  1523. //! @see_Versioned_Structs_
  1524. ARASize structSize;
  1525. //! @name Reading Archives
  1526. //@{
  1527. //! Query the size of the archive.
  1528. //! This may only be called from ARADocumentControllerInterface::restoreObjectsFromArchive(),
  1529. //! or if using API generation 1 from the deprecated begin-/endRestoringDocumentFromArchive() calls.
  1530. //! Plug-ins must respect this size when reading the archive, reading beyond the end of the data
  1531. //! is a programming error (and should thus be asserted by the host).
  1532. ARASize (ARA_CALL *getArchiveSize) (ARAArchivingControllerHostRef controllerHostRef, ARAArchiveReaderHostRef archiveReaderHostRef);
  1533. //! Read bytes.
  1534. //! This may only be called from ARADocumentControllerInterface::restoreObjectsFromArchive(),
  1535. //! or if using API generation 1 from the deprecated begin-/endRestoringDocumentFromArchive() calls.
  1536. //! Result is kARATrue upon success, or kARAFalse when there is a critical, nonrecoverable
  1537. //! I/O error, such as a network failure while the file is being read from a server.
  1538. //! In case of failing in this call, the host must notify the user about the problem in some
  1539. //! appropriate way. The archive will not be restored by the plug-in then, it'll fall back into
  1540. //! some proper initial state for the affected objects.
  1541. ARABool (ARA_CALL *readBytesFromArchive) (ARAArchivingControllerHostRef controllerHostRef, ARAArchiveReaderHostRef archiveReaderHostRef,
  1542. ARASize position, ARASize length, ARAByte buffer[]);
  1543. //@}
  1544. //! @name Writing Archives
  1545. //@{
  1546. //! Write bytes.
  1547. //! This may only be called from storeObjectsToArchive() or the deprecated storeDocumentToArchive().
  1548. //! Result is kARATrue upon success, or kARAFalse when there is a critical, nonrecoverable
  1549. //! I/O error, such as a network failure while the file is being written to a server.
  1550. //! In case of failing in this call, the host must notify the user about the problem in an appropriate way.
  1551. //! \br
  1552. //! Note that a plug-in should strive to write the data consecutively in a stream-like manner.
  1553. //! Nevertheless, repositioning is needed to support chunk-style archives where the chunk length
  1554. //! must be specified at the start of the chunk, but is not known until the chunk data has been
  1555. //! fully created (and possibly compressed). In that case, the plug-in will need to "rewind" to
  1556. //! the chunk size entry in the chunk header after writing the chunk and update it accordingly.
  1557. //! As in most file APIs, any range of bytes that was skipped when writing should be filled with
  1558. //! 0 by the host.
  1559. ARABool (ARA_CALL *writeBytesToArchive) (ARAArchivingControllerHostRef controllerHostRef, ARAArchiveWriterHostRef archiveWriterHostRef,
  1560. ARASize position, ARASize length, const ARAByte buffer[]);
  1561. //@}
  1562. //! @name (Un-)Archiving Progress Information
  1563. //@{
  1564. //! Message to the host signaling document save progress, value ranges from 0.0f to 1.0f.
  1565. //! This may only be called from storeObjectsToArchive() or from the deprecated storeDocumentToArchive().
  1566. //! In order to keep CPU load low, plug-ins should try to keep the update rate for this call
  1567. //! as low as about 1000 calls per archive, which equals increments of 0.1%.
  1568. void (ARA_CALL *notifyDocumentArchivingProgress) (ARAArchivingControllerHostRef controllerHostRef, float value);
  1569. //! Message to the host signaling document save progress, value ranges from 0.0f to 1.0f.
  1570. //! This may only be called from ARADocumentControllerInterface::restoreObjectsFromArchive(),
  1571. //! or if using API generation 1 from the deprecated begin-/endRestoringDocumentFromArchive()
  1572. //! and the associated model object creation/update calls guarded by them. In the deprecated form,
  1573. //! the first call should be made from begin- and the last call from endRestoringDocumentFromArchive().
  1574. //! In order to keep CPU load low, plug-ins should try to keep the update rate for this call
  1575. //! as low as about 1000 calls per archive, which equals increments of 0.1%.
  1576. void (ARA_CALL *notifyDocumentUnarchivingProgress) (ARAArchivingControllerHostRef controllerHostRef, float value);
  1577. //@}
  1578. //! @name Reading Archives
  1579. //@{
  1580. //! Query the document archive ID that the plug-in's factory provided when saving the archive.
  1581. //! This may only be called from ARADocumentControllerInterface::restoreObjectsFromArchive().
  1582. //! Plug-ins can use this information to optimize their unarchiving code in case different
  1583. //! archive formats are used depending on document archive ID.
  1584. //! The returned pointer is owned by the host and must remain valid until the archive reader
  1585. //! is destroyed.
  1586. //! All hosts that support kARAAPIGeneration_2_0_Final or newer must implement this call.
  1587. ARA_ADDENDUM(2_0_Final) ARAPersistentID (ARA_CALL *getDocumentArchiveID) (ARAArchivingControllerHostRef controllerHostRef, ARAArchiveReaderHostRef archiveReaderHostRef);
  1588. //@}
  1589. } ARAArchivingControllerInterface;
  1590. // Convenience constant for easy struct validation.
  1591. enum { kARAArchivingControllerInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAArchivingControllerInterface, notifyDocumentUnarchivingProgress) };
  1592. //! @}
  1593. /***************************************************************************************************/
  1594. //! @defgroup Host_Model_Content_Access_Controller Model Content Access Controller
  1595. //! This optional interface provides access to host model data such as the musical context.
  1596. //! Its functions may only be called from ARADocumentControllerInterface.create...() or update...()
  1597. //! for the object currently created/updated, or from ARADocumentControllerInterface::endEditing()
  1598. //! for any object.
  1599. //! \br
  1600. //! Host developer using C++ ARA Library can implement the ARA::Host::ContentAccessControllerInterface.
  1601. //! For plug-in developers this interface is wrapped by the ARA::PlugIn::HostContentAccessController.
  1602. //! @{
  1603. //! Reference to the host side representation of a content access controller (opaque to the plug-in).
  1604. typedef ARA_HOST_REF(ARAContentAccessControllerHostRef);
  1605. //! Host interface: content access controller.
  1606. //! As with all host interfaces, the function pointers in this struct must remain valid until
  1607. //! all document controllers on the plug-in side that use it have been destroyed.
  1608. typedef struct ARAContentAccessControllerInterface
  1609. {
  1610. //! @see_Versioned_Structs_
  1611. ARASize structSize;
  1612. //! @name Content Reader Management
  1613. //! These functions mirror the content reader section in ARADocumentControllerInterface.
  1614. //@{
  1615. //! Query whether the given content type is currently available for the given musical context.
  1616. ARABool (ARA_CALL *isMusicalContextContentAvailable) (ARAContentAccessControllerHostRef controllerHostRef,
  1617. ARAMusicalContextHostRef musicalContextHostRef, ARAContentType contentType);
  1618. //! Query the current quality of the information provided for the given musical context and content type.
  1619. ARAContentGrade (ARA_CALL *getMusicalContextContentGrade) (ARAContentAccessControllerHostRef controllerHostRef,
  1620. ARAMusicalContextHostRef musicalContextHostRef, ARAContentType contentType);
  1621. //! Create a content reader for the given musical context and content type.
  1622. //! This should only be called after availability has been confirmed using isMusicalContextContentAvailable(),
  1623. //! and is mainly used to communicate the song timeline to the plug-in.
  1624. //! The time range may be NULL, which means that the entire musical context shall be read.
  1625. //! If a time range is specified, all events that at least partially intersect with the range
  1626. //! will be read.
  1627. ARAContentReaderHostRef (ARA_CALL *createMusicalContextContentReader) (ARAContentAccessControllerHostRef controllerHostRef, ARAMusicalContextHostRef musicalContextHostRef,
  1628. ARAContentType contentType, const ARAContentTimeRange * range);
  1629. //! Query whether the given content type is currently available for the given audio source.
  1630. ARABool (ARA_CALL *isAudioSourceContentAvailable) (ARAContentAccessControllerHostRef controllerHostRef,
  1631. ARAAudioSourceHostRef audioSourceHostRef, ARAContentType contentType);
  1632. //! Query the current quality of the information provided for the given audio source and content type.
  1633. ARAContentGrade (ARA_CALL *getAudioSourceContentGrade) (ARAContentAccessControllerHostRef controllerHostRef,
  1634. ARAAudioSourceHostRef audioSourceHostRef, ARAContentType contentType);
  1635. //! Create a content reader for the given audio source and content type.
  1636. //! This should only be called after availability has been confirmed using isAudioSourceContentAvailable().
  1637. //! The host may be able to provide meta-information such as a known tempo or a known set of
  1638. //! notes used in the material, which may enable the plug-in to speed up or even skip completely
  1639. //! certain analysis passes (often depending on the content grade of the information).
  1640. //! The time range may be NULL, which means that the entire audio source shall be read.
  1641. //! If a time range is specified, all events that at least partially intersect with the range
  1642. //! will be read.
  1643. ARAContentReaderHostRef (ARA_CALL *createAudioSourceContentReader) (ARAContentAccessControllerHostRef controllerHostRef, ARAAudioSourceHostRef audioSourceHostRef,
  1644. ARAContentType contentType, const ARAContentTimeRange * range);
  1645. //! Query how many events the given reader exposes.
  1646. ARAInt32 (ARA_CALL *getContentReaderEventCount) (ARAContentAccessControllerHostRef controllerHostRef, ARAContentReaderHostRef contentReaderHostRef);
  1647. //! Query data of the given event of the given reader.
  1648. //! The returned pointer is owned by the host and must remain valid until either
  1649. //! getContentReaderDataForEvent() is called again or the content reader is destroyed.
  1650. const void * (ARA_CALL *getContentReaderDataForEvent) (ARAContentAccessControllerHostRef controllerHostRef,
  1651. ARAContentReaderHostRef contentReaderHostRef, ARAInt32 eventIndex);
  1652. //! Destroy the given content reader.
  1653. void (ARA_CALL *destroyContentReader) (ARAContentAccessControllerHostRef controllerHostRef, ARAContentReaderHostRef contentReaderHostRef);
  1654. //@}
  1655. } ARAContentAccessControllerInterface;
  1656. // Convenience constant for easy struct validation.
  1657. enum { kARAContentAccessControllerInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAContentAccessControllerInterface, destroyContentReader) };
  1658. //! @}
  1659. /***************************************************************************************************/
  1660. //! @defgroup Host_Model_Update_Controller_Interface Model Update Controller Interface
  1661. //! This optional host interface allows the host to be notified about content changes in the plug-in.
  1662. //! Its functions may only be called from ARADocumentControllerInterface::notifyModelUpdates().
  1663. //! \br
  1664. //! Host developer using C++ ARA Library can implement the ARA::Host::ModelUpdateControllerInterface.
  1665. //! For plug-in developers this interface is wrapped by the ARA::PlugIn::HostModelUpdateController.
  1666. //! @{
  1667. //! Reference to the host side representation of a model update controller (opaque to the plug-in).
  1668. typedef ARA_HOST_REF(ARAModelUpdateControllerHostRef);
  1669. //! Audio source analysis progress indication.
  1670. typedef ARA_32_BIT_ENUM(ARAAnalysisProgressState)
  1671. {
  1672. //! Required as first state for any given analysis.
  1673. kARAAnalysisProgressStarted = 0,
  1674. //! State for normal progress of an analysis.
  1675. kARAAnalysisProgressUpdated = 1,
  1676. //! Required as last state for any given analysis (no matter whether it completed or was cancelled).
  1677. kARAAnalysisProgressCompleted = 2
  1678. };
  1679. //! Host interface: model update controller.
  1680. //! As with all host interfaces, the function pointers in this struct must remain valid until
  1681. //! all document controllers on the plug-in side that use it have been destroyed.
  1682. typedef struct ARAModelUpdateControllerInterface
  1683. {
  1684. //! @see_Versioned_Structs
  1685. ARASize structSize;
  1686. //! Message to the host signaling analysis progress, value ranges from 0.0f to 1.0f.
  1687. //! The first message must be marked with kARAAnalysisProgressStarted, the last
  1688. //! with kARAAnalysisProgressCompleted.
  1689. //! This notification is intended solely for displaying a progress indication if desired, but
  1690. //! not to trigger content reading for updating content information. That is instead done when
  1691. //! receiving notifyAudioSourceContentChanged(), see below.
  1692. //! Note that since the updates are polled by the host, any analysis may already have progressed
  1693. //! somewhat by the time the start notification is actually delivered, so it may start with a
  1694. //! progress larger than 0. It is even possible that an analysis fully completes before its
  1695. //! start is notified, in which case the plug-in may choose not notify it at all.
  1696. //! If the plug-in internally executes multiple analysis task per audio source simultaneously
  1697. //! (for example because it splits them by content type), it must merge all internal progress
  1698. //! into a single outer progress.
  1699. void (ARA_CALL *notifyAudioSourceAnalysisProgress) (ARAModelUpdateControllerHostRef controllerHostRef, ARAAudioSourceHostRef audioSourceHostRef,
  1700. ARAAnalysisProgressState state, float value);
  1701. //! Message to the host when content of the given audio source changes.
  1702. //! Not to be called if the change was explicitly triggered by the host, e.g. when restoring
  1703. //! audio source state or if the host calls ARADocumentControllerInterface::updateAudioSourceContent().
  1704. //! When restoring state, plug-ins shall only make this call if the object state after loading is
  1705. //! not equal to the archived state. This can happen e.g when unarchiving encounters errors, or
  1706. //! when state is imported from older versions and converted to some updated model state.
  1707. //! The time range may be NULL, this means that the entire audio source is affected.
  1708. //! Note that this notification is what hosts will listen to when determining whether the state
  1709. //! returned by isAudioSourceContentAnalysisIncomplete() has changed. In other words, the
  1710. //! completion state of the analysis itself is considered to be a part of the overall content.
  1711. //! Thus, if it changes, the overall content has changed, even if neither the grade nor the data
  1712. //! for content readers did change (e.g. because an analysis failed to provide proper results).
  1713. void (ARA_CALL *notifyAudioSourceContentChanged) (ARAModelUpdateControllerHostRef controllerHostRef, ARAAudioSourceHostRef audioSourceHostRef,
  1714. const ARAContentTimeRange * range, ARAContentUpdateFlags flags);
  1715. //! Message to the host when content of the given audio modification changes.
  1716. //! Not to be called if the change was explicitly triggered by the host, e.g. when restoring
  1717. //! audio modification state.
  1718. //! When restoring state, plug-ins will only make this call if the object state after loading is
  1719. //! not equal to the archived state. This can happen e.g when unarchiving encounters errors, or
  1720. //! when state is imported from older versions and converted to some updated model state.
  1721. //! The time range may be NULL, this means that the entire audio modification is affected.
  1722. //! Whenever this notification is received, all playback regions for the given modification
  1723. //! are affected as well if their range in modification time intersects with the given time range.
  1724. //! Because of this, there was no separate change notification for playback region in ARA 1.
  1725. //! This changed with the introduction of content-based fades in ARA 2.0, because playback region
  1726. //! content can now change without any audio modification changes.
  1727. //! For many use cases, hosts that implement ARA 2 do no longer concern themselves with this call
  1728. //! (unless they are also hosting ARA 1 plug-ins and implement an according ARA 2 adapter).
  1729. void (ARA_CALL *notifyAudioModificationContentChanged) (ARAModelUpdateControllerHostRef controllerHostRef, ARAAudioModificationHostRef audioModificationHostRef,
  1730. const ARAContentTimeRange * range, ARAContentUpdateFlags flags);
  1731. //! Message to the host when content of the given playback region changes (added in ARA 2.0).
  1732. //! In ARA 1, region content updates were implicitly derived from audio modification updates,
  1733. //! (see notifyAudioModificationContentChanged()), based on the assumption that the content
  1734. //! of a playback region did depend only on the modification content and the transformation
  1735. //! described in the playback region properties.
  1736. //! Since ARA 2.0 however, plug-ins use the grouping provided by the region sequences to
  1737. //! derive further parameters for the transformation, which enables them to perform content
  1738. //! based fades or other custom adjustments. This means the content of any given region can
  1739. //! change even if its modification and region properties remain unchanged, and that the host
  1740. //! can no longer calculate the content of a region based on the content of its modification.
  1741. //! Note that when kARAContentUpdateSignalScopeRemainsUnchanged is not set, this message also
  1742. //! indicates that the host needs to update any cached copies of the rendered signal it may hold,
  1743. //! and needs to query getPlaybackRegionHeadAndTailTime() for potential updates.
  1744. //! The time range is specified in playback time and potentially covers head and tail time too.
  1745. //! The time range may be NULL, this means that the entire playback region (including its
  1746. //! head and tail time, which may be updated at the same time) is affected.
  1747. ARA_ADDENDUM(2_0_Draft) void (ARA_CALL *notifyPlaybackRegionContentChanged) (ARAModelUpdateControllerHostRef controllerHostRef, ARAPlaybackRegionHostRef playbackRegionHostRef,
  1748. const ARAContentTimeRange * range, ARAContentUpdateFlags flags);
  1749. } ARAModelUpdateControllerInterface;
  1750. // Convenience constant for easy struct validation.
  1751. enum { kARAModelUpdateControllerInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAModelUpdateControllerInterface, notifyAudioModificationContentChanged) };
  1752. //! @}
  1753. /***************************************************************************************************/
  1754. //! @defgroup Host_Playback_Controller_Interface Playback Controller Interface
  1755. //! This optional host interface allows the plug-in to request playback state changes.
  1756. //! The functions in this interface may be called concurrently, but not from render-threads.
  1757. //! The host may choose to ignore any of these requests.
  1758. //! The requests will typically be scheduled and executed with some delay.
  1759. //! The current state of playback is transmitted via the companion API.
  1760. //! \br
  1761. //! Host developer using C++ ARA Library can implement the ARA::Host::PlaybackControllerInterface.
  1762. //! For plug-in developers this interface is wrapped by the ARA::PlugIn::HostPlaybackController.
  1763. //! @{
  1764. //! Reference to the host side representation of a playback controller (opaque to the plug-in).
  1765. typedef ARA_HOST_REF(ARAPlaybackControllerHostRef);
  1766. //! Host interface: playback controller.
  1767. //! As with all host interfaces, the function pointers in this struct must remain valid until
  1768. //! all document controllers on the plug-in side that use it have been destroyed.
  1769. typedef struct ARAPlaybackControllerInterface
  1770. {
  1771. //! @see_Versioned_Structs
  1772. ARASize structSize;
  1773. //! Message to the host to start playback of our document.
  1774. void (ARA_CALL *requestStartPlayback) (ARAPlaybackControllerHostRef controllerHostRef);
  1775. //! Message to the host to stop playback of our document.
  1776. void (ARA_CALL *requestStopPlayback) (ARAPlaybackControllerHostRef controllerHostRef);
  1777. //! Message to the host to set the playback position of our document.
  1778. //! Note that this may be called both when playing back or when stopped.
  1779. void (ARA_CALL *requestSetPlaybackPosition) (ARAPlaybackControllerHostRef controllerHostRef,
  1780. ARATimePosition timePosition);
  1781. //! Message to the host to set the playback cycle range of our document.
  1782. void (ARA_CALL *requestSetCycleRange) (ARAPlaybackControllerHostRef controllerHostRef,
  1783. ARATimePosition startTime, ARATimeDuration duration);
  1784. //! Message to the host to enable or disable the playback cycle of our document.
  1785. void (ARA_CALL *requestEnableCycle) (ARAPlaybackControllerHostRef controllerHostRef, ARABool enable);
  1786. } ARAPlaybackControllerInterface;
  1787. // Convenience constant for easy struct validation.
  1788. enum { kARAPlaybackControllerInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAPlaybackControllerInterface, requestEnableCycle) };
  1789. //! @}
  1790. /***************************************************************************************************/
  1791. //! @defgroup Host_Document_Controller_Instance Document Controller Instance
  1792. //! The callbacks into the host are published by the host when creating a document controller on
  1793. //! the plug-in side to maintain an ARA model graph. The instance struct and all interfaces and
  1794. //! host refs therein must remain valid until the document controller is destroyed.
  1795. //! The host can choose to create its controller objects per document controller instance, or it
  1796. //! can share a single instance between all document controllers, whatever fits its needs.
  1797. //! It may even mix-and-match both approaches per individual interface.
  1798. //! @{
  1799. //! The document controller host instance struct and all interfaces and refs therein must remain valid
  1800. //! until all plug-in document controllers created with this struct have been destroyed by the host.
  1801. typedef struct ARADocumentControllerHostInstance
  1802. {
  1803. //! @see_Versioned_Structs_
  1804. ARASize structSize;
  1805. //! @name AudioAccessControllerInterface
  1806. //! Must always be supported.
  1807. //@{
  1808. ARAAudioAccessControllerHostRef audioAccessControllerHostRef;
  1809. const ARAAudioAccessControllerInterface * audioAccessControllerInterface;
  1810. //@}
  1811. //! @name ArchiveControllerInterface
  1812. //! Must always be supported.
  1813. //@{
  1814. ARAArchivingControllerHostRef archivingControllerHostRef;
  1815. const ARAArchivingControllerInterface * archivingControllerInterface;
  1816. //@}
  1817. //! @name ContentAccessControllerInterface
  1818. //! OPTIONAL INTERFACE: plug-in must check contentAccessControllerInterface is not NULL before calling!
  1819. //@{
  1820. ARAContentAccessControllerHostRef contentAccessControllerHostRef;
  1821. const ARAContentAccessControllerInterface * contentAccessControllerInterface;
  1822. //@}
  1823. //! @name ModelUpdateControllerInterface
  1824. //! OPTIONAL INTERFACE: plug-in must check modelUpdateControllerInterface is not NULL before calling!
  1825. //@{
  1826. ARAModelUpdateControllerHostRef modelUpdateControllerHostRef;
  1827. const ARAModelUpdateControllerInterface * modelUpdateControllerInterface;
  1828. //@}
  1829. //! @name PlaybackControllerInterface
  1830. //! OPTIONAL INTERFACE: plug-in must check playbackControllerInterface is not NULL before calling!
  1831. //@{
  1832. ARAPlaybackControllerHostRef playbackControllerHostRef;
  1833. const ARAPlaybackControllerInterface * playbackControllerInterface;
  1834. //@}
  1835. } ARADocumentControllerHostInstance;
  1836. // Convenience constant for easy struct validation.
  1837. enum { kARADocumentControllerHostInstanceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARADocumentControllerHostInstance, playbackControllerInterface) };
  1838. //! @}
  1839. //! @}
  1840. /***************************************************************************************************/
  1841. #if defined(__clang__)
  1842. #pragma mark Plug-In side controller interfaces and factory
  1843. #endif
  1844. //! @defgroup Plug_In_Interfaces Plug-In Interfaces
  1845. //! @{
  1846. /***************************************************************************************************/
  1847. // forward-declaration, defined below
  1848. struct ARAFactory;
  1849. typedef struct ARAFactory ARAFactory;
  1850. //! @defgroup Partial_Document_Persistency Partial Document Persistency
  1851. //! \br
  1852. //! These optional filters allow to only store a subset of the document graph into an archive,
  1853. //! or only restore a subset of an archive into the document graph.
  1854. //! @{
  1855. //! Optional filter when restoring objects.
  1856. //! \br
  1857. //! Allows the host to specify a subset of the persistent objects in the archive to restore in
  1858. //! ARADocumentControllerInterface::restoreObjectsFromArchive().
  1859. //! \br
  1860. //! The given IDs refer to objects in the archive, but can optionally be mapped to those used in the
  1861. //! current document. This may be necessary to resolve potential conflicts between persistent IDs
  1862. //! from different documents when importing parts of one document into another (since persistent IDs
  1863. //! are only required to be unique within a document, not across documents).
  1864. //! \br
  1865. //! The C++ ARA Library offers plug-in developers the ARA::PlugIn::RestoreObjectsFilter
  1866. //! utility class to ease the implementation of partial persistency.
  1867. ARA_ADDENDUM(2_0_Final) typedef struct ARARestoreObjectsFilter
  1868. {
  1869. //! @see_Versioned_Structs
  1870. ARASize structSize;
  1871. //! Flag to indicate whether the plug-in should include its private, opaque document state
  1872. //! in the archive - see ARAStoreObjectsFilter::documentData for details.
  1873. ARABool documentData;
  1874. //! Length of #audioSourceArchiveIDs and #audioSourceCurrentIDs (if provided).
  1875. ARASize audioSourceIDsCount;
  1876. //! Variable-sized C array listing the persistent IDs of the archived audio sources to restore.
  1877. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  1878. const ARAPersistentID * audioSourceArchiveIDs;
  1879. //! Optional variable-sized C array mapping each of the persistent IDs provided in audioSourceArchiveIDs
  1880. //! to a potentially different persistent ID currently used for the audio sources to be restore
  1881. //! in the current graph.
  1882. //! If no mapping is desired, i.e. all audio source persistent IDs to restore match those in
  1883. //! the current graph, the pointer should be NULL.
  1884. const ARAPersistentID * audioSourceCurrentIDs;
  1885. //! Length of #audioModificationArchiveIDs and #audioModificationCurrentIDs (if provided).
  1886. ARASize audioModificationIDsCount;
  1887. //! Variable-sized C array listing the persistent IDs of the archived audio modifications to restore.
  1888. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  1889. const ARAPersistentID * audioModificationArchiveIDs;
  1890. //! Optional variable-sized C array mapping each of the persistent IDs provided in audioModificationArchiveIDs
  1891. //! to a potentially different persistent ID currently used for the audio modifications to be restore
  1892. //! in the current graph.
  1893. //! If no mapping is desired, i.e. all audio modification persistent IDs to restore match those in
  1894. //! the current graph, the pointer should be NULL.
  1895. const ARAPersistentID * audioModificationCurrentIDs;
  1896. } ARARestoreObjectsFilter;
  1897. // Convenience constant for easy struct validation.
  1898. enum ARA_ADDENDUM(2_0_Final) { kARARestoreObjectsFilterMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARARestoreObjectsFilter, audioModificationCurrentIDs) };
  1899. //! Optional filter when storing objects.
  1900. //! \br
  1901. //! Allows the host to specify a subset of the objects in the model graph to be stored in
  1902. //! ARADocumentControllerInterface::storeObjectsToArchive().
  1903. //! \br
  1904. //! The C++ ARA Library offers plug-in developers the ARA::PlugIn::StoreObjectsFilter
  1905. //! utility class to ease the implementation of partial persistency.
  1906. ARA_ADDENDUM(2_0_Final) typedef struct ARAStoreObjectsFilter
  1907. {
  1908. //! @see_Versioned_Structs
  1909. ARASize structSize;
  1910. //! Flag to indicate whether the plug-in should include its private, opaque document state
  1911. //! in the archive.
  1912. //! A typical example of private data is a fallback implementation in the plug-in for data not
  1913. //! provided by the host. For example, if the host does not implement a chord track, a plug-in
  1914. //! may need to implement this in its own UI in order to be fully usable. Since the host is not
  1915. //! aware of this, the data must be stored privately at document level.
  1916. //! This flag should be set to kARAFalse if the archive is intended for copy/paste or other
  1917. //! means of data import/export between documents, or kARATrue if a host uses partial
  1918. //! persistency as a general technique to store ARA documents for performance reasons (e.g.
  1919. //! to avoid re-saving data that hasn't been changed, or to minimize sync activity when
  1920. //! implementing collaborative editing across the network - note that such optimizations rely
  1921. //! on proper update notifications by the plug-in).
  1922. //! If implementing the latter, hosts will typically split the document into a partial archive
  1923. //! that contains only the document data, plus a set of archives that each contain a single
  1924. //! audio source. In such a setup, the audio modifications are either stored in the same archive
  1925. //! as their underlying audio source, or each audio modification is separated into an archive
  1926. //! of its own.
  1927. //! The only restriction for such archive splicing (in addition to respecting the general data
  1928. //! dependency rules for partial persistency outlined in the documentation of
  1929. //! ARADocumentControllerInterface::restoreObjectsFromArchive()) is that when restoring, the
  1930. //! partial archive which was saved with documentData == kARATrue is restored as last archive in
  1931. //! the restore cycle, where the graph has its final structure and all object states are available.
  1932. ARABool documentData;
  1933. //! Length of #audioSourceRefs.
  1934. ARASize audioSourceRefsCount;
  1935. //! Variable-sized C array listing the audio sources to store.
  1936. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  1937. const ARAAudioSourceRef * audioSourceRefs;
  1938. //! Length of #audioModificationRefs.
  1939. ARASize audioModificationRefsCount;
  1940. //! Variable-sized C array listing the audio modifications to store.
  1941. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  1942. const ARAAudioModificationRef * audioModificationRefs;
  1943. } ARAStoreObjectsFilter;
  1944. // Convenience constant for easy struct validation.
  1945. enum ARA_ADDENDUM(2_0_Final) { kARAStoreObjectsFilterMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAStoreObjectsFilter, audioModificationRefs) };
  1946. //! @}
  1947. //! @defgroup Processing_Algorithm_Selection Processing Algorithm Selection
  1948. //! @{
  1949. //! Processing algorithm description returned by ARADocumentControllerInterface::getProcessingAlgorithmProperties()
  1950. //! Provides a unique identifier and a user-readable name of the algorithm, as displayed in the plug-in.
  1951. //! The pointers contained in this struct must remain valid until the document controller that has
  1952. //! provided the struct is destroyed.
  1953. ARA_ADDENDUM(2_0_Final) typedef struct ARAProcessingAlgorithmProperties
  1954. {
  1955. //! @see_Versioned_Structs
  1956. ARASize structSize;
  1957. //! ID for this particular processing algorithm.
  1958. ARAPersistentID persistentID;
  1959. //! Name as displayed by the plug-in (may be localized).
  1960. ARAUtf8String name;
  1961. } ARAProcessingAlgorithmProperties;
  1962. // Convenience constant for easy struct validation.
  1963. enum ARA_ADDENDUM(2_0_Final) { kARAProcessingAlgorithmPropertiesMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAProcessingAlgorithmProperties, name) };
  1964. //! @}
  1965. /***************************************************************************************************/
  1966. //! @defgroup Plug-In_Document_Controller Document Controller
  1967. //! ARA model objects are created and managed by the ARA Document Controller provided by the plug-in.
  1968. //! The host uses the factory and management functions of the Document Controller to create a partial
  1969. //! copy of its model translated into the ARA world.
  1970. //! It is created using a factory which can be either retrieved by scanning the plug-in binaries
  1971. //! for a dedicated factory or by requesting it from a living companion plug-in instance.
  1972. //! The host is responsible for keeping the document controller alive as long as any objects created
  1973. //! through it are still living (kind of implicit ref-counting). This means that its live time is
  1974. //! independent of the companion plug-in instances - they may all be gone at some point but the
  1975. //! ARA graph may still be accessed through its document controller.
  1976. //! The host must also keep the document controller alive as long as any companion plug-in instance
  1977. //! which it has bound to it is actively used. The actual destruction of the plug-in instance may
  1978. //! be done later (to ease reference counting implementation), but rendering the plug-in, accessing
  1979. //! its state or showing its UI is only valid as long as the ARA document controller it has been
  1980. //! bound is still alive.
  1981. //! Except for some rare, explicitly documented functions like getPlaybackRegionHeadAndTailTime(),
  1982. //! the document controller interface must always be called from the same thread - usually hosts
  1983. //! will manage their internal model as well as the attached ARA graph from the application's main
  1984. //! thread, triggered from the main run loop. If a host decides to use a different thread for
  1985. //! maintaining the ARA model, it may need to implement some sort of locking so that its updates on
  1986. //! the ARA model thread do not interfere concurrently with the main run loop's event processing
  1987. //! as it drives the plug-in's UI code and notification system.
  1988. //! \br
  1989. //! Plug-in developers using C++ ARA Library can implement the ARA::PlugIn::DocumentControllerInterface,
  1990. //! or extend the already implemented ARA::PlugIn::DocumentController class as needed.
  1991. //! For host developers this interface is wrapped by the ARA::Host::DocumentController.
  1992. //! @{
  1993. //! Reference to the plug-in side representation of a document controller (opaque to the host).
  1994. typedef ARA_REF(ARADocumentControllerRef);
  1995. //! Plug-in interface: document controller.
  1996. //! The function pointers in this struct must remain valid until the document controller is
  1997. //! destroyed by the host.
  1998. typedef struct ARADocumentControllerInterface
  1999. {
  2000. //! @see_Versioned_Structs_
  2001. ARASize structSize;
  2002. //! @name Destruction
  2003. //@{
  2004. //! Destroy the controller and its associated document.
  2005. //! The host must delete all objects associated with the document graph (audio sources,
  2006. //! musical contexts etc.) before making this call.
  2007. //! Note that the objects exported via the ARAPlugInExtensionInstance are not considered
  2008. //! part of the document graph, their destruction may happen before or after destroying the
  2009. //! document controller that they are bound to.
  2010. void (ARA_CALL *destroyDocumentController) (ARADocumentControllerRef controllerRef);
  2011. //@}
  2012. //! @name Link back to the factory
  2013. //@{
  2014. //! Query the static ARA factory that was used to create this controller.
  2015. //! This provides a convenient traversal to the name of the plug-in, the description of its
  2016. //! capabilities, its archive IDs etc.
  2017. const ARAFactory * (ARA_CALL *getFactory) (ARADocumentControllerRef controllerRef);
  2018. //@}
  2019. //! @name Update management
  2020. //@{
  2021. //! Start an editing session on a document.
  2022. //! An editing session can contain an arbitrary set of modifications that belong together.
  2023. //! Since many model edits can result in rather expensive updates on the plug-in side, this call
  2024. //! allows for grouping the edits and postponing the updates until the new model state is final,
  2025. //! which potentially saves some intermediate updates.
  2026. void (ARA_CALL *beginEditing) (ARADocumentControllerRef controllerRef);
  2027. //! End an editing session on a document.
  2028. //! Note that when receiving this call, the plug-in will update any amount of internal state.
  2029. //! These edits may lead to update notifications to the host, and the host may in turn read
  2030. //! affected content from the plug-in and update its own model accordingly.
  2031. //! One example for this the way that Melodyne maintains chords and scales associated with
  2032. //! audio modifications. It copies this data from the musical context into the audio
  2033. //! modifications, so that when editing regions the notes appear in the proper pitch grid.
  2034. //! If moving playback regions in the song, these copies may need to be updated, and Melodyne
  2035. //! will report the resulting audio modification content changes to the host.
  2036. //! To ensure that any such follow-up updates are added to the same undo cycle, hosts that
  2037. //! actively read plug-in content data should immediately (i.e. within the same undo frame)
  2038. //! call notifyModelUpdates() after making this call.
  2039. void (ARA_CALL *endEditing) (ARADocumentControllerRef controllerRef);
  2040. //! Tell the plug-in to send all pending update notifications for the given document.
  2041. //! This must be called periodically by the host whenever not editing nor restoring the document.
  2042. //! Only when processing this call, the plug-in may call back into the host using
  2043. //! ARAModelUpdateControllerInterface.
  2044. //! Hosts must be aware after receiving beginEditing(), plug-ins may choose to postpone any subset
  2045. //! of their internal state updates until the matching call to endEditing(). This means that if
  2046. //! the host for some reason needs to wait for a specific update in the plug-in to occur
  2047. //! (such as waiting for an analysis to finish) it must do so outside of pairs of beginEditing()
  2048. //! and endEditing().
  2049. void (ARA_CALL *notifyModelUpdates) (ARADocumentControllerRef controllerRef);
  2050. //@}
  2051. //! @name Document Persistency (extended in ARA 2.0)
  2052. //! This has been updated with ARA 2.0, see below.
  2053. //@{
  2054. //! Begin an unarchiving session of the document and its associated objects.
  2055. //! \deprecated
  2056. //! Since version 2_0_Final this call has been superseded by the combination of beginEditing()
  2057. //! and restoreObjectsFromArchive(). This allows for optional filtering, but also simplifies
  2058. //! both host and plug-in implementation.
  2059. ARA_DEPRECATED(2_0_Final) ARABool (ARA_CALL *beginRestoringDocumentFromArchive) (ARADocumentControllerRef controllerRef, ARAArchiveReaderHostRef archiveReaderHostRef);
  2060. //! End an unarchiving session of the document and its associated objects.
  2061. //! \deprecated
  2062. //! Since version 2_0_Final this call has been superseded by the combination of endEditing()
  2063. //! and restoreObjectsFromArchive(). This allows for optional filtering, but also simplifies
  2064. //! both host and plug-in implementation.
  2065. //! \br
  2066. //! When using API generation 1 or older and using this call, the host must pass the same
  2067. //! archiveReaderHostRef as used for beginRestoringDocumentFromArchive().
  2068. //! This way, plug-ins can choose to evaluate the archive upon beginRestoring() or endRestoring(),
  2069. //! or even upon both calls if needed.
  2070. ARA_DEPRECATED(2_0_Final) ARABool (ARA_CALL *endRestoringDocumentFromArchive) (ARADocumentControllerRef controllerRef, ARAArchiveReaderHostRef archiveReaderHostRef);
  2071. //! Create an archive of the internal state of a given document and all its associated objects.
  2072. //! \deprecated
  2073. //! Since version 2_0_Final this call has been superseded by storeObjectsToArchive(),
  2074. //! which allows for optional filtering, but is otherwise identical.
  2075. ARA_DEPRECATED(2_0_Final) ARABool (ARA_CALL *storeDocumentToArchive) (ARADocumentControllerRef controllerRef, ARAArchiveWriterHostRef archiveWriterHostRef);
  2076. //@}
  2077. //! @name Document Management
  2078. //! As with all model graph edits, calling these functions must be guarded by beginEditing() and endEditing().
  2079. //@{
  2080. //! Update the properties of the controller's document.
  2081. //! All properties must be specified, the plug-in will determine which have actually changed.
  2082. void (ARA_CALL *updateDocumentProperties) (ARADocumentControllerRef controllerRef, const ARADocumentProperties * properties);
  2083. //@}
  2084. //! @name Musical Context Management
  2085. //! As with all model graph edits, calling these functions must be guarded by beginEditing() and endEditing().
  2086. //@{
  2087. //! Create a new musical context associated with the controller's document.
  2088. ARAMusicalContextRef (ARA_CALL *createMusicalContext) (ARADocumentControllerRef controllerRef, ARAMusicalContextHostRef hostRef,
  2089. const ARAMusicalContextProperties * properties);
  2090. //! Update the properties of a given musical context.
  2091. //! All properties must be specified, the plug-in will determine which have actually changed.
  2092. void (ARA_CALL *updateMusicalContextProperties) (ARADocumentControllerRef controllerRef, ARAMusicalContextRef musicalContextRef,
  2093. const ARAMusicalContextProperties * properties);
  2094. //! Tell the plug-in to update the information obtainable via content readers for a given musical context.
  2095. //! The time range may be NULL, this means that the entire musical content is affected.
  2096. //! Creating a new musical context implies an initial content update for it - the host will
  2097. //! call this explicitly only for later content updates.
  2098. void (ARA_CALL *updateMusicalContextContent) (ARADocumentControllerRef controllerRef, ARAMusicalContextRef musicalContextRef,
  2099. const ARAContentTimeRange * range, ARAContentUpdateFlags flags);
  2100. //! Destroy a given musical context.
  2101. //! Destroying a musical context also implies removing it from its document.
  2102. //! The musical context must no longer be referred to by any playback region when making this call.
  2103. void (ARA_CALL *destroyMusicalContext) (ARADocumentControllerRef controllerRef, ARAMusicalContextRef musicalContextRef);
  2104. //@}
  2105. //! @name Audio Source Management
  2106. //! As with all model graph edits, calling these functions must be guarded by beginEditing() and endEditing(),
  2107. //! with the exception of enableAudioSourceSamplesAccess() (which is no model graph edit, but
  2108. //! but still has to occur on the ARA model thread).
  2109. //@{
  2110. //! Create a new audio source associated with the controller's document.
  2111. //! The newly created audio source has its sample data access initially disabled,
  2112. //! an explicit call to enableAudioSourceSamplesAccess() is needed.
  2113. ARAAudioSourceRef (ARA_CALL *createAudioSource) (ARADocumentControllerRef controllerRef, ARAAudioSourceHostRef hostRef,
  2114. const ARAAudioSourceProperties * properties);
  2115. //! Update the properties of a given audio source.
  2116. //! Depending on which properties are changed (see documentation of ARAAudioSourceProperties),
  2117. //! the host may not be able to make this call while the plug-in is reading data -
  2118. //! in that case, use enableAudioSourceSamplesAccess() accordingly.
  2119. //! All properties must be specified, the plug-in will determine which have actually changed.
  2120. void (ARA_CALL *updateAudioSourceProperties) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  2121. const ARAAudioSourceProperties * properties);
  2122. //! Tell the plug-in that the sample data or content information for the given audio source has changed.
  2123. //! Not to be called in response to ARAModelUpdateControllerInterface::notifyAudioSourceContentChanged().
  2124. //! The time range may be NULL, this means that the entire audio source is affected.
  2125. //! When implementing this call, remember to also flush any caches of the sampled data if needed
  2126. //! (see ::kARAContentUpdateSignalScopeRemainsUnchanged).
  2127. //! Creating a new audio source always implies an initial content update for it, i.e. the host
  2128. //! will call this function only for later content updates. Since audio sources are persistent,
  2129. //! plug-ins should preferably postpone the initial content reading until endEditing() -
  2130. //! if the host is restoring the audio source, this will remove the need to read initial content.
  2131. void (ARA_CALL *updateAudioSourceContent) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  2132. const ARAContentTimeRange * range, ARAContentUpdateFlags flags);
  2133. //! Enable or disable access to a given audio source.
  2134. //! This call allows the host to control the time when the plug-in may access sample data from
  2135. //! the given audio source. Disabling access forces the plug-in to destroy all audio readers
  2136. //! it currently has created for the affected audio source. This is a synchronous call,
  2137. //! blocking until all currently executing reads of the audio source are finished.
  2138. //! Access is disabled by default, hosts must explicitly enable it after creating an audio source.
  2139. //! Since this call does not modify the model graph, it may be called outside the usual
  2140. //! beginEditing() and endEditing() scope.
  2141. //! Note that disabling access will also abort any analysis currently being executed for the
  2142. //! audio source, making it necessary to start it from scratch when the access is enabled again.
  2143. //! This means that enableAudioSourceSamplesAccess() is an expensive call that only should be
  2144. //! made when necessary. It should not be (ab-)used to simply "pause ARA" whenever convenient.
  2145. void (ARA_CALL *enableAudioSourceSamplesAccess) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef, ARABool enable);
  2146. //! Deactivate the given audio source because it has become part of the undo history
  2147. //! and is no longer used actively.
  2148. //! The plug-in will cancel any pending analysis for this audio source and may free some memory
  2149. //! that is only needed when the audio source can be edited or rendered.
  2150. //! Before deactivating an audio source, the host must deactivate all connected audio modifications
  2151. //! first, and the opposite order is required when re-activating upon redo.
  2152. //! When deactivated, updating the properties or content of the audio source or reading its
  2153. //! content is no longer valid.
  2154. //! Like properties, deactivation is not necessarily persistent in the plug-in, so the host must
  2155. //! call this explicitly when restoring deactivated audio sources.
  2156. void (ARA_CALL *deactivateAudioSourceForUndoHistory) (ARADocumentControllerRef controllerRef,
  2157. ARAAudioSourceRef audioSourceRef, ARABool deactivate);
  2158. //! Destroy a given audio source.
  2159. //! Destroying an audio source also implies removing it from its document.
  2160. //! The host must delete all objects associated with the audio source (audio modifications etc.)
  2161. //! before deleting the audio source.
  2162. //! The host does not need to explicitly disable access to the audio source before making this call.
  2163. void (ARA_CALL *destroyAudioSource) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef);
  2164. //@}
  2165. //! @name Audio Modification Management
  2166. //! As with all model graph edits, calling these functions must be guarded by beginEditing() and endEditing().
  2167. //@{
  2168. //! Create a new audio modification associated with the given audio source.
  2169. ARAAudioModificationRef (ARA_CALL *createAudioModification) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  2170. ARAAudioModificationHostRef hostRef, const ARAAudioModificationProperties * properties);
  2171. //! Create a new audio modification that copies the state of another given audio modification.
  2172. //! The new modification will be associated with the same audio source.
  2173. //! This call is used to create independent variations of the audio as opposed to creating
  2174. //! aliases by merely adding playback regions to a given audio modification.
  2175. ARAAudioModificationRef (ARA_CALL *cloneAudioModification) (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  2176. ARAAudioModificationHostRef hostRef, const ARAAudioModificationProperties * properties);
  2177. //! Update the properties of a given audio modification.
  2178. //! All properties must be specified, the plug-in will determine which have actually changed.
  2179. void (ARA_CALL *updateAudioModificationProperties) (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  2180. const ARAAudioModificationProperties * properties);
  2181. //! Deactivate the given audio modification because it has become part of the undo history
  2182. //! and is no longer used actively.
  2183. //! The plug-in may free some memory that is only needed when the audio modification can be
  2184. //! edited or rendered.
  2185. //! When deactivated, updating the properties of the audio modification or reading its
  2186. //! content is no longer valid.
  2187. //! Like properties, deactivation is not necessarily persistent in the plug-in, so the host must
  2188. //! call this explicitly when restoring deactivated audio modifications.
  2189. void (ARA_CALL *deactivateAudioModificationForUndoHistory) (ARADocumentControllerRef controllerRef,
  2190. ARAAudioModificationRef audioModificationRef, ARABool deactivate);
  2191. //! Destroy a given audio modification.
  2192. //! Destroying an audio modification also implies removing it from its audio source.
  2193. //! The host must delete all objects associated with the audio modification (playback regions etc.)
  2194. //! before deleting the audio modification.
  2195. void (ARA_CALL *destroyAudioModification)(ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef);
  2196. //@}
  2197. //! @name Playback Region Management
  2198. //! As with all model graph edits, calling these functions must be guarded by beginEditing() and endEditing().
  2199. //@{
  2200. //! Create a new playback region associated with the given audio modification.
  2201. ARAPlaybackRegionRef (ARA_CALL *createPlaybackRegion) (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  2202. ARAPlaybackRegionHostRef hostRef, const ARAPlaybackRegionProperties * properties);
  2203. //! Update the properties of a given playback region.
  2204. //! All properties must be specified, the plug-in will determine which have actually changed.
  2205. void (ARA_CALL *updatePlaybackRegionProperties) (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef,
  2206. const ARAPlaybackRegionProperties * properties);
  2207. //! Destroy a given playback region.
  2208. //! Destroying a playback region also implies removing it from its audio modification.
  2209. //! The playback region must no longer be referred to by any plug-in extension when making this call.
  2210. void (ARA_CALL *destroyPlaybackRegion) (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef);
  2211. //@}
  2212. //! @name Content Reader Management
  2213. //! Content readers are not model objects but rather auxiliary objects to parse content without
  2214. //! extensive data copying, following a standard iterator pattern.
  2215. //! As is common with iterators, no changes may be made to the model graph while reading content.
  2216. //! Prior to the final release of ARA 2.0, this meant that making any of the content related calls
  2217. //! was limited to be done outside of pairs of beginEditing() and endEditing().
  2218. //! Since version 2_0_Final, it is also valid to use them while the document is in editing state,
  2219. //! but no other call to this document controller may be made in-between a series of content related
  2220. //! calls (except for getFactory() and getPlaybackRegionHeadAndTailTime()).
  2221. //! For example for a given audio source such a series of calls typically would be
  2222. //! isAudioSourceContentAvailable(), getAudioSourceContentGrade(), createAudioSourceContentReader(),
  2223. //! getContentReaderEventCount(), n times getContentReaderDataForEvent(), destroyContentReader().
  2224. //! Typically, content readers are temporary local objects on the stack of the ARA model thread,
  2225. //! which naturally satisfies these conditions.
  2226. //! This change is mainly intended to support partial persistency introduced with ARA 2.0, since
  2227. //! it allows hosts to read content of imported audio sources/modifications to adjust the playback
  2228. //! regions accordingly without toggling the editing state of the document back and forth.
  2229. //@{
  2230. //! Query whether the given content type is currently available for the given audio source.
  2231. ARABool (ARA_CALL *isAudioSourceContentAvailable) (ARADocumentControllerRef controllerRef,
  2232. ARAAudioSourceRef audioSourceRef, ARAContentType contentType);
  2233. //! Query whether an analysis of the given content type has been done for the given audio source.
  2234. //! This call will typically be used when the host uses the plug-in as a detection engine in the
  2235. //! background (i.e. without presenting the UI to the user). In that scenario, the host will
  2236. //! trigger the analysis of the desired content types using requestAudioSourceContentAnalysis()
  2237. //! and then wait until the plug-in calls ARAModelUpdateControllerInterface::notifyAudioSourceContentChanged().
  2238. //! From that call, the host will query the plug-in via isAudioSourceContentAnalysisIncomplete()
  2239. //! to determine which of the analysis requests have completed.
  2240. //! If the host did request a specific algorithm to be used, then the plug-in should return
  2241. //! kARATrue here until the request was satisfied (or rejected).
  2242. ARABool (ARA_CALL *isAudioSourceContentAnalysisIncomplete) (ARADocumentControllerRef controllerRef,
  2243. ARAAudioSourceRef audioSourceRef, ARAContentType contentType);
  2244. //! Explicitly trigger a certain analysis.
  2245. //! If the host wants to use the plug-in as detection engine, it needs to explicitly trigger the
  2246. //! desired analysis, since otherwise the plug-in may postpone any analysis as suitable.
  2247. //! To allow for optimizing the analysis on the plug-in side, all content types that are of
  2248. //! interest for the host should be specified in a single call if possible.
  2249. //! \br
  2250. //! Note that the plug-in may choose to perform any additional analysis at any point in time
  2251. //! if this is appropriate for its design. It will call
  2252. //! ARAModelUpdateControllerInterface::notifyAudioSourceContentChanged() if such an analysis
  2253. //! concludes successfully so that the host can update accordingly.
  2254. //! \br
  2255. //! The provided content types must be a non-empty subset of the plug-in's
  2256. //! ARAFactory::analyzeableContentTypes. To request all analysis types exported by the plug-in,
  2257. //! hosts can directly pass analyzeableContentTypes and -Count from the plug-in's ARAFactory.
  2258. //! The contentTypes pointer may be only valid for the duration of the call, it must be
  2259. //! evaluated inside the call, and the pointer must not be stored anywhere.
  2260. //! \br
  2261. //! Note that ARA 2.0 adds the capability for the host to also request the use of a certain
  2262. //! processing algorithm via requestProcessingAlgorithmForAudioSource() - if both are used then
  2263. //! the algorithm must be selected before requesting the analysis.
  2264. void (ARA_CALL *requestAudioSourceContentAnalysis) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  2265. ARASize contentTypesCount, const ARAContentType contentTypes[]);
  2266. //! Query the current quality of the information provided for the given audio source and content type.
  2267. ARAContentGrade (ARA_CALL *getAudioSourceContentGrade) (ARADocumentControllerRef controllerRef,
  2268. ARAAudioSourceRef audioSourceRef, ARAContentType contentType);
  2269. //! Create a content reader for the given audio source and content type.
  2270. //! This should only be called after availability has been confirmed using isAudioSourceContentAvailable().
  2271. //! The time range may be NULL, which means that the entire audio source shall be read.
  2272. //! If a time range is specified, all events that at least partially intersect with the range
  2273. //! will be read.
  2274. ARAContentReaderRef (ARA_CALL *createAudioSourceContentReader) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  2275. ARAContentType contentType, const ARAContentTimeRange * range);
  2276. //! Query whether the given content type is currently available for the given audio modification.
  2277. //! Note that since ARA 2.0, reading at playback region level is recommended for most content types,
  2278. //! see createAudioModificationContentReader().
  2279. ARABool (ARA_CALL *isAudioModificationContentAvailable) (ARADocumentControllerRef controllerRef,
  2280. ARAAudioModificationRef audioModificationRef, ARAContentType contentType);
  2281. //! Query the current quality of the information provided for a given audio modification and content type.
  2282. //! Note that since ARA 2.0, reading at playback region level is recommended for most content types,
  2283. //! see createAudioModificationContentReader().
  2284. ARAContentGrade (ARA_CALL *getAudioModificationContentGrade) (ARADocumentControllerRef controllerRef,
  2285. ARAAudioModificationRef audioModificationRef, ARAContentType contentType);
  2286. //! Create a content reader for the given audio modification and content type.
  2287. //! This should only be called after availability has been confirmed using isAudioModificationContentAvailable().
  2288. //! The time range may be NULL, which means that the entire audio modification shall be read.
  2289. //! If a time range is specified, all events that at least partially intersect with the range
  2290. //! will be read.
  2291. //! Note that with the introduction of region transitions in ARA 2.0, the content of a given
  2292. //! playback region can no longer be externally calculated by the host based on the content of
  2293. //! its underlying audio modification and the transformation flags. Instead, hosts should read
  2294. //! such content directly at region level. This particularly applies to kARAContentTypeNotes -
  2295. //! notes at borders will be adjusted on a per-region basis when using content based fades.
  2296. //! Playback region content reading is available in ARA 1.0 already, thus such an implementation
  2297. //! will be fully backwards compatible.
  2298. //! Reading content at audio modification (or audio source) level is still valid and useful if
  2299. //! the host needs access to the content in its original state, not transformed by a playback
  2300. //! region, e.g. when implementing features such as tempo and signature detection through ARA.
  2301. ARAContentReaderRef (ARA_CALL *createAudioModificationContentReader) (ARADocumentControllerRef controllerRef, ARAAudioModificationRef audioModificationRef,
  2302. ARAContentType contentType, const ARAContentTimeRange * range);
  2303. //! Query whether the given content type is currently available for the given playback region.
  2304. ARABool (ARA_CALL *isPlaybackRegionContentAvailable) (ARADocumentControllerRef controllerRef,
  2305. ARAPlaybackRegionRef playbackRegionRef, ARAContentType contentType);
  2306. //! Query the current quality of the information provided for the given playback region and content type.
  2307. ARAContentGrade (ARA_CALL *getPlaybackRegionContentGrade) (ARADocumentControllerRef controllerRef,
  2308. ARAPlaybackRegionRef playbackRegionRef, ARAContentType contentType);
  2309. //! Create a content reader for the given playback region and content type.
  2310. //! This should only be called after availability has been confirmed using isPlaybackRegionContentAvailable().
  2311. //! The time range may be NULL, which means that the entire playback region shall be read,
  2312. //! including its potential head and tail time.
  2313. //! If a time range is specified, all events that at least partially intersect with the range
  2314. //! will be read.
  2315. //! The time range must be given in playback time, and the time stamps provided by the content
  2316. //! reader are in playback time as well.
  2317. ARAContentReaderRef (ARA_CALL *createPlaybackRegionContentReader) (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef,
  2318. ARAContentType contentType, const ARAContentTimeRange * range);
  2319. //! Query how many events the given reader exposes.
  2320. ARAInt32 (ARA_CALL *getContentReaderEventCount) (ARADocumentControllerRef controllerRef, ARAContentReaderRef contentReaderRef);
  2321. //! Query data of the given event of the given reader.
  2322. //! The returned pointer is owned by the plug-in and must remain valid until either
  2323. //! getContentReaderDataForEvent() is called again or the content reader is destroyed.
  2324. const void * (ARA_CALL *getContentReaderDataForEvent) (ARADocumentControllerRef controllerRef,
  2325. ARAContentReaderRef contentReaderRef, ARAInt32 eventIndex);
  2326. //! Destroy the given content reader.
  2327. void (ARA_CALL *destroyContentReader) (ARADocumentControllerRef controllerRef, ARAContentReaderRef contentReaderRef);
  2328. //@}
  2329. //! @name Region Sequence Management (added in ARA 2.0)
  2330. //! As with all model graph edits, calling these functions must be guarded by beginEditing() and endEditing().
  2331. //@{
  2332. //! Create a new region sequence associated with the controller's document.
  2333. ARA_ADDENDUM(2_0_Draft) ARARegionSequenceRef (ARA_CALL *createRegionSequence) (ARADocumentControllerRef controllerRef, ARARegionSequenceHostRef hostRef,
  2334. const ARARegionSequenceProperties * properties);
  2335. //! Update the properties of a given region sequence.
  2336. //! All properties must be specified, the plug-in will determine which have actually changed.
  2337. ARA_ADDENDUM(2_0_Draft) void (ARA_CALL *updateRegionSequenceProperties) (ARADocumentControllerRef controllerRef, ARARegionSequenceRef regionSequenceRef,
  2338. const ARARegionSequenceProperties * properties);
  2339. //! Destroy a given region sequence.
  2340. //! The region sequence must no longer be referred to by any playback region when making this call.
  2341. ARA_ADDENDUM(2_0_Draft) void (ARA_CALL *destroyRegionSequence) (ARADocumentControllerRef controllerRef, ARARegionSequenceRef regionSequenceRef);
  2342. //@}
  2343. //! @name Playback Region Head and Tail Time (added in ARA 2.0)
  2344. //! Depending on the specific DSP performed by the plug-in, the resulting signal for any region may
  2345. //! exceed the region borders. Among other use cases such as delays, this will typically happen when
  2346. //! the content based fades are enabled.
  2347. //! Reporting this potential excess of signal both at start and end of a region allows for the host
  2348. //! to adjust their rendering so that it includes head and tail time, or else fade the signal at the
  2349. //! region borders to avoid crackles.
  2350. //! This function can be called either from the model thread or from any (realtime or offline)
  2351. //! audio rendering thread.
  2352. //! If edits that the host performs on the model affect the head or tail times (such as toggling
  2353. //! content based fades on or off), the new values can only be reliably queried on the model thread
  2354. //! once endEditing() has returned. On audio threads, they can only be reliably queried until all
  2355. //! render calls that may have occurred concurrently with endEditing() have returned.
  2356. //@{
  2357. //! Query the current head and tail time of a given playback region.
  2358. //! Note that when a plug-in optimizes region transitions, the head and tail of any given
  2359. //! region can change upon any model edit, even if it is not directly affected by the edit.
  2360. //! Also, in order to properly track interaction between regions, plug-ins may lazily update
  2361. //! this information upon endEditing(). Plug-ins will call notifyPlaybackRegionContentChanged()
  2362. //! whenever these values change.
  2363. //! headTime and tailTime must not be NULL.
  2364. //! Host may query this often, so plug-ins should cache the value if there's any expensive
  2365. //! calculation involved.
  2366. //! Note that most companion APIs also feature a tail time concept. For playback renderer plug-in
  2367. //! instances, the tail time reported via the companion API should be equal to or greater than
  2368. //! the maximum of the tail times of all playback regions currently associated with the given
  2369. //! renderer (i.e. the tail for any given playback region may be somewhat shorter then the
  2370. //! companion API tail, depending on the region's content).
  2371. ARA_ADDENDUM(2_0_Draft) void (ARA_CALL *getPlaybackRegionHeadAndTailTime) (ARADocumentControllerRef controllerRef, ARAPlaybackRegionRef playbackRegionRef,
  2372. ARATimeDuration * headTime, ARATimeDuration * tailTime);
  2373. //@}
  2374. //! @name Document Persistency (extended in ARA 2.0)
  2375. //! Persistently storing and restoring an ARA graph requires that both the host and the plug-in data
  2376. //! are properly maintained. When the host creates an archive of its own data, it therefore needs
  2377. //! to store a matching archive of the plug-in data. The link between the host objects and the
  2378. //! plug-in objects is preserved using the ARAPersistentID defined in the properties of each
  2379. //! persistent model graph object.
  2380. //! ARA 1.0 started out with calls to store and restore the complete model graph managed by a given
  2381. //! ARADocumentController instance. While such monolithic document archives handle song persistency
  2382. //! fine, they are not suitable for more elaborate features such as copying and pasting audio source
  2383. //! and audio modification state between songs.
  2384. //! ARA 2.0 therefore adds the option to store and restore arbitrary subsections of an ARA graph.
  2385. //! Such partial archives may even be restored from ARA-specific chunks inside an audio file - see
  2386. //! \ref ARAAudioFileChunks.
  2387. //! Using partial persistency is optional on the host side, but ARA 2 plug-ins are required to fully
  2388. //! support it.
  2389. //! \br
  2390. //! A crucial point to keep in mind when archiving and unarchiving partial graphs is to honor data
  2391. //! dependencies in the overall graph. The opaque state of a persistent object can depend both on its
  2392. //! properties, such as the sample count of an audio source, and on parent objects inside the graph,
  2393. //! such as audio modification state referencing data in the underlying audio source.
  2394. //! The host must honor these dependencies, or else the plug-in may not be able to properly restore
  2395. //! the archived state, causing some degree of data loss, up to a full reset of the affected object.
  2396. //! ARA 1 style full-document persistency intrinsically complies with this rule and can be trivially
  2397. //! migrated to the ARA 2 calls. For partial archives however, some notable consequences are:
  2398. //! - Before restoring the state of any ARA object, hosts must configure the properties for that
  2399. //! object appropriately.
  2400. //! - If a host splits restoring an ARA graph into multiple calls, each call that restores some
  2401. //! audio source state must either include or precede restoring the state of any audio modification
  2402. //! associated with the affected audio source.
  2403. //! - Restoring an audio modification without restoring its underlying audio source may not succeed
  2404. //! if the audio source state has changed since storing the audio modification. Hosts can observe
  2405. //! audio source content change notifications to track such changes (note that these notifications
  2406. //! are sent asynchronously, so they have to be polled directly before creating the archive, from
  2407. //! the same stack frame).
  2408. //! - When restoring the state of an audio source, the state of all audio modifications associated
  2409. //! with the audio source must be restored too.
  2410. //! \br
  2411. //! In some use cases, partial data loss may be acceptable. One example would be to copy and paste
  2412. //! just an audio modification state from one document to another when the underlying audio source
  2413. //! has been edited in either the source or target document.
  2414. //! Depending on what the actual difference in the audio source state is, the plug-in may be able to
  2415. //! adjust the pasted audio modification to the altered audio source state and still retain a valuable
  2416. //! amount of the original data. Therefore the host is allowed to perform such operations (at the
  2417. //! risk of loosing an unspecified amount of data), and plug-ins must deal with this situation as
  2418. //! reasonable as their internal models allow them to and not threat this as an error.
  2419. //@{
  2420. //! Unarchive the internal state of the specified objects.
  2421. //! This call can be used both for unarchiving entire documents and for importing arbitrary
  2422. //! objects into an existing document.
  2423. //! An unarchiving session is conceptually identical to an editing session: after starting the
  2424. //! session, the host rebuilds the graph using the regular object creation calls, then makes
  2425. //! this call to let the plug-in parse the archive and inject the archived internal state into
  2426. //! the graph as indicated by the persistentIDs of the relevant objects.
  2427. //! Similarly, when importing objects, the host will perform an editing session and either create
  2428. //! new objects or re-use existing objects (potentially adjusting their persistentID), then
  2429. //! make this call to inject the imported state.
  2430. //! \br
  2431. //! The optional filter allows for restoring only a subset of the archived states into the graph.
  2432. //! It can be NULL, in which case all archived states with matching persistentIDs will be restored.
  2433. //! In that case, the call sequence beginEditing(), restoreObjectsFromArchive(), endEditing()
  2434. //! is equivalent to the deprecated begin-/endRestoringDocumentFromArchive() for ARA 1, which
  2435. //! has been superseded by this call.
  2436. //! The host is not required to restore all objects in the archive. Any archived states that are
  2437. //! either filtered explicitly, or for which there is no object with a matching persistent ID in
  2438. //! the current graph are simply ignored.
  2439. //! Since persistent IDs are only required to be unique per document (and not globally), hosts
  2440. //! may encounter persistent ID conflicts when importing data from other documents.
  2441. //! The optional ARARestoreObjectsFilter provided for this call therefore allows to map between
  2442. //! the IDs used in the archive and those used in the current graph if needed.
  2443. //! \br
  2444. //! The host can make multiple calls to restoreObjectsFromArchive() within the same editing
  2445. //! session to import objects from multiple archives in one operation. It may even decide
  2446. //! to implement its persistency based on partial archives entirely, using several calls to
  2447. //! storeObjectsToArchive() with varying filters to split the document into slices appropriate
  2448. //! to its implementation, see ARAStoreObjectsFilter::documentData.
  2449. //! \br
  2450. //! Result is kARAFalse if the access to the archive reader failed while trying to read the
  2451. //! archive, or if decoding the data failed, kARATrue otherwise. Potential reason for failure
  2452. //! include data corruption due to storage hardware failures, or broken dependencies when
  2453. //! restoring partial archives as discussed above. The plug-in should try to recover as much
  2454. //! state as possible in all cases, and the host should notify the user of such errors.
  2455. //! If a failure happened already while reading the archive, the host is aware of this and can
  2456. //! augment its error message to the user accordingly. If the failure happens inside the plug-in
  2457. //! when decoding the data, the plug-in is responsible for guiding the user as good as possible,
  2458. //! e.g. by listing or marking the affected objects.
  2459. //! Note that since versioning is expressed through the ARA factory, the host must deal with
  2460. //! potential versioning conflicts before making this call, and provide proper UI too.
  2461. ARA_ADDENDUM(2_0_Final) ARABool (ARA_CALL *restoreObjectsFromArchive) (ARADocumentControllerRef controllerRef, ARAArchiveReaderHostRef archiveReaderHostRef,
  2462. const ARARestoreObjectsFilter * filter);
  2463. //! Create a partial archive of the internal state of the specified objects.
  2464. //! Archives may only be created from documents that are not being currently edited.
  2465. //! The optional filter allows for storing only a subset of the document graph into the archive.
  2466. //! It can be NULL, in which case all objects in the graph will be stored.
  2467. //! In that case, the call is equivalent to the deprecated storeDocumentToArchive(),
  2468. //! which has been superseded by this call.
  2469. //! Result is kARAFalse if the access to the archive writer failed while trying to write the
  2470. //! archive, kARATrue otherwise.
  2471. //! The host is responsible for alerting the user about archive write errors,
  2472. //! see ARAArchivingControllerInterface::writeBytesToArchive().
  2473. //! Note that for creating ARA audio file chunk archives, storeAudioSourceToAudioFileChunk()
  2474. //! must be used instead, so that the plug-in can pick the correct encoding and return the
  2475. //! corresponding (compatible) document archive ID.
  2476. ARA_ADDENDUM(2_0_Final) ARABool (ARA_CALL *storeObjectsToArchive) (ARADocumentControllerRef controllerRef, ARAArchiveWriterHostRef archiveWriterHostRef,
  2477. const ARAStoreObjectsFilter * filter);
  2478. //@}
  2479. //! @name Processing Algorithm Selection (added in ARA 2.0)
  2480. //! Many plug-ins feature a set of different processing algorithms, each suited for a given kind of
  2481. //! audio material. When analyzing the audio, plug-ins either try to automatically determine the
  2482. //! appropriate algorithm that best matches the nature of the given material, or delegate this
  2483. //! decision to the user. This fundamental selection may affect all further processing of the
  2484. //! audio source - in addition to the analysis results, internal editing and rendering parameters
  2485. //! and even the entire UI may change. Accordingly, changing this selection may invalidate some or
  2486. //! all edits done by the user in the audio modifications based on the audio source. To avoid such
  2487. //! data loss, making this selection appropriately should always be the first step when working with
  2488. //! audio sources.
  2489. //! By exporting the list of processing algorithms here, hosts can implement this selection,
  2490. //! based on their knowledge about the origin of the audio material.
  2491. //! Some hosts allow for configuring their built-in detection in a very similar way on a per-track
  2492. //! basis, usually via a menu. They can use this technique for compatible ARA plug-ins as well.
  2493. //! Host might also be able to implicitly deduce an appropriate processing algorithm. For example,
  2494. //! when adding a new audio source to a region sequence that already refers to a set of previously
  2495. //! analyzed audio sources which all use the same detection algorithm, this algorithm is likely
  2496. //! appropriate for the new audio source as well.
  2497. //! Along the same lines, when recording a new take of some material that already has been analyzed
  2498. //! by the plug-in, it is reasonable to use the same algorithm for the new take.
  2499. //! Note that each processing algorithm must implement detection for all content types exported by
  2500. //! the plug-in, albeit the detection quality may likely be different for some types.
  2501. //! Plug-ins should keep the list of available processing algorithms restricted to the smallest
  2502. //! reasonable set - after all, in an ideal (but currently not achievable) implementation, a
  2503. //! single detection algorithm would be powerful enough to cover all types of material flawlessly.
  2504. //@{
  2505. //! Return the count of processing algorithms provided by the plug-in.
  2506. //! If this optional method is not implemented or the call returns 0, then the plug-in does not support
  2507. //! algorithm selection through the host and the other related functions below must not be called.
  2508. ARA_ADDENDUM(2_0_Final) ARAInt32 (ARA_CALL *getProcessingAlgorithmsCount) (ARADocumentControllerRef controllerRef);
  2509. //! List of processing algorithms provided by the plug-in, described by their properties.
  2510. //! This method must be implemented if getProcessingAlgorithmsCount() is implemented.
  2511. //! Provides a unique identifier and a user-readable name of the algorithm as displayed in the plug-in.
  2512. //! The host should present the algorithms to the user in the order of this list, e.g. in a menu.
  2513. //! For a given version of the plug-in, the count and the order and values of the persistentIDs
  2514. //! must be the same, while the names may depend on localization settings that can be different
  2515. //! on different machines or between individual runs of the host.
  2516. //! The list may however change between different versions of the plug-in.
  2517. //! Both hosts and plug-ins must implement fallbacks for loading a document that contains an
  2518. //! processing algorithm persistentID which is no longer supported by the plug-in.
  2519. //! The pointers returned by this calls must remain valid until the document controller
  2520. //! is destroyed.
  2521. ARA_ADDENDUM(2_0_Final) const ARAProcessingAlgorithmProperties * (ARA_CALL *getProcessingAlgorithmProperties) (ARADocumentControllerRef controllerRef,
  2522. ARAInt32 algorithmIndex);
  2523. //! Query currently used processing algorithm for a given audio source.
  2524. //! This method must be implemented if getProcessingAlgorithmsCount() is implemented.
  2525. //! After the plug-in has concluded an analysis (as indicated via
  2526. //! ARAModelUpdateControllerInterface::notifyAudioSourceContentChanged()),
  2527. //! the host can query which processing algorithm was used and update its UI accordingly.
  2528. //! This is particularly relevant if the host did explicitly request an analysis with a
  2529. //! specific algorithm, but the plug-in was unable to satisfy this request for some reason.
  2530. //! Similarly, the user may have changed the algorithm through the plug-in's UI.
  2531. //! Note that until the first analysis has completed (i.e. as long as
  2532. //! isAudioSourceContentAnalysisIncomplete() returns kARATrue), the value returned here may be
  2533. //! an abstract default, not related to the actual audio source content. This will e.g. typically
  2534. //! be the case in Melodyne, which uses an "automatic mode" as default until the first analysis
  2535. //! has determined the actual processing algorithm that is suitable for the material.
  2536. //! The call should not be made while isAudioSourceContentAnalysisIncomplete() returns kARATrue,
  2537. //! because the returned value is likely stale.
  2538. ARA_ADDENDUM(2_0_Final) ARAInt32 (ARA_CALL *getProcessingAlgorithmForAudioSource) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef);
  2539. //! Request that any future analysis of the given audio source should use the given processing algorithm.
  2540. //! This method must be implemented if getProcessingAlgorithmsCount() is implemented.
  2541. //! This both affects any analysis requested by the host via requestAudioSourceContentAnalysis()
  2542. //! as well as any analysis done by the plug-in on demand.
  2543. //! Since this typically results in a model graph edit, calling this functions must be guarded
  2544. //! by beginEditing() and endEditing().
  2545. //! Note that the plug-in is not required to heed this request if its internal state suggest
  2546. //! otherwise, or if the user switches actively to a different algorithm.
  2547. //! Also, some algorithms may be "meta" algorithms that will be replaced by a different actual
  2548. //! algorithm, such as the "automatic" default algorithm in Melodyne which will pick an
  2549. //! appropriate algorithm from the remaining list of algorithms when doing the initial analysis.
  2550. ARA_ADDENDUM(2_0_Final) void (ARA_CALL *requestProcessingAlgorithmForAudioSource) (ARADocumentControllerRef controllerRef, ARAAudioSourceRef audioSourceRef,
  2551. ARAInt32 algorithmIndex);
  2552. //@}
  2553. //! @name License Management (added in ARA 2.0)
  2554. //! If using ARA plug-ins for regular editing, their UI is shown and they can implement all license
  2555. //! handling fully transparent for the host within their regular UI. If however the host is using the
  2556. //! plug-in as internal engine for analysis (e.g. audio-to-MIDI conversion) or for time-stretching,
  2557. //! it will typically not open the plug-in UI, and accordingly must then deal with potentially missing
  2558. //! licenses that the plug-in requires to perform the desired tasks.
  2559. //! As an example, Melodyne's analysis capabilities are only available when running Melodyne essential
  2560. //! or higher, i.e. they are not supported by an unlicensed "playback-only" installation.
  2561. //@{
  2562. //! With this optional call, hosts can test whether the current license state of the plug-in allows
  2563. //! for requesting analysis of the given content types and rendering the given playback transformations
  2564. //! (see requestAudioSourceContentAnalysis() and ARAPlaybackRegionProperties::transformationFlags).
  2565. //! The host can also optionally instruct the plug-in to run a modal licensing dialog if the current
  2566. //! license is not sufficient to perform the selected engine tasks, so that the user can review and
  2567. //! adjust the licensing accordingly, such downloading a license from their respective user account
  2568. //! or even purchase an upgrade that enables the requested features.
  2569. //! \br
  2570. //! The provided content types must be a subset of the plug-in's ARAFactory::analyzeableContentTypes.
  2571. //! To request all analysis types exported by the plug-in, hosts can directly pass
  2572. //! analyzeableContentTypes and -Count from the ARAFactory.
  2573. //! The contentTypes pointer may be only valid for the duration of the call, it must be evaluated
  2574. //! inside the call, and the pointer must not be stored anywhere.
  2575. //! If not intending to use analysis, the count should be 0 and the array pointer NULL.
  2576. //! The transformationFlags must be a subset of the plug-in's ARAFactory::supportedPlaybackTransformationFlags,
  2577. //! and may be kARAPlaybackTransformationNoChanges if not intending to use transformations.
  2578. //! The call returns kARATrue if the (potentially updated) license is sufficient to perform the
  2579. //! requested tasks.
  2580. ARA_ADDENDUM(2_0_Final) ARABool (ARA_CALL *isLicensedForCapabilities) (ARADocumentControllerRef controllerRef,
  2581. ARABool runModalActivationDialogIfNeeded,
  2582. ARASize contentTypesCount, const ARAContentType contentTypes[],
  2583. ARAPlaybackTransformationFlags transformationFlags);
  2584. //@}
  2585. //! @name Document Persistency (extended in ARA 2.0)
  2586. //@{
  2587. //! Create an archive of the internal state of the specified audio source suitable to be
  2588. //! embedded into the underlying audio file as ARA audio file chunks, see @ref ARAAudioFileChunks.
  2589. //! Hosts must check ARAFactory::supportsStoringAudioFileChunks before enabling users to store
  2590. //! audio file chunks for the given plug-in.
  2591. //! Archives may only be created from documents that are not being currently edited.
  2592. //! \br
  2593. //! This call differs from using storeObjectsToArchive() with an ARAStoreObjectsFilter in that
  2594. //! the plug-in may choose a different internal encoding more suitable for this use case,
  2595. //! indicated by returning a \p documentArchiveID that is likely one of the
  2596. //! ARAFactory::compatibleDocumentArchiveIDs rather than the ARAFactory::documentArchiveID.
  2597. //! The plug-in also returns whether openAutomatically should be set in the audio file chunk.
  2598. //! Result is kARAFalse if the access to the archive writer failed while trying to write the
  2599. //! archive, kARATrue otherwise.
  2600. //! The host is responsible for alerting the user about archive write errors,
  2601. //! see ARAArchivingControllerInterface::writeBytesToArchive().
  2602. ARA_ADDENDUM(2_0_Final) ARABool (ARA_CALL *storeAudioSourceToAudioFileChunk) (ARADocumentControllerRef controllerRef, ARAArchiveWriterHostRef archiveWriterHostRef,
  2603. ARAAudioSourceRef audioSourceRef, ARAPersistentID * documentArchiveID, ARABool * openAutomatically);
  2604. //@}
  2605. } ARADocumentControllerInterface;
  2606. // Convenience constant for easy struct validation.
  2607. enum { kARADocumentControllerInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARADocumentControllerInterface, destroyContentReader) };
  2608. //! @}
  2609. /***************************************************************************************************/
  2610. //! @defgroup Plug-In_Document_Controller_Instance Document Controller Instance
  2611. //! The callbacks into the plug-in are published by the plug-in when the host requests the creation
  2612. //! of a document controller via the factory. The instance struct and all interfaces and
  2613. //! host refs therein must remain valid until the document controller is destroyed.
  2614. //! The plug-in can choose to create its controller objects per document controller instance, or it
  2615. //! can share a single instance between all document controllers, whatever fits its needs.
  2616. //! It may even mix-and-match both approaches per individual interface.
  2617. //! @{
  2618. //! The document controller instance struct and all interfaces and refs therein must remain valid
  2619. //! until the document controller is destroyed by the host.
  2620. typedef struct ARADocumentControllerInstance
  2621. {
  2622. //! @see_Versioned_Structs_
  2623. ARASize structSize;
  2624. //! @name Document Controller Interface
  2625. //@{
  2626. ARADocumentControllerRef documentControllerRef;
  2627. const ARADocumentControllerInterface * documentControllerInterface;
  2628. //@}
  2629. } ARADocumentControllerInstance;
  2630. // Convenience constant for easy struct validation.
  2631. enum { kARADocumentControllerInstanceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARADocumentControllerInstance, documentControllerInterface) };
  2632. //! @}
  2633. /***************************************************************************************************/
  2634. //! @defgroup Plug-In_Factory Plug-In Factory
  2635. //! Static entry into ARA, allows to create ARA objects.
  2636. //! @{
  2637. //! API configuration.
  2638. //! This configuration struct allows for setting the desired API version, the debug callback etc.
  2639. //! Note that a pointer to this struct is only valid for the duration of the call to
  2640. //! initializeARAWithConfiguration() - the data must be fully evaluated/copied inside the call.
  2641. typedef struct ARAInterfaceConfiguration
  2642. {
  2643. //! @see_Versioned_Structs
  2644. ARASize structSize;
  2645. //! Defines the API generation to use, must be within the range of supported generations.
  2646. ARAAPIGeneration desiredApiGeneration;
  2647. //! Pointer to the global assert function address.
  2648. //! Be aware that this is a pointer to a function pointer, not the function pointer itself!
  2649. //! This indirection is necessary so that plug-ins can inject their debug code if needed.
  2650. //! The pointer must be the same for all instances that use the same API generation.
  2651. //! It must be always provided by the host, but can point to NULL to suppress debugging in
  2652. //! release versions. It must remain valid until uninitializeARA() is called.
  2653. ARAAssertFunction * assertFunctionAddress;
  2654. } ARAInterfaceConfiguration;
  2655. // Convenience constant for easy struct validation.
  2656. enum { kARAInterfaceConfigurationMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAInterfaceConfiguration, assertFunctionAddress) };
  2657. //! Static plug-in factory.
  2658. //! All pointers herein must remain valid as long as the binary is loaded.
  2659. //! The declaration of this struct will not change when updating to a new generation of the API,
  2660. //! only additions are possible.
  2661. /*typedef*/ struct ARAFactory // the typedef was forward-declared above
  2662. {
  2663. //! @see_Versioned_Structs_
  2664. ARASize structSize;
  2665. //! @name Factory and Global Initialization
  2666. //! The following data members and functions are involved when loading/unloading the plug-in binary.
  2667. //! \br
  2668. //! All function calls in this header may only be made between a single call to
  2669. //! initializeARAWithConfiguration() and another single call to uninitializeARA().
  2670. //! Typically, initialization/uninitialization is done right after loading/right before unloading
  2671. //! the binary, but it is valid to call them multiple times without loading/unloading the binary
  2672. //! in-between, provided the described order of calls is respected.
  2673. //@{
  2674. ARAAPIGeneration lowestSupportedApiGeneration; //!< Lower bound of supported ARAAPIGeneration.
  2675. ARAAPIGeneration highestSupportedApiGeneration; //!< Upper bound of supported ARAAPIGeneration.
  2676. //! Unique and versioned plug-in identifier.
  2677. //! This ID must be globally unique and identifies the plug-in's document controller class
  2678. //! created by this factory at runtime.
  2679. //! The ID includes versioning, it must be updated if e.g. the plug-in's (compatible) document
  2680. //! archive ID(s) or its analysis or playback transformation capabilities change.
  2681. //! Host applications can therefore use it to trigger cache updates if they implement a plug-in
  2682. //! caching mechanism to avoid scanning all plug-ins each time the program is launched.
  2683. //! If a given plug-in supports multiple companion APIs, it will return the same ID across all
  2684. //! companion APIs, allowing the host to choose which API to use for this particular plug-in.
  2685. //! See @ref sec_ManagingARAArchives for more information.
  2686. ARAPersistentID factoryID;
  2687. //! Start up ARA with the given configuration.
  2688. void (ARA_CALL * initializeARAWithConfiguration) (const ARAInterfaceConfiguration * config);
  2689. //! Shut down ARA.
  2690. void (ARA_CALL * uninitializeARA) (void);
  2691. //@}
  2692. //! @name User-Presentable Meta Information
  2693. //! This information is only intended for display purposes and should never be used for flow control.
  2694. //! In addition to all other potential uses, this information should always be stored alongside any
  2695. //! document archive that the host creates in order to be able to provide a proper error message if
  2696. //! the archive is being restored on a different system where the plug-in is not installed (or only
  2697. //! an older version of it).
  2698. //! See @ref sec_ManagingARAArchives for more information.
  2699. //@{
  2700. //! Name of the plug-in to display to the user.
  2701. ARAUtf8String plugInName;
  2702. //! Name of the manufacturer of the plug-in to display to the user.
  2703. ARAUtf8String manufacturerName;
  2704. //! Web page to refer the user to if they need further information about the plug-in.
  2705. ARAUtf8String informationURL;
  2706. //! Version string of the plug-in to display to the user.
  2707. ARAUtf8String version;
  2708. //@}
  2709. //! @name Document Controller and Document Archives
  2710. //! This section of the struct deals with creating document controllers and handling versioned
  2711. //! document archiving based on archive IDs.
  2712. //! Note that in addition to the actual document archive and its ID, the host should save the above
  2713. //! meta information about the plug-in alongside so it can do proper error handling, see above.
  2714. //@{
  2715. //! Factory function for the document controller.
  2716. //! This call is used both when creating a new document from scratch and when restoring
  2717. //! a document from an archive.
  2718. const ARADocumentControllerInstance * (ARA_CALL *createDocumentControllerWithDocument) (const ARADocumentControllerHostInstance * hostInstance,
  2719. const ARADocumentProperties * properties);
  2720. //! Identifier for document archives created by the document controller.
  2721. //! This ID must be globally unique and is shared only amongst document controllers that
  2722. //! create the same archives and produce the same render results based upon the same input data.
  2723. //! This means that the ID must be updated if the archive format changes in any way that is
  2724. //! no longer downwards compatible.
  2725. //! See @ref sec_ManagingARAArchives for more information.
  2726. ARAPersistentID documentArchiveID;
  2727. //! Length of compatibleDocumentArchiveIDs.
  2728. ARASize compatibleDocumentArchiveIDsCount;
  2729. //! Variable-sized C array listing other identifiers of archives that the document controller can import.
  2730. //! This list is used for example when updating the data structures inside the controller.
  2731. //! It is ordered descending, expressing a preference which state to load in case a document
  2732. //! contains more than one compatible archive of older versions.
  2733. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  2734. const ARAPersistentID * compatibleDocumentArchiveIDs;
  2735. //@}
  2736. //! @name Capabilities
  2737. //! If the host wants to utilize the plug-in as an internal engine for analysis or time-stretching,
  2738. //! it can use this information to determine if the plug-in is actually capable of handling its needs.
  2739. //! Further, the host may want to restrict the user from doing operations that make no sense for the
  2740. //! given plug-in, such as trying to time-stretch with a plug-in that cannot perform this task.
  2741. //! Note that even if a plug-in cannot analyze a given content type, it still may provide a UI where
  2742. //! the user can edit that content type, so it may support content reading for types missing here.
  2743. //@{
  2744. //! Length of analyzeableContentTypes.
  2745. ARASize analyzeableContentTypesCount;
  2746. //! Variable-sized C array listing the content types for which the plug-in can perform an analysis.
  2747. //! This list allows the host to determine whether the plug-in can be used as analysis engine in
  2748. //! the background (i.e. without presenting the UI to the user) to achieve certain host features.
  2749. //! Note that the plug-in may support more content types than listed here for some or all objects
  2750. //! in the graph, but may rely on user interaction when dealing with those content types.
  2751. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  2752. const ARAContentType * analyzeableContentTypes;
  2753. //! Set of transformations that the plug-in supports when configuring playback regions.
  2754. //! These flags allow the host to determine whether e.g. the plug-in can be used as time-stretch engine.
  2755. ARAPlaybackTransformationFlags supportedPlaybackTransformationFlags;
  2756. //! Flag whether the plug-in supports exporting ARA audio file chunks via
  2757. //! ARADocumentControllerInterface::storeAudioSourceToAudioFileChunk().
  2758. //! Note that reading such chunks is unaffected by this flag - as long as the documentArchiveID
  2759. //! in the chunk is compatible, the plug-in must be able to read the data via
  2760. //! ARADocumentControllerInterface::restoreObjectsFromArchive().
  2761. ARA_DRAFT ARABool supportsStoringAudioFileChunks;
  2762. //@}
  2763. } /*ARAFactory*/;
  2764. // Convenience constant for easy struct validation.
  2765. enum { kARAFactoryMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAFactory, supportedPlaybackTransformationFlags) };
  2766. //! @}
  2767. /***************************************************************************************************/
  2768. //! @defgroup Plug-In_Extension Plug-In Extension
  2769. //! The plug-in extension provides ARA-specific additional functionality per companion plug-in instance.
  2770. //! On a conceptual level, the plug-in extension is not an object of its own, but merely a set of
  2771. //! additional interfaces of the companion plug-in instance, augmenting it with a few ARA-specific
  2772. //! features in a fashion that is independent from the actual companion API in use.
  2773. //! Accordingly, it is coupled 1:1 to the companion plug-in instance and its lifetime matches the
  2774. //! lifetime of the companion plug-in instance (no separate destruction function needed).
  2775. //! Along the same lines, plug-in extensions themselves are not persistent.
  2776. //! \br
  2777. //! The plug-in extension is exposed towards the host when it binds a plug-in instance as created by the
  2778. //! companion APIs to a specific ARA model graph, represented by its associated document controller.
  2779. //! This setup call is executed via a vendor-specific extension of the companion API and may only be
  2780. //! made once. It shifts the "normal" companion plug-in into the ARA world, and once established, this
  2781. //! coupling cannot be undone, it remains active until the plug-in instance is destroyed.
  2782. //! \br
  2783. //! Note that both performing the explicit binding and the implicit unbinding upon destruction will
  2784. //! likely need to access plug-in internal data structures shared with with the document controller
  2785. //! implementation. To avoid adding costly thread safety measures when maintaining this shared state,
  2786. //! hosts should always perform these operations from the document controller thread (typically the
  2787. //! main thread). This restriction may or may not apply when using the same companion API without ARA,
  2788. //! so host developers might need to add extra precaution for the ARA case.
  2789. //! \br
  2790. //! When ARA is enabled, the renderer behavior has slightly different semantics compared to the
  2791. //! non-ARA use case. Since ARA renderers are essentially generators that use non-realtime data to
  2792. //! generate realtime signals, they do not use the realtime input signal for processing.
  2793. //! Playback renderers will simply ignore their inputs, but editor renderers will always add their
  2794. //! output signal to the input signal provided by the host. If a plug-in assumes both rendering
  2795. //! roles, playback rendering will already ignore the inputs, so the editor rendering will directly
  2796. //! add to the playback output, not to the input.
  2797. //! \br
  2798. //! Since ARA 2.0, the host can explicitly establish the roles that the given instance will assume
  2799. //! in its specific implementation upon binding the plug-in instance to the ARA document controller.
  2800. //! Each role is associated with a dedicated feature set that only is available when the particular
  2801. //! role has been established.
  2802. //! Depending on the chosen roles, the following calls control which playback regions are to be
  2803. //! rendered according to which rule.
  2804. //! Separating roles allows for more flexible ARA integrations and optimizes resource usage.
  2805. //! A host could for example use a playback renderer plug-in instance playback region, plus
  2806. //! one plug-in instance per track for editor rendering and viewing all regions on that track.
  2807. //! Amongst other behavior, the roles heavily affect the relationship between plug-in instances
  2808. //! and playback regions.
  2809. //! For rendering, each plug-in extension can handle multiple playback regions if desired, albeit
  2810. //! the semantics for modifying the set of associated regions per renderer are somewhat different
  2811. //! between playback and editor renderers, see below.
  2812. //! For editor view purposes, the relationship is not explicit to accommodate for a very broad range
  2813. //! of user interface concepts that need to interact with the API. Generally, each editor view is
  2814. //! associated with all playback regions in the document controller to which the plug-in is bound.
  2815. //! However, typically only a varying subset of those regions will be shown at any point in time,
  2816. //! depending on the intrinsic feature set of the plug-in, and reflecting the selection that the
  2817. //! user has performed in the host - see notifySelection().
  2818. //! @{
  2819. //! Plug-in instance role flags.
  2820. typedef ARA_32_BIT_ENUM(ARAPlugInInstanceRoleFlags)
  2821. {
  2822. //! Role: playback render.
  2823. //! Plug-in instances fulfilling this role are performing playback rendering, both for realtime
  2824. //! song playback or for offline or realtime bounces/exports.
  2825. //! Playback render plug-ins can be responsible for more than one playback region at a time,
  2826. //! although hosts may prefer to use a 1:1 relationship to simplify their implementation and
  2827. //! easily allow for further per-region processing in the host (fades, region gain).
  2828. //! When dealing with looped regions and using the content based fades, a trivial optimization
  2829. //! of the above pattern is to use the same renderer instance for all consecutive repetitions
  2830. //! of the loop, which still allows for properly applying region gain and fades at the start or
  2831. //! end of the consecutive repetitions.
  2832. //! Another viable approach would be to use as many playback renderer instances per track as
  2833. //! there are concurrently sounding regions on the track (i.e. including head and tail time),
  2834. //! and distribute the regions in a round-robin fashion across those renderers so that in each
  2835. //! renderer the regions never overlap. This way, the host could extract a separate signal per
  2836. //! region with a minimal count of playback renderers.
  2837. //! Note that there may be several playback renderers per playback region, for example if a host
  2838. //! executes an export as background tasks that run concurrently with realtime playback.
  2839. //! A playback render plug-in will replace its inputs with the rendered signal. If it does not
  2840. //! also have editor rendering responsibilities, it does not need to be rendered while stopped,
  2841. //! and during playback only needs to be rendered for the range covered by the region, plus its
  2842. //! head and tail time.
  2843. //! Playback renderers are transient, the host does not need to store the state of these
  2844. //! instances via the companion API (unless they also fulfill kARAEditorViewRole or other
  2845. //! persistent roles).
  2846. kARAPlaybackRendererRole = 1 << 0,
  2847. //! Role: editor render.
  2848. //! Plug-in instances fulfilling this role are performing auxiliary realtime rendering
  2849. //! that is only used to support the editing process, such as metronome clicks or playing
  2850. //! the pitch of a note while it's being dragged to a different pitch.
  2851. //! There should only be one plug-in instance that handles editor rendering for any given
  2852. //! playback region. Since it is up to the plug-in to decide when it will generate previewing
  2853. //! output based on the editing, it needs to be permanently rendered by the host.
  2854. //! If a editor rendering plug-in is not responsible for playback, it will always forward its
  2855. //! input signal to the output, adding its preview signal as needed. Otherwise it will add the
  2856. //! signal to the playback render output described above.
  2857. //! Editor renderers are transient, the host does not need to store the state of these
  2858. //! instances via the companion API (unless they also fulfill kARAEditorViewRole or other
  2859. //! persistent roles).
  2860. kARAEditorRendererRole = 1 << 1,
  2861. //! Role: editor view.
  2862. //! Plug-in instances fulfilling this role can be used to display a GUI.
  2863. //! Unlike rendering for playback or editing, the view role is not tied to individual
  2864. //! playback regions or region sequences, but rather to all regions and sequences within the
  2865. //! document controller to which the given plug-in instance is bound.
  2866. //! Selection and hiding of host entities is communicated to editor view plug-ins so that
  2867. //! they can dynamically show a proper subset of the full document graph.
  2868. //! Editor view plug-ins may contain some state related to user interface configuration, and
  2869. //! thus their state needs to be persistent via the companion API.
  2870. kARAEditorViewRole = 1 << 2
  2871. };
  2872. /***************************************************************************************************/
  2873. //! @defgroup Playback_Renderer_Interface Playback Renderer Interface (Added In ARA 2.0)
  2874. //! See ::kARAPlaybackRendererRole.
  2875. //! \br
  2876. //! Plug-in developers using C++ ARA Library can implement the ARA::PlugIn::PlaybackRendererInterface,
  2877. //! or extend the already implemented ARA::PlugIn::PlaybackRenderer class as needed.
  2878. //! For host developers this interface is wrapped by the ARA::Host::PlaybackRenderer.
  2879. //! @{
  2880. //! Reference to the plug-in side representation of a playback renderer (opaque to the host).
  2881. ARA_ADDENDUM(2_0_Draft) typedef ARA_REF(ARAPlaybackRendererRef);
  2882. //! Plug-in interface: playback renderer.
  2883. //! The function pointers in this struct must remain valid until the companion API plug-in instance
  2884. //! (and accordingly its plug-in extension) is destroyed by the host.
  2885. ARA_ADDENDUM(2_0_Draft) typedef struct ARAPlaybackRendererInterface
  2886. {
  2887. //! @name Size-based struct versioning
  2888. //! See \ref Versioned_structs "Versioned structs".
  2889. //@{
  2890. ARASize structSize;
  2891. //@}
  2892. //! @name Assigning the playback region(s) for playback rendering
  2893. //! Specify the playback region(s) for which the this plug-in instance provides playback rendering.
  2894. //! (and, if using ARA1 which does not distinguish roles: also editor rendering and view).
  2895. //! These calls can only be made when the plug-in is not in render-state ("not active" in VST3
  2896. //! speak, "not initialized" in AU-speak), however the host may display the UI for the plug-in
  2897. //! while making these calls.
  2898. //! They can be made both inside or outside any editing or restoration cycles of the associated
  2899. //! ARA document controller, but doing them between ARADocumentControllerInterface::beginEditing()
  2900. //! and ARADocumentControllerInterface::endEditing() when feasible may yield better performance
  2901. //! since all updates can be calculated together.
  2902. //! When called outside beginEditing() and endEditing(), the changes may not be audible until the
  2903. //! next render call that starts after the plug-in has returned from the respective call.
  2904. //! The calls shall be made on the same thread that also hosts the document controller.
  2905. //! The host is not required to remove the playback regions before destroying the plug-in.
  2906. //! If multiple regions are set, they will all be sounding concurrently in case they overlap.
  2907. //! @anchor Assigning_ARAPlaybackRendererInterface_Regions
  2908. //@{
  2909. void (ARA_CALL *addPlaybackRegion) (ARAPlaybackRendererRef playbackRendererRef, ARAPlaybackRegionRef playbackRegionRef);
  2910. void (ARA_CALL *removePlaybackRegion) (ARAPlaybackRendererRef playbackRendererRef, ARAPlaybackRegionRef playbackRegionRef);
  2911. //@}
  2912. } ARAPlaybackRendererInterface;
  2913. // Convenience constant for easy struct validation.
  2914. enum ARA_ADDENDUM(2_0_Draft) { kARAPlaybackRendererInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAPlaybackRendererInterface, removePlaybackRegion) };
  2915. //! @}
  2916. /***************************************************************************************************/
  2917. //! @defgroup Editor_Renderer_Interface Editor Renderer Interface (Added In ARA 2.0)
  2918. //! See ::kARAEditorRendererRole.
  2919. //! \br
  2920. //! Plug-in developers using C++ ARA Library can implement the ARA::PlugIn::EditorRendererInterface,
  2921. //! or extend the already implemented ARA::PlugIn::EditorRenderer class as needed.
  2922. //! For host developers this interface is wrapped by the ARA::Host::EditorRenderer.
  2923. //! @{
  2924. //! Reference to the plug-in side representation of a editor renderer (opaque to the host).
  2925. ARA_ADDENDUM(2_0_Draft) typedef ARA_REF(ARAEditorRendererRef);
  2926. //! Plug-in interface: editor renderer.
  2927. //! The function pointers in this struct must remain valid until the companion API plug-in instance
  2928. //! (and accordingly its plug-in extension) is destroyed by the host.
  2929. ARA_ADDENDUM(2_0_Draft) typedef struct ARAEditorRendererInterface
  2930. {
  2931. //! @see_Versioned_Structs_
  2932. ARASize structSize;
  2933. //! @name Assigning the playback region(s) for preview while editing
  2934. //! Specify the set of playback region(s) for which the this plug-in instance provides previewing.
  2935. //! Hosts can choose to either maintain individual regions, or conveniently maintain regions by
  2936. //! specifying region sequences as a shortcut for all regions on those sequences.
  2937. //! Behavior is identical in both cases, but hosts should not mix both types of call on a single
  2938. //! plug-in instance.
  2939. //! Preview should be unambiguous, i.e. there should be only one editor renderer plug-in instance
  2940. //! associated with each playback region. During transitions however (such as moving a region
  2941. //! from one track to another), this rule may be disregarded temporarily.
  2942. //! The host can make these calls while the plug-in is in render-state ("active" in VST3 speak,
  2943. //! "initialized" in Audio Unit speak). Plug-ins must implement a proper bridging to the
  2944. //! concurrent render threads.
  2945. //! Further, the host may display the UI for the plug-in while making these calls.
  2946. //! They can be made both inside or outside any editing or restoration cycles of the associated
  2947. //! ARA document controller, but doing them between ARADocumentControllerInterface::beginEditing()
  2948. //! ARADocumentControllerInterface::endEditing() when feasible may yield better performance since
  2949. //! all updates can be calculated together.
  2950. //! The calls shall be made on the same thread that also hosts the document controller.
  2951. //! The host is not required to remove any or all playback regions or region sequences before
  2952. //! destroying the plug-in.
  2953. //! If a plug-in does not implement any audio preview features, it can safely ignore these calls
  2954. //! and provide empty implementations.
  2955. //! @anchor Assigning_ARAEditorRendererInterface_Regions
  2956. //@{
  2957. void (ARA_CALL *addPlaybackRegion) (ARAEditorRendererRef editorRendererRef, ARAPlaybackRegionRef playbackRegionRef);
  2958. void (ARA_CALL *removePlaybackRegion) (ARAEditorRendererRef editorRendererRef, ARAPlaybackRegionRef playbackRegionRef);
  2959. void (ARA_CALL *addRegionSequence) (ARAEditorRendererRef editorRendererRef, ARARegionSequenceRef regionSequenceRef);
  2960. void (ARA_CALL *removeRegionSequence) (ARAEditorRendererRef editorRendererRef, ARARegionSequenceRef regionSequenceRef);
  2961. //@}
  2962. } ARAEditorRendererInterface;
  2963. // Convenience constant for easy struct validation.
  2964. enum ARA_ADDENDUM(2_0_Draft) { kARAEditorRendererInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAEditorRendererInterface, removeRegionSequence) };
  2965. //! @}
  2966. /***************************************************************************************************/
  2967. //! @defgroup Editor_View_Interface Editor View Interface (Added In ARA 2.0)
  2968. //! See ::kARAEditorViewRole.
  2969. //! \br
  2970. //! Users will often reconfigure the plug-in view through scrolling, zooming, navigating lists of
  2971. //! entities, etc. to select the subset of ARA entities that they currently need to view or edit.
  2972. //! Those selection features can be implemented in the plug-in (which was the only available
  2973. //! solution in ARA 1). However, the host applications already have established user workflows for
  2974. //! selecting their representations of the ARA objects. Making those workflows available to the
  2975. //! plug-ins is leads to a much more consistent, streamlined user experience.
  2976. //! Since the views are implemented through the companion API, there is no matching ARA entity yet.
  2977. //! Instead, the companion plug-in instance is used as a controller for its associated view.
  2978. //! (Note that while some companion APIs allow for multiple views of a given plug-in used at the
  2979. //! same time, this is not recommended when using ARA editor views.)
  2980. //! These calls only affect views, not the audio rendering.
  2981. //! They only should be made while the plug-in is showing its UI, or before entering this
  2982. //! state (i.e. during GUI setup phase), in order to optimize resource usage. Accordingly, the
  2983. //! host should send an update of the selection when (re-)opening an ARA plug-in view.
  2984. //! These calls also may be made while changes are being made to the model graph (i.e. inside of pairs
  2985. //! of ARADocumentControllerInterface::beginEditing() and ARADocumentControllerInterface::endEditing()).
  2986. //! \br
  2987. //! Plug-in developers using C++ ARA Library can implement the ARA::PlugIn::EditorViewInterface,
  2988. //! or extend the already implemented ARA::PlugIn::EditorView class as needed.
  2989. //! For host developers this interface is wrapped by the ARA::Host::EditorView.
  2990. //! @{
  2991. //! Host generated ARA view selection.
  2992. typedef struct ARAViewSelection
  2993. {
  2994. //! @see_Versioned_Structs
  2995. ARASize structSize;
  2996. //! Length of #playbackRegionRefs.
  2997. ARASize playbackRegionRefsCount;
  2998. //! Variable-sized C array listing the explicitly selected playback regions.
  2999. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  3000. //! If the plug-in requires a playback region selections in its view, it can derive an implicit
  3001. //! playback region selection from the region sequence selection and the time range in that case.
  3002. const ARAPlaybackRegionRef * playbackRegionRefs;
  3003. //! Length of #regionSequenceRefs.
  3004. ARASize regionSequenceRefsCount;
  3005. //! Variable-sized C array listing the explicitly selected region sequences.
  3006. //! The list may be empty, in which case count should be 0 and the pointer NULL.
  3007. //! If the plug-in requires a region sequence selections in its view, it can derive an implicit
  3008. //! region sequence selection from the playback region selection in that case.
  3009. const ARARegionSequenceRef * regionSequenceRefs;
  3010. //! Pointer to the explicitly selected time range.
  3011. //! This pointer can be NULL to indicate that selection command does not include an explicit
  3012. //! time range selection.
  3013. //! If the plug-in requires a time range selection in its view, it can derive an implicit
  3014. //! time range selection from the playback region selection, or if that isn't provided either
  3015. //! it can evaluate the list of all playback regions of the selected region sequences.
  3016. const ARAContentTimeRange * timeRange;
  3017. } ARAViewSelection;
  3018. // Convenience constant for easy struct validation.
  3019. enum { kARAViewSelectionMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAViewSelection, timeRange) };
  3020. //! Reference to the plug-in side representation of a editor view (opaque to the host).
  3021. ARA_ADDENDUM(2_0_Draft) typedef ARA_REF(ARAEditorViewRef);
  3022. //! Plug-in interface: view controller.
  3023. //! The function pointers in this struct must remain valid until the document controller is
  3024. //! destroyed by the host.
  3025. ARA_ADDENDUM(2_0_Draft) typedef struct ARAEditorViewInterface
  3026. {
  3027. //! @see_Versioned_Structs_
  3028. ARASize structSize;
  3029. //! @name Host UI notifications
  3030. //@{
  3031. //! Apply the given host selection to all associated views.
  3032. //! This ARA 2.0 addition allows hosts to translate the effects of their selection implementation
  3033. //! to a selection of ARA objects that can be interpreted by the plug-in.
  3034. //! The command is not strict a setter for the given selection state, it rather notifies the
  3035. //! plug-in about relevant user interaction in the host so that it can adopt in whatever way
  3036. //! provides the best user experience within the context of the given plug-in design.
  3037. //! A plug-in may e.g. implement scrolling to relevant positions, select the playback regions in
  3038. //! its inspector(s), or filter the provided objects further depending on user settings.
  3039. //! The plug-in also remains free to modify its internal selection at any time through its
  3040. //! build-in UI behavior.
  3041. //! For example, a plug-in may design its UI around individual regions being edited, or around
  3042. //! entire region sequences. Melodyne features both modes, switchable by the user. When editing
  3043. //! an individual region, it will always pick the "most suitable" region from the selection,
  3044. //! and ignore the other selected regions.
  3045. //! Melodyne also implements various ways to switch the editable region sequence(s) or playback
  3046. //! region at any time independently from the host selection, as well as a user option to
  3047. //! temporarily ignore host selection changes to "pin" the current selection.
  3048. //! The same "loose" coupling applies on the host side: the selection sent by the host is not
  3049. //! necessarily equal to its actual selection, but rather the best representation of the
  3050. //! users' intent. For example, the user may be able to select entities that are not directly
  3051. //! represented in the ARA API, but relate to a set of playback regions in some meaningful way.
  3052. //! In that case, those regions may be sent as selection.
  3053. //! The selection command includes various optional entities that describe the selection on the
  3054. //! host side, such as playback regions or region sequences. Host will only explicitly provide
  3055. //! those objects that best describe their current selection, but plug-ins can often derive other
  3056. //! selections from that, such as calculating a region selection based on sequence selection and
  3057. //! time range.
  3058. //! Most hosts offer both an object-based selection which typically centers around selected
  3059. //! arrange events (playback regions) and tracks (region sequences) versus a time-range based
  3060. //! selection that is independent of the arrange events but typically also includes track selection.
  3061. //! Both modes shall be distinguished by providing a time range only in the latter case.
  3062. //! Some hosts even allow to select multiple time ranges, this should be expressed by sending
  3063. //! their union range across the API.
  3064. //! For an object-based selection, the time range remains NULL, and plug-ins can calculate an
  3065. //! implicit time range from the selected playback regions if desired.
  3066. //! Arrange event selection may linked to track selection in a variety of ways. For example,
  3067. //! selecting a track may select its events (often filter by playback cycle range), and selecting
  3068. //! an event may select its associated track as well. The ARA selection must be always updated
  3069. //! to reflect any such linking accordingly.
  3070. //! In each object list, objects are ordered by importance, with the most relevant, "focused"
  3071. //! object being first. So if a plug-in supports only a single region selection, it should use
  3072. //! the first region. If it can only show a single region sequence at a time, it should use the
  3073. //! first selected sequence, or if no sequences are included in the selection fall back to the
  3074. //! sequence of the first selected region, etc.
  3075. //! Each new selection call describes a full selection, i.e. replaces the previous selection.
  3076. //! An empty selection is valid and should be communicated by the host, since some plug-ins may
  3077. //! need to evaluate this in special cases.
  3078. //! Being selected does not affect the life time of the objects - selected objects may be deleted
  3079. //! without updating the selection status first.
  3080. //! Note that a pointer to this struct and all pointers contained therein are only valid for the
  3081. //! duration of the current call receiving the pointer - the data must be evaluated/copied inside
  3082. //! the call, and the pointers must not be stored anywhere.
  3083. void (ARA_CALL *notifySelection) (ARAEditorViewRef editorViewRef, const ARAViewSelection * selection);
  3084. //! Reflect hiding of region sequences in all associated views.
  3085. //! Some hosts offer the option to hide arrange tracks from view, so that they are no longer
  3086. //! visible, while still being played back regularly. This can be communicated to the plug-in
  3087. //! so that it follows suite.
  3088. //! Each call implicitly unhides all previously hidden region sequences, so calling this with
  3089. //! an empty list makes all sequences visible.
  3090. //! The regionSequenceRefs pointer is only valid for the duration of the call, it must be evaluated
  3091. //! inside the call, and the pointer must not be stored anywhere.
  3092. //! It should be NULL if regionSequenceRefsCount is 0.
  3093. void (ARA_CALL *notifyHideRegionSequences) (ARAEditorViewRef editorViewRef,
  3094. ARASize regionSequenceRefsCount, const ARARegionSequenceRef regionSequenceRefs[]);
  3095. //@}
  3096. } ARAEditorViewInterface;
  3097. // Convenience constant for easy struct validation.
  3098. enum ARA_ADDENDUM(2_0_Draft) { kARAEditorViewInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAEditorViewInterface, notifyHideRegionSequences) };
  3099. //! @}
  3100. //! @defgroup Plug-In_Extension_Interface Deprecated: Plug-In Extension Interface.
  3101. //! This interface was used before ARA 2.0 defined dedicated plug-in roles.
  3102. //! It is only to be implemented when ARA 1 backwards compatibility is desired.
  3103. //! An ARA 1 call to set/removePlaybackRegion() in this interface is equivalent
  3104. //! to calling both set/removePlaybackRegion() in ARAPlaybackRendererInterface
  3105. //! and add/removePlaybackRegion() in ARAEditorRendererInterface.
  3106. //! To some extend ARA 1 also uses this to for tasks now associated with
  3107. //! ARAEditorViewInterface: opening the UI of an ARA 1 plug-in instance is
  3108. //! interpreted as selection of the playback region set via this interface.
  3109. //! @{
  3110. ARA_DEPRECATED(2_0_Draft) typedef ARA_REF(ARAPlugInExtensionRef);
  3111. ARA_DEPRECATED(2_0_Draft) typedef struct ARAPlugInExtensionInterface
  3112. {
  3113. ARASize structSize;
  3114. void (ARA_CALL *setPlaybackRegion) (ARAPlugInExtensionRef plugInExtensionRef, ARAPlaybackRegionRef playbackRegionRef);
  3115. void (ARA_CALL *removePlaybackRegion) (ARAPlugInExtensionRef plugInExtensionRef, ARAPlaybackRegionRef playbackRegionRef);
  3116. } ARAPlugInExtensionInterface;
  3117. enum ARA_DEPRECATED(2_0_Draft) { kARAPlugInExtensionInterfaceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAPlugInExtensionInterface, removePlaybackRegion) };
  3118. //! @}
  3119. //! The plug-in extension instance struct and all interfaces and refs therein must remain valid
  3120. //! until the companion plug-in is destroyed by the host.
  3121. //! Note that the companion plug-in destruction may happen before or after destroying the document
  3122. //! controller it has been bound to, plug-ins must handle both possible destruction orders.
  3123. //! Plug-ins must provide all interfaces that have been requested by the host through the role
  3124. //! assignment, and suppress interfaces explicitly excluded by the roles - e.g. if the host did
  3125. //! not assign kARAEditorRendererRole even it was known, editorRendererInterface will be NULL.
  3126. typedef struct ARAPlugInExtensionInstance
  3127. {
  3128. //! @see_Versioned_Structs_
  3129. ARASize structSize;
  3130. ARA_DEPRECATED(2_0_Draft) ARAPlugInExtensionRef plugInExtensionRef;
  3131. ARA_DEPRECATED(2_0_Draft) const ARAPlugInExtensionInterface * plugInExtensionInterface;
  3132. //! @name ARA2 Instance Roles
  3133. //@{
  3134. ARAPlaybackRendererRef playbackRendererRef;
  3135. const ARAPlaybackRendererInterface * playbackRendererInterface;
  3136. ARAEditorRendererRef editorRendererRef;
  3137. const ARAEditorRendererInterface * editorRendererInterface;
  3138. ARAEditorViewRef editorViewRef;
  3139. const ARAEditorViewInterface * editorViewInterface;
  3140. //@}
  3141. } ARAPlugInExtensionInstance;
  3142. // Convenience constant for easy struct validation.
  3143. enum { kARAPlugInExtensionInstanceMinSize = ARA_IMPLEMENTED_STRUCT_SIZE(ARAPlugInExtensionInstance, plugInExtensionInterface) };
  3144. //! @}
  3145. //! @}
  3146. /***************************************************************************************************/
  3147. // various configurations/decorations to ensure binary compatibility
  3148. #undef ARA_32_BIT_ENUM
  3149. #if defined(_MSC_VER) || defined(__GNUC__)
  3150. #pragma pack(pop)
  3151. #else
  3152. #error "struct packing and alignment not yet defined for this compiler"
  3153. #endif
  3154. #if defined(__cplusplus) && !(ARA_DOXYGEN_BUILD)
  3155. } // extern "C"
  3156. } // namespace ARA
  3157. #endif
  3158. #endif // ARAInterface_h