SoundSource.cs 18 KB

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