SoundSource.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // SoundSource.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 source component with stereo position. A sound source needs to be created to a node to be considered "enabled" and be able to play, however that node does not need to belong to a scene.
  21. /// </summary>
  22. public unsafe partial class SoundSource : Component
  23. {
  24. public SoundSource (IntPtr handle) : base (handle)
  25. {
  26. }
  27. protected SoundSource (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  28. {
  29. }
  30. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  31. internal static extern int SoundSource_GetType (IntPtr handle);
  32. private StringHash UrhoGetType ()
  33. {
  34. Runtime.ValidateRefCounted (this);
  35. return new StringHash (SoundSource_GetType (handle));
  36. }
  37. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  38. internal static extern IntPtr SoundSource_GetTypeName (IntPtr handle);
  39. private string GetTypeName ()
  40. {
  41. Runtime.ValidateRefCounted (this);
  42. return Marshal.PtrToStringAnsi (SoundSource_GetTypeName (handle));
  43. }
  44. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  45. internal static extern int SoundSource_GetTypeStatic ();
  46. private static StringHash GetTypeStatic ()
  47. {
  48. Runtime.Validate (typeof(SoundSource));
  49. return new StringHash (SoundSource_GetTypeStatic ());
  50. }
  51. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  52. internal static extern IntPtr SoundSource_GetTypeNameStatic ();
  53. private static string GetTypeNameStatic ()
  54. {
  55. Runtime.Validate (typeof(SoundSource));
  56. return Marshal.PtrToStringAnsi (SoundSource_GetTypeNameStatic ());
  57. }
  58. public SoundSource () : this (Application.CurrentContext)
  59. {
  60. }
  61. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  62. internal static extern IntPtr SoundSource_SoundSource (IntPtr context);
  63. public SoundSource (Context context) : base (UrhoObjectFlag.Empty)
  64. {
  65. Runtime.Validate (typeof(SoundSource));
  66. handle = SoundSource_SoundSource ((object)context == null ? IntPtr.Zero : context.Handle);
  67. Runtime.RegisterObject (this);
  68. }
  69. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  70. internal static extern void SoundSource_RegisterObject (IntPtr context);
  71. /// <summary>
  72. /// Register object factory.
  73. /// </summary>
  74. public new static void RegisterObject (Context context)
  75. {
  76. Runtime.Validate (typeof(SoundSource));
  77. SoundSource_RegisterObject ((object)context == null ? IntPtr.Zero : context.Handle);
  78. }
  79. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  80. internal static extern void SoundSource_Play (IntPtr handle, IntPtr sound);
  81. /// <summary>
  82. /// Play a sound.
  83. /// </summary>
  84. public void Play (Sound sound)
  85. {
  86. Runtime.ValidateRefCounted (this);
  87. SoundSource_Play (handle, (object)sound == null ? IntPtr.Zero : sound.Handle);
  88. }
  89. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  90. internal static extern void SoundSource_Play0 (IntPtr handle, IntPtr sound, float frequency);
  91. /// <summary>
  92. /// Play a sound with specified frequency.
  93. /// </summary>
  94. public void Play (Sound sound, float frequency)
  95. {
  96. Runtime.ValidateRefCounted (this);
  97. SoundSource_Play0 (handle, (object)sound == null ? IntPtr.Zero : sound.Handle, frequency);
  98. }
  99. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  100. internal static extern void SoundSource_Play1 (IntPtr handle, IntPtr sound, float frequency, float gain);
  101. /// <summary>
  102. /// Play a sound with specified frequency and gain.
  103. /// </summary>
  104. public void Play (Sound sound, float frequency, float gain)
  105. {
  106. Runtime.ValidateRefCounted (this);
  107. SoundSource_Play1 (handle, (object)sound == null ? IntPtr.Zero : sound.Handle, frequency, gain);
  108. }
  109. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  110. internal static extern void SoundSource_Play2 (IntPtr handle, IntPtr sound, float frequency, float gain, float panning);
  111. /// <summary>
  112. /// Play a sound with specified frequency, gain and panning.
  113. /// </summary>
  114. public void Play (Sound sound, float frequency, float gain, float panning)
  115. {
  116. Runtime.ValidateRefCounted (this);
  117. SoundSource_Play2 (handle, (object)sound == null ? IntPtr.Zero : sound.Handle, frequency, gain, panning);
  118. }
  119. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  120. internal static extern void SoundSource_Play3 (IntPtr handle, IntPtr stream);
  121. /// <summary>
  122. /// Start playing a sound stream.
  123. /// </summary>
  124. public void Play (SoundStream stream)
  125. {
  126. Runtime.ValidateRefCounted (this);
  127. SoundSource_Play3 (handle, (object)stream == null ? IntPtr.Zero : stream.Handle);
  128. }
  129. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  130. internal static extern void SoundSource_Stop (IntPtr handle);
  131. /// <summary>
  132. /// Stop playback.
  133. /// </summary>
  134. public void Stop ()
  135. {
  136. Runtime.ValidateRefCounted (this);
  137. SoundSource_Stop (handle);
  138. }
  139. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  140. internal static extern void SoundSource_SetSoundType (IntPtr handle, string type);
  141. /// <summary>
  142. /// Set sound type, determines the master gain group.
  143. /// </summary>
  144. public void SetSoundType (string type)
  145. {
  146. Runtime.ValidateRefCounted (this);
  147. SoundSource_SetSoundType (handle, type);
  148. }
  149. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  150. internal static extern void SoundSource_SetFrequency (IntPtr handle, float frequency);
  151. /// <summary>
  152. /// Set frequency.
  153. /// </summary>
  154. private void SetFrequency (float frequency)
  155. {
  156. Runtime.ValidateRefCounted (this);
  157. SoundSource_SetFrequency (handle, frequency);
  158. }
  159. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  160. internal static extern void SoundSource_SetGain (IntPtr handle, float gain);
  161. /// <summary>
  162. /// Set gain. 0.0 is silence, 1.0 is full volume.
  163. /// </summary>
  164. private void SetGain (float gain)
  165. {
  166. Runtime.ValidateRefCounted (this);
  167. SoundSource_SetGain (handle, gain);
  168. }
  169. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  170. internal static extern void SoundSource_SetAttenuation (IntPtr handle, float attenuation);
  171. /// <summary>
  172. /// Set attenuation. 1.0 is unaltered. Used for distance attenuated playback.
  173. /// </summary>
  174. private void SetAttenuation (float attenuation)
  175. {
  176. Runtime.ValidateRefCounted (this);
  177. SoundSource_SetAttenuation (handle, attenuation);
  178. }
  179. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  180. internal static extern void SoundSource_SetPanning (IntPtr handle, float panning);
  181. /// <summary>
  182. /// Set stereo panning. -1.0 is full left and 1.0 is full right.
  183. /// </summary>
  184. private void SetPanning (float panning)
  185. {
  186. Runtime.ValidateRefCounted (this);
  187. SoundSource_SetPanning (handle, panning);
  188. }
  189. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  190. internal static extern void SoundSource_SetAutoRemoveMode (IntPtr handle, AutoRemoveMode mode);
  191. /// <summary>
  192. /// / Set to remove either the sound source component or its owner node from the scene automatically on sound playback completion. Disabled by default.
  193. /// </summary>
  194. private void SetAutoRemoveMode (AutoRemoveMode mode)
  195. {
  196. Runtime.ValidateRefCounted (this);
  197. SoundSource_SetAutoRemoveMode (handle, mode);
  198. }
  199. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  200. internal static extern void SoundSource_SetPlayPosition (IntPtr handle, sbyte* pos);
  201. /// <summary>
  202. /// Set new playback position.
  203. /// </summary>
  204. public void SetPlayPosition (sbyte* pos)
  205. {
  206. Runtime.ValidateRefCounted (this);
  207. SoundSource_SetPlayPosition (handle, pos);
  208. }
  209. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  210. internal static extern IntPtr SoundSource_GetSound (IntPtr handle);
  211. /// <summary>
  212. /// Return sound.
  213. /// </summary>
  214. private Sound GetSound ()
  215. {
  216. Runtime.ValidateRefCounted (this);
  217. return Runtime.LookupObject<Sound> (SoundSource_GetSound (handle));
  218. }
  219. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  220. internal static extern sbyte* SoundSource_GetPlayPosition (IntPtr handle);
  221. /// <summary>
  222. /// Return playback position.
  223. /// </summary>
  224. private sbyte* GetPlayPosition ()
  225. {
  226. Runtime.ValidateRefCounted (this);
  227. return SoundSource_GetPlayPosition (handle);
  228. }
  229. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  230. internal static extern IntPtr SoundSource_GetSoundType (IntPtr handle);
  231. /// <summary>
  232. /// Return sound type, determines the master gain group.
  233. /// </summary>
  234. private string GetSoundType ()
  235. {
  236. Runtime.ValidateRefCounted (this);
  237. return Marshal.PtrToStringAnsi (SoundSource_GetSoundType (handle));
  238. }
  239. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  240. internal static extern float SoundSource_GetTimePosition (IntPtr handle);
  241. /// <summary>
  242. /// Return playback time position.
  243. /// </summary>
  244. private float GetTimePosition ()
  245. {
  246. Runtime.ValidateRefCounted (this);
  247. return SoundSource_GetTimePosition (handle);
  248. }
  249. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  250. internal static extern float SoundSource_GetFrequency (IntPtr handle);
  251. /// <summary>
  252. /// Return frequency.
  253. /// </summary>
  254. private float GetFrequency ()
  255. {
  256. Runtime.ValidateRefCounted (this);
  257. return SoundSource_GetFrequency (handle);
  258. }
  259. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  260. internal static extern float SoundSource_GetGain (IntPtr handle);
  261. /// <summary>
  262. /// Return gain.
  263. /// </summary>
  264. private float GetGain ()
  265. {
  266. Runtime.ValidateRefCounted (this);
  267. return SoundSource_GetGain (handle);
  268. }
  269. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  270. internal static extern float SoundSource_GetAttenuation (IntPtr handle);
  271. /// <summary>
  272. /// Return attenuation.
  273. /// </summary>
  274. private float GetAttenuation ()
  275. {
  276. Runtime.ValidateRefCounted (this);
  277. return SoundSource_GetAttenuation (handle);
  278. }
  279. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  280. internal static extern float SoundSource_GetPanning (IntPtr handle);
  281. /// <summary>
  282. /// Return stereo panning.
  283. /// </summary>
  284. private float GetPanning ()
  285. {
  286. Runtime.ValidateRefCounted (this);
  287. return SoundSource_GetPanning (handle);
  288. }
  289. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  290. internal static extern AutoRemoveMode SoundSource_GetAutoRemoveMode (IntPtr handle);
  291. /// <summary>
  292. /// Return automatic removal mode on sound playback completion.
  293. /// </summary>
  294. private AutoRemoveMode GetAutoRemoveMode ()
  295. {
  296. Runtime.ValidateRefCounted (this);
  297. return SoundSource_GetAutoRemoveMode (handle);
  298. }
  299. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  300. internal static extern bool SoundSource_IsPlaying (IntPtr handle);
  301. /// <summary>
  302. /// Return whether is playing.
  303. /// </summary>
  304. private bool IsPlaying ()
  305. {
  306. Runtime.ValidateRefCounted (this);
  307. return SoundSource_IsPlaying (handle);
  308. }
  309. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  310. internal static extern void SoundSource_Update (IntPtr handle, float timeStep);
  311. /// <summary>
  312. /// Update the sound source. Perform subclass specific operations. Called by Audio.
  313. /// </summary>
  314. public virtual void Update (float timeStep)
  315. {
  316. Runtime.ValidateRefCounted (this);
  317. SoundSource_Update (handle, timeStep);
  318. }
  319. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  320. internal static extern void SoundSource_Mix (IntPtr handle, int* dest, uint samples, int mixRate, bool stereo, bool interpolation);
  321. /// <summary>
  322. /// Mix sound source output to a 32-bit clipping buffer. Called by Audio.
  323. /// </summary>
  324. public void Mix (int* dest, uint samples, int mixRate, bool stereo, bool interpolation)
  325. {
  326. Runtime.ValidateRefCounted (this);
  327. SoundSource_Mix (handle, dest, samples, mixRate, stereo, interpolation);
  328. }
  329. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  330. internal static extern void SoundSource_UpdateMasterGain (IntPtr handle);
  331. /// <summary>
  332. /// Update the effective master gain. Called internally and by Audio when the master gain changes.
  333. /// </summary>
  334. public void UpdateMasterGain ()
  335. {
  336. Runtime.ValidateRefCounted (this);
  337. SoundSource_UpdateMasterGain (handle);
  338. }
  339. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  340. internal static extern void SoundSource_SetPositionAttr (IntPtr handle, int value);
  341. /// <summary>
  342. /// Set sound position attribute.
  343. /// </summary>
  344. private void SetPositionAttr (int value)
  345. {
  346. Runtime.ValidateRefCounted (this);
  347. SoundSource_SetPositionAttr (handle, value);
  348. }
  349. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  350. internal static extern ResourceRef SoundSource_GetSoundAttr (IntPtr handle);
  351. /// <summary>
  352. /// Return sound attribute.
  353. /// </summary>
  354. private ResourceRef GetSoundAttr ()
  355. {
  356. Runtime.ValidateRefCounted (this);
  357. return SoundSource_GetSoundAttr (handle);
  358. }
  359. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  360. internal static extern void SoundSource_SetPlayingAttr (IntPtr handle, bool value);
  361. /// <summary>
  362. /// Set sound playing attribute
  363. /// </summary>
  364. public void SetPlayingAttr (bool value)
  365. {
  366. Runtime.ValidateRefCounted (this);
  367. SoundSource_SetPlayingAttr (handle, value);
  368. }
  369. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  370. internal static extern int SoundSource_GetPositionAttr (IntPtr handle);
  371. /// <summary>
  372. /// Return sound position attribute.
  373. /// </summary>
  374. private int GetPositionAttr ()
  375. {
  376. Runtime.ValidateRefCounted (this);
  377. return SoundSource_GetPositionAttr (handle);
  378. }
  379. public override StringHash Type {
  380. get {
  381. return UrhoGetType ();
  382. }
  383. }
  384. public override string TypeName {
  385. get {
  386. return GetTypeName ();
  387. }
  388. }
  389. public new static StringHash TypeStatic {
  390. get {
  391. return GetTypeStatic ();
  392. }
  393. }
  394. public new static string TypeNameStatic {
  395. get {
  396. return GetTypeNameStatic ();
  397. }
  398. }
  399. /// <summary>
  400. /// Return sound type, determines the master gain group.
  401. /// </summary>
  402. public string SoundType {
  403. get {
  404. return GetSoundType ();
  405. }
  406. }
  407. /// <summary>
  408. /// Return frequency.
  409. /// Or
  410. /// Set frequency.
  411. /// </summary>
  412. public float Frequency {
  413. get {
  414. return GetFrequency ();
  415. }
  416. set {
  417. SetFrequency (value);
  418. }
  419. }
  420. /// <summary>
  421. /// Return gain.
  422. /// Or
  423. /// Set gain. 0.0 is silence, 1.0 is full volume.
  424. /// </summary>
  425. public float Gain {
  426. get {
  427. return GetGain ();
  428. }
  429. set {
  430. SetGain (value);
  431. }
  432. }
  433. /// <summary>
  434. /// Return attenuation.
  435. /// Or
  436. /// Set attenuation. 1.0 is unaltered. Used for distance attenuated playback.
  437. /// </summary>
  438. public float Attenuation {
  439. get {
  440. return GetAttenuation ();
  441. }
  442. set {
  443. SetAttenuation (value);
  444. }
  445. }
  446. /// <summary>
  447. /// Return stereo panning.
  448. /// Or
  449. /// Set stereo panning. -1.0 is full left and 1.0 is full right.
  450. /// </summary>
  451. public float Panning {
  452. get {
  453. return GetPanning ();
  454. }
  455. set {
  456. SetPanning (value);
  457. }
  458. }
  459. /// <summary>
  460. /// Return automatic removal mode on sound playback completion.
  461. /// Or
  462. /// / Set to remove either the sound source component or its owner node from the scene automatically on sound playback completion. Disabled by default.
  463. /// </summary>
  464. public AutoRemoveMode AutoRemoveMode {
  465. get {
  466. return GetAutoRemoveMode ();
  467. }
  468. set {
  469. SetAutoRemoveMode (value);
  470. }
  471. }
  472. /// <summary>
  473. /// Return playback position.
  474. /// </summary>
  475. public sbyte* PlayPosition {
  476. get {
  477. return GetPlayPosition ();
  478. }
  479. }
  480. /// <summary>
  481. /// Return sound.
  482. /// </summary>
  483. public Sound Sound {
  484. get {
  485. return GetSound ();
  486. }
  487. }
  488. /// <summary>
  489. /// Return playback time position.
  490. /// </summary>
  491. public float TimePosition {
  492. get {
  493. return GetTimePosition ();
  494. }
  495. }
  496. /// <summary>
  497. /// Return whether is playing.
  498. /// </summary>
  499. public bool Playing {
  500. get {
  501. return IsPlaying ();
  502. }
  503. }
  504. /// <summary>
  505. /// Return sound attribute.
  506. /// </summary>
  507. public ResourceRef SoundAttr {
  508. get {
  509. return GetSoundAttr ();
  510. }
  511. }
  512. /// <summary>
  513. /// Return sound position attribute.
  514. /// Or
  515. /// Set sound position attribute.
  516. /// </summary>
  517. public int PositionAttr {
  518. get {
  519. return GetPositionAttr ();
  520. }
  521. set {
  522. SetPositionAttr (value);
  523. }
  524. }
  525. }
  526. }