fmod.cs 191 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081
  1. /* ======================================================================================== */
  2. /* FMOD Core API - C# wrapper. */
  3. /* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2024. */
  4. /* */
  5. /* For more detail visit: */
  6. /* https://fmod.com/docs/2.03/api/core-api.html */
  7. /* ======================================================================================== */
  8. using System;
  9. using System.Text;
  10. using System.Runtime.InteropServices;
  11. using System.Collections.Generic;
  12. namespace FMOD
  13. {
  14. /*
  15. FMOD version number. Check this against FMOD::System::getVersion / System_GetVersion
  16. 0xaaaabbcc -> aaaa = major version number. bb = minor version number. cc = development version number.
  17. */
  18. public partial class VERSION
  19. {
  20. public const int number = 0x00020302;
  21. #if !UNITY_2021_3_OR_NEWER
  22. public const string dll = "fmod";
  23. #endif
  24. }
  25. public class CONSTANTS
  26. {
  27. public const int MAX_CHANNEL_WIDTH = 32;
  28. public const int MAX_LISTENERS = 8;
  29. public const int REVERB_MAXINSTANCES = 4;
  30. public const int MAX_SYSTEMS = 8;
  31. }
  32. /*
  33. FMOD core types
  34. */
  35. public enum RESULT : int
  36. {
  37. OK,
  38. ERR_BADCOMMAND,
  39. ERR_CHANNEL_ALLOC,
  40. ERR_CHANNEL_STOLEN,
  41. ERR_DMA,
  42. ERR_DSP_CONNECTION,
  43. ERR_DSP_DONTPROCESS,
  44. ERR_DSP_FORMAT,
  45. ERR_DSP_INUSE,
  46. ERR_DSP_NOTFOUND,
  47. ERR_DSP_RESERVED,
  48. ERR_DSP_SILENCE,
  49. ERR_DSP_TYPE,
  50. ERR_FILE_BAD,
  51. ERR_FILE_COULDNOTSEEK,
  52. ERR_FILE_DISKEJECTED,
  53. ERR_FILE_EOF,
  54. ERR_FILE_ENDOFDATA,
  55. ERR_FILE_NOTFOUND,
  56. ERR_FORMAT,
  57. ERR_HEADER_MISMATCH,
  58. ERR_HTTP,
  59. ERR_HTTP_ACCESS,
  60. ERR_HTTP_PROXY_AUTH,
  61. ERR_HTTP_SERVER_ERROR,
  62. ERR_HTTP_TIMEOUT,
  63. ERR_INITIALIZATION,
  64. ERR_INITIALIZED,
  65. ERR_INTERNAL,
  66. ERR_INVALID_FLOAT,
  67. ERR_INVALID_HANDLE,
  68. ERR_INVALID_PARAM,
  69. ERR_INVALID_POSITION,
  70. ERR_INVALID_SPEAKER,
  71. ERR_INVALID_SYNCPOINT,
  72. ERR_INVALID_THREAD,
  73. ERR_INVALID_VECTOR,
  74. ERR_MAXAUDIBLE,
  75. ERR_MEMORY,
  76. ERR_MEMORY_CANTPOINT,
  77. ERR_NEEDS3D,
  78. ERR_NEEDSHARDWARE,
  79. ERR_NET_CONNECT,
  80. ERR_NET_SOCKET_ERROR,
  81. ERR_NET_URL,
  82. ERR_NET_WOULD_BLOCK,
  83. ERR_NOTREADY,
  84. ERR_OUTPUT_ALLOCATED,
  85. ERR_OUTPUT_CREATEBUFFER,
  86. ERR_OUTPUT_DRIVERCALL,
  87. ERR_OUTPUT_FORMAT,
  88. ERR_OUTPUT_INIT,
  89. ERR_OUTPUT_NODRIVERS,
  90. ERR_PLUGIN,
  91. ERR_PLUGIN_MISSING,
  92. ERR_PLUGIN_RESOURCE,
  93. ERR_PLUGIN_VERSION,
  94. ERR_RECORD,
  95. ERR_REVERB_CHANNELGROUP,
  96. ERR_REVERB_INSTANCE,
  97. ERR_SUBSOUNDS,
  98. ERR_SUBSOUND_ALLOCATED,
  99. ERR_SUBSOUND_CANTMOVE,
  100. ERR_TAGNOTFOUND,
  101. ERR_TOOMANYCHANNELS,
  102. ERR_TRUNCATED,
  103. ERR_UNIMPLEMENTED,
  104. ERR_UNINITIALIZED,
  105. ERR_UNSUPPORTED,
  106. ERR_VERSION,
  107. ERR_EVENT_ALREADY_LOADED,
  108. ERR_EVENT_LIVEUPDATE_BUSY,
  109. ERR_EVENT_LIVEUPDATE_MISMATCH,
  110. ERR_EVENT_LIVEUPDATE_TIMEOUT,
  111. ERR_EVENT_NOTFOUND,
  112. ERR_STUDIO_UNINITIALIZED,
  113. ERR_STUDIO_NOT_LOADED,
  114. ERR_INVALID_STRING,
  115. ERR_ALREADY_LOCKED,
  116. ERR_NOT_LOCKED,
  117. ERR_RECORD_DISCONNECTED,
  118. ERR_TOOMANYSAMPLES,
  119. }
  120. public enum CHANNELCONTROL_TYPE : int
  121. {
  122. CHANNEL,
  123. CHANNELGROUP,
  124. MAX
  125. }
  126. [StructLayout(LayoutKind.Sequential)]
  127. public struct VECTOR
  128. {
  129. public float x;
  130. public float y;
  131. public float z;
  132. }
  133. [StructLayout(LayoutKind.Sequential)]
  134. public struct ATTRIBUTES_3D
  135. {
  136. public VECTOR position;
  137. public VECTOR velocity;
  138. public VECTOR forward;
  139. public VECTOR up;
  140. }
  141. [StructLayout(LayoutKind.Sequential)]
  142. public partial struct GUID
  143. {
  144. public int Data1;
  145. public int Data2;
  146. public int Data3;
  147. public int Data4;
  148. }
  149. [StructLayout(LayoutKind.Sequential)]
  150. public struct ASYNCREADINFO
  151. {
  152. public IntPtr handle;
  153. public uint offset;
  154. public uint sizebytes;
  155. public int priority;
  156. public IntPtr userdata;
  157. public IntPtr buffer;
  158. public uint bytesread;
  159. public FILE_ASYNCDONE_FUNC done;
  160. }
  161. public enum OUTPUTTYPE : int
  162. {
  163. AUTODETECT,
  164. UNKNOWN,
  165. NOSOUND,
  166. WAVWRITER,
  167. NOSOUND_NRT,
  168. WAVWRITER_NRT,
  169. WASAPI,
  170. ASIO,
  171. PULSEAUDIO,
  172. ALSA,
  173. COREAUDIO,
  174. AUDIOTRACK,
  175. OPENSL,
  176. AUDIOOUT,
  177. AUDIO3D,
  178. WEBAUDIO,
  179. NNAUDIO,
  180. WINSONIC,
  181. AAUDIO,
  182. AUDIOWORKLET,
  183. PHASE,
  184. OHAUDIO,
  185. MAX,
  186. }
  187. public enum PORT_TYPE : int
  188. {
  189. MUSIC,
  190. COPYRIGHT_MUSIC,
  191. VOICE,
  192. CONTROLLER,
  193. PERSONAL,
  194. VIBRATION,
  195. AUX,
  196. PASSTHROUGH,
  197. VR_VIBRATION,
  198. MAX
  199. }
  200. public enum DEBUG_MODE : int
  201. {
  202. TTY,
  203. FILE,
  204. CALLBACK,
  205. }
  206. [Flags]
  207. public enum DEBUG_FLAGS : uint
  208. {
  209. NONE = 0x00000000,
  210. ERROR = 0x00000001,
  211. WARNING = 0x00000002,
  212. LOG = 0x00000004,
  213. TYPE_MEMORY = 0x00000100,
  214. TYPE_FILE = 0x00000200,
  215. TYPE_CODEC = 0x00000400,
  216. TYPE_TRACE = 0x00000800,
  217. DISPLAY_TIMESTAMPS = 0x00010000,
  218. DISPLAY_LINENUMBERS = 0x00020000,
  219. DISPLAY_THREAD = 0x00040000,
  220. }
  221. [Flags]
  222. public enum MEMORY_TYPE : uint
  223. {
  224. NORMAL = 0x00000000,
  225. STREAM_FILE = 0x00000001,
  226. STREAM_DECODE = 0x00000002,
  227. SAMPLEDATA = 0x00000004,
  228. DSP_BUFFER = 0x00000008,
  229. PLUGIN = 0x00000010,
  230. PERSISTENT = 0x00200000,
  231. ALL = 0xFFFFFFFF
  232. }
  233. public enum SPEAKERMODE : int
  234. {
  235. DEFAULT,
  236. RAW,
  237. MONO,
  238. STEREO,
  239. QUAD,
  240. SURROUND,
  241. _5POINT1,
  242. _7POINT1,
  243. _7POINT1POINT4,
  244. MAX,
  245. }
  246. public enum SPEAKER : int
  247. {
  248. NONE = -1,
  249. FRONT_LEFT,
  250. FRONT_RIGHT,
  251. FRONT_CENTER,
  252. LOW_FREQUENCY,
  253. SURROUND_LEFT,
  254. SURROUND_RIGHT,
  255. BACK_LEFT,
  256. BACK_RIGHT,
  257. TOP_FRONT_LEFT,
  258. TOP_FRONT_RIGHT,
  259. TOP_BACK_LEFT,
  260. TOP_BACK_RIGHT,
  261. MAX,
  262. }
  263. [Flags]
  264. public enum CHANNELMASK : uint
  265. {
  266. FRONT_LEFT = 0x00000001,
  267. FRONT_RIGHT = 0x00000002,
  268. FRONT_CENTER = 0x00000004,
  269. LOW_FREQUENCY = 0x00000008,
  270. SURROUND_LEFT = 0x00000010,
  271. SURROUND_RIGHT = 0x00000020,
  272. BACK_LEFT = 0x00000040,
  273. BACK_RIGHT = 0x00000080,
  274. BACK_CENTER = 0x00000100,
  275. MONO = (FRONT_LEFT),
  276. STEREO = (FRONT_LEFT | FRONT_RIGHT),
  277. LRC = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER),
  278. QUAD = (FRONT_LEFT | FRONT_RIGHT | SURROUND_LEFT | SURROUND_RIGHT),
  279. SURROUND = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT),
  280. _5POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT),
  281. _5POINT1_REARS = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | BACK_LEFT | BACK_RIGHT),
  282. _7POINT0 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT),
  283. _7POINT1 = (FRONT_LEFT | FRONT_RIGHT | FRONT_CENTER | LOW_FREQUENCY | SURROUND_LEFT | SURROUND_RIGHT | BACK_LEFT | BACK_RIGHT)
  284. }
  285. public enum CHANNELORDER : int
  286. {
  287. DEFAULT,
  288. WAVEFORMAT,
  289. PROTOOLS,
  290. ALLMONO,
  291. ALLSTEREO,
  292. ALSA,
  293. MAX,
  294. }
  295. public enum PLUGINTYPE : int
  296. {
  297. OUTPUT,
  298. CODEC,
  299. DSP,
  300. MAX,
  301. }
  302. [StructLayout(LayoutKind.Sequential)]
  303. public struct PLUGINLIST
  304. {
  305. PLUGINTYPE type;
  306. IntPtr description;
  307. }
  308. [Flags]
  309. public enum INITFLAGS : uint
  310. {
  311. NORMAL = 0x00000000,
  312. STREAM_FROM_UPDATE = 0x00000001,
  313. MIX_FROM_UPDATE = 0x00000002,
  314. _3D_RIGHTHANDED = 0x00000004,
  315. CLIP_OUTPUT = 0x00000008,
  316. CHANNEL_LOWPASS = 0x00000100,
  317. CHANNEL_DISTANCEFILTER = 0x00000200,
  318. PROFILE_ENABLE = 0x00010000,
  319. VOL0_BECOMES_VIRTUAL = 0x00020000,
  320. GEOMETRY_USECLOSEST = 0x00040000,
  321. PREFER_DOLBY_DOWNMIX = 0x00080000,
  322. THREAD_UNSAFE = 0x00100000,
  323. PROFILE_METER_ALL = 0x00200000,
  324. MEMORY_TRACKING = 0x00400000,
  325. }
  326. public enum SOUND_TYPE : int
  327. {
  328. UNKNOWN,
  329. AIFF,
  330. ASF,
  331. DLS,
  332. FLAC,
  333. FSB,
  334. IT,
  335. MIDI,
  336. MOD,
  337. MPEG,
  338. OGGVORBIS,
  339. PLAYLIST,
  340. RAW,
  341. S3M,
  342. USER,
  343. WAV,
  344. XM,
  345. XMA,
  346. AUDIOQUEUE,
  347. AT9,
  348. VORBIS,
  349. MEDIA_FOUNDATION,
  350. MEDIACODEC,
  351. FADPCM,
  352. OPUS,
  353. MAX,
  354. }
  355. public enum SOUND_FORMAT : int
  356. {
  357. NONE,
  358. PCM8,
  359. PCM16,
  360. PCM24,
  361. PCM32,
  362. PCMFLOAT,
  363. BITSTREAM,
  364. MAX
  365. }
  366. [Flags]
  367. public enum MODE : uint
  368. {
  369. DEFAULT = 0x00000000,
  370. LOOP_OFF = 0x00000001,
  371. LOOP_NORMAL = 0x00000002,
  372. LOOP_BIDI = 0x00000004,
  373. _2D = 0x00000008,
  374. _3D = 0x00000010,
  375. CREATESTREAM = 0x00000080,
  376. CREATESAMPLE = 0x00000100,
  377. CREATECOMPRESSEDSAMPLE = 0x00000200,
  378. OPENUSER = 0x00000400,
  379. OPENMEMORY = 0x00000800,
  380. OPENMEMORY_POINT = 0x10000000,
  381. OPENRAW = 0x00001000,
  382. OPENONLY = 0x00002000,
  383. ACCURATETIME = 0x00004000,
  384. MPEGSEARCH = 0x00008000,
  385. NONBLOCKING = 0x00010000,
  386. UNIQUE = 0x00020000,
  387. _3D_HEADRELATIVE = 0x00040000,
  388. _3D_WORLDRELATIVE = 0x00080000,
  389. _3D_INVERSEROLLOFF = 0x00100000,
  390. _3D_LINEARROLLOFF = 0x00200000,
  391. _3D_LINEARSQUAREROLLOFF = 0x00400000,
  392. _3D_INVERSETAPEREDROLLOFF = 0x00800000,
  393. _3D_CUSTOMROLLOFF = 0x04000000,
  394. _3D_IGNOREGEOMETRY = 0x40000000,
  395. IGNORETAGS = 0x02000000,
  396. LOWMEM = 0x08000000,
  397. VIRTUAL_PLAYFROMSTART = 0x80000000
  398. }
  399. public enum OPENSTATE : int
  400. {
  401. READY = 0,
  402. LOADING,
  403. ERROR,
  404. CONNECTING,
  405. BUFFERING,
  406. SEEKING,
  407. PLAYING,
  408. SETPOSITION,
  409. MAX,
  410. }
  411. public enum SOUNDGROUP_BEHAVIOR : int
  412. {
  413. BEHAVIOR_FAIL,
  414. BEHAVIOR_MUTE,
  415. BEHAVIOR_STEALLOWEST,
  416. MAX,
  417. }
  418. public enum CHANNELCONTROL_CALLBACK_TYPE : int
  419. {
  420. END,
  421. VIRTUALVOICE,
  422. SYNCPOINT,
  423. OCCLUSION,
  424. MAX,
  425. }
  426. public struct CHANNELCONTROL_DSP_INDEX
  427. {
  428. public const int HEAD = -1;
  429. public const int FADER = -2;
  430. public const int TAIL = -3;
  431. }
  432. public enum ERRORCALLBACK_INSTANCETYPE : int
  433. {
  434. NONE,
  435. SYSTEM,
  436. CHANNEL,
  437. CHANNELGROUP,
  438. CHANNELCONTROL,
  439. SOUND,
  440. SOUNDGROUP,
  441. DSP,
  442. DSPCONNECTION,
  443. GEOMETRY,
  444. REVERB3D,
  445. STUDIO_SYSTEM,
  446. STUDIO_EVENTDESCRIPTION,
  447. STUDIO_EVENTINSTANCE,
  448. STUDIO_PARAMETERINSTANCE,
  449. STUDIO_BUS,
  450. STUDIO_VCA,
  451. STUDIO_BANK,
  452. STUDIO_COMMANDREPLAY
  453. }
  454. [StructLayout(LayoutKind.Sequential)]
  455. public struct ERRORCALLBACK_INFO
  456. {
  457. public RESULT result;
  458. public ERRORCALLBACK_INSTANCETYPE instancetype;
  459. public IntPtr instance;
  460. public StringWrapper functionname;
  461. public StringWrapper functionparams;
  462. }
  463. [StructLayout(LayoutKind.Sequential)]
  464. public struct CPU_USAGE
  465. {
  466. public float dsp; /* DSP mixing CPU usage. */
  467. public float stream; /* Streaming engine CPU usage. */
  468. public float geometry; /* Geometry engine CPU usage. */
  469. public float update; /* System::update CPU usage. */
  470. public float convolution1; /* Convolution reverb processing thread #1 CPU usage */
  471. public float convolution2; /* Convolution reverb processing thread #2 CPU usage */
  472. }
  473. [StructLayout(LayoutKind.Sequential)]
  474. public struct DSP_DATA_PARAMETER_INFO
  475. {
  476. public IntPtr data;
  477. public uint length;
  478. public int index;
  479. }
  480. [Flags]
  481. public enum SYSTEM_CALLBACK_TYPE : uint
  482. {
  483. DEVICELISTCHANGED = 0x00000001,
  484. DEVICELOST = 0x00000002,
  485. MEMORYALLOCATIONFAILED = 0x00000004,
  486. THREADCREATED = 0x00000008,
  487. BADDSPCONNECTION = 0x00000010,
  488. PREMIX = 0x00000020,
  489. POSTMIX = 0x00000040,
  490. ERROR = 0x00000080,
  491. THREADDESTROYED = 0x00000100,
  492. PREUPDATE = 0x00000200,
  493. POSTUPDATE = 0x00000400,
  494. RECORDLISTCHANGED = 0x00000800,
  495. BUFFEREDNOMIX = 0x00001000,
  496. DEVICEREINITIALIZE = 0x00002000,
  497. OUTPUTUNDERRUN = 0x00004000,
  498. RECORDPOSITIONCHANGED = 0x00008000,
  499. ALL = 0xFFFFFFFF,
  500. }
  501. /*
  502. FMOD Callbacks
  503. */
  504. public delegate RESULT DEBUG_CALLBACK (DEBUG_FLAGS flags, IntPtr file, int line, IntPtr func, IntPtr message);
  505. public delegate RESULT SYSTEM_CALLBACK (IntPtr system, SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata);
  506. public delegate RESULT CHANNELCONTROL_CALLBACK (IntPtr channelcontrol, CHANNELCONTROL_TYPE controltype, CHANNELCONTROL_CALLBACK_TYPE callbacktype, IntPtr commanddata1, IntPtr commanddata2);
  507. public delegate RESULT DSP_CALLBACK (IntPtr dsp, DSP_CALLBACK_TYPE type, IntPtr data);
  508. public delegate RESULT SOUND_NONBLOCK_CALLBACK (IntPtr sound, RESULT result);
  509. public delegate RESULT SOUND_PCMREAD_CALLBACK (IntPtr sound, IntPtr data, uint datalen);
  510. public delegate RESULT SOUND_PCMSETPOS_CALLBACK (IntPtr sound, int subsound, uint position, TIMEUNIT postype);
  511. public delegate RESULT FILE_OPEN_CALLBACK (IntPtr name, ref uint filesize, ref IntPtr handle, IntPtr userdata);
  512. public delegate RESULT FILE_CLOSE_CALLBACK (IntPtr handle, IntPtr userdata);
  513. public delegate RESULT FILE_READ_CALLBACK (IntPtr handle, IntPtr buffer, uint sizebytes, ref uint bytesread, IntPtr userdata);
  514. public delegate RESULT FILE_SEEK_CALLBACK (IntPtr handle, uint pos, IntPtr userdata);
  515. public delegate RESULT FILE_ASYNCREAD_CALLBACK (IntPtr info, IntPtr userdata);
  516. public delegate RESULT FILE_ASYNCCANCEL_CALLBACK(IntPtr info, IntPtr userdata);
  517. public delegate void FILE_ASYNCDONE_FUNC (IntPtr info, RESULT result);
  518. public delegate IntPtr MEMORY_ALLOC_CALLBACK (uint size, MEMORY_TYPE type, IntPtr sourcestr);
  519. public delegate IntPtr MEMORY_REALLOC_CALLBACK (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
  520. public delegate void MEMORY_FREE_CALLBACK (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
  521. public delegate float CB_3D_ROLLOFF_CALLBACK (IntPtr channelcontrol, float distance);
  522. public enum DSP_RESAMPLER : int
  523. {
  524. DEFAULT,
  525. NOINTERP,
  526. LINEAR,
  527. CUBIC,
  528. SPLINE,
  529. MAX,
  530. }
  531. public enum DSP_CALLBACK_TYPE : int
  532. {
  533. DATAPARAMETERRELEASE,
  534. MAX,
  535. }
  536. public enum DSPCONNECTION_TYPE : int
  537. {
  538. STANDARD,
  539. SIDECHAIN,
  540. SEND,
  541. SEND_SIDECHAIN,
  542. MAX,
  543. }
  544. public enum TAGTYPE : int
  545. {
  546. UNKNOWN = 0,
  547. ID3V1,
  548. ID3V2,
  549. VORBISCOMMENT,
  550. SHOUTCAST,
  551. ICECAST,
  552. ASF,
  553. MIDI,
  554. PLAYLIST,
  555. FMOD,
  556. USER,
  557. MAX
  558. }
  559. public enum TAGDATATYPE : int
  560. {
  561. BINARY = 0,
  562. INT,
  563. FLOAT,
  564. STRING,
  565. STRING_UTF16,
  566. STRING_UTF16BE,
  567. STRING_UTF8,
  568. MAX
  569. }
  570. [StructLayout(LayoutKind.Sequential)]
  571. public struct TAG
  572. {
  573. public TAGTYPE type;
  574. public TAGDATATYPE datatype;
  575. public StringWrapper name;
  576. public IntPtr data;
  577. public uint datalen;
  578. public bool updated;
  579. }
  580. [Flags]
  581. public enum TIMEUNIT : uint
  582. {
  583. MS = 0x00000001,
  584. PCM = 0x00000002,
  585. PCMBYTES = 0x00000004,
  586. RAWBYTES = 0x00000008,
  587. PCMFRACTION = 0x00000010,
  588. MODORDER = 0x00000100,
  589. MODROW = 0x00000200,
  590. MODPATTERN = 0x00000400,
  591. }
  592. public struct PORT_INDEX
  593. {
  594. public const ulong NONE = 0xFFFFFFFFFFFFFFFF;
  595. }
  596. [StructLayout(LayoutKind.Sequential)]
  597. public struct CREATESOUNDEXINFO
  598. {
  599. public int cbsize;
  600. public uint length;
  601. public uint fileoffset;
  602. public int numchannels;
  603. public int defaultfrequency;
  604. public SOUND_FORMAT format;
  605. public uint decodebuffersize;
  606. public int initialsubsound;
  607. public int numsubsounds;
  608. public IntPtr inclusionlist;
  609. public int inclusionlistnum;
  610. public IntPtr pcmreadcallback_internal;
  611. public IntPtr pcmsetposcallback_internal;
  612. public IntPtr nonblockcallback_internal;
  613. public IntPtr dlsname;
  614. public IntPtr encryptionkey;
  615. public int maxpolyphony;
  616. public IntPtr userdata;
  617. public SOUND_TYPE suggestedsoundtype;
  618. public IntPtr fileuseropen_internal;
  619. public IntPtr fileuserclose_internal;
  620. public IntPtr fileuserread_internal;
  621. public IntPtr fileuserseek_internal;
  622. public IntPtr fileuserasyncread_internal;
  623. public IntPtr fileuserasynccancel_internal;
  624. public IntPtr fileuserdata;
  625. public int filebuffersize;
  626. public CHANNELORDER channelorder;
  627. public IntPtr initialsoundgroup;
  628. public uint initialseekposition;
  629. public TIMEUNIT initialseekpostype;
  630. public int ignoresetfilesystem;
  631. public uint audioqueuepolicy;
  632. public uint minmidigranularity;
  633. public int nonblockthreadid;
  634. public IntPtr fsbguid;
  635. public SOUND_PCMREAD_CALLBACK pcmreadcallback
  636. {
  637. set { pcmreadcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  638. get { return pcmreadcallback_internal == IntPtr.Zero ? null : (SOUND_PCMREAD_CALLBACK)Marshal.GetDelegateForFunctionPointer(pcmreadcallback_internal, typeof(SOUND_PCMREAD_CALLBACK)); }
  639. }
  640. public SOUND_PCMSETPOS_CALLBACK pcmsetposcallback
  641. {
  642. set { pcmsetposcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  643. get { return pcmsetposcallback_internal == IntPtr.Zero ? null : (SOUND_PCMSETPOS_CALLBACK)Marshal.GetDelegateForFunctionPointer(pcmsetposcallback_internal, typeof(SOUND_PCMSETPOS_CALLBACK)); }
  644. }
  645. public SOUND_NONBLOCK_CALLBACK nonblockcallback
  646. {
  647. set { nonblockcallback_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  648. get { return nonblockcallback_internal == IntPtr.Zero ? null : (SOUND_NONBLOCK_CALLBACK)Marshal.GetDelegateForFunctionPointer(nonblockcallback_internal, typeof(SOUND_NONBLOCK_CALLBACK)); }
  649. }
  650. public FILE_OPEN_CALLBACK fileuseropen
  651. {
  652. set { fileuseropen_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  653. get { return fileuseropen_internal == IntPtr.Zero ? null : (FILE_OPEN_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuseropen_internal, typeof(FILE_OPEN_CALLBACK)); }
  654. }
  655. public FILE_CLOSE_CALLBACK fileuserclose
  656. {
  657. set { fileuserclose_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  658. get { return fileuserclose_internal == IntPtr.Zero ? null : (FILE_CLOSE_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserclose_internal, typeof(FILE_CLOSE_CALLBACK)); }
  659. }
  660. public FILE_READ_CALLBACK fileuserread
  661. {
  662. set { fileuserread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  663. get { return fileuserread_internal == IntPtr.Zero ? null : (FILE_READ_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserread_internal, typeof(FILE_READ_CALLBACK)); }
  664. }
  665. public FILE_SEEK_CALLBACK fileuserseek
  666. {
  667. set { fileuserseek_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  668. get { return fileuserseek_internal == IntPtr.Zero ? null : (FILE_SEEK_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserseek_internal, typeof(FILE_SEEK_CALLBACK)); }
  669. }
  670. public FILE_ASYNCREAD_CALLBACK fileuserasyncread
  671. {
  672. set { fileuserasyncread_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  673. get { return fileuserasyncread_internal == IntPtr.Zero ? null : (FILE_ASYNCREAD_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserasyncread_internal, typeof(FILE_ASYNCREAD_CALLBACK)); }
  674. }
  675. public FILE_ASYNCCANCEL_CALLBACK fileuserasynccancel
  676. {
  677. set { fileuserasynccancel_internal = (value == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(value)); }
  678. get { return fileuserasynccancel_internal == IntPtr.Zero ? null : (FILE_ASYNCCANCEL_CALLBACK)Marshal.GetDelegateForFunctionPointer(fileuserasynccancel_internal, typeof(FILE_ASYNCCANCEL_CALLBACK)); }
  679. }
  680. }
  681. #pragma warning disable 414
  682. [StructLayout(LayoutKind.Sequential)]
  683. public struct REVERB_PROPERTIES
  684. {
  685. public float DecayTime;
  686. public float EarlyDelay;
  687. public float LateDelay;
  688. public float HFReference;
  689. public float HFDecayRatio;
  690. public float Diffusion;
  691. public float Density;
  692. public float LowShelfFrequency;
  693. public float LowShelfGain;
  694. public float HighCut;
  695. public float EarlyLateMix;
  696. public float WetLevel;
  697. #region wrapperinternal
  698. public REVERB_PROPERTIES(float decayTime, float earlyDelay, float lateDelay, float hfReference,
  699. float hfDecayRatio, float diffusion, float density, float lowShelfFrequency, float lowShelfGain,
  700. float highCut, float earlyLateMix, float wetLevel)
  701. {
  702. DecayTime = decayTime;
  703. EarlyDelay = earlyDelay;
  704. LateDelay = lateDelay;
  705. HFReference = hfReference;
  706. HFDecayRatio = hfDecayRatio;
  707. Diffusion = diffusion;
  708. Density = density;
  709. LowShelfFrequency = lowShelfFrequency;
  710. LowShelfGain = lowShelfGain;
  711. HighCut = highCut;
  712. EarlyLateMix = earlyLateMix;
  713. WetLevel = wetLevel;
  714. }
  715. #endregion
  716. }
  717. #pragma warning restore 414
  718. public class PRESET
  719. {
  720. public static REVERB_PROPERTIES OFF() { return new REVERB_PROPERTIES( 1000, 7, 11, 5000, 100, 100, 100, 250, 0, 20, 96, -80.0f );}
  721. public static REVERB_PROPERTIES GENERIC() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 83, 100, 100, 250, 0, 14500, 96, -8.0f );}
  722. public static REVERB_PROPERTIES PADDEDCELL() { return new REVERB_PROPERTIES( 170, 1, 2, 5000, 10, 100, 100, 250, 0, 160, 84, -7.8f );}
  723. public static REVERB_PROPERTIES ROOM() { return new REVERB_PROPERTIES( 400, 2, 3, 5000, 83, 100, 100, 250, 0, 6050, 88, -9.4f );}
  724. public static REVERB_PROPERTIES BATHROOM() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 54, 100, 60, 250, 0, 2900, 83, 0.5f );}
  725. public static REVERB_PROPERTIES LIVINGROOM() { return new REVERB_PROPERTIES( 500, 3, 4, 5000, 10, 100, 100, 250, 0, 160, 58, -19.0f );}
  726. public static REVERB_PROPERTIES STONEROOM() { return new REVERB_PROPERTIES( 2300, 12, 17, 5000, 64, 100, 100, 250, 0, 7800, 71, -8.5f );}
  727. public static REVERB_PROPERTIES AUDITORIUM() { return new REVERB_PROPERTIES( 4300, 20, 30, 5000, 59, 100, 100, 250, 0, 5850, 64, -11.7f );}
  728. public static REVERB_PROPERTIES CONCERTHALL() { return new REVERB_PROPERTIES( 3900, 20, 29, 5000, 70, 100, 100, 250, 0, 5650, 80, -9.8f );}
  729. public static REVERB_PROPERTIES CAVE() { return new REVERB_PROPERTIES( 2900, 15, 22, 5000, 100, 100, 100, 250, 0, 20000, 59, -11.3f );}
  730. public static REVERB_PROPERTIES ARENA() { return new REVERB_PROPERTIES( 7200, 20, 30, 5000, 33, 100, 100, 250, 0, 4500, 80, -9.6f );}
  731. public static REVERB_PROPERTIES HANGAR() { return new REVERB_PROPERTIES( 10000, 20, 30, 5000, 23, 100, 100, 250, 0, 3400, 72, -7.4f );}
  732. public static REVERB_PROPERTIES CARPETTEDHALLWAY() { return new REVERB_PROPERTIES( 300, 2, 30, 5000, 10, 100, 100, 250, 0, 500, 56, -24.0f );}
  733. public static REVERB_PROPERTIES HALLWAY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 59, 100, 100, 250, 0, 7800, 87, -5.5f );}
  734. public static REVERB_PROPERTIES STONECORRIDOR() { return new REVERB_PROPERTIES( 270, 13, 20, 5000, 79, 100, 100, 250, 0, 9000, 86, -6.0f );}
  735. public static REVERB_PROPERTIES ALLEY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 86, 100, 100, 250, 0, 8300, 80, -9.8f );}
  736. public static REVERB_PROPERTIES FOREST() { return new REVERB_PROPERTIES( 1500, 162, 88, 5000, 54, 79, 100, 250, 0, 760, 94, -12.3f );}
  737. public static REVERB_PROPERTIES CITY() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 67, 50, 100, 250, 0, 4050, 66, -26.0f );}
  738. public static REVERB_PROPERTIES MOUNTAINS() { return new REVERB_PROPERTIES( 1500, 300, 100, 5000, 21, 27, 100, 250, 0, 1220, 82, -24.0f );}
  739. public static REVERB_PROPERTIES QUARRY() { return new REVERB_PROPERTIES( 1500, 61, 25, 5000, 83, 100, 100, 250, 0, 3400, 100, -5.0f );}
  740. public static REVERB_PROPERTIES PLAIN() { return new REVERB_PROPERTIES( 1500, 179, 100, 5000, 50, 21, 100, 250, 0, 1670, 65, -28.0f );}
  741. public static REVERB_PROPERTIES PARKINGLOT() { return new REVERB_PROPERTIES( 1700, 8, 12, 5000, 100, 100, 100, 250, 0, 20000, 56, -19.5f );}
  742. public static REVERB_PROPERTIES SEWERPIPE() { return new REVERB_PROPERTIES( 2800, 14, 21, 5000, 14, 80, 60, 250, 0, 3400, 66, 1.2f );}
  743. public static REVERB_PROPERTIES UNDERWATER() { return new REVERB_PROPERTIES( 1500, 7, 11, 5000, 10, 100, 100, 250, 0, 500, 92, 7.0f );}
  744. }
  745. [StructLayout(LayoutKind.Sequential)]
  746. public struct ADVANCEDSETTINGS
  747. {
  748. public int cbSize;
  749. public int maxMPEGCodecs;
  750. public int maxADPCMCodecs;
  751. public int maxXMACodecs;
  752. public int maxVorbisCodecs;
  753. public int maxAT9Codecs;
  754. public int maxFADPCMCodecs;
  755. public int maxOpusCodecs;
  756. public int ASIONumChannels;
  757. public IntPtr ASIOChannelList;
  758. public IntPtr ASIOSpeakerList;
  759. public float vol0virtualvol;
  760. public uint defaultDecodeBufferSize;
  761. public ushort profilePort;
  762. public uint geometryMaxFadeTime;
  763. public float distanceFilterCenterFreq;
  764. public int reverb3Dinstance;
  765. public int DSPBufferPoolSize;
  766. public DSP_RESAMPLER resamplerMethod;
  767. public uint randomSeed;
  768. public int maxConvolutionThreads;
  769. public int maxSpatialObjects;
  770. }
  771. [Flags]
  772. public enum DRIVER_STATE : uint
  773. {
  774. CONNECTED = 0x00000001,
  775. DEFAULT = 0x00000002,
  776. }
  777. public enum THREAD_PRIORITY : int
  778. {
  779. /* Platform specific priority range */
  780. PLATFORM_MIN = -32 * 1024,
  781. PLATFORM_MAX = 32 * 1024,
  782. /* Platform agnostic priorities, maps internally to platform specific value */
  783. DEFAULT = PLATFORM_MIN - 1,
  784. LOW = PLATFORM_MIN - 2,
  785. MEDIUM = PLATFORM_MIN - 3,
  786. HIGH = PLATFORM_MIN - 4,
  787. VERY_HIGH = PLATFORM_MIN - 5,
  788. EXTREME = PLATFORM_MIN - 6,
  789. CRITICAL = PLATFORM_MIN - 7,
  790. /* Thread defaults */
  791. MIXER = EXTREME,
  792. FEEDER = CRITICAL,
  793. STREAM = VERY_HIGH,
  794. FILE = HIGH,
  795. NONBLOCKING = HIGH,
  796. RECORD = HIGH,
  797. GEOMETRY = LOW,
  798. PROFILER = MEDIUM,
  799. STUDIO_UPDATE = MEDIUM,
  800. STUDIO_LOAD_BANK = MEDIUM,
  801. STUDIO_LOAD_SAMPLE = MEDIUM,
  802. CONVOLUTION1 = VERY_HIGH,
  803. CONVOLUTION2 = VERY_HIGH
  804. }
  805. public enum THREAD_STACK_SIZE : uint
  806. {
  807. DEFAULT = 0,
  808. MIXER = 80 * 1024,
  809. FEEDER = 16 * 1024,
  810. STREAM = 96 * 1024,
  811. FILE = 64 * 1024,
  812. NONBLOCKING = 112 * 1024,
  813. RECORD = 16 * 1024,
  814. GEOMETRY = 48 * 1024,
  815. PROFILER = 128 * 1024,
  816. STUDIO_UPDATE = 96 * 1024,
  817. STUDIO_LOAD_BANK = 96 * 1024,
  818. STUDIO_LOAD_SAMPLE = 96 * 1024,
  819. CONVOLUTION1 = 16 * 1024,
  820. CONVOLUTION2 = 16 * 1024
  821. }
  822. [Flags]
  823. public enum THREAD_AFFINITY : long
  824. {
  825. /* Platform agnostic thread groupings */
  826. GROUP_DEFAULT = 0x4000000000000000,
  827. GROUP_A = 0x4000000000000001,
  828. GROUP_B = 0x4000000000000002,
  829. GROUP_C = 0x4000000000000003,
  830. /* Thread defaults */
  831. MIXER = GROUP_A,
  832. FEEDER = GROUP_C,
  833. STREAM = GROUP_C,
  834. FILE = GROUP_C,
  835. NONBLOCKING = GROUP_C,
  836. RECORD = GROUP_C,
  837. GEOMETRY = GROUP_C,
  838. PROFILER = GROUP_C,
  839. STUDIO_UPDATE = GROUP_B,
  840. STUDIO_LOAD_BANK = GROUP_C,
  841. STUDIO_LOAD_SAMPLE = GROUP_C,
  842. CONVOLUTION1 = GROUP_C,
  843. CONVOLUTION2 = GROUP_C,
  844. /* Core mask, valid up to 1 << 61 */
  845. CORE_ALL = 0,
  846. CORE_0 = 1 << 0,
  847. CORE_1 = 1 << 1,
  848. CORE_2 = 1 << 2,
  849. CORE_3 = 1 << 3,
  850. CORE_4 = 1 << 4,
  851. CORE_5 = 1 << 5,
  852. CORE_6 = 1 << 6,
  853. CORE_7 = 1 << 7,
  854. CORE_8 = 1 << 8,
  855. CORE_9 = 1 << 9,
  856. CORE_10 = 1 << 10,
  857. CORE_11 = 1 << 11,
  858. CORE_12 = 1 << 12,
  859. CORE_13 = 1 << 13,
  860. CORE_14 = 1 << 14,
  861. CORE_15 = 1 << 15
  862. }
  863. public enum THREAD_TYPE : int
  864. {
  865. MIXER,
  866. FEEDER,
  867. STREAM,
  868. FILE,
  869. NONBLOCKING,
  870. RECORD,
  871. GEOMETRY,
  872. PROFILER,
  873. STUDIO_UPDATE,
  874. STUDIO_LOAD_BANK,
  875. STUDIO_LOAD_SAMPLE,
  876. CONVOLUTION1,
  877. CONVOLUTION2,
  878. MAX
  879. }
  880. /*
  881. FMOD System factory functions. Use this to create an FMOD System Instance. below you will see System init/close to get started.
  882. */
  883. public struct Factory
  884. {
  885. public static RESULT System_Create(out System system)
  886. {
  887. return FMOD5_System_Create(out system.handle, VERSION.number);
  888. }
  889. #region importfunctions
  890. [DllImport(VERSION.dll)]
  891. private static extern RESULT FMOD5_System_Create(out IntPtr system, uint headerversion);
  892. #endregion
  893. }
  894. /*
  895. FMOD global system functions (optional).
  896. */
  897. public struct Memory
  898. {
  899. public static RESULT Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags = MEMORY_TYPE.ALL)
  900. {
  901. return FMOD5_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags);
  902. }
  903. public static RESULT GetStats(out int currentalloced, out int maxalloced, bool blocking = true)
  904. {
  905. return FMOD5_Memory_GetStats(out currentalloced, out maxalloced, blocking);
  906. }
  907. #region importfunctions
  908. [DllImport(VERSION.dll)]
  909. private static extern RESULT FMOD5_Memory_Initialize(IntPtr poolmem, int poollen, MEMORY_ALLOC_CALLBACK useralloc, MEMORY_REALLOC_CALLBACK userrealloc, MEMORY_FREE_CALLBACK userfree, MEMORY_TYPE memtypeflags);
  910. [DllImport(VERSION.dll)]
  911. private static extern RESULT FMOD5_Memory_GetStats (out int currentalloced, out int maxalloced, bool blocking);
  912. #endregion
  913. }
  914. public struct Debug
  915. {
  916. public static RESULT Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode = DEBUG_MODE.TTY, DEBUG_CALLBACK callback = null, string filename = null)
  917. {
  918. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  919. {
  920. return FMOD5_Debug_Initialize(flags, mode, callback, encoder.byteFromStringUTF8(filename));
  921. }
  922. }
  923. #region importfunctions
  924. [DllImport(VERSION.dll)]
  925. private static extern RESULT FMOD5_Debug_Initialize(DEBUG_FLAGS flags, DEBUG_MODE mode, DEBUG_CALLBACK callback, byte[] filename);
  926. #endregion
  927. }
  928. public struct Thread
  929. {
  930. public static RESULT SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity = THREAD_AFFINITY.GROUP_DEFAULT, THREAD_PRIORITY priority = THREAD_PRIORITY.DEFAULT, THREAD_STACK_SIZE stacksize = THREAD_STACK_SIZE.DEFAULT)
  931. {
  932. return FMOD5_Thread_SetAttributes(type, affinity, priority, stacksize);
  933. }
  934. #region importfunctions
  935. [DllImport(VERSION.dll)]
  936. private static extern RESULT FMOD5_Thread_SetAttributes(THREAD_TYPE type, THREAD_AFFINITY affinity, THREAD_PRIORITY priority, THREAD_STACK_SIZE stacksize);
  937. #endregion
  938. }
  939. /*
  940. 'System' API.
  941. */
  942. public struct System
  943. {
  944. public RESULT release()
  945. {
  946. return FMOD5_System_Release(this.handle);
  947. }
  948. // Setup functions.
  949. public RESULT setOutput(OUTPUTTYPE output)
  950. {
  951. return FMOD5_System_SetOutput(this.handle, output);
  952. }
  953. public RESULT getOutput(out OUTPUTTYPE output)
  954. {
  955. return FMOD5_System_GetOutput(this.handle, out output);
  956. }
  957. public RESULT getNumDrivers(out int numdrivers)
  958. {
  959. return FMOD5_System_GetNumDrivers(this.handle, out numdrivers);
  960. }
  961. public RESULT getDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels)
  962. {
  963. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  964. RESULT result = FMOD5_System_GetDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels);
  965. using (StringHelper.ThreadSafeEncoding encoding = StringHelper.GetFreeHelper())
  966. {
  967. name = encoding.stringFromNative(stringMem);
  968. }
  969. Marshal.FreeHGlobal(stringMem);
  970. return result;
  971. }
  972. public RESULT getDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels)
  973. {
  974. return FMOD5_System_GetDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels);
  975. }
  976. public RESULT setDriver(int driver)
  977. {
  978. return FMOD5_System_SetDriver(this.handle, driver);
  979. }
  980. public RESULT getDriver(out int driver)
  981. {
  982. return FMOD5_System_GetDriver(this.handle, out driver);
  983. }
  984. public RESULT setSoftwareChannels(int numsoftwarechannels)
  985. {
  986. return FMOD5_System_SetSoftwareChannels(this.handle, numsoftwarechannels);
  987. }
  988. public RESULT getSoftwareChannels(out int numsoftwarechannels)
  989. {
  990. return FMOD5_System_GetSoftwareChannels(this.handle, out numsoftwarechannels);
  991. }
  992. public RESULT setSoftwareFormat(int samplerate, SPEAKERMODE speakermode, int numrawspeakers)
  993. {
  994. return FMOD5_System_SetSoftwareFormat(this.handle, samplerate, speakermode, numrawspeakers);
  995. }
  996. public RESULT getSoftwareFormat(out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers)
  997. {
  998. return FMOD5_System_GetSoftwareFormat(this.handle, out samplerate, out speakermode, out numrawspeakers);
  999. }
  1000. public RESULT setDSPBufferSize(uint bufferlength, int numbuffers)
  1001. {
  1002. return FMOD5_System_SetDSPBufferSize(this.handle, bufferlength, numbuffers);
  1003. }
  1004. public RESULT getDSPBufferSize(out uint bufferlength, out int numbuffers)
  1005. {
  1006. return FMOD5_System_GetDSPBufferSize(this.handle, out bufferlength, out numbuffers);
  1007. }
  1008. public RESULT setFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign)
  1009. {
  1010. return FMOD5_System_SetFileSystem(this.handle, useropen, userclose, userread, userseek, userasyncread, userasynccancel, blockalign);
  1011. }
  1012. public RESULT attachFileSystem(FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek)
  1013. {
  1014. return FMOD5_System_AttachFileSystem(this.handle, useropen, userclose, userread, userseek);
  1015. }
  1016. public RESULT setAdvancedSettings(ref ADVANCEDSETTINGS settings)
  1017. {
  1018. settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS));
  1019. return FMOD5_System_SetAdvancedSettings(this.handle, ref settings);
  1020. }
  1021. public RESULT getAdvancedSettings(ref ADVANCEDSETTINGS settings)
  1022. {
  1023. settings.cbSize = MarshalHelper.SizeOf(typeof(ADVANCEDSETTINGS));
  1024. return FMOD5_System_GetAdvancedSettings(this.handle, ref settings);
  1025. }
  1026. public RESULT setCallback(SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask = SYSTEM_CALLBACK_TYPE.ALL)
  1027. {
  1028. return FMOD5_System_SetCallback(this.handle, callback, callbackmask);
  1029. }
  1030. // Plug-in support.
  1031. public RESULT setPluginPath(string path)
  1032. {
  1033. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1034. {
  1035. return FMOD5_System_SetPluginPath(this.handle, encoder.byteFromStringUTF8(path));
  1036. }
  1037. }
  1038. public RESULT loadPlugin(string filename, out uint handle, uint priority = 0)
  1039. {
  1040. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1041. {
  1042. return FMOD5_System_LoadPlugin(this.handle, encoder.byteFromStringUTF8(filename), out handle, priority);
  1043. }
  1044. }
  1045. public RESULT unloadPlugin(uint handle)
  1046. {
  1047. return FMOD5_System_UnloadPlugin(this.handle, handle);
  1048. }
  1049. public RESULT getNumNestedPlugins(uint handle, out int count)
  1050. {
  1051. return FMOD5_System_GetNumNestedPlugins(this.handle, handle, out count);
  1052. }
  1053. public RESULT getNestedPlugin(uint handle, int index, out uint nestedhandle)
  1054. {
  1055. return FMOD5_System_GetNestedPlugin(this.handle, handle, index, out nestedhandle);
  1056. }
  1057. public RESULT getNumPlugins(PLUGINTYPE plugintype, out int numplugins)
  1058. {
  1059. return FMOD5_System_GetNumPlugins(this.handle, plugintype, out numplugins);
  1060. }
  1061. public RESULT getPluginHandle(PLUGINTYPE plugintype, int index, out uint handle)
  1062. {
  1063. return FMOD5_System_GetPluginHandle(this.handle, plugintype, index, out handle);
  1064. }
  1065. public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out string name, int namelen, out uint version)
  1066. {
  1067. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  1068. RESULT result = FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, stringMem, namelen, out version);
  1069. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1070. {
  1071. name = encoder.stringFromNative(stringMem);
  1072. }
  1073. Marshal.FreeHGlobal(stringMem);
  1074. return result;
  1075. }
  1076. public RESULT getPluginInfo(uint handle, out PLUGINTYPE plugintype, out uint version)
  1077. {
  1078. return FMOD5_System_GetPluginInfo(this.handle, handle, out plugintype, IntPtr.Zero, 0, out version);
  1079. }
  1080. public RESULT setOutputByPlugin(uint handle)
  1081. {
  1082. return FMOD5_System_SetOutputByPlugin(this.handle, handle);
  1083. }
  1084. public RESULT getOutputByPlugin(out uint handle)
  1085. {
  1086. return FMOD5_System_GetOutputByPlugin(this.handle, out handle);
  1087. }
  1088. public RESULT createDSPByPlugin(uint handle, out DSP dsp)
  1089. {
  1090. return FMOD5_System_CreateDSPByPlugin(this.handle, handle, out dsp.handle);
  1091. }
  1092. public RESULT getDSPInfoByPlugin(uint handle, out IntPtr description)
  1093. {
  1094. return FMOD5_System_GetDSPInfoByPlugin(this.handle, handle, out description);
  1095. }
  1096. public RESULT registerDSP(ref DSP_DESCRIPTION description, out uint handle)
  1097. {
  1098. return FMOD5_System_RegisterDSP(this.handle, ref description, out handle);
  1099. }
  1100. // Init/Close.
  1101. public RESULT init(int maxchannels, INITFLAGS flags, IntPtr extradriverdata)
  1102. {
  1103. return FMOD5_System_Init(this.handle, maxchannels, flags, extradriverdata);
  1104. }
  1105. public RESULT close()
  1106. {
  1107. return FMOD5_System_Close(this.handle);
  1108. }
  1109. // General post-init system functions.
  1110. public RESULT update()
  1111. {
  1112. return FMOD5_System_Update(this.handle);
  1113. }
  1114. public RESULT setSpeakerPosition(SPEAKER speaker, float x, float y, bool active)
  1115. {
  1116. return FMOD5_System_SetSpeakerPosition(this.handle, speaker, x, y, active);
  1117. }
  1118. public RESULT getSpeakerPosition(SPEAKER speaker, out float x, out float y, out bool active)
  1119. {
  1120. return FMOD5_System_GetSpeakerPosition(this.handle, speaker, out x, out y, out active);
  1121. }
  1122. public RESULT setStreamBufferSize(uint filebuffersize, TIMEUNIT filebuffersizetype)
  1123. {
  1124. return FMOD5_System_SetStreamBufferSize(this.handle, filebuffersize, filebuffersizetype);
  1125. }
  1126. public RESULT getStreamBufferSize(out uint filebuffersize, out TIMEUNIT filebuffersizetype)
  1127. {
  1128. return FMOD5_System_GetStreamBufferSize(this.handle, out filebuffersize, out filebuffersizetype);
  1129. }
  1130. public RESULT set3DSettings(float dopplerscale, float distancefactor, float rolloffscale)
  1131. {
  1132. return FMOD5_System_Set3DSettings(this.handle, dopplerscale, distancefactor, rolloffscale);
  1133. }
  1134. public RESULT get3DSettings(out float dopplerscale, out float distancefactor, out float rolloffscale)
  1135. {
  1136. return FMOD5_System_Get3DSettings(this.handle, out dopplerscale, out distancefactor, out rolloffscale);
  1137. }
  1138. public RESULT set3DNumListeners(int numlisteners)
  1139. {
  1140. return FMOD5_System_Set3DNumListeners(this.handle, numlisteners);
  1141. }
  1142. public RESULT get3DNumListeners(out int numlisteners)
  1143. {
  1144. return FMOD5_System_Get3DNumListeners(this.handle, out numlisteners);
  1145. }
  1146. public RESULT set3DListenerAttributes(int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up)
  1147. {
  1148. return FMOD5_System_Set3DListenerAttributes(this.handle, listener, ref pos, ref vel, ref forward, ref up);
  1149. }
  1150. public RESULT get3DListenerAttributes(int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up)
  1151. {
  1152. return FMOD5_System_Get3DListenerAttributes(this.handle, listener, out pos, out vel, out forward, out up);
  1153. }
  1154. public RESULT set3DRolloffCallback(CB_3D_ROLLOFF_CALLBACK callback)
  1155. {
  1156. return FMOD5_System_Set3DRolloffCallback(this.handle, callback);
  1157. }
  1158. public RESULT mixerSuspend()
  1159. {
  1160. return FMOD5_System_MixerSuspend(this.handle);
  1161. }
  1162. public RESULT mixerResume()
  1163. {
  1164. return FMOD5_System_MixerResume(this.handle);
  1165. }
  1166. public RESULT getDefaultMixMatrix(SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop)
  1167. {
  1168. return FMOD5_System_GetDefaultMixMatrix(this.handle, sourcespeakermode, targetspeakermode, matrix, matrixhop);
  1169. }
  1170. public RESULT getSpeakerModeChannels(SPEAKERMODE mode, out int channels)
  1171. {
  1172. return FMOD5_System_GetSpeakerModeChannels(this.handle, mode, out channels);
  1173. }
  1174. // System information functions.
  1175. public RESULT getVersion(out uint version)
  1176. {
  1177. uint buildnumber;
  1178. return getVersion(out version, out buildnumber);
  1179. }
  1180. public RESULT getVersion(out uint version, out uint buildnumber)
  1181. {
  1182. return FMOD5_System_GetVersion(this.handle, out version, out buildnumber);
  1183. }
  1184. public RESULT getOutputHandle(out IntPtr handle)
  1185. {
  1186. return FMOD5_System_GetOutputHandle(this.handle, out handle);
  1187. }
  1188. public RESULT getChannelsPlaying(out int channels)
  1189. {
  1190. return FMOD5_System_GetChannelsPlaying(this.handle, out channels, IntPtr.Zero);
  1191. }
  1192. public RESULT getChannelsPlaying(out int channels, out int realchannels)
  1193. {
  1194. return FMOD5_System_GetChannelsPlaying(this.handle, out channels, out realchannels);
  1195. }
  1196. public RESULT getCPUUsage(out CPU_USAGE usage)
  1197. {
  1198. return FMOD5_System_GetCPUUsage(this.handle, out usage);
  1199. }
  1200. public RESULT getFileUsage(out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead)
  1201. {
  1202. return FMOD5_System_GetFileUsage(this.handle, out sampleBytesRead, out streamBytesRead, out otherBytesRead);
  1203. }
  1204. // Sound/DSP/Channel/FX creation and retrieval.
  1205. public RESULT createSound(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
  1206. {
  1207. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1208. {
  1209. return FMOD5_System_CreateSound(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle);
  1210. }
  1211. }
  1212. public RESULT createSound(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
  1213. {
  1214. return FMOD5_System_CreateSound(this.handle, data, mode, ref exinfo, out sound.handle);
  1215. }
  1216. public RESULT createSound(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
  1217. {
  1218. return FMOD5_System_CreateSound(this.handle, name_or_data, mode, ref exinfo, out sound.handle);
  1219. }
  1220. public RESULT createSound(string name, MODE mode, out Sound sound)
  1221. {
  1222. CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
  1223. exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO));
  1224. return createSound(name, mode, ref exinfo, out sound);
  1225. }
  1226. public RESULT createStream(string name, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
  1227. {
  1228. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1229. {
  1230. return FMOD5_System_CreateStream(this.handle, encoder.byteFromStringUTF8(name), mode, ref exinfo, out sound.handle);
  1231. }
  1232. }
  1233. public RESULT createStream(byte[] data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
  1234. {
  1235. return FMOD5_System_CreateStream(this.handle, data, mode, ref exinfo, out sound.handle);
  1236. }
  1237. public RESULT createStream(IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out Sound sound)
  1238. {
  1239. return FMOD5_System_CreateStream(this.handle, name_or_data, mode, ref exinfo, out sound.handle);
  1240. }
  1241. public RESULT createStream(string name, MODE mode, out Sound sound)
  1242. {
  1243. CREATESOUNDEXINFO exinfo = new CREATESOUNDEXINFO();
  1244. exinfo.cbsize = MarshalHelper.SizeOf(typeof(CREATESOUNDEXINFO));
  1245. return createStream(name, mode, ref exinfo, out sound);
  1246. }
  1247. public RESULT createDSP(ref DSP_DESCRIPTION description, out DSP dsp)
  1248. {
  1249. return FMOD5_System_CreateDSP(this.handle, ref description, out dsp.handle);
  1250. }
  1251. public RESULT createDSPByType(DSP_TYPE type, out DSP dsp)
  1252. {
  1253. return FMOD5_System_CreateDSPByType(this.handle, type, out dsp.handle);
  1254. }
  1255. public RESULT createChannelGroup(string name, out ChannelGroup channelgroup)
  1256. {
  1257. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1258. {
  1259. return FMOD5_System_CreateChannelGroup(this.handle, encoder.byteFromStringUTF8(name), out channelgroup.handle);
  1260. }
  1261. }
  1262. public RESULT createSoundGroup(string name, out SoundGroup soundgroup)
  1263. {
  1264. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1265. {
  1266. return FMOD5_System_CreateSoundGroup(this.handle, encoder.byteFromStringUTF8(name), out soundgroup.handle);
  1267. }
  1268. }
  1269. public RESULT createReverb3D(out Reverb3D reverb)
  1270. {
  1271. return FMOD5_System_CreateReverb3D(this.handle, out reverb.handle);
  1272. }
  1273. public RESULT playSound(Sound sound, ChannelGroup channelgroup, bool paused, out Channel channel)
  1274. {
  1275. return FMOD5_System_PlaySound(this.handle, sound.handle, channelgroup.handle, paused, out channel.handle);
  1276. }
  1277. public RESULT playDSP(DSP dsp, ChannelGroup channelgroup, bool paused, out Channel channel)
  1278. {
  1279. return FMOD5_System_PlayDSP(this.handle, dsp.handle, channelgroup.handle, paused, out channel.handle);
  1280. }
  1281. public RESULT getChannel(int channelid, out Channel channel)
  1282. {
  1283. return FMOD5_System_GetChannel(this.handle, channelid, out channel.handle);
  1284. }
  1285. public RESULT getDSPInfoByType(DSP_TYPE type, out IntPtr description)
  1286. {
  1287. return FMOD5_System_GetDSPInfoByType(this.handle, type, out description);
  1288. }
  1289. public RESULT getMasterChannelGroup(out ChannelGroup channelgroup)
  1290. {
  1291. return FMOD5_System_GetMasterChannelGroup(this.handle, out channelgroup.handle);
  1292. }
  1293. public RESULT getMasterSoundGroup(out SoundGroup soundgroup)
  1294. {
  1295. return FMOD5_System_GetMasterSoundGroup(this.handle, out soundgroup.handle);
  1296. }
  1297. // Routing to ports.
  1298. public RESULT attachChannelGroupToPort(PORT_TYPE portType, ulong portIndex, ChannelGroup channelgroup, bool passThru = false)
  1299. {
  1300. return FMOD5_System_AttachChannelGroupToPort(this.handle, portType, portIndex, channelgroup.handle, passThru);
  1301. }
  1302. public RESULT detachChannelGroupFromPort(ChannelGroup channelgroup)
  1303. {
  1304. return FMOD5_System_DetachChannelGroupFromPort(this.handle, channelgroup.handle);
  1305. }
  1306. // Reverb api.
  1307. public RESULT setReverbProperties(int instance, ref REVERB_PROPERTIES prop)
  1308. {
  1309. return FMOD5_System_SetReverbProperties(this.handle, instance, ref prop);
  1310. }
  1311. public RESULT getReverbProperties(int instance, out REVERB_PROPERTIES prop)
  1312. {
  1313. return FMOD5_System_GetReverbProperties(this.handle, instance, out prop);
  1314. }
  1315. // System level DSP functionality.
  1316. public RESULT lockDSP()
  1317. {
  1318. return FMOD5_System_LockDSP(this.handle);
  1319. }
  1320. public RESULT unlockDSP()
  1321. {
  1322. return FMOD5_System_UnlockDSP(this.handle);
  1323. }
  1324. // Recording api
  1325. public RESULT getRecordNumDrivers(out int numdrivers, out int numconnected)
  1326. {
  1327. return FMOD5_System_GetRecordNumDrivers(this.handle, out numdrivers, out numconnected);
  1328. }
  1329. public RESULT getRecordDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state)
  1330. {
  1331. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  1332. RESULT result = FMOD5_System_GetRecordDriverInfo(this.handle, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state);
  1333. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1334. {
  1335. name = encoder.stringFromNative(stringMem);
  1336. }
  1337. Marshal.FreeHGlobal(stringMem);
  1338. return result;
  1339. }
  1340. public RESULT getRecordDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state)
  1341. {
  1342. return FMOD5_System_GetRecordDriverInfo(this.handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels, out state);
  1343. }
  1344. public RESULT getRecordPosition(int id, out uint position)
  1345. {
  1346. return FMOD5_System_GetRecordPosition(this.handle, id, out position);
  1347. }
  1348. public RESULT recordStart(int id, Sound sound, bool loop)
  1349. {
  1350. return FMOD5_System_RecordStart(this.handle, id, sound.handle, loop);
  1351. }
  1352. public RESULT recordStop(int id)
  1353. {
  1354. return FMOD5_System_RecordStop(this.handle, id);
  1355. }
  1356. public RESULT isRecording(int id, out bool recording)
  1357. {
  1358. return FMOD5_System_IsRecording(this.handle, id, out recording);
  1359. }
  1360. // Geometry api
  1361. public RESULT createGeometry(int maxpolygons, int maxvertices, out Geometry geometry)
  1362. {
  1363. return FMOD5_System_CreateGeometry(this.handle, maxpolygons, maxvertices, out geometry.handle);
  1364. }
  1365. public RESULT setGeometrySettings(float maxworldsize)
  1366. {
  1367. return FMOD5_System_SetGeometrySettings(this.handle, maxworldsize);
  1368. }
  1369. public RESULT getGeometrySettings(out float maxworldsize)
  1370. {
  1371. return FMOD5_System_GetGeometrySettings(this.handle, out maxworldsize);
  1372. }
  1373. public RESULT loadGeometry(IntPtr data, int datasize, out Geometry geometry)
  1374. {
  1375. return FMOD5_System_LoadGeometry(this.handle, data, datasize, out geometry.handle);
  1376. }
  1377. public RESULT getGeometryOcclusion(ref VECTOR listener, ref VECTOR source, out float direct, out float reverb)
  1378. {
  1379. return FMOD5_System_GetGeometryOcclusion(this.handle, ref listener, ref source, out direct, out reverb);
  1380. }
  1381. // Network functions
  1382. public RESULT setNetworkProxy(string proxy)
  1383. {
  1384. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1385. {
  1386. return FMOD5_System_SetNetworkProxy(this.handle, encoder.byteFromStringUTF8(proxy));
  1387. }
  1388. }
  1389. public RESULT getNetworkProxy(out string proxy, int proxylen)
  1390. {
  1391. IntPtr stringMem = Marshal.AllocHGlobal(proxylen);
  1392. RESULT result = FMOD5_System_GetNetworkProxy(this.handle, stringMem, proxylen);
  1393. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1394. {
  1395. proxy = encoder.stringFromNative(stringMem);
  1396. }
  1397. Marshal.FreeHGlobal(stringMem);
  1398. return result;
  1399. }
  1400. public RESULT setNetworkTimeout(int timeout)
  1401. {
  1402. return FMOD5_System_SetNetworkTimeout(this.handle, timeout);
  1403. }
  1404. public RESULT getNetworkTimeout(out int timeout)
  1405. {
  1406. return FMOD5_System_GetNetworkTimeout(this.handle, out timeout);
  1407. }
  1408. // Userdata set/get
  1409. public RESULT setUserData(IntPtr userdata)
  1410. {
  1411. return FMOD5_System_SetUserData(this.handle, userdata);
  1412. }
  1413. public RESULT getUserData(out IntPtr userdata)
  1414. {
  1415. return FMOD5_System_GetUserData(this.handle, out userdata);
  1416. }
  1417. #region importfunctions
  1418. [DllImport(VERSION.dll)]
  1419. private static extern RESULT FMOD5_System_Release (IntPtr system);
  1420. [DllImport(VERSION.dll)]
  1421. private static extern RESULT FMOD5_System_SetOutput (IntPtr system, OUTPUTTYPE output);
  1422. [DllImport(VERSION.dll)]
  1423. private static extern RESULT FMOD5_System_GetOutput (IntPtr system, out OUTPUTTYPE output);
  1424. [DllImport(VERSION.dll)]
  1425. private static extern RESULT FMOD5_System_GetNumDrivers (IntPtr system, out int numdrivers);
  1426. [DllImport(VERSION.dll)]
  1427. private static extern RESULT FMOD5_System_GetDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels);
  1428. [DllImport(VERSION.dll)]
  1429. private static extern RESULT FMOD5_System_SetDriver (IntPtr system, int driver);
  1430. [DllImport(VERSION.dll)]
  1431. private static extern RESULT FMOD5_System_GetDriver (IntPtr system, out int driver);
  1432. [DllImport(VERSION.dll)]
  1433. private static extern RESULT FMOD5_System_SetSoftwareChannels (IntPtr system, int numsoftwarechannels);
  1434. [DllImport(VERSION.dll)]
  1435. private static extern RESULT FMOD5_System_GetSoftwareChannels (IntPtr system, out int numsoftwarechannels);
  1436. [DllImport(VERSION.dll)]
  1437. private static extern RESULT FMOD5_System_SetSoftwareFormat (IntPtr system, int samplerate, SPEAKERMODE speakermode, int numrawspeakers);
  1438. [DllImport(VERSION.dll)]
  1439. private static extern RESULT FMOD5_System_GetSoftwareFormat (IntPtr system, out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers);
  1440. [DllImport(VERSION.dll)]
  1441. private static extern RESULT FMOD5_System_SetDSPBufferSize (IntPtr system, uint bufferlength, int numbuffers);
  1442. [DllImport(VERSION.dll)]
  1443. private static extern RESULT FMOD5_System_GetDSPBufferSize (IntPtr system, out uint bufferlength, out int numbuffers);
  1444. [DllImport(VERSION.dll)]
  1445. private static extern RESULT FMOD5_System_SetFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek, FILE_ASYNCREAD_CALLBACK userasyncread, FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign);
  1446. [DllImport(VERSION.dll)]
  1447. private static extern RESULT FMOD5_System_AttachFileSystem (IntPtr system, FILE_OPEN_CALLBACK useropen, FILE_CLOSE_CALLBACK userclose, FILE_READ_CALLBACK userread, FILE_SEEK_CALLBACK userseek);
  1448. [DllImport(VERSION.dll)]
  1449. private static extern RESULT FMOD5_System_SetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings);
  1450. [DllImport(VERSION.dll)]
  1451. private static extern RESULT FMOD5_System_GetAdvancedSettings (IntPtr system, ref ADVANCEDSETTINGS settings);
  1452. [DllImport(VERSION.dll)]
  1453. private static extern RESULT FMOD5_System_SetCallback (IntPtr system, SYSTEM_CALLBACK callback, SYSTEM_CALLBACK_TYPE callbackmask);
  1454. [DllImport(VERSION.dll)]
  1455. private static extern RESULT FMOD5_System_SetPluginPath (IntPtr system, byte[] path);
  1456. [DllImport(VERSION.dll)]
  1457. private static extern RESULT FMOD5_System_LoadPlugin (IntPtr system, byte[] filename, out uint handle, uint priority);
  1458. [DllImport(VERSION.dll)]
  1459. private static extern RESULT FMOD5_System_UnloadPlugin (IntPtr system, uint handle);
  1460. [DllImport(VERSION.dll)]
  1461. private static extern RESULT FMOD5_System_GetNumNestedPlugins (IntPtr system, uint handle, out int count);
  1462. [DllImport(VERSION.dll)]
  1463. private static extern RESULT FMOD5_System_GetNestedPlugin (IntPtr system, uint handle, int index, out uint nestedhandle);
  1464. [DllImport(VERSION.dll)]
  1465. private static extern RESULT FMOD5_System_GetNumPlugins (IntPtr system, PLUGINTYPE plugintype, out int numplugins);
  1466. [DllImport(VERSION.dll)]
  1467. private static extern RESULT FMOD5_System_GetPluginHandle (IntPtr system, PLUGINTYPE plugintype, int index, out uint handle);
  1468. [DllImport(VERSION.dll)]
  1469. private static extern RESULT FMOD5_System_GetPluginInfo (IntPtr system, uint handle, out PLUGINTYPE plugintype, IntPtr name, int namelen, out uint version);
  1470. [DllImport(VERSION.dll)]
  1471. private static extern RESULT FMOD5_System_SetOutputByPlugin (IntPtr system, uint handle);
  1472. [DllImport(VERSION.dll)]
  1473. private static extern RESULT FMOD5_System_GetOutputByPlugin (IntPtr system, out uint handle);
  1474. [DllImport(VERSION.dll)]
  1475. private static extern RESULT FMOD5_System_CreateDSPByPlugin (IntPtr system, uint handle, out IntPtr dsp);
  1476. [DllImport(VERSION.dll)]
  1477. private static extern RESULT FMOD5_System_GetDSPInfoByPlugin (IntPtr system, uint handle, out IntPtr description);
  1478. [DllImport(VERSION.dll)]
  1479. private static extern RESULT FMOD5_System_RegisterDSP (IntPtr system, ref DSP_DESCRIPTION description, out uint handle);
  1480. [DllImport(VERSION.dll)]
  1481. private static extern RESULT FMOD5_System_Init (IntPtr system, int maxchannels, INITFLAGS flags, IntPtr extradriverdata);
  1482. [DllImport(VERSION.dll)]
  1483. private static extern RESULT FMOD5_System_Close (IntPtr system);
  1484. [DllImport(VERSION.dll)]
  1485. private static extern RESULT FMOD5_System_Update (IntPtr system);
  1486. [DllImport(VERSION.dll)]
  1487. private static extern RESULT FMOD5_System_SetSpeakerPosition (IntPtr system, SPEAKER speaker, float x, float y, bool active);
  1488. [DllImport(VERSION.dll)]
  1489. private static extern RESULT FMOD5_System_GetSpeakerPosition (IntPtr system, SPEAKER speaker, out float x, out float y, out bool active);
  1490. [DllImport(VERSION.dll)]
  1491. private static extern RESULT FMOD5_System_SetStreamBufferSize (IntPtr system, uint filebuffersize, TIMEUNIT filebuffersizetype);
  1492. [DllImport(VERSION.dll)]
  1493. private static extern RESULT FMOD5_System_GetStreamBufferSize (IntPtr system, out uint filebuffersize, out TIMEUNIT filebuffersizetype);
  1494. [DllImport(VERSION.dll)]
  1495. private static extern RESULT FMOD5_System_Set3DSettings (IntPtr system, float dopplerscale, float distancefactor, float rolloffscale);
  1496. [DllImport(VERSION.dll)]
  1497. private static extern RESULT FMOD5_System_Get3DSettings (IntPtr system, out float dopplerscale, out float distancefactor, out float rolloffscale);
  1498. [DllImport(VERSION.dll)]
  1499. private static extern RESULT FMOD5_System_Set3DNumListeners (IntPtr system, int numlisteners);
  1500. [DllImport(VERSION.dll)]
  1501. private static extern RESULT FMOD5_System_Get3DNumListeners (IntPtr system, out int numlisteners);
  1502. [DllImport(VERSION.dll)]
  1503. private static extern RESULT FMOD5_System_Set3DListenerAttributes (IntPtr system, int listener, ref VECTOR pos, ref VECTOR vel, ref VECTOR forward, ref VECTOR up);
  1504. [DllImport(VERSION.dll)]
  1505. private static extern RESULT FMOD5_System_Get3DListenerAttributes (IntPtr system, int listener, out VECTOR pos, out VECTOR vel, out VECTOR forward, out VECTOR up);
  1506. [DllImport(VERSION.dll)]
  1507. private static extern RESULT FMOD5_System_Set3DRolloffCallback (IntPtr system, CB_3D_ROLLOFF_CALLBACK callback);
  1508. [DllImport(VERSION.dll)]
  1509. private static extern RESULT FMOD5_System_MixerSuspend (IntPtr system);
  1510. [DllImport(VERSION.dll)]
  1511. private static extern RESULT FMOD5_System_MixerResume (IntPtr system);
  1512. [DllImport(VERSION.dll)]
  1513. private static extern RESULT FMOD5_System_GetDefaultMixMatrix (IntPtr system, SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop);
  1514. [DllImport(VERSION.dll)]
  1515. private static extern RESULT FMOD5_System_GetSpeakerModeChannels (IntPtr system, SPEAKERMODE mode, out int channels);
  1516. [DllImport(VERSION.dll)]
  1517. private static extern RESULT FMOD5_System_GetVersion (IntPtr system, out uint version, out uint buildnumber);
  1518. [DllImport(VERSION.dll)]
  1519. private static extern RESULT FMOD5_System_GetOutputHandle (IntPtr system, out IntPtr handle);
  1520. [DllImport(VERSION.dll)]
  1521. private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, IntPtr zero);
  1522. [DllImport(VERSION.dll)]
  1523. private static extern RESULT FMOD5_System_GetChannelsPlaying (IntPtr system, out int channels, out int realchannels);
  1524. [DllImport(VERSION.dll)]
  1525. private static extern RESULT FMOD5_System_GetCPUUsage (IntPtr system, out CPU_USAGE usage);
  1526. [DllImport(VERSION.dll)]
  1527. private static extern RESULT FMOD5_System_GetFileUsage (IntPtr system, out Int64 sampleBytesRead, out Int64 streamBytesRead, out Int64 otherBytesRead);
  1528. [DllImport(VERSION.dll)]
  1529. private static extern RESULT FMOD5_System_CreateSound (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
  1530. [DllImport(VERSION.dll)]
  1531. private static extern RESULT FMOD5_System_CreateSound (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
  1532. [DllImport(VERSION.dll)]
  1533. private static extern RESULT FMOD5_System_CreateStream (IntPtr system, byte[] name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
  1534. [DllImport(VERSION.dll)]
  1535. private static extern RESULT FMOD5_System_CreateStream (IntPtr system, IntPtr name_or_data, MODE mode, ref CREATESOUNDEXINFO exinfo, out IntPtr sound);
  1536. [DllImport(VERSION.dll)]
  1537. private static extern RESULT FMOD5_System_CreateDSP (IntPtr system, ref DSP_DESCRIPTION description, out IntPtr dsp);
  1538. [DllImport(VERSION.dll)]
  1539. private static extern RESULT FMOD5_System_CreateDSPByType (IntPtr system, DSP_TYPE type, out IntPtr dsp);
  1540. [DllImport(VERSION.dll)]
  1541. private static extern RESULT FMOD5_System_CreateChannelGroup (IntPtr system, byte[] name, out IntPtr channelgroup);
  1542. [DllImport(VERSION.dll)]
  1543. private static extern RESULT FMOD5_System_CreateSoundGroup (IntPtr system, byte[] name, out IntPtr soundgroup);
  1544. [DllImport(VERSION.dll)]
  1545. private static extern RESULT FMOD5_System_CreateReverb3D (IntPtr system, out IntPtr reverb);
  1546. [DllImport(VERSION.dll)]
  1547. private static extern RESULT FMOD5_System_PlaySound (IntPtr system, IntPtr sound, IntPtr channelgroup, bool paused, out IntPtr channel);
  1548. [DllImport(VERSION.dll)]
  1549. private static extern RESULT FMOD5_System_PlayDSP (IntPtr system, IntPtr dsp, IntPtr channelgroup, bool paused, out IntPtr channel);
  1550. [DllImport(VERSION.dll)]
  1551. private static extern RESULT FMOD5_System_GetChannel (IntPtr system, int channelid, out IntPtr channel);
  1552. [DllImport(VERSION.dll)]
  1553. private static extern RESULT FMOD5_System_GetDSPInfoByType (IntPtr system, DSP_TYPE type, out IntPtr description);
  1554. [DllImport(VERSION.dll)]
  1555. private static extern RESULT FMOD5_System_GetMasterChannelGroup (IntPtr system, out IntPtr channelgroup);
  1556. [DllImport(VERSION.dll)]
  1557. private static extern RESULT FMOD5_System_GetMasterSoundGroup (IntPtr system, out IntPtr soundgroup);
  1558. [DllImport(VERSION.dll)]
  1559. private static extern RESULT FMOD5_System_AttachChannelGroupToPort (IntPtr system, PORT_TYPE portType, ulong portIndex, IntPtr channelgroup, bool passThru);
  1560. [DllImport(VERSION.dll)]
  1561. private static extern RESULT FMOD5_System_DetachChannelGroupFromPort(IntPtr system, IntPtr channelgroup);
  1562. [DllImport(VERSION.dll)]
  1563. private static extern RESULT FMOD5_System_SetReverbProperties (IntPtr system, int instance, ref REVERB_PROPERTIES prop);
  1564. [DllImport(VERSION.dll)]
  1565. private static extern RESULT FMOD5_System_GetReverbProperties (IntPtr system, int instance, out REVERB_PROPERTIES prop);
  1566. [DllImport(VERSION.dll)]
  1567. private static extern RESULT FMOD5_System_LockDSP (IntPtr system);
  1568. [DllImport(VERSION.dll)]
  1569. private static extern RESULT FMOD5_System_UnlockDSP (IntPtr system);
  1570. [DllImport(VERSION.dll)]
  1571. private static extern RESULT FMOD5_System_GetRecordNumDrivers (IntPtr system, out int numdrivers, out int numconnected);
  1572. [DllImport(VERSION.dll)]
  1573. private static extern RESULT FMOD5_System_GetRecordDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state);
  1574. [DllImport(VERSION.dll)]
  1575. private static extern RESULT FMOD5_System_GetRecordPosition (IntPtr system, int id, out uint position);
  1576. [DllImport(VERSION.dll)]
  1577. private static extern RESULT FMOD5_System_RecordStart (IntPtr system, int id, IntPtr sound, bool loop);
  1578. [DllImport(VERSION.dll)]
  1579. private static extern RESULT FMOD5_System_RecordStop (IntPtr system, int id);
  1580. [DllImport(VERSION.dll)]
  1581. private static extern RESULT FMOD5_System_IsRecording (IntPtr system, int id, out bool recording);
  1582. [DllImport(VERSION.dll)]
  1583. private static extern RESULT FMOD5_System_CreateGeometry (IntPtr system, int maxpolygons, int maxvertices, out IntPtr geometry);
  1584. [DllImport(VERSION.dll)]
  1585. private static extern RESULT FMOD5_System_SetGeometrySettings (IntPtr system, float maxworldsize);
  1586. [DllImport(VERSION.dll)]
  1587. private static extern RESULT FMOD5_System_GetGeometrySettings (IntPtr system, out float maxworldsize);
  1588. [DllImport(VERSION.dll)]
  1589. private static extern RESULT FMOD5_System_LoadGeometry (IntPtr system, IntPtr data, int datasize, out IntPtr geometry);
  1590. [DllImport(VERSION.dll)]
  1591. private static extern RESULT FMOD5_System_GetGeometryOcclusion (IntPtr system, ref VECTOR listener, ref VECTOR source, out float direct, out float reverb);
  1592. [DllImport(VERSION.dll)]
  1593. private static extern RESULT FMOD5_System_SetNetworkProxy (IntPtr system, byte[] proxy);
  1594. [DllImport(VERSION.dll)]
  1595. private static extern RESULT FMOD5_System_GetNetworkProxy (IntPtr system, IntPtr proxy, int proxylen);
  1596. [DllImport(VERSION.dll)]
  1597. private static extern RESULT FMOD5_System_SetNetworkTimeout (IntPtr system, int timeout);
  1598. [DllImport(VERSION.dll)]
  1599. private static extern RESULT FMOD5_System_GetNetworkTimeout (IntPtr system, out int timeout);
  1600. [DllImport(VERSION.dll)]
  1601. private static extern RESULT FMOD5_System_SetUserData (IntPtr system, IntPtr userdata);
  1602. [DllImport(VERSION.dll)]
  1603. private static extern RESULT FMOD5_System_GetUserData (IntPtr system, out IntPtr userdata);
  1604. #endregion
  1605. #region wrapperinternal
  1606. public IntPtr handle;
  1607. public System(IntPtr ptr) { this.handle = ptr; }
  1608. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  1609. public void clearHandle() { this.handle = IntPtr.Zero; }
  1610. #endregion
  1611. }
  1612. /*
  1613. 'Sound' API.
  1614. */
  1615. public struct Sound
  1616. {
  1617. public RESULT release()
  1618. {
  1619. return FMOD5_Sound_Release(this.handle);
  1620. }
  1621. public RESULT getSystemObject(out System system)
  1622. {
  1623. return FMOD5_Sound_GetSystemObject(this.handle, out system.handle);
  1624. }
  1625. // Standard sound manipulation functions.
  1626. public RESULT @lock(uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2)
  1627. {
  1628. return FMOD5_Sound_Lock(this.handle, offset, length, out ptr1, out ptr2, out len1, out len2);
  1629. }
  1630. public RESULT unlock(IntPtr ptr1, IntPtr ptr2, uint len1, uint len2)
  1631. {
  1632. return FMOD5_Sound_Unlock(this.handle, ptr1, ptr2, len1, len2);
  1633. }
  1634. public RESULT setDefaults(float frequency, int priority)
  1635. {
  1636. return FMOD5_Sound_SetDefaults(this.handle, frequency, priority);
  1637. }
  1638. public RESULT getDefaults(out float frequency, out int priority)
  1639. {
  1640. return FMOD5_Sound_GetDefaults(this.handle, out frequency, out priority);
  1641. }
  1642. public RESULT set3DMinMaxDistance(float min, float max)
  1643. {
  1644. return FMOD5_Sound_Set3DMinMaxDistance(this.handle, min, max);
  1645. }
  1646. public RESULT get3DMinMaxDistance(out float min, out float max)
  1647. {
  1648. return FMOD5_Sound_Get3DMinMaxDistance(this.handle, out min, out max);
  1649. }
  1650. public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume)
  1651. {
  1652. return FMOD5_Sound_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume);
  1653. }
  1654. public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume)
  1655. {
  1656. return FMOD5_Sound_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume);
  1657. }
  1658. public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints)
  1659. {
  1660. return FMOD5_Sound_Set3DCustomRolloff(this.handle, ref points, numpoints);
  1661. }
  1662. public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints)
  1663. {
  1664. return FMOD5_Sound_Get3DCustomRolloff(this.handle, out points, out numpoints);
  1665. }
  1666. public RESULT getSubSound(int index, out Sound subsound)
  1667. {
  1668. return FMOD5_Sound_GetSubSound(this.handle, index, out subsound.handle);
  1669. }
  1670. public RESULT getSubSoundParent(out Sound parentsound)
  1671. {
  1672. return FMOD5_Sound_GetSubSoundParent(this.handle, out parentsound.handle);
  1673. }
  1674. public RESULT getName(out string name, int namelen)
  1675. {
  1676. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  1677. RESULT result = FMOD5_Sound_GetName(this.handle, stringMem, namelen);
  1678. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1679. {
  1680. name = encoder.stringFromNative(stringMem);
  1681. }
  1682. Marshal.FreeHGlobal(stringMem);
  1683. return result;
  1684. }
  1685. public RESULT getLength(out uint length, TIMEUNIT lengthtype)
  1686. {
  1687. return FMOD5_Sound_GetLength(this.handle, out length, lengthtype);
  1688. }
  1689. public RESULT getFormat(out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits)
  1690. {
  1691. return FMOD5_Sound_GetFormat(this.handle, out type, out format, out channels, out bits);
  1692. }
  1693. public RESULT getNumSubSounds(out int numsubsounds)
  1694. {
  1695. return FMOD5_Sound_GetNumSubSounds(this.handle, out numsubsounds);
  1696. }
  1697. public RESULT getNumTags(out int numtags, out int numtagsupdated)
  1698. {
  1699. return FMOD5_Sound_GetNumTags(this.handle, out numtags, out numtagsupdated);
  1700. }
  1701. public RESULT getTag(string name, int index, out TAG tag)
  1702. {
  1703. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1704. {
  1705. return FMOD5_Sound_GetTag(this.handle, encoder.byteFromStringUTF8(name), index, out tag);
  1706. }
  1707. }
  1708. public RESULT getOpenState(out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy)
  1709. {
  1710. return FMOD5_Sound_GetOpenState(this.handle, out openstate, out percentbuffered, out starving, out diskbusy);
  1711. }
  1712. public RESULT readData(byte[] buffer)
  1713. {
  1714. return FMOD5_Sound_ReadData(this.handle, buffer, (uint)buffer.Length, IntPtr.Zero);
  1715. }
  1716. public RESULT readData(byte[] buffer, out uint read)
  1717. {
  1718. return FMOD5_Sound_ReadData(this.handle, buffer, (uint)buffer.Length, out read);
  1719. }
  1720. public RESULT seekData(uint pcm)
  1721. {
  1722. return FMOD5_Sound_SeekData(this.handle, pcm);
  1723. }
  1724. public RESULT setSoundGroup(SoundGroup soundgroup)
  1725. {
  1726. return FMOD5_Sound_SetSoundGroup(this.handle, soundgroup.handle);
  1727. }
  1728. public RESULT getSoundGroup(out SoundGroup soundgroup)
  1729. {
  1730. return FMOD5_Sound_GetSoundGroup(this.handle, out soundgroup.handle);
  1731. }
  1732. // Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.
  1733. public RESULT getNumSyncPoints(out int numsyncpoints)
  1734. {
  1735. return FMOD5_Sound_GetNumSyncPoints(this.handle, out numsyncpoints);
  1736. }
  1737. public RESULT getSyncPoint(int index, out IntPtr point)
  1738. {
  1739. return FMOD5_Sound_GetSyncPoint(this.handle, index, out point);
  1740. }
  1741. public RESULT getSyncPointInfo(IntPtr point, out string name, int namelen, out uint offset, TIMEUNIT offsettype)
  1742. {
  1743. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  1744. RESULT result = FMOD5_Sound_GetSyncPointInfo(this.handle, point, stringMem, namelen, out offset, offsettype);
  1745. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1746. {
  1747. name = encoder.stringFromNative(stringMem);
  1748. }
  1749. Marshal.FreeHGlobal(stringMem);
  1750. return result;
  1751. }
  1752. public RESULT getSyncPointInfo(IntPtr point, out uint offset, TIMEUNIT offsettype)
  1753. {
  1754. return FMOD5_Sound_GetSyncPointInfo(this.handle, point, IntPtr.Zero, 0, out offset, offsettype);
  1755. }
  1756. public RESULT addSyncPoint(uint offset, TIMEUNIT offsettype, string name, out IntPtr point)
  1757. {
  1758. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  1759. {
  1760. return FMOD5_Sound_AddSyncPoint(this.handle, offset, offsettype, encoder.byteFromStringUTF8(name), out point);
  1761. }
  1762. }
  1763. public RESULT deleteSyncPoint(IntPtr point)
  1764. {
  1765. return FMOD5_Sound_DeleteSyncPoint(this.handle, point);
  1766. }
  1767. // Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
  1768. public RESULT setMode(MODE mode)
  1769. {
  1770. return FMOD5_Sound_SetMode(this.handle, mode);
  1771. }
  1772. public RESULT getMode(out MODE mode)
  1773. {
  1774. return FMOD5_Sound_GetMode(this.handle, out mode);
  1775. }
  1776. public RESULT setLoopCount(int loopcount)
  1777. {
  1778. return FMOD5_Sound_SetLoopCount(this.handle, loopcount);
  1779. }
  1780. public RESULT getLoopCount(out int loopcount)
  1781. {
  1782. return FMOD5_Sound_GetLoopCount(this.handle, out loopcount);
  1783. }
  1784. public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype)
  1785. {
  1786. return FMOD5_Sound_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype);
  1787. }
  1788. public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype)
  1789. {
  1790. return FMOD5_Sound_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype);
  1791. }
  1792. // For MOD/S3M/XM/IT/MID sequenced formats only.
  1793. public RESULT getMusicNumChannels(out int numchannels)
  1794. {
  1795. return FMOD5_Sound_GetMusicNumChannels(this.handle, out numchannels);
  1796. }
  1797. public RESULT setMusicChannelVolume(int channel, float volume)
  1798. {
  1799. return FMOD5_Sound_SetMusicChannelVolume(this.handle, channel, volume);
  1800. }
  1801. public RESULT getMusicChannelVolume(int channel, out float volume)
  1802. {
  1803. return FMOD5_Sound_GetMusicChannelVolume(this.handle, channel, out volume);
  1804. }
  1805. public RESULT setMusicSpeed(float speed)
  1806. {
  1807. return FMOD5_Sound_SetMusicSpeed(this.handle, speed);
  1808. }
  1809. public RESULT getMusicSpeed(out float speed)
  1810. {
  1811. return FMOD5_Sound_GetMusicSpeed(this.handle, out speed);
  1812. }
  1813. // Userdata set/get.
  1814. public RESULT setUserData(IntPtr userdata)
  1815. {
  1816. return FMOD5_Sound_SetUserData(this.handle, userdata);
  1817. }
  1818. public RESULT getUserData(out IntPtr userdata)
  1819. {
  1820. return FMOD5_Sound_GetUserData(this.handle, out userdata);
  1821. }
  1822. #region importfunctions
  1823. [DllImport(VERSION.dll)]
  1824. private static extern RESULT FMOD5_Sound_Release (IntPtr sound);
  1825. [DllImport(VERSION.dll)]
  1826. private static extern RESULT FMOD5_Sound_GetSystemObject (IntPtr sound, out IntPtr system);
  1827. [DllImport(VERSION.dll)]
  1828. private static extern RESULT FMOD5_Sound_Lock (IntPtr sound, uint offset, uint length, out IntPtr ptr1, out IntPtr ptr2, out uint len1, out uint len2);
  1829. [DllImport(VERSION.dll)]
  1830. private static extern RESULT FMOD5_Sound_Unlock (IntPtr sound, IntPtr ptr1, IntPtr ptr2, uint len1, uint len2);
  1831. [DllImport(VERSION.dll)]
  1832. private static extern RESULT FMOD5_Sound_SetDefaults (IntPtr sound, float frequency, int priority);
  1833. [DllImport(VERSION.dll)]
  1834. private static extern RESULT FMOD5_Sound_GetDefaults (IntPtr sound, out float frequency, out int priority);
  1835. [DllImport(VERSION.dll)]
  1836. private static extern RESULT FMOD5_Sound_Set3DMinMaxDistance (IntPtr sound, float min, float max);
  1837. [DllImport(VERSION.dll)]
  1838. private static extern RESULT FMOD5_Sound_Get3DMinMaxDistance (IntPtr sound, out float min, out float max);
  1839. [DllImport(VERSION.dll)]
  1840. private static extern RESULT FMOD5_Sound_Set3DConeSettings (IntPtr sound, float insideconeangle, float outsideconeangle, float outsidevolume);
  1841. [DllImport(VERSION.dll)]
  1842. private static extern RESULT FMOD5_Sound_Get3DConeSettings (IntPtr sound, out float insideconeangle, out float outsideconeangle, out float outsidevolume);
  1843. [DllImport(VERSION.dll)]
  1844. private static extern RESULT FMOD5_Sound_Set3DCustomRolloff (IntPtr sound, ref VECTOR points, int numpoints);
  1845. [DllImport(VERSION.dll)]
  1846. private static extern RESULT FMOD5_Sound_Get3DCustomRolloff (IntPtr sound, out IntPtr points, out int numpoints);
  1847. [DllImport(VERSION.dll)]
  1848. private static extern RESULT FMOD5_Sound_GetSubSound (IntPtr sound, int index, out IntPtr subsound);
  1849. [DllImport(VERSION.dll)]
  1850. private static extern RESULT FMOD5_Sound_GetSubSoundParent (IntPtr sound, out IntPtr parentsound);
  1851. [DllImport(VERSION.dll)]
  1852. private static extern RESULT FMOD5_Sound_GetName (IntPtr sound, IntPtr name, int namelen);
  1853. [DllImport(VERSION.dll)]
  1854. private static extern RESULT FMOD5_Sound_GetLength (IntPtr sound, out uint length, TIMEUNIT lengthtype);
  1855. [DllImport(VERSION.dll)]
  1856. private static extern RESULT FMOD5_Sound_GetFormat (IntPtr sound, out SOUND_TYPE type, out SOUND_FORMAT format, out int channels, out int bits);
  1857. [DllImport(VERSION.dll)]
  1858. private static extern RESULT FMOD5_Sound_GetNumSubSounds (IntPtr sound, out int numsubsounds);
  1859. [DllImport(VERSION.dll)]
  1860. private static extern RESULT FMOD5_Sound_GetNumTags (IntPtr sound, out int numtags, out int numtagsupdated);
  1861. [DllImport(VERSION.dll)]
  1862. private static extern RESULT FMOD5_Sound_GetTag (IntPtr sound, byte[] name, int index, out TAG tag);
  1863. [DllImport(VERSION.dll)]
  1864. private static extern RESULT FMOD5_Sound_GetOpenState (IntPtr sound, out OPENSTATE openstate, out uint percentbuffered, out bool starving, out bool diskbusy);
  1865. [DllImport(VERSION.dll)]
  1866. private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, byte[] buffer, uint length, IntPtr zero);
  1867. [DllImport(VERSION.dll)]
  1868. private static extern RESULT FMOD5_Sound_ReadData (IntPtr sound, byte[] buffer, uint length, out uint read);
  1869. [DllImport(VERSION.dll)]
  1870. private static extern RESULT FMOD5_Sound_SeekData (IntPtr sound, uint pcm);
  1871. [DllImport(VERSION.dll)]
  1872. private static extern RESULT FMOD5_Sound_SetSoundGroup (IntPtr sound, IntPtr soundgroup);
  1873. [DllImport(VERSION.dll)]
  1874. private static extern RESULT FMOD5_Sound_GetSoundGroup (IntPtr sound, out IntPtr soundgroup);
  1875. [DllImport(VERSION.dll)]
  1876. private static extern RESULT FMOD5_Sound_GetNumSyncPoints (IntPtr sound, out int numsyncpoints);
  1877. [DllImport(VERSION.dll)]
  1878. private static extern RESULT FMOD5_Sound_GetSyncPoint (IntPtr sound, int index, out IntPtr point);
  1879. [DllImport(VERSION.dll)]
  1880. private static extern RESULT FMOD5_Sound_GetSyncPointInfo (IntPtr sound, IntPtr point, IntPtr name, int namelen, out uint offset, TIMEUNIT offsettype);
  1881. [DllImport(VERSION.dll)]
  1882. private static extern RESULT FMOD5_Sound_AddSyncPoint (IntPtr sound, uint offset, TIMEUNIT offsettype, byte[] name, out IntPtr point);
  1883. [DllImport(VERSION.dll)]
  1884. private static extern RESULT FMOD5_Sound_DeleteSyncPoint (IntPtr sound, IntPtr point);
  1885. [DllImport(VERSION.dll)]
  1886. private static extern RESULT FMOD5_Sound_SetMode (IntPtr sound, MODE mode);
  1887. [DllImport(VERSION.dll)]
  1888. private static extern RESULT FMOD5_Sound_GetMode (IntPtr sound, out MODE mode);
  1889. [DllImport(VERSION.dll)]
  1890. private static extern RESULT FMOD5_Sound_SetLoopCount (IntPtr sound, int loopcount);
  1891. [DllImport(VERSION.dll)]
  1892. private static extern RESULT FMOD5_Sound_GetLoopCount (IntPtr sound, out int loopcount);
  1893. [DllImport(VERSION.dll)]
  1894. private static extern RESULT FMOD5_Sound_SetLoopPoints (IntPtr sound, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype);
  1895. [DllImport(VERSION.dll)]
  1896. private static extern RESULT FMOD5_Sound_GetLoopPoints (IntPtr sound, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype);
  1897. [DllImport(VERSION.dll)]
  1898. private static extern RESULT FMOD5_Sound_GetMusicNumChannels (IntPtr sound, out int numchannels);
  1899. [DllImport(VERSION.dll)]
  1900. private static extern RESULT FMOD5_Sound_SetMusicChannelVolume (IntPtr sound, int channel, float volume);
  1901. [DllImport(VERSION.dll)]
  1902. private static extern RESULT FMOD5_Sound_GetMusicChannelVolume (IntPtr sound, int channel, out float volume);
  1903. [DllImport(VERSION.dll)]
  1904. private static extern RESULT FMOD5_Sound_SetMusicSpeed (IntPtr sound, float speed);
  1905. [DllImport(VERSION.dll)]
  1906. private static extern RESULT FMOD5_Sound_GetMusicSpeed (IntPtr sound, out float speed);
  1907. [DllImport(VERSION.dll)]
  1908. private static extern RESULT FMOD5_Sound_SetUserData (IntPtr sound, IntPtr userdata);
  1909. [DllImport(VERSION.dll)]
  1910. private static extern RESULT FMOD5_Sound_GetUserData (IntPtr sound, out IntPtr userdata);
  1911. #endregion
  1912. #region wrapperinternal
  1913. public IntPtr handle;
  1914. public Sound(IntPtr ptr) { this.handle = ptr; }
  1915. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  1916. public void clearHandle() { this.handle = IntPtr.Zero; }
  1917. #endregion
  1918. }
  1919. /*
  1920. 'ChannelControl' API
  1921. */
  1922. interface IChannelControl
  1923. {
  1924. RESULT getSystemObject (out System system);
  1925. // General control functionality for Channels and ChannelGroups.
  1926. RESULT stop ();
  1927. RESULT setPaused (bool paused);
  1928. RESULT getPaused (out bool paused);
  1929. RESULT setVolume (float volume);
  1930. RESULT getVolume (out float volume);
  1931. RESULT setVolumeRamp (bool ramp);
  1932. RESULT getVolumeRamp (out bool ramp);
  1933. RESULT getAudibility (out float audibility);
  1934. RESULT setPitch (float pitch);
  1935. RESULT getPitch (out float pitch);
  1936. RESULT setMute (bool mute);
  1937. RESULT getMute (out bool mute);
  1938. RESULT setReverbProperties (int instance, float wet);
  1939. RESULT getReverbProperties (int instance, out float wet);
  1940. RESULT setLowPassGain (float gain);
  1941. RESULT getLowPassGain (out float gain);
  1942. RESULT setMode (MODE mode);
  1943. RESULT getMode (out MODE mode);
  1944. RESULT setCallback (CHANNELCONTROL_CALLBACK callback);
  1945. RESULT isPlaying (out bool isplaying);
  1946. // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
  1947. RESULT setPan (float pan);
  1948. RESULT setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
  1949. RESULT setMixLevelsInput (float[] levels, int numlevels);
  1950. RESULT setMixMatrix (float[] matrix, int outchannels, int inchannels, int inchannel_hop);
  1951. RESULT getMixMatrix (float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
  1952. // Clock based functionality.
  1953. RESULT getDSPClock (out ulong dspclock, out ulong parentclock);
  1954. RESULT setDelay (ulong dspclock_start, ulong dspclock_end, bool stopchannels);
  1955. RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end);
  1956. RESULT getDelay (out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);
  1957. RESULT addFadePoint (ulong dspclock, float volume);
  1958. RESULT setFadePointRamp (ulong dspclock, float volume);
  1959. RESULT removeFadePoints (ulong dspclock_start, ulong dspclock_end);
  1960. RESULT getFadePoints (ref uint numpoints, ulong[] point_dspclock, float[] point_volume);
  1961. // DSP effects.
  1962. RESULT getDSP (int index, out DSP dsp);
  1963. RESULT addDSP (int index, DSP dsp);
  1964. RESULT removeDSP (DSP dsp);
  1965. RESULT getNumDSPs (out int numdsps);
  1966. RESULT setDSPIndex (DSP dsp, int index);
  1967. RESULT getDSPIndex (DSP dsp, out int index);
  1968. // 3D functionality.
  1969. RESULT set3DAttributes (ref VECTOR pos, ref VECTOR vel);
  1970. RESULT get3DAttributes (out VECTOR pos, out VECTOR vel);
  1971. RESULT set3DMinMaxDistance (float mindistance, float maxdistance);
  1972. RESULT get3DMinMaxDistance (out float mindistance, out float maxdistance);
  1973. RESULT set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);
  1974. RESULT get3DConeSettings (out float insideconeangle, out float outsideconeangle, out float outsidevolume);
  1975. RESULT set3DConeOrientation (ref VECTOR orientation);
  1976. RESULT get3DConeOrientation (out VECTOR orientation);
  1977. RESULT set3DCustomRolloff (ref VECTOR points, int numpoints);
  1978. RESULT get3DCustomRolloff (out IntPtr points, out int numpoints);
  1979. RESULT set3DOcclusion (float directocclusion, float reverbocclusion);
  1980. RESULT get3DOcclusion (out float directocclusion, out float reverbocclusion);
  1981. RESULT set3DSpread (float angle);
  1982. RESULT get3DSpread (out float angle);
  1983. RESULT set3DLevel (float level);
  1984. RESULT get3DLevel (out float level);
  1985. RESULT set3DDopplerLevel (float level);
  1986. RESULT get3DDopplerLevel (out float level);
  1987. RESULT set3DDistanceFilter (bool custom, float customLevel, float centerFreq);
  1988. RESULT get3DDistanceFilter (out bool custom, out float customLevel, out float centerFreq);
  1989. // Userdata set/get.
  1990. RESULT setUserData (IntPtr userdata);
  1991. RESULT getUserData (out IntPtr userdata);
  1992. }
  1993. /*
  1994. 'Channel' API
  1995. */
  1996. public struct Channel : IChannelControl
  1997. {
  1998. // Channel specific control functionality.
  1999. public RESULT setFrequency(float frequency)
  2000. {
  2001. return FMOD5_Channel_SetFrequency(this.handle, frequency);
  2002. }
  2003. public RESULT getFrequency(out float frequency)
  2004. {
  2005. return FMOD5_Channel_GetFrequency(this.handle, out frequency);
  2006. }
  2007. public RESULT setPriority(int priority)
  2008. {
  2009. return FMOD5_Channel_SetPriority(this.handle, priority);
  2010. }
  2011. public RESULT getPriority(out int priority)
  2012. {
  2013. return FMOD5_Channel_GetPriority(this.handle, out priority);
  2014. }
  2015. public RESULT setPosition(uint position, TIMEUNIT postype)
  2016. {
  2017. return FMOD5_Channel_SetPosition(this.handle, position, postype);
  2018. }
  2019. public RESULT getPosition(out uint position, TIMEUNIT postype)
  2020. {
  2021. return FMOD5_Channel_GetPosition(this.handle, out position, postype);
  2022. }
  2023. public RESULT setChannelGroup(ChannelGroup channelgroup)
  2024. {
  2025. return FMOD5_Channel_SetChannelGroup(this.handle, channelgroup.handle);
  2026. }
  2027. public RESULT getChannelGroup(out ChannelGroup channelgroup)
  2028. {
  2029. return FMOD5_Channel_GetChannelGroup(this.handle, out channelgroup.handle);
  2030. }
  2031. public RESULT setLoopCount(int loopcount)
  2032. {
  2033. return FMOD5_Channel_SetLoopCount(this.handle, loopcount);
  2034. }
  2035. public RESULT getLoopCount(out int loopcount)
  2036. {
  2037. return FMOD5_Channel_GetLoopCount(this.handle, out loopcount);
  2038. }
  2039. public RESULT setLoopPoints(uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype)
  2040. {
  2041. return FMOD5_Channel_SetLoopPoints(this.handle, loopstart, loopstarttype, loopend, loopendtype);
  2042. }
  2043. public RESULT getLoopPoints(out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype)
  2044. {
  2045. return FMOD5_Channel_GetLoopPoints(this.handle, out loopstart, loopstarttype, out loopend, loopendtype);
  2046. }
  2047. // Information only functions.
  2048. public RESULT isVirtual(out bool isvirtual)
  2049. {
  2050. return FMOD5_Channel_IsVirtual(this.handle, out isvirtual);
  2051. }
  2052. public RESULT getCurrentSound(out Sound sound)
  2053. {
  2054. return FMOD5_Channel_GetCurrentSound(this.handle, out sound.handle);
  2055. }
  2056. public RESULT getIndex(out int index)
  2057. {
  2058. return FMOD5_Channel_GetIndex(this.handle, out index);
  2059. }
  2060. public RESULT getSystemObject(out System system)
  2061. {
  2062. return FMOD5_Channel_GetSystemObject(this.handle, out system.handle);
  2063. }
  2064. // General control functionality for Channels and ChannelGroups.
  2065. public RESULT stop()
  2066. {
  2067. return FMOD5_Channel_Stop(this.handle);
  2068. }
  2069. public RESULT setPaused(bool paused)
  2070. {
  2071. return FMOD5_Channel_SetPaused(this.handle, paused);
  2072. }
  2073. public RESULT getPaused(out bool paused)
  2074. {
  2075. return FMOD5_Channel_GetPaused(this.handle, out paused);
  2076. }
  2077. public RESULT setVolume(float volume)
  2078. {
  2079. return FMOD5_Channel_SetVolume(this.handle, volume);
  2080. }
  2081. public RESULT getVolume(out float volume)
  2082. {
  2083. return FMOD5_Channel_GetVolume(this.handle, out volume);
  2084. }
  2085. public RESULT setVolumeRamp(bool ramp)
  2086. {
  2087. return FMOD5_Channel_SetVolumeRamp(this.handle, ramp);
  2088. }
  2089. public RESULT getVolumeRamp(out bool ramp)
  2090. {
  2091. return FMOD5_Channel_GetVolumeRamp(this.handle, out ramp);
  2092. }
  2093. public RESULT getAudibility(out float audibility)
  2094. {
  2095. return FMOD5_Channel_GetAudibility(this.handle, out audibility);
  2096. }
  2097. public RESULT setPitch(float pitch)
  2098. {
  2099. return FMOD5_Channel_SetPitch(this.handle, pitch);
  2100. }
  2101. public RESULT getPitch(out float pitch)
  2102. {
  2103. return FMOD5_Channel_GetPitch(this.handle, out pitch);
  2104. }
  2105. public RESULT setMute(bool mute)
  2106. {
  2107. return FMOD5_Channel_SetMute(this.handle, mute);
  2108. }
  2109. public RESULT getMute(out bool mute)
  2110. {
  2111. return FMOD5_Channel_GetMute(this.handle, out mute);
  2112. }
  2113. public RESULT setReverbProperties(int instance, float wet)
  2114. {
  2115. return FMOD5_Channel_SetReverbProperties(this.handle, instance, wet);
  2116. }
  2117. public RESULT getReverbProperties(int instance, out float wet)
  2118. {
  2119. return FMOD5_Channel_GetReverbProperties(this.handle, instance, out wet);
  2120. }
  2121. public RESULT setLowPassGain(float gain)
  2122. {
  2123. return FMOD5_Channel_SetLowPassGain(this.handle, gain);
  2124. }
  2125. public RESULT getLowPassGain(out float gain)
  2126. {
  2127. return FMOD5_Channel_GetLowPassGain(this.handle, out gain);
  2128. }
  2129. public RESULT setMode(MODE mode)
  2130. {
  2131. return FMOD5_Channel_SetMode(this.handle, mode);
  2132. }
  2133. public RESULT getMode(out MODE mode)
  2134. {
  2135. return FMOD5_Channel_GetMode(this.handle, out mode);
  2136. }
  2137. public RESULT setCallback(CHANNELCONTROL_CALLBACK callback)
  2138. {
  2139. return FMOD5_Channel_SetCallback(this.handle, callback);
  2140. }
  2141. public RESULT isPlaying(out bool isplaying)
  2142. {
  2143. return FMOD5_Channel_IsPlaying(this.handle, out isplaying);
  2144. }
  2145. // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
  2146. public RESULT setPan(float pan)
  2147. {
  2148. return FMOD5_Channel_SetPan(this.handle, pan);
  2149. }
  2150. public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright)
  2151. {
  2152. return FMOD5_Channel_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright);
  2153. }
  2154. public RESULT setMixLevelsInput(float[] levels, int numlevels)
  2155. {
  2156. return FMOD5_Channel_SetMixLevelsInput(this.handle, levels, numlevels);
  2157. }
  2158. public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0)
  2159. {
  2160. return FMOD5_Channel_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop);
  2161. }
  2162. public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0)
  2163. {
  2164. return FMOD5_Channel_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop);
  2165. }
  2166. // Clock based functionality.
  2167. public RESULT getDSPClock(out ulong dspclock, out ulong parentclock)
  2168. {
  2169. return FMOD5_Channel_GetDSPClock(this.handle, out dspclock, out parentclock);
  2170. }
  2171. public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels = true)
  2172. {
  2173. return FMOD5_Channel_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels);
  2174. }
  2175. public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end)
  2176. {
  2177. return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero);
  2178. }
  2179. public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels)
  2180. {
  2181. return FMOD5_Channel_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels);
  2182. }
  2183. public RESULT addFadePoint(ulong dspclock, float volume)
  2184. {
  2185. return FMOD5_Channel_AddFadePoint(this.handle, dspclock, volume);
  2186. }
  2187. public RESULT setFadePointRamp(ulong dspclock, float volume)
  2188. {
  2189. return FMOD5_Channel_SetFadePointRamp(this.handle, dspclock, volume);
  2190. }
  2191. public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end)
  2192. {
  2193. return FMOD5_Channel_RemoveFadePoints(this.handle, dspclock_start, dspclock_end);
  2194. }
  2195. public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume)
  2196. {
  2197. return FMOD5_Channel_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume);
  2198. }
  2199. // DSP effects.
  2200. public RESULT getDSP(int index, out DSP dsp)
  2201. {
  2202. return FMOD5_Channel_GetDSP(this.handle, index, out dsp.handle);
  2203. }
  2204. public RESULT addDSP(int index, DSP dsp)
  2205. {
  2206. return FMOD5_Channel_AddDSP(this.handle, index, dsp.handle);
  2207. }
  2208. public RESULT removeDSP(DSP dsp)
  2209. {
  2210. return FMOD5_Channel_RemoveDSP(this.handle, dsp.handle);
  2211. }
  2212. public RESULT getNumDSPs(out int numdsps)
  2213. {
  2214. return FMOD5_Channel_GetNumDSPs(this.handle, out numdsps);
  2215. }
  2216. public RESULT setDSPIndex(DSP dsp, int index)
  2217. {
  2218. return FMOD5_Channel_SetDSPIndex(this.handle, dsp.handle, index);
  2219. }
  2220. public RESULT getDSPIndex(DSP dsp, out int index)
  2221. {
  2222. return FMOD5_Channel_GetDSPIndex(this.handle, dsp.handle, out index);
  2223. }
  2224. // 3D functionality.
  2225. public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel)
  2226. {
  2227. return FMOD5_Channel_Set3DAttributes(this.handle, ref pos, ref vel);
  2228. }
  2229. public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel)
  2230. {
  2231. return FMOD5_Channel_Get3DAttributes(this.handle, out pos, out vel);
  2232. }
  2233. public RESULT set3DMinMaxDistance(float mindistance, float maxdistance)
  2234. {
  2235. return FMOD5_Channel_Set3DMinMaxDistance(this.handle, mindistance, maxdistance);
  2236. }
  2237. public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance)
  2238. {
  2239. return FMOD5_Channel_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance);
  2240. }
  2241. public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume)
  2242. {
  2243. return FMOD5_Channel_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume);
  2244. }
  2245. public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume)
  2246. {
  2247. return FMOD5_Channel_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume);
  2248. }
  2249. public RESULT set3DConeOrientation(ref VECTOR orientation)
  2250. {
  2251. return FMOD5_Channel_Set3DConeOrientation(this.handle, ref orientation);
  2252. }
  2253. public RESULT get3DConeOrientation(out VECTOR orientation)
  2254. {
  2255. return FMOD5_Channel_Get3DConeOrientation(this.handle, out orientation);
  2256. }
  2257. public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints)
  2258. {
  2259. return FMOD5_Channel_Set3DCustomRolloff(this.handle, ref points, numpoints);
  2260. }
  2261. public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints)
  2262. {
  2263. return FMOD5_Channel_Get3DCustomRolloff(this.handle, out points, out numpoints);
  2264. }
  2265. public RESULT set3DOcclusion(float directocclusion, float reverbocclusion)
  2266. {
  2267. return FMOD5_Channel_Set3DOcclusion(this.handle, directocclusion, reverbocclusion);
  2268. }
  2269. public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion)
  2270. {
  2271. return FMOD5_Channel_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion);
  2272. }
  2273. public RESULT set3DSpread(float angle)
  2274. {
  2275. return FMOD5_Channel_Set3DSpread(this.handle, angle);
  2276. }
  2277. public RESULT get3DSpread(out float angle)
  2278. {
  2279. return FMOD5_Channel_Get3DSpread(this.handle, out angle);
  2280. }
  2281. public RESULT set3DLevel(float level)
  2282. {
  2283. return FMOD5_Channel_Set3DLevel(this.handle, level);
  2284. }
  2285. public RESULT get3DLevel(out float level)
  2286. {
  2287. return FMOD5_Channel_Get3DLevel(this.handle, out level);
  2288. }
  2289. public RESULT set3DDopplerLevel(float level)
  2290. {
  2291. return FMOD5_Channel_Set3DDopplerLevel(this.handle, level);
  2292. }
  2293. public RESULT get3DDopplerLevel(out float level)
  2294. {
  2295. return FMOD5_Channel_Get3DDopplerLevel(this.handle, out level);
  2296. }
  2297. public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq)
  2298. {
  2299. return FMOD5_Channel_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq);
  2300. }
  2301. public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq)
  2302. {
  2303. return FMOD5_Channel_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq);
  2304. }
  2305. // Userdata set/get.
  2306. public RESULT setUserData(IntPtr userdata)
  2307. {
  2308. return FMOD5_Channel_SetUserData(this.handle, userdata);
  2309. }
  2310. public RESULT getUserData(out IntPtr userdata)
  2311. {
  2312. return FMOD5_Channel_GetUserData(this.handle, out userdata);
  2313. }
  2314. #region importfunctions
  2315. [DllImport(VERSION.dll)]
  2316. private static extern RESULT FMOD5_Channel_SetFrequency (IntPtr channel, float frequency);
  2317. [DllImport(VERSION.dll)]
  2318. private static extern RESULT FMOD5_Channel_GetFrequency (IntPtr channel, out float frequency);
  2319. [DllImport(VERSION.dll)]
  2320. private static extern RESULT FMOD5_Channel_SetPriority (IntPtr channel, int priority);
  2321. [DllImport(VERSION.dll)]
  2322. private static extern RESULT FMOD5_Channel_GetPriority (IntPtr channel, out int priority);
  2323. [DllImport(VERSION.dll)]
  2324. private static extern RESULT FMOD5_Channel_SetPosition (IntPtr channel, uint position, TIMEUNIT postype);
  2325. [DllImport(VERSION.dll)]
  2326. private static extern RESULT FMOD5_Channel_GetPosition (IntPtr channel, out uint position, TIMEUNIT postype);
  2327. [DllImport(VERSION.dll)]
  2328. private static extern RESULT FMOD5_Channel_SetChannelGroup (IntPtr channel, IntPtr channelgroup);
  2329. [DllImport(VERSION.dll)]
  2330. private static extern RESULT FMOD5_Channel_GetChannelGroup (IntPtr channel, out IntPtr channelgroup);
  2331. [DllImport(VERSION.dll)]
  2332. private static extern RESULT FMOD5_Channel_SetLoopCount (IntPtr channel, int loopcount);
  2333. [DllImport(VERSION.dll)]
  2334. private static extern RESULT FMOD5_Channel_GetLoopCount (IntPtr channel, out int loopcount);
  2335. [DllImport(VERSION.dll)]
  2336. private static extern RESULT FMOD5_Channel_SetLoopPoints (IntPtr channel, uint loopstart, TIMEUNIT loopstarttype, uint loopend, TIMEUNIT loopendtype);
  2337. [DllImport(VERSION.dll)]
  2338. private static extern RESULT FMOD5_Channel_GetLoopPoints (IntPtr channel, out uint loopstart, TIMEUNIT loopstarttype, out uint loopend, TIMEUNIT loopendtype);
  2339. [DllImport(VERSION.dll)]
  2340. private static extern RESULT FMOD5_Channel_IsVirtual (IntPtr channel, out bool isvirtual);
  2341. [DllImport(VERSION.dll)]
  2342. private static extern RESULT FMOD5_Channel_GetCurrentSound (IntPtr channel, out IntPtr sound);
  2343. [DllImport(VERSION.dll)]
  2344. private static extern RESULT FMOD5_Channel_GetIndex (IntPtr channel, out int index);
  2345. [DllImport(VERSION.dll)]
  2346. private static extern RESULT FMOD5_Channel_GetSystemObject (IntPtr channel, out IntPtr system);
  2347. [DllImport(VERSION.dll)]
  2348. private static extern RESULT FMOD5_Channel_Stop (IntPtr channel);
  2349. [DllImport(VERSION.dll)]
  2350. private static extern RESULT FMOD5_Channel_SetPaused (IntPtr channel, bool paused);
  2351. [DllImport(VERSION.dll)]
  2352. private static extern RESULT FMOD5_Channel_GetPaused (IntPtr channel, out bool paused);
  2353. [DllImport(VERSION.dll)]
  2354. private static extern RESULT FMOD5_Channel_SetVolume (IntPtr channel, float volume);
  2355. [DllImport(VERSION.dll)]
  2356. private static extern RESULT FMOD5_Channel_GetVolume (IntPtr channel, out float volume);
  2357. [DllImport(VERSION.dll)]
  2358. private static extern RESULT FMOD5_Channel_SetVolumeRamp (IntPtr channel, bool ramp);
  2359. [DllImport(VERSION.dll)]
  2360. private static extern RESULT FMOD5_Channel_GetVolumeRamp (IntPtr channel, out bool ramp);
  2361. [DllImport(VERSION.dll)]
  2362. private static extern RESULT FMOD5_Channel_GetAudibility (IntPtr channel, out float audibility);
  2363. [DllImport(VERSION.dll)]
  2364. private static extern RESULT FMOD5_Channel_SetPitch (IntPtr channel, float pitch);
  2365. [DllImport(VERSION.dll)]
  2366. private static extern RESULT FMOD5_Channel_GetPitch (IntPtr channel, out float pitch);
  2367. [DllImport(VERSION.dll)]
  2368. private static extern RESULT FMOD5_Channel_SetMute (IntPtr channel, bool mute);
  2369. [DllImport(VERSION.dll)]
  2370. private static extern RESULT FMOD5_Channel_GetMute (IntPtr channel, out bool mute);
  2371. [DllImport(VERSION.dll)]
  2372. private static extern RESULT FMOD5_Channel_SetReverbProperties (IntPtr channel, int instance, float wet);
  2373. [DllImport(VERSION.dll)]
  2374. private static extern RESULT FMOD5_Channel_GetReverbProperties (IntPtr channel, int instance, out float wet);
  2375. [DllImport(VERSION.dll)]
  2376. private static extern RESULT FMOD5_Channel_SetLowPassGain (IntPtr channel, float gain);
  2377. [DllImport(VERSION.dll)]
  2378. private static extern RESULT FMOD5_Channel_GetLowPassGain (IntPtr channel, out float gain);
  2379. [DllImport(VERSION.dll)]
  2380. private static extern RESULT FMOD5_Channel_SetMode (IntPtr channel, MODE mode);
  2381. [DllImport(VERSION.dll)]
  2382. private static extern RESULT FMOD5_Channel_GetMode (IntPtr channel, out MODE mode);
  2383. [DllImport(VERSION.dll)]
  2384. private static extern RESULT FMOD5_Channel_SetCallback (IntPtr channel, CHANNELCONTROL_CALLBACK callback);
  2385. [DllImport(VERSION.dll)]
  2386. private static extern RESULT FMOD5_Channel_IsPlaying (IntPtr channel, out bool isplaying);
  2387. [DllImport(VERSION.dll)]
  2388. private static extern RESULT FMOD5_Channel_SetPan (IntPtr channel, float pan);
  2389. [DllImport(VERSION.dll)]
  2390. private static extern RESULT FMOD5_Channel_SetMixLevelsOutput (IntPtr channel, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
  2391. [DllImport(VERSION.dll)]
  2392. private static extern RESULT FMOD5_Channel_SetMixLevelsInput (IntPtr channel, float[] levels, int numlevels);
  2393. [DllImport(VERSION.dll)]
  2394. private static extern RESULT FMOD5_Channel_SetMixMatrix (IntPtr channel, float[] matrix, int outchannels, int inchannels, int inchannel_hop);
  2395. [DllImport(VERSION.dll)]
  2396. private static extern RESULT FMOD5_Channel_GetMixMatrix (IntPtr channel, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
  2397. [DllImport(VERSION.dll)]
  2398. private static extern RESULT FMOD5_Channel_GetDSPClock (IntPtr channel, out ulong dspclock, out ulong parentclock);
  2399. [DllImport(VERSION.dll)]
  2400. private static extern RESULT FMOD5_Channel_SetDelay (IntPtr channel, ulong dspclock_start, ulong dspclock_end, bool stopchannels);
  2401. [DllImport(VERSION.dll)]
  2402. private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero);
  2403. [DllImport(VERSION.dll)]
  2404. private static extern RESULT FMOD5_Channel_GetDelay (IntPtr channel, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);
  2405. [DllImport(VERSION.dll)]
  2406. private static extern RESULT FMOD5_Channel_AddFadePoint (IntPtr channel, ulong dspclock, float volume);
  2407. [DllImport(VERSION.dll)]
  2408. private static extern RESULT FMOD5_Channel_SetFadePointRamp (IntPtr channel, ulong dspclock, float volume);
  2409. [DllImport(VERSION.dll)]
  2410. private static extern RESULT FMOD5_Channel_RemoveFadePoints (IntPtr channel, ulong dspclock_start, ulong dspclock_end);
  2411. [DllImport(VERSION.dll)]
  2412. private static extern RESULT FMOD5_Channel_GetFadePoints (IntPtr channel, ref uint numpoints, ulong[] point_dspclock, float[] point_volume);
  2413. [DllImport(VERSION.dll)]
  2414. private static extern RESULT FMOD5_Channel_GetDSP (IntPtr channel, int index, out IntPtr dsp);
  2415. [DllImport(VERSION.dll)]
  2416. private static extern RESULT FMOD5_Channel_AddDSP (IntPtr channel, int index, IntPtr dsp);
  2417. [DllImport(VERSION.dll)]
  2418. private static extern RESULT FMOD5_Channel_RemoveDSP (IntPtr channel, IntPtr dsp);
  2419. [DllImport(VERSION.dll)]
  2420. private static extern RESULT FMOD5_Channel_GetNumDSPs (IntPtr channel, out int numdsps);
  2421. [DllImport(VERSION.dll)]
  2422. private static extern RESULT FMOD5_Channel_SetDSPIndex (IntPtr channel, IntPtr dsp, int index);
  2423. [DllImport(VERSION.dll)]
  2424. private static extern RESULT FMOD5_Channel_GetDSPIndex (IntPtr channel, IntPtr dsp, out int index);
  2425. [DllImport(VERSION.dll)]
  2426. private static extern RESULT FMOD5_Channel_Set3DAttributes (IntPtr channel, ref VECTOR pos, ref VECTOR vel);
  2427. [DllImport(VERSION.dll)]
  2428. private static extern RESULT FMOD5_Channel_Get3DAttributes (IntPtr channel, out VECTOR pos, out VECTOR vel);
  2429. [DllImport(VERSION.dll)]
  2430. private static extern RESULT FMOD5_Channel_Set3DMinMaxDistance (IntPtr channel, float mindistance, float maxdistance);
  2431. [DllImport(VERSION.dll)]
  2432. private static extern RESULT FMOD5_Channel_Get3DMinMaxDistance (IntPtr channel, out float mindistance, out float maxdistance);
  2433. [DllImport(VERSION.dll)]
  2434. private static extern RESULT FMOD5_Channel_Set3DConeSettings (IntPtr channel, float insideconeangle, float outsideconeangle, float outsidevolume);
  2435. [DllImport(VERSION.dll)]
  2436. private static extern RESULT FMOD5_Channel_Get3DConeSettings (IntPtr channel, out float insideconeangle, out float outsideconeangle, out float outsidevolume);
  2437. [DllImport(VERSION.dll)]
  2438. private static extern RESULT FMOD5_Channel_Set3DConeOrientation (IntPtr channel, ref VECTOR orientation);
  2439. [DllImport(VERSION.dll)]
  2440. private static extern RESULT FMOD5_Channel_Get3DConeOrientation (IntPtr channel, out VECTOR orientation);
  2441. [DllImport(VERSION.dll)]
  2442. private static extern RESULT FMOD5_Channel_Set3DCustomRolloff (IntPtr channel, ref VECTOR points, int numpoints);
  2443. [DllImport(VERSION.dll)]
  2444. private static extern RESULT FMOD5_Channel_Get3DCustomRolloff (IntPtr channel, out IntPtr points, out int numpoints);
  2445. [DllImport(VERSION.dll)]
  2446. private static extern RESULT FMOD5_Channel_Set3DOcclusion (IntPtr channel, float directocclusion, float reverbocclusion);
  2447. [DllImport(VERSION.dll)]
  2448. private static extern RESULT FMOD5_Channel_Get3DOcclusion (IntPtr channel, out float directocclusion, out float reverbocclusion);
  2449. [DllImport(VERSION.dll)]
  2450. private static extern RESULT FMOD5_Channel_Set3DSpread (IntPtr channel, float angle);
  2451. [DllImport(VERSION.dll)]
  2452. private static extern RESULT FMOD5_Channel_Get3DSpread (IntPtr channel, out float angle);
  2453. [DllImport(VERSION.dll)]
  2454. private static extern RESULT FMOD5_Channel_Set3DLevel (IntPtr channel, float level);
  2455. [DllImport(VERSION.dll)]
  2456. private static extern RESULT FMOD5_Channel_Get3DLevel (IntPtr channel, out float level);
  2457. [DllImport(VERSION.dll)]
  2458. private static extern RESULT FMOD5_Channel_Set3DDopplerLevel (IntPtr channel, float level);
  2459. [DllImport(VERSION.dll)]
  2460. private static extern RESULT FMOD5_Channel_Get3DDopplerLevel (IntPtr channel, out float level);
  2461. [DllImport(VERSION.dll)]
  2462. private static extern RESULT FMOD5_Channel_Set3DDistanceFilter (IntPtr channel, bool custom, float customLevel, float centerFreq);
  2463. [DllImport(VERSION.dll)]
  2464. private static extern RESULT FMOD5_Channel_Get3DDistanceFilter (IntPtr channel, out bool custom, out float customLevel, out float centerFreq);
  2465. [DllImport(VERSION.dll)]
  2466. private static extern RESULT FMOD5_Channel_SetUserData (IntPtr channel, IntPtr userdata);
  2467. [DllImport(VERSION.dll)]
  2468. private static extern RESULT FMOD5_Channel_GetUserData (IntPtr channel, out IntPtr userdata);
  2469. #endregion
  2470. #region wrapperinternal
  2471. public IntPtr handle;
  2472. public Channel(IntPtr ptr) { this.handle = ptr; }
  2473. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  2474. public void clearHandle() { this.handle = IntPtr.Zero; }
  2475. #endregion
  2476. }
  2477. /*
  2478. 'ChannelGroup' API
  2479. */
  2480. public struct ChannelGroup : IChannelControl
  2481. {
  2482. public RESULT release()
  2483. {
  2484. return FMOD5_ChannelGroup_Release(this.handle);
  2485. }
  2486. // Nested channel groups.
  2487. public RESULT addGroup(ChannelGroup group, bool propagatedspclock = true)
  2488. {
  2489. return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, IntPtr.Zero);
  2490. }
  2491. public RESULT addGroup(ChannelGroup group, bool propagatedspclock, out DSPConnection connection)
  2492. {
  2493. return FMOD5_ChannelGroup_AddGroup(this.handle, group.handle, propagatedspclock, out connection.handle);
  2494. }
  2495. public RESULT getNumGroups(out int numgroups)
  2496. {
  2497. return FMOD5_ChannelGroup_GetNumGroups(this.handle, out numgroups);
  2498. }
  2499. public RESULT getGroup(int index, out ChannelGroup group)
  2500. {
  2501. return FMOD5_ChannelGroup_GetGroup(this.handle, index, out group.handle);
  2502. }
  2503. public RESULT getParentGroup(out ChannelGroup group)
  2504. {
  2505. return FMOD5_ChannelGroup_GetParentGroup(this.handle, out group.handle);
  2506. }
  2507. // Information only functions.
  2508. public RESULT getName(out string name, int namelen)
  2509. {
  2510. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  2511. RESULT result = FMOD5_ChannelGroup_GetName(this.handle, stringMem, namelen);
  2512. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  2513. {
  2514. name = encoder.stringFromNative(stringMem);
  2515. }
  2516. Marshal.FreeHGlobal(stringMem);
  2517. return result;
  2518. }
  2519. public RESULT getNumChannels(out int numchannels)
  2520. {
  2521. return FMOD5_ChannelGroup_GetNumChannels(this.handle, out numchannels);
  2522. }
  2523. public RESULT getChannel(int index, out Channel channel)
  2524. {
  2525. return FMOD5_ChannelGroup_GetChannel(this.handle, index, out channel.handle);
  2526. }
  2527. public RESULT getSystemObject(out System system)
  2528. {
  2529. return FMOD5_ChannelGroup_GetSystemObject(this.handle, out system.handle);
  2530. }
  2531. // General control functionality for Channels and ChannelGroups.
  2532. public RESULT stop()
  2533. {
  2534. return FMOD5_ChannelGroup_Stop(this.handle);
  2535. }
  2536. public RESULT setPaused(bool paused)
  2537. {
  2538. return FMOD5_ChannelGroup_SetPaused(this.handle, paused);
  2539. }
  2540. public RESULT getPaused(out bool paused)
  2541. {
  2542. return FMOD5_ChannelGroup_GetPaused(this.handle, out paused);
  2543. }
  2544. public RESULT setVolume(float volume)
  2545. {
  2546. return FMOD5_ChannelGroup_SetVolume(this.handle, volume);
  2547. }
  2548. public RESULT getVolume(out float volume)
  2549. {
  2550. return FMOD5_ChannelGroup_GetVolume(this.handle, out volume);
  2551. }
  2552. public RESULT setVolumeRamp(bool ramp)
  2553. {
  2554. return FMOD5_ChannelGroup_SetVolumeRamp(this.handle, ramp);
  2555. }
  2556. public RESULT getVolumeRamp(out bool ramp)
  2557. {
  2558. return FMOD5_ChannelGroup_GetVolumeRamp(this.handle, out ramp);
  2559. }
  2560. public RESULT getAudibility(out float audibility)
  2561. {
  2562. return FMOD5_ChannelGroup_GetAudibility(this.handle, out audibility);
  2563. }
  2564. public RESULT setPitch(float pitch)
  2565. {
  2566. return FMOD5_ChannelGroup_SetPitch(this.handle, pitch);
  2567. }
  2568. public RESULT getPitch(out float pitch)
  2569. {
  2570. return FMOD5_ChannelGroup_GetPitch(this.handle, out pitch);
  2571. }
  2572. public RESULT setMute(bool mute)
  2573. {
  2574. return FMOD5_ChannelGroup_SetMute(this.handle, mute);
  2575. }
  2576. public RESULT getMute(out bool mute)
  2577. {
  2578. return FMOD5_ChannelGroup_GetMute(this.handle, out mute);
  2579. }
  2580. public RESULT setReverbProperties(int instance, float wet)
  2581. {
  2582. return FMOD5_ChannelGroup_SetReverbProperties(this.handle, instance, wet);
  2583. }
  2584. public RESULT getReverbProperties(int instance, out float wet)
  2585. {
  2586. return FMOD5_ChannelGroup_GetReverbProperties(this.handle, instance, out wet);
  2587. }
  2588. public RESULT setLowPassGain(float gain)
  2589. {
  2590. return FMOD5_ChannelGroup_SetLowPassGain(this.handle, gain);
  2591. }
  2592. public RESULT getLowPassGain(out float gain)
  2593. {
  2594. return FMOD5_ChannelGroup_GetLowPassGain(this.handle, out gain);
  2595. }
  2596. public RESULT setMode(MODE mode)
  2597. {
  2598. return FMOD5_ChannelGroup_SetMode(this.handle, mode);
  2599. }
  2600. public RESULT getMode(out MODE mode)
  2601. {
  2602. return FMOD5_ChannelGroup_GetMode(this.handle, out mode);
  2603. }
  2604. public RESULT setCallback(CHANNELCONTROL_CALLBACK callback)
  2605. {
  2606. return FMOD5_ChannelGroup_SetCallback(this.handle, callback);
  2607. }
  2608. public RESULT isPlaying(out bool isplaying)
  2609. {
  2610. return FMOD5_ChannelGroup_IsPlaying(this.handle, out isplaying);
  2611. }
  2612. // Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
  2613. public RESULT setPan(float pan)
  2614. {
  2615. return FMOD5_ChannelGroup_SetPan(this.handle, pan);
  2616. }
  2617. public RESULT setMixLevelsOutput(float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright)
  2618. {
  2619. return FMOD5_ChannelGroup_SetMixLevelsOutput(this.handle, frontleft, frontright, center, lfe, surroundleft, surroundright, backleft, backright);
  2620. }
  2621. public RESULT setMixLevelsInput(float[] levels, int numlevels)
  2622. {
  2623. return FMOD5_ChannelGroup_SetMixLevelsInput(this.handle, levels, numlevels);
  2624. }
  2625. public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop)
  2626. {
  2627. return FMOD5_ChannelGroup_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop);
  2628. }
  2629. public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop)
  2630. {
  2631. return FMOD5_ChannelGroup_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop);
  2632. }
  2633. // Clock based functionality.
  2634. public RESULT getDSPClock(out ulong dspclock, out ulong parentclock)
  2635. {
  2636. return FMOD5_ChannelGroup_GetDSPClock(this.handle, out dspclock, out parentclock);
  2637. }
  2638. public RESULT setDelay(ulong dspclock_start, ulong dspclock_end, bool stopchannels)
  2639. {
  2640. return FMOD5_ChannelGroup_SetDelay(this.handle, dspclock_start, dspclock_end, stopchannels);
  2641. }
  2642. public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end)
  2643. {
  2644. return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, IntPtr.Zero);
  2645. }
  2646. public RESULT getDelay(out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels)
  2647. {
  2648. return FMOD5_ChannelGroup_GetDelay(this.handle, out dspclock_start, out dspclock_end, out stopchannels);
  2649. }
  2650. public RESULT addFadePoint(ulong dspclock, float volume)
  2651. {
  2652. return FMOD5_ChannelGroup_AddFadePoint(this.handle, dspclock, volume);
  2653. }
  2654. public RESULT setFadePointRamp(ulong dspclock, float volume)
  2655. {
  2656. return FMOD5_ChannelGroup_SetFadePointRamp(this.handle, dspclock, volume);
  2657. }
  2658. public RESULT removeFadePoints(ulong dspclock_start, ulong dspclock_end)
  2659. {
  2660. return FMOD5_ChannelGroup_RemoveFadePoints(this.handle, dspclock_start, dspclock_end);
  2661. }
  2662. public RESULT getFadePoints(ref uint numpoints, ulong[] point_dspclock, float[] point_volume)
  2663. {
  2664. return FMOD5_ChannelGroup_GetFadePoints(this.handle, ref numpoints, point_dspclock, point_volume);
  2665. }
  2666. // DSP effects.
  2667. public RESULT getDSP(int index, out DSP dsp)
  2668. {
  2669. return FMOD5_ChannelGroup_GetDSP(this.handle, index, out dsp.handle);
  2670. }
  2671. public RESULT addDSP(int index, DSP dsp)
  2672. {
  2673. return FMOD5_ChannelGroup_AddDSP(this.handle, index, dsp.handle);
  2674. }
  2675. public RESULT removeDSP(DSP dsp)
  2676. {
  2677. return FMOD5_ChannelGroup_RemoveDSP(this.handle, dsp.handle);
  2678. }
  2679. public RESULT getNumDSPs(out int numdsps)
  2680. {
  2681. return FMOD5_ChannelGroup_GetNumDSPs(this.handle, out numdsps);
  2682. }
  2683. public RESULT setDSPIndex(DSP dsp, int index)
  2684. {
  2685. return FMOD5_ChannelGroup_SetDSPIndex(this.handle, dsp.handle, index);
  2686. }
  2687. public RESULT getDSPIndex(DSP dsp, out int index)
  2688. {
  2689. return FMOD5_ChannelGroup_GetDSPIndex(this.handle, dsp.handle, out index);
  2690. }
  2691. // 3D functionality.
  2692. public RESULT set3DAttributes(ref VECTOR pos, ref VECTOR vel)
  2693. {
  2694. return FMOD5_ChannelGroup_Set3DAttributes(this.handle, ref pos, ref vel);
  2695. }
  2696. public RESULT get3DAttributes(out VECTOR pos, out VECTOR vel)
  2697. {
  2698. return FMOD5_ChannelGroup_Get3DAttributes(this.handle, out pos, out vel);
  2699. }
  2700. public RESULT set3DMinMaxDistance(float mindistance, float maxdistance)
  2701. {
  2702. return FMOD5_ChannelGroup_Set3DMinMaxDistance(this.handle, mindistance, maxdistance);
  2703. }
  2704. public RESULT get3DMinMaxDistance(out float mindistance, out float maxdistance)
  2705. {
  2706. return FMOD5_ChannelGroup_Get3DMinMaxDistance(this.handle, out mindistance, out maxdistance);
  2707. }
  2708. public RESULT set3DConeSettings(float insideconeangle, float outsideconeangle, float outsidevolume)
  2709. {
  2710. return FMOD5_ChannelGroup_Set3DConeSettings(this.handle, insideconeangle, outsideconeangle, outsidevolume);
  2711. }
  2712. public RESULT get3DConeSettings(out float insideconeangle, out float outsideconeangle, out float outsidevolume)
  2713. {
  2714. return FMOD5_ChannelGroup_Get3DConeSettings(this.handle, out insideconeangle, out outsideconeangle, out outsidevolume);
  2715. }
  2716. public RESULT set3DConeOrientation(ref VECTOR orientation)
  2717. {
  2718. return FMOD5_ChannelGroup_Set3DConeOrientation(this.handle, ref orientation);
  2719. }
  2720. public RESULT get3DConeOrientation(out VECTOR orientation)
  2721. {
  2722. return FMOD5_ChannelGroup_Get3DConeOrientation(this.handle, out orientation);
  2723. }
  2724. public RESULT set3DCustomRolloff(ref VECTOR points, int numpoints)
  2725. {
  2726. return FMOD5_ChannelGroup_Set3DCustomRolloff(this.handle, ref points, numpoints);
  2727. }
  2728. public RESULT get3DCustomRolloff(out IntPtr points, out int numpoints)
  2729. {
  2730. return FMOD5_ChannelGroup_Get3DCustomRolloff(this.handle, out points, out numpoints);
  2731. }
  2732. public RESULT set3DOcclusion(float directocclusion, float reverbocclusion)
  2733. {
  2734. return FMOD5_ChannelGroup_Set3DOcclusion(this.handle, directocclusion, reverbocclusion);
  2735. }
  2736. public RESULT get3DOcclusion(out float directocclusion, out float reverbocclusion)
  2737. {
  2738. return FMOD5_ChannelGroup_Get3DOcclusion(this.handle, out directocclusion, out reverbocclusion);
  2739. }
  2740. public RESULT set3DSpread(float angle)
  2741. {
  2742. return FMOD5_ChannelGroup_Set3DSpread(this.handle, angle);
  2743. }
  2744. public RESULT get3DSpread(out float angle)
  2745. {
  2746. return FMOD5_ChannelGroup_Get3DSpread(this.handle, out angle);
  2747. }
  2748. public RESULT set3DLevel(float level)
  2749. {
  2750. return FMOD5_ChannelGroup_Set3DLevel(this.handle, level);
  2751. }
  2752. public RESULT get3DLevel(out float level)
  2753. {
  2754. return FMOD5_ChannelGroup_Get3DLevel(this.handle, out level);
  2755. }
  2756. public RESULT set3DDopplerLevel(float level)
  2757. {
  2758. return FMOD5_ChannelGroup_Set3DDopplerLevel(this.handle, level);
  2759. }
  2760. public RESULT get3DDopplerLevel(out float level)
  2761. {
  2762. return FMOD5_ChannelGroup_Get3DDopplerLevel(this.handle, out level);
  2763. }
  2764. public RESULT set3DDistanceFilter(bool custom, float customLevel, float centerFreq)
  2765. {
  2766. return FMOD5_ChannelGroup_Set3DDistanceFilter(this.handle, custom, customLevel, centerFreq);
  2767. }
  2768. public RESULT get3DDistanceFilter(out bool custom, out float customLevel, out float centerFreq)
  2769. {
  2770. return FMOD5_ChannelGroup_Get3DDistanceFilter(this.handle, out custom, out customLevel, out centerFreq);
  2771. }
  2772. // Userdata set/get.
  2773. public RESULT setUserData(IntPtr userdata)
  2774. {
  2775. return FMOD5_ChannelGroup_SetUserData(this.handle, userdata);
  2776. }
  2777. public RESULT getUserData(out IntPtr userdata)
  2778. {
  2779. return FMOD5_ChannelGroup_GetUserData(this.handle, out userdata);
  2780. }
  2781. #region importfunctions
  2782. [DllImport(VERSION.dll)]
  2783. private static extern RESULT FMOD5_ChannelGroup_Release (IntPtr channelgroup);
  2784. [DllImport(VERSION.dll)]
  2785. private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, IntPtr zero);
  2786. [DllImport(VERSION.dll)]
  2787. private static extern RESULT FMOD5_ChannelGroup_AddGroup (IntPtr channelgroup, IntPtr group, bool propagatedspclock, out IntPtr connection);
  2788. [DllImport(VERSION.dll)]
  2789. private static extern RESULT FMOD5_ChannelGroup_GetNumGroups (IntPtr channelgroup, out int numgroups);
  2790. [DllImport(VERSION.dll)]
  2791. private static extern RESULT FMOD5_ChannelGroup_GetGroup (IntPtr channelgroup, int index, out IntPtr group);
  2792. [DllImport(VERSION.dll)]
  2793. private static extern RESULT FMOD5_ChannelGroup_GetParentGroup (IntPtr channelgroup, out IntPtr group);
  2794. [DllImport(VERSION.dll)]
  2795. private static extern RESULT FMOD5_ChannelGroup_GetName (IntPtr channelgroup, IntPtr name, int namelen);
  2796. [DllImport(VERSION.dll)]
  2797. private static extern RESULT FMOD5_ChannelGroup_GetNumChannels (IntPtr channelgroup, out int numchannels);
  2798. [DllImport(VERSION.dll)]
  2799. private static extern RESULT FMOD5_ChannelGroup_GetChannel (IntPtr channelgroup, int index, out IntPtr channel);
  2800. [DllImport(VERSION.dll)]
  2801. private static extern RESULT FMOD5_ChannelGroup_GetSystemObject (IntPtr channelgroup, out IntPtr system);
  2802. [DllImport(VERSION.dll)]
  2803. private static extern RESULT FMOD5_ChannelGroup_Stop (IntPtr channelgroup);
  2804. [DllImport(VERSION.dll)]
  2805. private static extern RESULT FMOD5_ChannelGroup_SetPaused (IntPtr channelgroup, bool paused);
  2806. [DllImport(VERSION.dll)]
  2807. private static extern RESULT FMOD5_ChannelGroup_GetPaused (IntPtr channelgroup, out bool paused);
  2808. [DllImport(VERSION.dll)]
  2809. private static extern RESULT FMOD5_ChannelGroup_SetVolume (IntPtr channelgroup, float volume);
  2810. [DllImport(VERSION.dll)]
  2811. private static extern RESULT FMOD5_ChannelGroup_GetVolume (IntPtr channelgroup, out float volume);
  2812. [DllImport(VERSION.dll)]
  2813. private static extern RESULT FMOD5_ChannelGroup_SetVolumeRamp (IntPtr channelgroup, bool ramp);
  2814. [DllImport(VERSION.dll)]
  2815. private static extern RESULT FMOD5_ChannelGroup_GetVolumeRamp (IntPtr channelgroup, out bool ramp);
  2816. [DllImport(VERSION.dll)]
  2817. private static extern RESULT FMOD5_ChannelGroup_GetAudibility (IntPtr channelgroup, out float audibility);
  2818. [DllImport(VERSION.dll)]
  2819. private static extern RESULT FMOD5_ChannelGroup_SetPitch (IntPtr channelgroup, float pitch);
  2820. [DllImport(VERSION.dll)]
  2821. private static extern RESULT FMOD5_ChannelGroup_GetPitch (IntPtr channelgroup, out float pitch);
  2822. [DllImport(VERSION.dll)]
  2823. private static extern RESULT FMOD5_ChannelGroup_SetMute (IntPtr channelgroup, bool mute);
  2824. [DllImport(VERSION.dll)]
  2825. private static extern RESULT FMOD5_ChannelGroup_GetMute (IntPtr channelgroup, out bool mute);
  2826. [DllImport(VERSION.dll)]
  2827. private static extern RESULT FMOD5_ChannelGroup_SetReverbProperties (IntPtr channelgroup, int instance, float wet);
  2828. [DllImport(VERSION.dll)]
  2829. private static extern RESULT FMOD5_ChannelGroup_GetReverbProperties (IntPtr channelgroup, int instance, out float wet);
  2830. [DllImport(VERSION.dll)]
  2831. private static extern RESULT FMOD5_ChannelGroup_SetLowPassGain (IntPtr channelgroup, float gain);
  2832. [DllImport(VERSION.dll)]
  2833. private static extern RESULT FMOD5_ChannelGroup_GetLowPassGain (IntPtr channelgroup, out float gain);
  2834. [DllImport(VERSION.dll)]
  2835. private static extern RESULT FMOD5_ChannelGroup_SetMode (IntPtr channelgroup, MODE mode);
  2836. [DllImport(VERSION.dll)]
  2837. private static extern RESULT FMOD5_ChannelGroup_GetMode (IntPtr channelgroup, out MODE mode);
  2838. [DllImport(VERSION.dll)]
  2839. private static extern RESULT FMOD5_ChannelGroup_SetCallback (IntPtr channelgroup, CHANNELCONTROL_CALLBACK callback);
  2840. [DllImport(VERSION.dll)]
  2841. private static extern RESULT FMOD5_ChannelGroup_IsPlaying (IntPtr channelgroup, out bool isplaying);
  2842. [DllImport(VERSION.dll)]
  2843. private static extern RESULT FMOD5_ChannelGroup_SetPan (IntPtr channelgroup, float pan);
  2844. [DllImport(VERSION.dll)]
  2845. private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsOutput (IntPtr channelgroup, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
  2846. [DllImport(VERSION.dll)]
  2847. private static extern RESULT FMOD5_ChannelGroup_SetMixLevelsInput (IntPtr channelgroup, float[] levels, int numlevels);
  2848. [DllImport(VERSION.dll)]
  2849. private static extern RESULT FMOD5_ChannelGroup_SetMixMatrix (IntPtr channelgroup, float[] matrix, int outchannels, int inchannels, int inchannel_hop);
  2850. [DllImport(VERSION.dll)]
  2851. private static extern RESULT FMOD5_ChannelGroup_GetMixMatrix (IntPtr channelgroup, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
  2852. [DllImport(VERSION.dll)]
  2853. private static extern RESULT FMOD5_ChannelGroup_GetDSPClock (IntPtr channelgroup, out ulong dspclock, out ulong parentclock);
  2854. [DllImport(VERSION.dll)]
  2855. private static extern RESULT FMOD5_ChannelGroup_SetDelay (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end, bool stopchannels);
  2856. [DllImport(VERSION.dll)]
  2857. private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, IntPtr zero);
  2858. [DllImport(VERSION.dll)]
  2859. private static extern RESULT FMOD5_ChannelGroup_GetDelay (IntPtr channelgroup, out ulong dspclock_start, out ulong dspclock_end, out bool stopchannels);
  2860. [DllImport(VERSION.dll)]
  2861. private static extern RESULT FMOD5_ChannelGroup_AddFadePoint (IntPtr channelgroup, ulong dspclock, float volume);
  2862. [DllImport(VERSION.dll)]
  2863. private static extern RESULT FMOD5_ChannelGroup_SetFadePointRamp (IntPtr channelgroup, ulong dspclock, float volume);
  2864. [DllImport(VERSION.dll)]
  2865. private static extern RESULT FMOD5_ChannelGroup_RemoveFadePoints (IntPtr channelgroup, ulong dspclock_start, ulong dspclock_end);
  2866. [DllImport(VERSION.dll)]
  2867. private static extern RESULT FMOD5_ChannelGroup_GetFadePoints (IntPtr channelgroup, ref uint numpoints, ulong[] point_dspclock, float[] point_volume);
  2868. [DllImport(VERSION.dll)]
  2869. private static extern RESULT FMOD5_ChannelGroup_GetDSP (IntPtr channelgroup, int index, out IntPtr dsp);
  2870. [DllImport(VERSION.dll)]
  2871. private static extern RESULT FMOD5_ChannelGroup_AddDSP (IntPtr channelgroup, int index, IntPtr dsp);
  2872. [DllImport(VERSION.dll)]
  2873. private static extern RESULT FMOD5_ChannelGroup_RemoveDSP (IntPtr channelgroup, IntPtr dsp);
  2874. [DllImport(VERSION.dll)]
  2875. private static extern RESULT FMOD5_ChannelGroup_GetNumDSPs (IntPtr channelgroup, out int numdsps);
  2876. [DllImport(VERSION.dll)]
  2877. private static extern RESULT FMOD5_ChannelGroup_SetDSPIndex (IntPtr channelgroup, IntPtr dsp, int index);
  2878. [DllImport(VERSION.dll)]
  2879. private static extern RESULT FMOD5_ChannelGroup_GetDSPIndex (IntPtr channelgroup, IntPtr dsp, out int index);
  2880. [DllImport(VERSION.dll)]
  2881. private static extern RESULT FMOD5_ChannelGroup_Set3DAttributes (IntPtr channelgroup, ref VECTOR pos, ref VECTOR vel);
  2882. [DllImport(VERSION.dll)]
  2883. private static extern RESULT FMOD5_ChannelGroup_Get3DAttributes (IntPtr channelgroup, out VECTOR pos, out VECTOR vel);
  2884. [DllImport(VERSION.dll)]
  2885. private static extern RESULT FMOD5_ChannelGroup_Set3DMinMaxDistance (IntPtr channelgroup, float mindistance, float maxdistance);
  2886. [DllImport(VERSION.dll)]
  2887. private static extern RESULT FMOD5_ChannelGroup_Get3DMinMaxDistance (IntPtr channelgroup, out float mindistance, out float maxdistance);
  2888. [DllImport(VERSION.dll)]
  2889. private static extern RESULT FMOD5_ChannelGroup_Set3DConeSettings (IntPtr channelgroup, float insideconeangle, float outsideconeangle, float outsidevolume);
  2890. [DllImport(VERSION.dll)]
  2891. private static extern RESULT FMOD5_ChannelGroup_Get3DConeSettings (IntPtr channelgroup, out float insideconeangle, out float outsideconeangle, out float outsidevolume);
  2892. [DllImport(VERSION.dll)]
  2893. private static extern RESULT FMOD5_ChannelGroup_Set3DConeOrientation(IntPtr channelgroup, ref VECTOR orientation);
  2894. [DllImport(VERSION.dll)]
  2895. private static extern RESULT FMOD5_ChannelGroup_Get3DConeOrientation(IntPtr channelgroup, out VECTOR orientation);
  2896. [DllImport(VERSION.dll)]
  2897. private static extern RESULT FMOD5_ChannelGroup_Set3DCustomRolloff (IntPtr channelgroup, ref VECTOR points, int numpoints);
  2898. [DllImport(VERSION.dll)]
  2899. private static extern RESULT FMOD5_ChannelGroup_Get3DCustomRolloff (IntPtr channelgroup, out IntPtr points, out int numpoints);
  2900. [DllImport(VERSION.dll)]
  2901. private static extern RESULT FMOD5_ChannelGroup_Set3DOcclusion (IntPtr channelgroup, float directocclusion, float reverbocclusion);
  2902. [DllImport(VERSION.dll)]
  2903. private static extern RESULT FMOD5_ChannelGroup_Get3DOcclusion (IntPtr channelgroup, out float directocclusion, out float reverbocclusion);
  2904. [DllImport(VERSION.dll)]
  2905. private static extern RESULT FMOD5_ChannelGroup_Set3DSpread (IntPtr channelgroup, float angle);
  2906. [DllImport(VERSION.dll)]
  2907. private static extern RESULT FMOD5_ChannelGroup_Get3DSpread (IntPtr channelgroup, out float angle);
  2908. [DllImport(VERSION.dll)]
  2909. private static extern RESULT FMOD5_ChannelGroup_Set3DLevel (IntPtr channelgroup, float level);
  2910. [DllImport(VERSION.dll)]
  2911. private static extern RESULT FMOD5_ChannelGroup_Get3DLevel (IntPtr channelgroup, out float level);
  2912. [DllImport(VERSION.dll)]
  2913. private static extern RESULT FMOD5_ChannelGroup_Set3DDopplerLevel (IntPtr channelgroup, float level);
  2914. [DllImport(VERSION.dll)]
  2915. private static extern RESULT FMOD5_ChannelGroup_Get3DDopplerLevel (IntPtr channelgroup, out float level);
  2916. [DllImport(VERSION.dll)]
  2917. private static extern RESULT FMOD5_ChannelGroup_Set3DDistanceFilter (IntPtr channelgroup, bool custom, float customLevel, float centerFreq);
  2918. [DllImport(VERSION.dll)]
  2919. private static extern RESULT FMOD5_ChannelGroup_Get3DDistanceFilter (IntPtr channelgroup, out bool custom, out float customLevel, out float centerFreq);
  2920. [DllImport(VERSION.dll)]
  2921. private static extern RESULT FMOD5_ChannelGroup_SetUserData (IntPtr channelgroup, IntPtr userdata);
  2922. [DllImport(VERSION.dll)]
  2923. private static extern RESULT FMOD5_ChannelGroup_GetUserData (IntPtr channelgroup, out IntPtr userdata);
  2924. #endregion
  2925. #region wrapperinternal
  2926. public IntPtr handle;
  2927. public ChannelGroup(IntPtr ptr) { this.handle = ptr; }
  2928. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  2929. public void clearHandle() { this.handle = IntPtr.Zero; }
  2930. #endregion
  2931. }
  2932. /*
  2933. 'SoundGroup' API
  2934. */
  2935. public struct SoundGroup
  2936. {
  2937. public RESULT release()
  2938. {
  2939. return FMOD5_SoundGroup_Release(this.handle);
  2940. }
  2941. public RESULT getSystemObject(out System system)
  2942. {
  2943. return FMOD5_SoundGroup_GetSystemObject(this.handle, out system.handle);
  2944. }
  2945. // SoundGroup control functions.
  2946. public RESULT setMaxAudible(int maxaudible)
  2947. {
  2948. return FMOD5_SoundGroup_SetMaxAudible(this.handle, maxaudible);
  2949. }
  2950. public RESULT getMaxAudible(out int maxaudible)
  2951. {
  2952. return FMOD5_SoundGroup_GetMaxAudible(this.handle, out maxaudible);
  2953. }
  2954. public RESULT setMaxAudibleBehavior(SOUNDGROUP_BEHAVIOR behavior)
  2955. {
  2956. return FMOD5_SoundGroup_SetMaxAudibleBehavior(this.handle, behavior);
  2957. }
  2958. public RESULT getMaxAudibleBehavior(out SOUNDGROUP_BEHAVIOR behavior)
  2959. {
  2960. return FMOD5_SoundGroup_GetMaxAudibleBehavior(this.handle, out behavior);
  2961. }
  2962. public RESULT setMuteFadeSpeed(float speed)
  2963. {
  2964. return FMOD5_SoundGroup_SetMuteFadeSpeed(this.handle, speed);
  2965. }
  2966. public RESULT getMuteFadeSpeed(out float speed)
  2967. {
  2968. return FMOD5_SoundGroup_GetMuteFadeSpeed(this.handle, out speed);
  2969. }
  2970. public RESULT setVolume(float volume)
  2971. {
  2972. return FMOD5_SoundGroup_SetVolume(this.handle, volume);
  2973. }
  2974. public RESULT getVolume(out float volume)
  2975. {
  2976. return FMOD5_SoundGroup_GetVolume(this.handle, out volume);
  2977. }
  2978. public RESULT stop()
  2979. {
  2980. return FMOD5_SoundGroup_Stop(this.handle);
  2981. }
  2982. // Information only functions.
  2983. public RESULT getName(out string name, int namelen)
  2984. {
  2985. IntPtr stringMem = Marshal.AllocHGlobal(namelen);
  2986. RESULT result = FMOD5_SoundGroup_GetName(this.handle, stringMem, namelen);
  2987. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  2988. {
  2989. name = encoder.stringFromNative(stringMem);
  2990. }
  2991. Marshal.FreeHGlobal(stringMem);
  2992. return result;
  2993. }
  2994. public RESULT getNumSounds(out int numsounds)
  2995. {
  2996. return FMOD5_SoundGroup_GetNumSounds(this.handle, out numsounds);
  2997. }
  2998. public RESULT getSound(int index, out Sound sound)
  2999. {
  3000. return FMOD5_SoundGroup_GetSound(this.handle, index, out sound.handle);
  3001. }
  3002. public RESULT getNumPlaying(out int numplaying)
  3003. {
  3004. return FMOD5_SoundGroup_GetNumPlaying(this.handle, out numplaying);
  3005. }
  3006. // Userdata set/get.
  3007. public RESULT setUserData(IntPtr userdata)
  3008. {
  3009. return FMOD5_SoundGroup_SetUserData(this.handle, userdata);
  3010. }
  3011. public RESULT getUserData(out IntPtr userdata)
  3012. {
  3013. return FMOD5_SoundGroup_GetUserData(this.handle, out userdata);
  3014. }
  3015. #region importfunctions
  3016. [DllImport(VERSION.dll)]
  3017. private static extern RESULT FMOD5_SoundGroup_Release (IntPtr soundgroup);
  3018. [DllImport(VERSION.dll)]
  3019. private static extern RESULT FMOD5_SoundGroup_GetSystemObject (IntPtr soundgroup, out IntPtr system);
  3020. [DllImport(VERSION.dll)]
  3021. private static extern RESULT FMOD5_SoundGroup_SetMaxAudible (IntPtr soundgroup, int maxaudible);
  3022. [DllImport(VERSION.dll)]
  3023. private static extern RESULT FMOD5_SoundGroup_GetMaxAudible (IntPtr soundgroup, out int maxaudible);
  3024. [DllImport(VERSION.dll)]
  3025. private static extern RESULT FMOD5_SoundGroup_SetMaxAudibleBehavior (IntPtr soundgroup, SOUNDGROUP_BEHAVIOR behavior);
  3026. [DllImport(VERSION.dll)]
  3027. private static extern RESULT FMOD5_SoundGroup_GetMaxAudibleBehavior (IntPtr soundgroup, out SOUNDGROUP_BEHAVIOR behavior);
  3028. [DllImport(VERSION.dll)]
  3029. private static extern RESULT FMOD5_SoundGroup_SetMuteFadeSpeed (IntPtr soundgroup, float speed);
  3030. [DllImport(VERSION.dll)]
  3031. private static extern RESULT FMOD5_SoundGroup_GetMuteFadeSpeed (IntPtr soundgroup, out float speed);
  3032. [DllImport(VERSION.dll)]
  3033. private static extern RESULT FMOD5_SoundGroup_SetVolume (IntPtr soundgroup, float volume);
  3034. [DllImport(VERSION.dll)]
  3035. private static extern RESULT FMOD5_SoundGroup_GetVolume (IntPtr soundgroup, out float volume);
  3036. [DllImport(VERSION.dll)]
  3037. private static extern RESULT FMOD5_SoundGroup_Stop (IntPtr soundgroup);
  3038. [DllImport(VERSION.dll)]
  3039. private static extern RESULT FMOD5_SoundGroup_GetName (IntPtr soundgroup, IntPtr name, int namelen);
  3040. [DllImport(VERSION.dll)]
  3041. private static extern RESULT FMOD5_SoundGroup_GetNumSounds (IntPtr soundgroup, out int numsounds);
  3042. [DllImport(VERSION.dll)]
  3043. private static extern RESULT FMOD5_SoundGroup_GetSound (IntPtr soundgroup, int index, out IntPtr sound);
  3044. [DllImport(VERSION.dll)]
  3045. private static extern RESULT FMOD5_SoundGroup_GetNumPlaying (IntPtr soundgroup, out int numplaying);
  3046. [DllImport(VERSION.dll)]
  3047. private static extern RESULT FMOD5_SoundGroup_SetUserData (IntPtr soundgroup, IntPtr userdata);
  3048. [DllImport(VERSION.dll)]
  3049. private static extern RESULT FMOD5_SoundGroup_GetUserData (IntPtr soundgroup, out IntPtr userdata);
  3050. #endregion
  3051. #region wrapperinternal
  3052. public IntPtr handle;
  3053. public SoundGroup(IntPtr ptr) { this.handle = ptr; }
  3054. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  3055. public void clearHandle() { this.handle = IntPtr.Zero; }
  3056. #endregion
  3057. }
  3058. /*
  3059. 'DSP' API
  3060. */
  3061. public struct DSP
  3062. {
  3063. public RESULT release()
  3064. {
  3065. return FMOD5_DSP_Release(this.handle);
  3066. }
  3067. public RESULT getSystemObject(out System system)
  3068. {
  3069. return FMOD5_DSP_GetSystemObject(this.handle, out system.handle);
  3070. }
  3071. // Connection / disconnection / input and output enumeration.
  3072. public RESULT addInput(DSP input)
  3073. {
  3074. return FMOD5_DSP_AddInput(this.handle, input.handle, IntPtr.Zero, DSPCONNECTION_TYPE.STANDARD);
  3075. }
  3076. public RESULT addInput(DSP input, out DSPConnection connection, DSPCONNECTION_TYPE type = DSPCONNECTION_TYPE.STANDARD)
  3077. {
  3078. return FMOD5_DSP_AddInput(this.handle, input.handle, out connection.handle, type);
  3079. }
  3080. public RESULT disconnectFrom(DSP target, DSPConnection connection)
  3081. {
  3082. return FMOD5_DSP_DisconnectFrom(this.handle, target.handle, connection.handle);
  3083. }
  3084. public RESULT disconnectAll(bool inputs, bool outputs)
  3085. {
  3086. return FMOD5_DSP_DisconnectAll(this.handle, inputs, outputs);
  3087. }
  3088. public RESULT getNumInputs(out int numinputs)
  3089. {
  3090. return FMOD5_DSP_GetNumInputs(this.handle, out numinputs);
  3091. }
  3092. public RESULT getNumOutputs(out int numoutputs)
  3093. {
  3094. return FMOD5_DSP_GetNumOutputs(this.handle, out numoutputs);
  3095. }
  3096. public RESULT getInput(int index, out DSP input, out DSPConnection inputconnection)
  3097. {
  3098. return FMOD5_DSP_GetInput(this.handle, index, out input.handle, out inputconnection.handle);
  3099. }
  3100. public RESULT getOutput(int index, out DSP output, out DSPConnection outputconnection)
  3101. {
  3102. return FMOD5_DSP_GetOutput(this.handle, index, out output.handle, out outputconnection.handle);
  3103. }
  3104. // DSP unit control.
  3105. public RESULT setActive(bool active)
  3106. {
  3107. return FMOD5_DSP_SetActive(this.handle, active);
  3108. }
  3109. public RESULT getActive(out bool active)
  3110. {
  3111. return FMOD5_DSP_GetActive(this.handle, out active);
  3112. }
  3113. public RESULT setBypass(bool bypass)
  3114. {
  3115. return FMOD5_DSP_SetBypass(this.handle, bypass);
  3116. }
  3117. public RESULT getBypass(out bool bypass)
  3118. {
  3119. return FMOD5_DSP_GetBypass(this.handle, out bypass);
  3120. }
  3121. public RESULT setWetDryMix(float prewet, float postwet, float dry)
  3122. {
  3123. return FMOD5_DSP_SetWetDryMix(this.handle, prewet, postwet, dry);
  3124. }
  3125. public RESULT getWetDryMix(out float prewet, out float postwet, out float dry)
  3126. {
  3127. return FMOD5_DSP_GetWetDryMix(this.handle, out prewet, out postwet, out dry);
  3128. }
  3129. public RESULT setChannelFormat(CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode)
  3130. {
  3131. return FMOD5_DSP_SetChannelFormat(this.handle, channelmask, numchannels, source_speakermode);
  3132. }
  3133. public RESULT getChannelFormat(out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode)
  3134. {
  3135. return FMOD5_DSP_GetChannelFormat(this.handle, out channelmask, out numchannels, out source_speakermode);
  3136. }
  3137. public RESULT getOutputChannelFormat(CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode)
  3138. {
  3139. return FMOD5_DSP_GetOutputChannelFormat(this.handle, inmask, inchannels, inspeakermode, out outmask, out outchannels, out outspeakermode);
  3140. }
  3141. public RESULT reset()
  3142. {
  3143. return FMOD5_DSP_Reset(this.handle);
  3144. }
  3145. public RESULT setCallback(DSP_CALLBACK callback)
  3146. {
  3147. return FMOD5_DSP_SetCallback(this.handle, callback);
  3148. }
  3149. // DSP parameter control.
  3150. public RESULT setParameterFloat(int index, float value)
  3151. {
  3152. return FMOD5_DSP_SetParameterFloat(this.handle, index, value);
  3153. }
  3154. public RESULT setParameterInt(int index, int value)
  3155. {
  3156. return FMOD5_DSP_SetParameterInt(this.handle, index, value);
  3157. }
  3158. public RESULT setParameterBool(int index, bool value)
  3159. {
  3160. return FMOD5_DSP_SetParameterBool(this.handle, index, value);
  3161. }
  3162. public RESULT setParameterData(int index, byte[] data)
  3163. {
  3164. return FMOD5_DSP_SetParameterData(this.handle, index, Marshal.UnsafeAddrOfPinnedArrayElement(data, 0), (uint)data.Length);
  3165. }
  3166. public RESULT getParameterFloat(int index, out float value)
  3167. {
  3168. return FMOD5_DSP_GetParameterFloat(this.handle, index, out value, IntPtr.Zero, 0);
  3169. }
  3170. public RESULT getParameterInt(int index, out int value)
  3171. {
  3172. return FMOD5_DSP_GetParameterInt(this.handle, index, out value, IntPtr.Zero, 0);
  3173. }
  3174. public RESULT getParameterBool(int index, out bool value)
  3175. {
  3176. return FMOD5_DSP_GetParameterBool(this.handle, index, out value, IntPtr.Zero, 0);
  3177. }
  3178. public RESULT getParameterData(int index, out IntPtr data, out uint length)
  3179. {
  3180. return FMOD5_DSP_GetParameterData(this.handle, index, out data, out length, IntPtr.Zero, 0);
  3181. }
  3182. public RESULT getNumParameters(out int numparams)
  3183. {
  3184. return FMOD5_DSP_GetNumParameters(this.handle, out numparams);
  3185. }
  3186. public RESULT getParameterInfo(int index, out DSP_PARAMETER_DESC desc)
  3187. {
  3188. IntPtr descPtr;
  3189. RESULT result = FMOD5_DSP_GetParameterInfo(this.handle, index, out descPtr);
  3190. desc = (DSP_PARAMETER_DESC)MarshalHelper.PtrToStructure(descPtr, typeof(DSP_PARAMETER_DESC));
  3191. return result;
  3192. }
  3193. public RESULT getDataParameterIndex(int datatype, out int index)
  3194. {
  3195. return FMOD5_DSP_GetDataParameterIndex(this.handle, datatype, out index);
  3196. }
  3197. public RESULT showConfigDialog(IntPtr hwnd, bool show)
  3198. {
  3199. return FMOD5_DSP_ShowConfigDialog(this.handle, hwnd, show);
  3200. }
  3201. // DSP attributes.
  3202. public RESULT getInfo(out string name, out uint version, out int channels, out int configwidth, out int configheight)
  3203. {
  3204. IntPtr nameMem = Marshal.AllocHGlobal(32);
  3205. RESULT result = FMOD5_DSP_GetInfo(this.handle, nameMem, out version, out channels, out configwidth, out configheight);
  3206. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  3207. {
  3208. name = encoder.stringFromNative(nameMem);
  3209. }
  3210. Marshal.FreeHGlobal(nameMem);
  3211. return result;
  3212. }
  3213. public RESULT getInfo(out uint version, out int channels, out int configwidth, out int configheight)
  3214. {
  3215. return FMOD5_DSP_GetInfo(this.handle, IntPtr.Zero, out version, out channels, out configwidth, out configheight); ;
  3216. }
  3217. public RESULT getType(out DSP_TYPE type)
  3218. {
  3219. return FMOD5_DSP_GetType(this.handle, out type);
  3220. }
  3221. public RESULT getIdle(out bool idle)
  3222. {
  3223. return FMOD5_DSP_GetIdle(this.handle, out idle);
  3224. }
  3225. // Userdata set/get.
  3226. public RESULT setUserData(IntPtr userdata)
  3227. {
  3228. return FMOD5_DSP_SetUserData(this.handle, userdata);
  3229. }
  3230. public RESULT getUserData(out IntPtr userdata)
  3231. {
  3232. return FMOD5_DSP_GetUserData(this.handle, out userdata);
  3233. }
  3234. // Metering.
  3235. public RESULT setMeteringEnabled(bool inputEnabled, bool outputEnabled)
  3236. {
  3237. return FMOD5_DSP_SetMeteringEnabled(this.handle, inputEnabled, outputEnabled);
  3238. }
  3239. public RESULT getMeteringEnabled(out bool inputEnabled, out bool outputEnabled)
  3240. {
  3241. return FMOD5_DSP_GetMeteringEnabled(this.handle, out inputEnabled, out outputEnabled);
  3242. }
  3243. public RESULT getMeteringInfo(IntPtr zero, out DSP_METERING_INFO outputInfo)
  3244. {
  3245. return FMOD5_DSP_GetMeteringInfo(this.handle, zero, out outputInfo);
  3246. }
  3247. public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, IntPtr zero)
  3248. {
  3249. return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, zero);
  3250. }
  3251. public RESULT getMeteringInfo(out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo)
  3252. {
  3253. return FMOD5_DSP_GetMeteringInfo(this.handle, out inputInfo, out outputInfo);
  3254. }
  3255. public RESULT getCPUUsage(out uint exclusive, out uint inclusive)
  3256. {
  3257. return FMOD5_DSP_GetCPUUsage(this.handle, out exclusive, out inclusive);
  3258. }
  3259. #region importfunctions
  3260. [DllImport(VERSION.dll)]
  3261. private static extern RESULT FMOD5_DSP_Release (IntPtr dsp);
  3262. [DllImport(VERSION.dll)]
  3263. private static extern RESULT FMOD5_DSP_GetSystemObject (IntPtr dsp, out IntPtr system);
  3264. [DllImport(VERSION.dll)]
  3265. private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, IntPtr zero, DSPCONNECTION_TYPE type);
  3266. [DllImport(VERSION.dll)]
  3267. private static extern RESULT FMOD5_DSP_AddInput (IntPtr dsp, IntPtr input, out IntPtr connection, DSPCONNECTION_TYPE type);
  3268. [DllImport(VERSION.dll)]
  3269. private static extern RESULT FMOD5_DSP_DisconnectFrom (IntPtr dsp, IntPtr target, IntPtr connection);
  3270. [DllImport(VERSION.dll)]
  3271. private static extern RESULT FMOD5_DSP_DisconnectAll (IntPtr dsp, bool inputs, bool outputs);
  3272. [DllImport(VERSION.dll)]
  3273. private static extern RESULT FMOD5_DSP_GetNumInputs (IntPtr dsp, out int numinputs);
  3274. [DllImport(VERSION.dll)]
  3275. private static extern RESULT FMOD5_DSP_GetNumOutputs (IntPtr dsp, out int numoutputs);
  3276. [DllImport(VERSION.dll)]
  3277. private static extern RESULT FMOD5_DSP_GetInput (IntPtr dsp, int index, out IntPtr input, out IntPtr inputconnection);
  3278. [DllImport(VERSION.dll)]
  3279. private static extern RESULT FMOD5_DSP_GetOutput (IntPtr dsp, int index, out IntPtr output, out IntPtr outputconnection);
  3280. [DllImport(VERSION.dll)]
  3281. private static extern RESULT FMOD5_DSP_SetActive (IntPtr dsp, bool active);
  3282. [DllImport(VERSION.dll)]
  3283. private static extern RESULT FMOD5_DSP_GetActive (IntPtr dsp, out bool active);
  3284. [DllImport(VERSION.dll)]
  3285. private static extern RESULT FMOD5_DSP_SetBypass (IntPtr dsp, bool bypass);
  3286. [DllImport(VERSION.dll)]
  3287. private static extern RESULT FMOD5_DSP_GetBypass (IntPtr dsp, out bool bypass);
  3288. [DllImport(VERSION.dll)]
  3289. private static extern RESULT FMOD5_DSP_SetWetDryMix (IntPtr dsp, float prewet, float postwet, float dry);
  3290. [DllImport(VERSION.dll)]
  3291. private static extern RESULT FMOD5_DSP_GetWetDryMix (IntPtr dsp, out float prewet, out float postwet, out float dry);
  3292. [DllImport(VERSION.dll)]
  3293. private static extern RESULT FMOD5_DSP_SetChannelFormat (IntPtr dsp, CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode);
  3294. [DllImport(VERSION.dll)]
  3295. private static extern RESULT FMOD5_DSP_GetChannelFormat (IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode);
  3296. [DllImport(VERSION.dll)]
  3297. private static extern RESULT FMOD5_DSP_GetOutputChannelFormat (IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode);
  3298. [DllImport(VERSION.dll)]
  3299. private static extern RESULT FMOD5_DSP_Reset (IntPtr dsp);
  3300. [DllImport(VERSION.dll)]
  3301. private static extern RESULT FMOD5_DSP_SetCallback (IntPtr dsp, DSP_CALLBACK callback);
  3302. [DllImport(VERSION.dll)]
  3303. private static extern RESULT FMOD5_DSP_SetParameterFloat (IntPtr dsp, int index, float value);
  3304. [DllImport(VERSION.dll)]
  3305. private static extern RESULT FMOD5_DSP_SetParameterInt (IntPtr dsp, int index, int value);
  3306. [DllImport(VERSION.dll)]
  3307. private static extern RESULT FMOD5_DSP_SetParameterBool (IntPtr dsp, int index, bool value);
  3308. [DllImport(VERSION.dll)]
  3309. private static extern RESULT FMOD5_DSP_SetParameterData (IntPtr dsp, int index, IntPtr data, uint length);
  3310. [DllImport(VERSION.dll)]
  3311. private static extern RESULT FMOD5_DSP_GetParameterFloat (IntPtr dsp, int index, out float value, IntPtr valuestr, int valuestrlen);
  3312. [DllImport(VERSION.dll)]
  3313. private static extern RESULT FMOD5_DSP_GetParameterInt (IntPtr dsp, int index, out int value, IntPtr valuestr, int valuestrlen);
  3314. [DllImport(VERSION.dll)]
  3315. private static extern RESULT FMOD5_DSP_GetParameterBool (IntPtr dsp, int index, out bool value, IntPtr valuestr, int valuestrlen);
  3316. [DllImport(VERSION.dll)]
  3317. private static extern RESULT FMOD5_DSP_GetParameterData (IntPtr dsp, int index, out IntPtr data, out uint length, IntPtr valuestr, int valuestrlen);
  3318. [DllImport(VERSION.dll)]
  3319. private static extern RESULT FMOD5_DSP_GetNumParameters (IntPtr dsp, out int numparams);
  3320. [DllImport(VERSION.dll)]
  3321. private static extern RESULT FMOD5_DSP_GetParameterInfo (IntPtr dsp, int index, out IntPtr desc);
  3322. [DllImport(VERSION.dll)]
  3323. private static extern RESULT FMOD5_DSP_GetDataParameterIndex (IntPtr dsp, int datatype, out int index);
  3324. [DllImport(VERSION.dll)]
  3325. private static extern RESULT FMOD5_DSP_ShowConfigDialog (IntPtr dsp, IntPtr hwnd, bool show);
  3326. [DllImport(VERSION.dll)]
  3327. private static extern RESULT FMOD5_DSP_GetInfo (IntPtr dsp, IntPtr name, out uint version, out int channels, out int configwidth, out int configheight);
  3328. [DllImport(VERSION.dll)]
  3329. private static extern RESULT FMOD5_DSP_GetType (IntPtr dsp, out DSP_TYPE type);
  3330. [DllImport(VERSION.dll)]
  3331. private static extern RESULT FMOD5_DSP_GetIdle (IntPtr dsp, out bool idle);
  3332. [DllImport(VERSION.dll)]
  3333. private static extern RESULT FMOD5_DSP_SetUserData (IntPtr dsp, IntPtr userdata);
  3334. [DllImport(VERSION.dll)]
  3335. private static extern RESULT FMOD5_DSP_GetUserData (IntPtr dsp, out IntPtr userdata);
  3336. [DllImport(VERSION.dll)]
  3337. public static extern RESULT FMOD5_DSP_SetMeteringEnabled (IntPtr dsp, bool inputEnabled, bool outputEnabled);
  3338. [DllImport(VERSION.dll)]
  3339. public static extern RESULT FMOD5_DSP_GetMeteringEnabled (IntPtr dsp, out bool inputEnabled, out bool outputEnabled);
  3340. [DllImport(VERSION.dll)]
  3341. public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, IntPtr zero, out DSP_METERING_INFO outputInfo);
  3342. [DllImport(VERSION.dll)]
  3343. public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, IntPtr zero);
  3344. [DllImport(VERSION.dll)]
  3345. public static extern RESULT FMOD5_DSP_GetMeteringInfo (IntPtr dsp, out DSP_METERING_INFO inputInfo, out DSP_METERING_INFO outputInfo);
  3346. [DllImport(VERSION.dll)]
  3347. public static extern RESULT FMOD5_DSP_GetCPUUsage (IntPtr dsp, out uint exclusive, out uint inclusive);
  3348. #endregion
  3349. #region wrapperinternal
  3350. public IntPtr handle;
  3351. public DSP(IntPtr ptr) { this.handle = ptr; }
  3352. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  3353. public void clearHandle() { this.handle = IntPtr.Zero; }
  3354. #endregion
  3355. }
  3356. /*
  3357. 'DSPConnection' API
  3358. */
  3359. public struct DSPConnection
  3360. {
  3361. public RESULT getInput(out DSP input)
  3362. {
  3363. return FMOD5_DSPConnection_GetInput(this.handle, out input.handle);
  3364. }
  3365. public RESULT getOutput(out DSP output)
  3366. {
  3367. return FMOD5_DSPConnection_GetOutput(this.handle, out output.handle);
  3368. }
  3369. public RESULT setMix(float volume)
  3370. {
  3371. return FMOD5_DSPConnection_SetMix(this.handle, volume);
  3372. }
  3373. public RESULT getMix(out float volume)
  3374. {
  3375. return FMOD5_DSPConnection_GetMix(this.handle, out volume);
  3376. }
  3377. public RESULT setMixMatrix(float[] matrix, int outchannels, int inchannels, int inchannel_hop = 0)
  3378. {
  3379. return FMOD5_DSPConnection_SetMixMatrix(this.handle, matrix, outchannels, inchannels, inchannel_hop);
  3380. }
  3381. public RESULT getMixMatrix(float[] matrix, out int outchannels, out int inchannels, int inchannel_hop = 0)
  3382. {
  3383. return FMOD5_DSPConnection_GetMixMatrix(this.handle, matrix, out outchannels, out inchannels, inchannel_hop);
  3384. }
  3385. public RESULT getType(out DSPCONNECTION_TYPE type)
  3386. {
  3387. return FMOD5_DSPConnection_GetType(this.handle, out type);
  3388. }
  3389. // Userdata set/get.
  3390. public RESULT setUserData(IntPtr userdata)
  3391. {
  3392. return FMOD5_DSPConnection_SetUserData(this.handle, userdata);
  3393. }
  3394. public RESULT getUserData(out IntPtr userdata)
  3395. {
  3396. return FMOD5_DSPConnection_GetUserData(this.handle, out userdata);
  3397. }
  3398. #region importfunctions
  3399. [DllImport(VERSION.dll)]
  3400. private static extern RESULT FMOD5_DSPConnection_GetInput (IntPtr dspconnection, out IntPtr input);
  3401. [DllImport(VERSION.dll)]
  3402. private static extern RESULT FMOD5_DSPConnection_GetOutput (IntPtr dspconnection, out IntPtr output);
  3403. [DllImport(VERSION.dll)]
  3404. private static extern RESULT FMOD5_DSPConnection_SetMix (IntPtr dspconnection, float volume);
  3405. [DllImport(VERSION.dll)]
  3406. private static extern RESULT FMOD5_DSPConnection_GetMix (IntPtr dspconnection, out float volume);
  3407. [DllImport(VERSION.dll)]
  3408. private static extern RESULT FMOD5_DSPConnection_SetMixMatrix (IntPtr dspconnection, float[] matrix, int outchannels, int inchannels, int inchannel_hop);
  3409. [DllImport(VERSION.dll)]
  3410. private static extern RESULT FMOD5_DSPConnection_GetMixMatrix (IntPtr dspconnection, float[] matrix, out int outchannels, out int inchannels, int inchannel_hop);
  3411. [DllImport(VERSION.dll)]
  3412. private static extern RESULT FMOD5_DSPConnection_GetType (IntPtr dspconnection, out DSPCONNECTION_TYPE type);
  3413. [DllImport(VERSION.dll)]
  3414. private static extern RESULT FMOD5_DSPConnection_SetUserData (IntPtr dspconnection, IntPtr userdata);
  3415. [DllImport(VERSION.dll)]
  3416. private static extern RESULT FMOD5_DSPConnection_GetUserData (IntPtr dspconnection, out IntPtr userdata);
  3417. #endregion
  3418. #region wrapperinternal
  3419. public IntPtr handle;
  3420. public DSPConnection(IntPtr ptr) { this.handle = ptr; }
  3421. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  3422. public void clearHandle() { this.handle = IntPtr.Zero; }
  3423. #endregion
  3424. }
  3425. /*
  3426. 'Geometry' API
  3427. */
  3428. public struct Geometry
  3429. {
  3430. public RESULT release()
  3431. {
  3432. return FMOD5_Geometry_Release(this.handle);
  3433. }
  3434. // Polygon manipulation.
  3435. public RESULT addPolygon(float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex)
  3436. {
  3437. return FMOD5_Geometry_AddPolygon(this.handle, directocclusion, reverbocclusion, doublesided, numvertices, vertices, out polygonindex);
  3438. }
  3439. public RESULT getNumPolygons(out int numpolygons)
  3440. {
  3441. return FMOD5_Geometry_GetNumPolygons(this.handle, out numpolygons);
  3442. }
  3443. public RESULT getMaxPolygons(out int maxpolygons, out int maxvertices)
  3444. {
  3445. return FMOD5_Geometry_GetMaxPolygons(this.handle, out maxpolygons, out maxvertices);
  3446. }
  3447. public RESULT getPolygonNumVertices(int index, out int numvertices)
  3448. {
  3449. return FMOD5_Geometry_GetPolygonNumVertices(this.handle, index, out numvertices);
  3450. }
  3451. public RESULT setPolygonVertex(int index, int vertexindex, ref VECTOR vertex)
  3452. {
  3453. return FMOD5_Geometry_SetPolygonVertex(this.handle, index, vertexindex, ref vertex);
  3454. }
  3455. public RESULT getPolygonVertex(int index, int vertexindex, out VECTOR vertex)
  3456. {
  3457. return FMOD5_Geometry_GetPolygonVertex(this.handle, index, vertexindex, out vertex);
  3458. }
  3459. public RESULT setPolygonAttributes(int index, float directocclusion, float reverbocclusion, bool doublesided)
  3460. {
  3461. return FMOD5_Geometry_SetPolygonAttributes(this.handle, index, directocclusion, reverbocclusion, doublesided);
  3462. }
  3463. public RESULT getPolygonAttributes(int index, out float directocclusion, out float reverbocclusion, out bool doublesided)
  3464. {
  3465. return FMOD5_Geometry_GetPolygonAttributes(this.handle, index, out directocclusion, out reverbocclusion, out doublesided);
  3466. }
  3467. // Object manipulation.
  3468. public RESULT setActive(bool active)
  3469. {
  3470. return FMOD5_Geometry_SetActive(this.handle, active);
  3471. }
  3472. public RESULT getActive(out bool active)
  3473. {
  3474. return FMOD5_Geometry_GetActive(this.handle, out active);
  3475. }
  3476. public RESULT setRotation(ref VECTOR forward, ref VECTOR up)
  3477. {
  3478. return FMOD5_Geometry_SetRotation(this.handle, ref forward, ref up);
  3479. }
  3480. public RESULT getRotation(out VECTOR forward, out VECTOR up)
  3481. {
  3482. return FMOD5_Geometry_GetRotation(this.handle, out forward, out up);
  3483. }
  3484. public RESULT setPosition(ref VECTOR position)
  3485. {
  3486. return FMOD5_Geometry_SetPosition(this.handle, ref position);
  3487. }
  3488. public RESULT getPosition(out VECTOR position)
  3489. {
  3490. return FMOD5_Geometry_GetPosition(this.handle, out position);
  3491. }
  3492. public RESULT setScale(ref VECTOR scale)
  3493. {
  3494. return FMOD5_Geometry_SetScale(this.handle, ref scale);
  3495. }
  3496. public RESULT getScale(out VECTOR scale)
  3497. {
  3498. return FMOD5_Geometry_GetScale(this.handle, out scale);
  3499. }
  3500. public RESULT save(IntPtr data, out int datasize)
  3501. {
  3502. return FMOD5_Geometry_Save(this.handle, data, out datasize);
  3503. }
  3504. // Userdata set/get.
  3505. public RESULT setUserData(IntPtr userdata)
  3506. {
  3507. return FMOD5_Geometry_SetUserData(this.handle, userdata);
  3508. }
  3509. public RESULT getUserData(out IntPtr userdata)
  3510. {
  3511. return FMOD5_Geometry_GetUserData(this.handle, out userdata);
  3512. }
  3513. #region importfunctions
  3514. [DllImport(VERSION.dll)]
  3515. private static extern RESULT FMOD5_Geometry_Release (IntPtr geometry);
  3516. [DllImport(VERSION.dll)]
  3517. private static extern RESULT FMOD5_Geometry_AddPolygon (IntPtr geometry, float directocclusion, float reverbocclusion, bool doublesided, int numvertices, VECTOR[] vertices, out int polygonindex);
  3518. [DllImport(VERSION.dll)]
  3519. private static extern RESULT FMOD5_Geometry_GetNumPolygons (IntPtr geometry, out int numpolygons);
  3520. [DllImport(VERSION.dll)]
  3521. private static extern RESULT FMOD5_Geometry_GetMaxPolygons (IntPtr geometry, out int maxpolygons, out int maxvertices);
  3522. [DllImport(VERSION.dll)]
  3523. private static extern RESULT FMOD5_Geometry_GetPolygonNumVertices(IntPtr geometry, int index, out int numvertices);
  3524. [DllImport(VERSION.dll)]
  3525. private static extern RESULT FMOD5_Geometry_SetPolygonVertex (IntPtr geometry, int index, int vertexindex, ref VECTOR vertex);
  3526. [DllImport(VERSION.dll)]
  3527. private static extern RESULT FMOD5_Geometry_GetPolygonVertex (IntPtr geometry, int index, int vertexindex, out VECTOR vertex);
  3528. [DllImport(VERSION.dll)]
  3529. private static extern RESULT FMOD5_Geometry_SetPolygonAttributes (IntPtr geometry, int index, float directocclusion, float reverbocclusion, bool doublesided);
  3530. [DllImport(VERSION.dll)]
  3531. private static extern RESULT FMOD5_Geometry_GetPolygonAttributes (IntPtr geometry, int index, out float directocclusion, out float reverbocclusion, out bool doublesided);
  3532. [DllImport(VERSION.dll)]
  3533. private static extern RESULT FMOD5_Geometry_SetActive (IntPtr geometry, bool active);
  3534. [DllImport(VERSION.dll)]
  3535. private static extern RESULT FMOD5_Geometry_GetActive (IntPtr geometry, out bool active);
  3536. [DllImport(VERSION.dll)]
  3537. private static extern RESULT FMOD5_Geometry_SetRotation (IntPtr geometry, ref VECTOR forward, ref VECTOR up);
  3538. [DllImport(VERSION.dll)]
  3539. private static extern RESULT FMOD5_Geometry_GetRotation (IntPtr geometry, out VECTOR forward, out VECTOR up);
  3540. [DllImport(VERSION.dll)]
  3541. private static extern RESULT FMOD5_Geometry_SetPosition (IntPtr geometry, ref VECTOR position);
  3542. [DllImport(VERSION.dll)]
  3543. private static extern RESULT FMOD5_Geometry_GetPosition (IntPtr geometry, out VECTOR position);
  3544. [DllImport(VERSION.dll)]
  3545. private static extern RESULT FMOD5_Geometry_SetScale (IntPtr geometry, ref VECTOR scale);
  3546. [DllImport(VERSION.dll)]
  3547. private static extern RESULT FMOD5_Geometry_GetScale (IntPtr geometry, out VECTOR scale);
  3548. [DllImport(VERSION.dll)]
  3549. private static extern RESULT FMOD5_Geometry_Save (IntPtr geometry, IntPtr data, out int datasize);
  3550. [DllImport(VERSION.dll)]
  3551. private static extern RESULT FMOD5_Geometry_SetUserData (IntPtr geometry, IntPtr userdata);
  3552. [DllImport(VERSION.dll)]
  3553. private static extern RESULT FMOD5_Geometry_GetUserData (IntPtr geometry, out IntPtr userdata);
  3554. #endregion
  3555. #region wrapperinternal
  3556. public IntPtr handle;
  3557. public Geometry(IntPtr ptr) { this.handle = ptr; }
  3558. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  3559. public void clearHandle() { this.handle = IntPtr.Zero; }
  3560. #endregion
  3561. }
  3562. /*
  3563. 'Reverb3D' API
  3564. */
  3565. public struct Reverb3D
  3566. {
  3567. public RESULT release()
  3568. {
  3569. return FMOD5_Reverb3D_Release(this.handle);
  3570. }
  3571. // Reverb manipulation.
  3572. public RESULT set3DAttributes(ref VECTOR position, float mindistance, float maxdistance)
  3573. {
  3574. return FMOD5_Reverb3D_Set3DAttributes(this.handle, ref position, mindistance, maxdistance);
  3575. }
  3576. public RESULT get3DAttributes(ref VECTOR position, ref float mindistance, ref float maxdistance)
  3577. {
  3578. return FMOD5_Reverb3D_Get3DAttributes(this.handle, ref position, ref mindistance, ref maxdistance);
  3579. }
  3580. public RESULT setProperties(ref REVERB_PROPERTIES properties)
  3581. {
  3582. return FMOD5_Reverb3D_SetProperties(this.handle, ref properties);
  3583. }
  3584. public RESULT getProperties(ref REVERB_PROPERTIES properties)
  3585. {
  3586. return FMOD5_Reverb3D_GetProperties(this.handle, ref properties);
  3587. }
  3588. public RESULT setActive(bool active)
  3589. {
  3590. return FMOD5_Reverb3D_SetActive(this.handle, active);
  3591. }
  3592. public RESULT getActive(out bool active)
  3593. {
  3594. return FMOD5_Reverb3D_GetActive(this.handle, out active);
  3595. }
  3596. // Userdata set/get.
  3597. public RESULT setUserData(IntPtr userdata)
  3598. {
  3599. return FMOD5_Reverb3D_SetUserData(this.handle, userdata);
  3600. }
  3601. public RESULT getUserData(out IntPtr userdata)
  3602. {
  3603. return FMOD5_Reverb3D_GetUserData(this.handle, out userdata);
  3604. }
  3605. #region importfunctions
  3606. [DllImport(VERSION.dll)]
  3607. private static extern RESULT FMOD5_Reverb3D_Release (IntPtr reverb3d);
  3608. [DllImport(VERSION.dll)]
  3609. private static extern RESULT FMOD5_Reverb3D_Set3DAttributes (IntPtr reverb3d, ref VECTOR position, float mindistance, float maxdistance);
  3610. [DllImport(VERSION.dll)]
  3611. private static extern RESULT FMOD5_Reverb3D_Get3DAttributes (IntPtr reverb3d, ref VECTOR position, ref float mindistance, ref float maxdistance);
  3612. [DllImport(VERSION.dll)]
  3613. private static extern RESULT FMOD5_Reverb3D_SetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties);
  3614. [DllImport(VERSION.dll)]
  3615. private static extern RESULT FMOD5_Reverb3D_GetProperties (IntPtr reverb3d, ref REVERB_PROPERTIES properties);
  3616. [DllImport(VERSION.dll)]
  3617. private static extern RESULT FMOD5_Reverb3D_SetActive (IntPtr reverb3d, bool active);
  3618. [DllImport(VERSION.dll)]
  3619. private static extern RESULT FMOD5_Reverb3D_GetActive (IntPtr reverb3d, out bool active);
  3620. [DllImport(VERSION.dll)]
  3621. private static extern RESULT FMOD5_Reverb3D_SetUserData (IntPtr reverb3d, IntPtr userdata);
  3622. [DllImport(VERSION.dll)]
  3623. private static extern RESULT FMOD5_Reverb3D_GetUserData (IntPtr reverb3d, out IntPtr userdata);
  3624. #endregion
  3625. #region wrapperinternal
  3626. public IntPtr handle;
  3627. public Reverb3D(IntPtr ptr) { this.handle = ptr; }
  3628. public bool hasHandle() { return this.handle != IntPtr.Zero; }
  3629. public void clearHandle() { this.handle = IntPtr.Zero; }
  3630. #endregion
  3631. }
  3632. #region Helper Functions
  3633. [StructLayout(LayoutKind.Sequential)]
  3634. public struct StringWrapper
  3635. {
  3636. IntPtr nativeUtf8Ptr;
  3637. public StringWrapper(IntPtr ptr)
  3638. {
  3639. nativeUtf8Ptr = ptr;
  3640. }
  3641. public static implicit operator string(StringWrapper fstring)
  3642. {
  3643. using (StringHelper.ThreadSafeEncoding encoder = StringHelper.GetFreeHelper())
  3644. {
  3645. return encoder.stringFromNative(fstring.nativeUtf8Ptr);
  3646. }
  3647. }
  3648. public bool StartsWith(byte[] prefix)
  3649. {
  3650. if (nativeUtf8Ptr == IntPtr.Zero)
  3651. {
  3652. return false;
  3653. }
  3654. for (int i = 0; i < prefix.Length; i++)
  3655. {
  3656. if (Marshal.ReadByte(nativeUtf8Ptr, i) != prefix[i])
  3657. {
  3658. return false;
  3659. }
  3660. }
  3661. return true;
  3662. }
  3663. public bool Equals(byte[] comparison)
  3664. {
  3665. if (nativeUtf8Ptr == IntPtr.Zero)
  3666. {
  3667. return false;
  3668. }
  3669. for (int i = 0; i < comparison.Length; i++)
  3670. {
  3671. if (Marshal.ReadByte(nativeUtf8Ptr, i) != comparison[i])
  3672. {
  3673. return false;
  3674. }
  3675. }
  3676. if (Marshal.ReadByte(nativeUtf8Ptr, comparison.Length) != 0)
  3677. {
  3678. return false;
  3679. }
  3680. return true;
  3681. }
  3682. }
  3683. static class StringHelper
  3684. {
  3685. public class ThreadSafeEncoding : IDisposable
  3686. {
  3687. UTF8Encoding encoding = new UTF8Encoding();
  3688. byte[] encodedBuffer = new byte[128];
  3689. char[] decodedBuffer = new char[128];
  3690. bool inUse;
  3691. GCHandle gcHandle;
  3692. public bool InUse() { return inUse; }
  3693. public void SetInUse() { inUse = true; }
  3694. private int roundUpPowerTwo(int number)
  3695. {
  3696. int newNumber = 1;
  3697. while (newNumber <= number)
  3698. {
  3699. newNumber *= 2;
  3700. }
  3701. return newNumber;
  3702. }
  3703. public byte[] byteFromStringUTF8(string s)
  3704. {
  3705. if (s == null)
  3706. {
  3707. return null;
  3708. }
  3709. int maximumLength = encoding.GetMaxByteCount(s.Length) + 1; // +1 for null terminator
  3710. if (maximumLength > encodedBuffer.Length)
  3711. {
  3712. int encodedLength = encoding.GetByteCount(s) + 1; // +1 for null terminator
  3713. if (encodedLength > encodedBuffer.Length)
  3714. {
  3715. encodedBuffer = new byte[roundUpPowerTwo(encodedLength)];
  3716. }
  3717. }
  3718. int byteCount = encoding.GetBytes(s, 0, s.Length, encodedBuffer, 0);
  3719. encodedBuffer[byteCount] = 0; // Apply null terminator
  3720. return encodedBuffer;
  3721. }
  3722. public IntPtr intptrFromStringUTF8(string s)
  3723. {
  3724. if (s == null)
  3725. {
  3726. return IntPtr.Zero;
  3727. }
  3728. gcHandle = GCHandle.Alloc(byteFromStringUTF8(s), GCHandleType.Pinned);
  3729. return gcHandle.AddrOfPinnedObject();
  3730. }
  3731. public string stringFromNative(IntPtr nativePtr)
  3732. {
  3733. if (nativePtr == IntPtr.Zero)
  3734. {
  3735. return "";
  3736. }
  3737. int nativeLen = 0;
  3738. while (Marshal.ReadByte(nativePtr, nativeLen) != 0)
  3739. {
  3740. nativeLen++;
  3741. }
  3742. if (nativeLen == 0)
  3743. {
  3744. return "";
  3745. }
  3746. if (nativeLen > encodedBuffer.Length)
  3747. {
  3748. encodedBuffer = new byte[roundUpPowerTwo(nativeLen)];
  3749. }
  3750. Marshal.Copy(nativePtr, encodedBuffer, 0, nativeLen);
  3751. int maximumLength = encoding.GetMaxCharCount(nativeLen);
  3752. if (maximumLength > decodedBuffer.Length)
  3753. {
  3754. int decodedLength = encoding.GetCharCount(encodedBuffer, 0, nativeLen);
  3755. if (decodedLength > decodedBuffer.Length)
  3756. {
  3757. decodedBuffer = new char[roundUpPowerTwo(decodedLength)];
  3758. }
  3759. }
  3760. int charCount = encoding.GetChars(encodedBuffer, 0, nativeLen, decodedBuffer, 0);
  3761. return new String(decodedBuffer, 0, charCount);
  3762. }
  3763. public void Dispose()
  3764. {
  3765. if (gcHandle.IsAllocated)
  3766. {
  3767. gcHandle.Free();
  3768. }
  3769. lock (encoders)
  3770. {
  3771. inUse = false;
  3772. }
  3773. }
  3774. }
  3775. static List<ThreadSafeEncoding> encoders = new List<ThreadSafeEncoding>(1);
  3776. public static ThreadSafeEncoding GetFreeHelper()
  3777. {
  3778. lock (encoders)
  3779. {
  3780. ThreadSafeEncoding helper = null;
  3781. // Search for not in use helper
  3782. for (int i = 0; i < encoders.Count; i++)
  3783. {
  3784. if (!encoders[i].InUse())
  3785. {
  3786. helper = encoders[i];
  3787. break;
  3788. }
  3789. }
  3790. // Otherwise create another helper
  3791. if (helper == null)
  3792. {
  3793. helper = new ThreadSafeEncoding();
  3794. encoders.Add(helper);
  3795. }
  3796. helper.SetInUse();
  3797. return helper;
  3798. }
  3799. }
  3800. }
  3801. // Some of the Marshal functions were marked as deprecated / obsolete, however that decision was reversed: https://github.com/dotnet/corefx/pull/10541
  3802. // Use the old syntax (non-generic) to ensure maximum compatibility (especially with Unity) ignoring the warnings
  3803. public static class MarshalHelper
  3804. {
  3805. #pragma warning disable 618
  3806. public static int SizeOf(Type t)
  3807. {
  3808. return Marshal.SizeOf(t); // Always use Type version, never Object version as it boxes causes GC allocations
  3809. }
  3810. public static object PtrToStructure(IntPtr ptr, Type structureType)
  3811. {
  3812. return Marshal.PtrToStructure(ptr, structureType);
  3813. }
  3814. #pragma warning restore 618
  3815. }
  3816. #endregion
  3817. }