Audio.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Audio.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho.Audio
  18. {
  19. /// <summary>
  20. /// %Audio subsystem.
  21. /// </summary>
  22. public unsafe partial class Audio : UrhoObject
  23. {
  24. unsafe partial void OnAudioCreated ();
  25. [Preserve]
  26. public Audio (IntPtr handle) : base (handle)
  27. {
  28. OnAudioCreated ();
  29. }
  30. [Preserve]
  31. protected Audio (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnAudioCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Audio_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Audio_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Audio_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Audio_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Audio_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Audio));
  54. return new StringHash (Audio_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Audio_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Audio));
  61. return Marshal.PtrToStringAnsi (Audio_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Audio () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Audio_Audio (IntPtr context);
  69. [Preserve]
  70. public Audio (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Audio));
  73. handle = Audio_Audio ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnAudioCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern bool Audio_SetMode (IntPtr handle, int bufferLengthMSec, int mixRate, bool stereo, bool interpolation);
  79. /// <summary>
  80. /// Initialize sound output with specified buffer length and output mode.
  81. /// </summary>
  82. public bool SetMode (int bufferLengthMSec, int mixRate, bool stereo, bool interpolation = true)
  83. {
  84. Runtime.ValidateRefCounted (this);
  85. return Audio_SetMode (handle, bufferLengthMSec, mixRate, stereo, interpolation);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern void Audio_Update (IntPtr handle, float timeStep);
  89. /// <summary>
  90. /// Run update on sound sources. Not required for continued playback, but frees unused sound sources
  91. /// &
  92. /// sounds and updates 3D positions.
  93. /// </summary>
  94. public void Update (float timeStep)
  95. {
  96. Runtime.ValidateRefCounted (this);
  97. Audio_Update (handle, timeStep);
  98. }
  99. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  100. internal static extern bool Audio_Play (IntPtr handle);
  101. /// <summary>
  102. /// Restart sound output.
  103. /// </summary>
  104. public bool Play ()
  105. {
  106. Runtime.ValidateRefCounted (this);
  107. return Audio_Play (handle);
  108. }
  109. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  110. internal static extern void Audio_Stop (IntPtr handle);
  111. /// <summary>
  112. /// Suspend sound output.
  113. /// </summary>
  114. public void Stop ()
  115. {
  116. Runtime.ValidateRefCounted (this);
  117. Audio_Stop (handle);
  118. }
  119. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  120. internal static extern void Audio_SetMasterGain (IntPtr handle, string type, float gain);
  121. /// <summary>
  122. /// Set master gain on a specific sound type such as sound effects, music or voice.
  123. /// </summary>
  124. public void SetMasterGain (string type, float gain)
  125. {
  126. Runtime.ValidateRefCounted (this);
  127. Audio_SetMasterGain (handle, type, gain);
  128. }
  129. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  130. internal static extern void Audio_PauseSoundType (IntPtr handle, string type);
  131. /// <summary>
  132. /// Pause playback of specific sound type. This allows to suspend e.g. sound effects or voice when the game is paused. By default all sound types are unpaused.
  133. /// </summary>
  134. public void PauseSoundType (string type)
  135. {
  136. Runtime.ValidateRefCounted (this);
  137. Audio_PauseSoundType (handle, type);
  138. }
  139. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  140. internal static extern void Audio_ResumeSoundType (IntPtr handle, string type);
  141. /// <summary>
  142. /// Resume playback of specific sound type.
  143. /// </summary>
  144. public void ResumeSoundType (string type)
  145. {
  146. Runtime.ValidateRefCounted (this);
  147. Audio_ResumeSoundType (handle, type);
  148. }
  149. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  150. internal static extern void Audio_ResumeAll (IntPtr handle);
  151. /// <summary>
  152. /// Resume playback of all sound types.
  153. /// </summary>
  154. public void ResumeAll ()
  155. {
  156. Runtime.ValidateRefCounted (this);
  157. Audio_ResumeAll (handle);
  158. }
  159. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  160. internal static extern void Audio_SetListener (IntPtr handle, IntPtr listener);
  161. /// <summary>
  162. /// Set active sound listener for 3D sounds.
  163. /// </summary>
  164. private void SetListener (SoundListener listener)
  165. {
  166. Runtime.ValidateRefCounted (this);
  167. Audio_SetListener (handle, (object)listener == null ? IntPtr.Zero : listener.Handle);
  168. }
  169. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  170. internal static extern void Audio_StopSound (IntPtr handle, IntPtr sound);
  171. /// <summary>
  172. /// Stop any sound source playing a certain sound clip.
  173. /// </summary>
  174. public void StopSound (Sound sound)
  175. {
  176. Runtime.ValidateRefCounted (this);
  177. Audio_StopSound (handle, (object)sound == null ? IntPtr.Zero : sound.Handle);
  178. }
  179. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  180. internal static extern uint Audio_GetSampleSize (IntPtr handle);
  181. /// <summary>
  182. /// Return byte size of one sample.
  183. /// </summary>
  184. private uint GetSampleSize ()
  185. {
  186. Runtime.ValidateRefCounted (this);
  187. return Audio_GetSampleSize (handle);
  188. }
  189. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  190. internal static extern int Audio_GetMixRate (IntPtr handle);
  191. /// <summary>
  192. /// Return mixing rate.
  193. /// </summary>
  194. private int GetMixRate ()
  195. {
  196. Runtime.ValidateRefCounted (this);
  197. return Audio_GetMixRate (handle);
  198. }
  199. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  200. internal static extern bool Audio_GetInterpolation (IntPtr handle);
  201. /// <summary>
  202. /// Return whether output is interpolated.
  203. /// </summary>
  204. private bool GetInterpolation ()
  205. {
  206. Runtime.ValidateRefCounted (this);
  207. return Audio_GetInterpolation (handle);
  208. }
  209. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  210. internal static extern bool Audio_IsStereo (IntPtr handle);
  211. /// <summary>
  212. /// Return whether output is stereo.
  213. /// </summary>
  214. private bool IsStereo ()
  215. {
  216. Runtime.ValidateRefCounted (this);
  217. return Audio_IsStereo (handle);
  218. }
  219. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  220. internal static extern bool Audio_IsPlaying (IntPtr handle);
  221. /// <summary>
  222. /// Return whether audio is being output.
  223. /// </summary>
  224. private bool IsPlaying ()
  225. {
  226. Runtime.ValidateRefCounted (this);
  227. return Audio_IsPlaying (handle);
  228. }
  229. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  230. internal static extern bool Audio_IsInitialized (IntPtr handle);
  231. /// <summary>
  232. /// Return whether an audio stream has been reserved.
  233. /// </summary>
  234. private bool IsInitialized ()
  235. {
  236. Runtime.ValidateRefCounted (this);
  237. return Audio_IsInitialized (handle);
  238. }
  239. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  240. internal static extern float Audio_GetMasterGain (IntPtr handle, string type);
  241. /// <summary>
  242. /// Return master gain for a specific sound source type. Unknown sound types will return full gain (1).
  243. /// </summary>
  244. public float GetMasterGain (string type)
  245. {
  246. Runtime.ValidateRefCounted (this);
  247. return Audio_GetMasterGain (handle, type);
  248. }
  249. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  250. internal static extern bool Audio_IsSoundTypePaused (IntPtr handle, string type);
  251. /// <summary>
  252. /// Return whether specific sound type has been paused.
  253. /// </summary>
  254. public bool IsSoundTypePaused (string type)
  255. {
  256. Runtime.ValidateRefCounted (this);
  257. return Audio_IsSoundTypePaused (handle, type);
  258. }
  259. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  260. internal static extern IntPtr Audio_GetListener (IntPtr handle);
  261. /// <summary>
  262. /// Return active sound listener.
  263. /// </summary>
  264. private SoundListener GetListener ()
  265. {
  266. Runtime.ValidateRefCounted (this);
  267. return Runtime.LookupObject<SoundListener> (Audio_GetListener (handle));
  268. }
  269. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  270. internal static extern bool Audio_HasMasterGain (IntPtr handle, string type);
  271. /// <summary>
  272. /// Return whether the specified master gain has been defined.
  273. /// </summary>
  274. public bool HasMasterGain (string type)
  275. {
  276. Runtime.ValidateRefCounted (this);
  277. return Audio_HasMasterGain (handle, type);
  278. }
  279. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  280. internal static extern void Audio_AddSoundSource (IntPtr handle, IntPtr soundSource);
  281. /// <summary>
  282. /// Add a sound source to keep track of. Called by SoundSource.
  283. /// </summary>
  284. public void AddSoundSource (SoundSource soundSource)
  285. {
  286. Runtime.ValidateRefCounted (this);
  287. Audio_AddSoundSource (handle, (object)soundSource == null ? IntPtr.Zero : soundSource.Handle);
  288. }
  289. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  290. internal static extern void Audio_RemoveSoundSource (IntPtr handle, IntPtr soundSource);
  291. /// <summary>
  292. /// Remove a sound source. Called by SoundSource.
  293. /// </summary>
  294. public void RemoveSoundSource (SoundSource soundSource)
  295. {
  296. Runtime.ValidateRefCounted (this);
  297. Audio_RemoveSoundSource (handle, (object)soundSource == null ? IntPtr.Zero : soundSource.Handle);
  298. }
  299. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  300. internal static extern float Audio_GetSoundSourceMasterGain (IntPtr handle, int typeHash);
  301. /// <summary>
  302. /// Return sound type specific gain multiplied by master gain.
  303. /// </summary>
  304. public float GetSoundSourceMasterGain (StringHash typeHash)
  305. {
  306. Runtime.ValidateRefCounted (this);
  307. return Audio_GetSoundSourceMasterGain (handle, typeHash.Code);
  308. }
  309. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  310. internal static extern void Audio_MixOutput (IntPtr handle, IntPtr dest, uint samples);
  311. /// <summary>
  312. /// Mix sound sources into the buffer.
  313. /// </summary>
  314. public void MixOutput (IntPtr dest, uint samples)
  315. {
  316. Runtime.ValidateRefCounted (this);
  317. Audio_MixOutput (handle, dest, samples);
  318. }
  319. public override StringHash Type {
  320. get {
  321. return UrhoGetType ();
  322. }
  323. }
  324. public override string TypeName {
  325. get {
  326. return GetTypeName ();
  327. }
  328. }
  329. [Preserve]
  330. public static StringHash TypeStatic {
  331. get {
  332. return GetTypeStatic ();
  333. }
  334. }
  335. public static string TypeNameStatic {
  336. get {
  337. return GetTypeNameStatic ();
  338. }
  339. }
  340. /// <summary>
  341. /// Return active sound listener.
  342. /// Or
  343. /// Set active sound listener for 3D sounds.
  344. /// </summary>
  345. public SoundListener Listener {
  346. get {
  347. return GetListener ();
  348. }
  349. set {
  350. SetListener (value);
  351. }
  352. }
  353. /// <summary>
  354. /// Return byte size of one sample.
  355. /// </summary>
  356. public uint SampleSize {
  357. get {
  358. return GetSampleSize ();
  359. }
  360. }
  361. /// <summary>
  362. /// Return mixing rate.
  363. /// </summary>
  364. public int MixRate {
  365. get {
  366. return GetMixRate ();
  367. }
  368. }
  369. /// <summary>
  370. /// Return whether output is interpolated.
  371. /// </summary>
  372. public bool Interpolation {
  373. get {
  374. return GetInterpolation ();
  375. }
  376. }
  377. /// <summary>
  378. /// Return whether output is stereo.
  379. /// </summary>
  380. public bool Stereo {
  381. get {
  382. return IsStereo ();
  383. }
  384. }
  385. /// <summary>
  386. /// Return whether audio is being output.
  387. /// </summary>
  388. public bool Playing {
  389. get {
  390. return IsPlaying ();
  391. }
  392. }
  393. /// <summary>
  394. /// Return whether an audio stream has been reserved.
  395. /// </summary>
  396. public bool Initialized {
  397. get {
  398. return IsInitialized ();
  399. }
  400. }
  401. }
  402. }