Sound.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Sound.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. /// %Sound resource.
  21. /// </summary>
  22. public unsafe partial class Sound : ResourceWithMetadata
  23. {
  24. unsafe partial void OnSoundCreated ();
  25. [Preserve]
  26. public Sound (IntPtr handle) : base (handle)
  27. {
  28. OnSoundCreated ();
  29. }
  30. [Preserve]
  31. protected Sound (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnSoundCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Sound_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Sound_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Sound_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Sound_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Sound_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Sound));
  54. return new StringHash (Sound_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Sound_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Sound));
  61. return Marshal.PtrToStringAnsi (Sound_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Sound () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Sound_Sound (IntPtr context);
  69. [Preserve]
  70. public Sound (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Sound));
  73. handle = Sound_Sound ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnSoundCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern void Sound_RegisterObject (IntPtr context);
  79. /// <summary>
  80. /// Register object factory.
  81. /// </summary>
  82. public static void RegisterObject (Context context)
  83. {
  84. Runtime.Validate (typeof(Sound));
  85. Sound_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern bool Sound_BeginLoad_File (IntPtr handle, IntPtr source);
  89. /// <summary>
  90. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  91. /// </summary>
  92. public override bool BeginLoad (File source)
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Sound_BeginLoad_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern bool Sound_BeginLoad_MemoryBuffer (IntPtr handle, IntPtr source);
  99. /// <summary>
  100. /// Load resource from stream. May be called from a worker thread. Return true if successful.
  101. /// </summary>
  102. public override bool BeginLoad (MemoryBuffer source)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return Sound_BeginLoad_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern bool Sound_LoadRaw_File (IntPtr handle, IntPtr source);
  109. /// <summary>
  110. /// Load raw sound data.
  111. /// </summary>
  112. public bool LoadRaw (File source)
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Sound_LoadRaw_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern bool Sound_LoadRaw_MemoryBuffer (IntPtr handle, IntPtr source);
  119. /// <summary>
  120. /// Load raw sound data.
  121. /// </summary>
  122. public bool LoadRaw (MemoryBuffer source)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. return Sound_LoadRaw_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern bool Sound_LoadWav_File (IntPtr handle, IntPtr source);
  129. /// <summary>
  130. /// Load WAV format sound data.
  131. /// </summary>
  132. public bool LoadWav (File source)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. return Sound_LoadWav_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern bool Sound_LoadWav_MemoryBuffer (IntPtr handle, IntPtr source);
  139. /// <summary>
  140. /// Load WAV format sound data.
  141. /// </summary>
  142. public bool LoadWav (MemoryBuffer source)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. return Sound_LoadWav_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern bool Sound_LoadOggVorbis_File (IntPtr handle, IntPtr source);
  149. /// <summary>
  150. /// Load Ogg Vorbis format sound data. Does not decode at load, but will rather be decoded while playing.
  151. /// </summary>
  152. public bool LoadOggVorbis (File source)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. return Sound_LoadOggVorbis_File (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern bool Sound_LoadOggVorbis_MemoryBuffer (IntPtr handle, IntPtr source);
  159. /// <summary>
  160. /// Load Ogg Vorbis format sound data. Does not decode at load, but will rather be decoded while playing.
  161. /// </summary>
  162. public bool LoadOggVorbis (MemoryBuffer source)
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. return Sound_LoadOggVorbis_MemoryBuffer (handle, (object)source == null ? IntPtr.Zero : source.Handle);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern void Sound_SetSize (IntPtr handle, uint dataSize);
  169. /// <summary>
  170. /// Set sound size in bytes. Also resets the sound to be uncompressed and one-shot.
  171. /// </summary>
  172. public void SetSize (uint dataSize)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. Sound_SetSize (handle, dataSize);
  176. }
  177. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  178. internal static extern void Sound_SetData (IntPtr handle, void* data, uint dataSize);
  179. /// <summary>
  180. /// Set uncompressed sound data.
  181. /// </summary>
  182. public void SetData (void* data, uint dataSize)
  183. {
  184. Runtime.ValidateRefCounted (this);
  185. Sound_SetData (handle, data, dataSize);
  186. }
  187. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  188. internal static extern void Sound_SetFormat (IntPtr handle, uint frequency, bool sixteenBit, bool stereo);
  189. /// <summary>
  190. /// Set uncompressed sound data format.
  191. /// </summary>
  192. public void SetFormat (uint frequency, bool sixteenBit, bool stereo)
  193. {
  194. Runtime.ValidateRefCounted (this);
  195. Sound_SetFormat (handle, frequency, sixteenBit, stereo);
  196. }
  197. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  198. internal static extern void Sound_SetLooped (IntPtr handle, bool enable);
  199. /// <summary>
  200. /// Set loop on/off. If loop is enabled, sets the full sound as loop range.
  201. /// </summary>
  202. private void SetLooped (bool enable)
  203. {
  204. Runtime.ValidateRefCounted (this);
  205. Sound_SetLooped (handle, enable);
  206. }
  207. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  208. internal static extern void Sound_SetLoop (IntPtr handle, uint repeatOffset, uint endOffset);
  209. /// <summary>
  210. /// Define loop.
  211. /// </summary>
  212. public void SetLoop (uint repeatOffset, uint endOffset)
  213. {
  214. Runtime.ValidateRefCounted (this);
  215. Sound_SetLoop (handle, repeatOffset, endOffset);
  216. }
  217. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  218. internal static extern IntPtr Sound_GetDecoderStream (IntPtr handle);
  219. /// <summary>
  220. /// Return a new instance of a decoder sound stream. Used by compressed sounds.
  221. /// </summary>
  222. private SoundStream GetDecoderStream ()
  223. {
  224. Runtime.ValidateRefCounted (this);
  225. return Runtime.LookupRefCounted<SoundStream> (Sound_GetDecoderStream (handle));
  226. }
  227. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  228. internal static extern sbyte* Sound_GetStart (IntPtr handle);
  229. /// <summary>
  230. /// Return sound data start.
  231. /// </summary>
  232. private sbyte* GetStart ()
  233. {
  234. Runtime.ValidateRefCounted (this);
  235. return Sound_GetStart (handle);
  236. }
  237. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  238. internal static extern sbyte* Sound_GetRepeat (IntPtr handle);
  239. /// <summary>
  240. /// Return loop start.
  241. /// </summary>
  242. private sbyte* GetRepeat ()
  243. {
  244. Runtime.ValidateRefCounted (this);
  245. return Sound_GetRepeat (handle);
  246. }
  247. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  248. internal static extern sbyte* Sound_GetEnd (IntPtr handle);
  249. /// <summary>
  250. /// Return sound data end.
  251. /// </summary>
  252. private sbyte* GetEnd ()
  253. {
  254. Runtime.ValidateRefCounted (this);
  255. return Sound_GetEnd (handle);
  256. }
  257. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  258. internal static extern float Sound_GetLength (IntPtr handle);
  259. /// <summary>
  260. /// Return length in seconds.
  261. /// </summary>
  262. private float GetLength ()
  263. {
  264. Runtime.ValidateRefCounted (this);
  265. return Sound_GetLength (handle);
  266. }
  267. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  268. internal static extern uint Sound_GetDataSize (IntPtr handle);
  269. /// <summary>
  270. /// Return total sound data size.
  271. /// </summary>
  272. private uint GetDataSize ()
  273. {
  274. Runtime.ValidateRefCounted (this);
  275. return Sound_GetDataSize (handle);
  276. }
  277. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  278. internal static extern uint Sound_GetSampleSize (IntPtr handle);
  279. /// <summary>
  280. /// Return sample size.
  281. /// </summary>
  282. private uint GetSampleSize ()
  283. {
  284. Runtime.ValidateRefCounted (this);
  285. return Sound_GetSampleSize (handle);
  286. }
  287. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  288. internal static extern float Sound_GetFrequency (IntPtr handle);
  289. /// <summary>
  290. /// Return default frequency as a float.
  291. /// </summary>
  292. private float GetFrequency ()
  293. {
  294. Runtime.ValidateRefCounted (this);
  295. return Sound_GetFrequency (handle);
  296. }
  297. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  298. internal static extern uint Sound_GetIntFrequency (IntPtr handle);
  299. /// <summary>
  300. /// Return default frequency as an integer.
  301. /// </summary>
  302. private uint GetIntFrequency ()
  303. {
  304. Runtime.ValidateRefCounted (this);
  305. return Sound_GetIntFrequency (handle);
  306. }
  307. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  308. internal static extern bool Sound_IsLooped (IntPtr handle);
  309. /// <summary>
  310. /// Return whether is looped.
  311. /// </summary>
  312. private bool IsLooped ()
  313. {
  314. Runtime.ValidateRefCounted (this);
  315. return Sound_IsLooped (handle);
  316. }
  317. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  318. internal static extern bool Sound_IsSixteenBit (IntPtr handle);
  319. /// <summary>
  320. /// Return whether data is sixteen bit.
  321. /// </summary>
  322. private bool IsSixteenBit ()
  323. {
  324. Runtime.ValidateRefCounted (this);
  325. return Sound_IsSixteenBit (handle);
  326. }
  327. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  328. internal static extern bool Sound_IsStereo (IntPtr handle);
  329. /// <summary>
  330. /// Return whether data is stereo.
  331. /// </summary>
  332. private bool IsStereo ()
  333. {
  334. Runtime.ValidateRefCounted (this);
  335. return Sound_IsStereo (handle);
  336. }
  337. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  338. internal static extern bool Sound_IsCompressed (IntPtr handle);
  339. /// <summary>
  340. /// Return whether is compressed.
  341. /// </summary>
  342. private bool IsCompressed ()
  343. {
  344. Runtime.ValidateRefCounted (this);
  345. return Sound_IsCompressed (handle);
  346. }
  347. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  348. internal static extern void Sound_FixInterpolation (IntPtr handle);
  349. /// <summary>
  350. /// Fix interpolation by copying data from loop start to loop end (looped), or adding silence (oneshot.) Called internally, does not normally need to be called, unless the sound data is modified manually on the fly.
  351. /// </summary>
  352. public void FixInterpolation ()
  353. {
  354. Runtime.ValidateRefCounted (this);
  355. Sound_FixInterpolation (handle);
  356. }
  357. public override StringHash Type {
  358. get {
  359. return UrhoGetType ();
  360. }
  361. }
  362. public override string TypeName {
  363. get {
  364. return GetTypeName ();
  365. }
  366. }
  367. [Preserve]
  368. public new static StringHash TypeStatic {
  369. get {
  370. return GetTypeStatic ();
  371. }
  372. }
  373. public new static string TypeNameStatic {
  374. get {
  375. return GetTypeNameStatic ();
  376. }
  377. }
  378. /// <summary>
  379. /// Return whether is looped.
  380. /// Or
  381. /// Set loop on/off. If loop is enabled, sets the full sound as loop range.
  382. /// </summary>
  383. public bool Looped {
  384. get {
  385. return IsLooped ();
  386. }
  387. set {
  388. SetLooped (value);
  389. }
  390. }
  391. /// <summary>
  392. /// Return a new instance of a decoder sound stream. Used by compressed sounds.
  393. /// </summary>
  394. public SoundStream DecoderStream {
  395. get {
  396. return GetDecoderStream ();
  397. }
  398. }
  399. /// <summary>
  400. /// Return sound data start.
  401. /// </summary>
  402. public sbyte* Start {
  403. get {
  404. return GetStart ();
  405. }
  406. }
  407. /// <summary>
  408. /// Return loop start.
  409. /// </summary>
  410. public sbyte* Repeat {
  411. get {
  412. return GetRepeat ();
  413. }
  414. }
  415. /// <summary>
  416. /// Return sound data end.
  417. /// </summary>
  418. public sbyte* End {
  419. get {
  420. return GetEnd ();
  421. }
  422. }
  423. /// <summary>
  424. /// Return length in seconds.
  425. /// </summary>
  426. public float Length {
  427. get {
  428. return GetLength ();
  429. }
  430. }
  431. /// <summary>
  432. /// Return total sound data size.
  433. /// </summary>
  434. public uint DataSize {
  435. get {
  436. return GetDataSize ();
  437. }
  438. }
  439. /// <summary>
  440. /// Return sample size.
  441. /// </summary>
  442. public uint SampleSize {
  443. get {
  444. return GetSampleSize ();
  445. }
  446. }
  447. /// <summary>
  448. /// Return default frequency as a float.
  449. /// </summary>
  450. public float Frequency {
  451. get {
  452. return GetFrequency ();
  453. }
  454. }
  455. /// <summary>
  456. /// Return default frequency as an integer.
  457. /// </summary>
  458. public uint IntFrequency {
  459. get {
  460. return GetIntFrequency ();
  461. }
  462. }
  463. /// <summary>
  464. /// Return whether data is sixteen bit.
  465. /// </summary>
  466. public bool SixteenBit {
  467. get {
  468. return IsSixteenBit ();
  469. }
  470. }
  471. /// <summary>
  472. /// Return whether data is stereo.
  473. /// </summary>
  474. public bool Stereo {
  475. get {
  476. return IsStereo ();
  477. }
  478. }
  479. /// <summary>
  480. /// Return whether is compressed.
  481. /// </summary>
  482. public bool Compressed {
  483. get {
  484. return IsCompressed ();
  485. }
  486. }
  487. }
  488. }