class_eventplayer.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_EventPlayer:
  4. EventPlayer
  5. ===========
  6. **Inherits:** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Class for event stream playback.
  11. Member Functions
  12. ----------------
  13. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`set_stream<class_EventPlayer_set_stream>` **(** :ref:`EventStream<class_eventstream>` stream **)** |
  15. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`EventStream<class_eventstream>` | :ref:`get_stream<class_EventPlayer_get_stream>` **(** **)** const |
  17. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | void | :ref:`play<class_EventPlayer_play>` **(** **)** |
  19. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`stop<class_EventPlayer_stop>` **(** **)** |
  21. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`is_playing<class_EventPlayer_is_playing>` **(** **)** const |
  23. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | void | :ref:`set_paused<class_EventPlayer_set_paused>` **(** :ref:`bool<class_bool>` paused **)** |
  25. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`is_paused<class_EventPlayer_is_paused>` **(** **)** const |
  27. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`set_loop<class_EventPlayer_set_loop>` **(** :ref:`bool<class_bool>` enabled **)** |
  29. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`has_loop<class_EventPlayer_has_loop>` **(** **)** const |
  31. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_volume<class_EventPlayer_set_volume>` **(** :ref:`float<class_float>` volume **)** |
  33. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`float<class_float>` | :ref:`get_volume<class_EventPlayer_get_volume>` **(** **)** const |
  35. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | void | :ref:`set_pitch_scale<class_EventPlayer_set_pitch_scale>` **(** :ref:`float<class_float>` pitch_scale **)** |
  37. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`float<class_float>` | :ref:`get_pitch_scale<class_EventPlayer_get_pitch_scale>` **(** **)** const |
  39. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_tempo_scale<class_EventPlayer_set_tempo_scale>` **(** :ref:`float<class_float>` tempo_scale **)** |
  41. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`float<class_float>` | :ref:`get_tempo_scale<class_EventPlayer_get_tempo_scale>` **(** **)** const |
  43. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`set_volume_db<class_EventPlayer_set_volume_db>` **(** :ref:`float<class_float>` db **)** |
  45. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_volume_db<class_EventPlayer_get_volume_db>` **(** **)** const |
  47. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`String<class_string>` | :ref:`get_stream_name<class_EventPlayer_get_stream_name>` **(** **)** const |
  49. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`int<class_int>` | :ref:`get_loop_count<class_EventPlayer_get_loop_count>` **(** **)** const |
  51. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`get_pos<class_EventPlayer_get_pos>` **(** **)** const |
  53. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`seek_pos<class_EventPlayer_seek_pos>` **(** :ref:`float<class_float>` time **)** |
  55. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`float<class_float>` | :ref:`get_length<class_EventPlayer_get_length>` **(** **)** const |
  57. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | void | :ref:`set_autoplay<class_EventPlayer_set_autoplay>` **(** :ref:`bool<class_bool>` enabled **)** |
  59. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`bool<class_bool>` | :ref:`has_autoplay<class_EventPlayer_has_autoplay>` **(** **)** const |
  61. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`set_channel_volume<class_EventPlayer_set_channel_volume>` **(** :ref:`int<class_int>` channel, :ref:`float<class_float>` channel_volume **)** |
  63. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`float<class_float>` | :ref:`get_channel_volume<class_EventPlayer_get_channel_volume>` **(** :ref:`int<class_int>` channel **)** const |
  65. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`float<class_float>` | :ref:`get_channel_last_note_time<class_EventPlayer_get_channel_last_note_time>` **(** :ref:`int<class_int>` channel **)** const |
  67. +----------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. Description
  69. -----------
  70. Class for event stream playback. Event streams are music expressed as a series of events (note on, note off, instrument change...), as opposed to audio streams, which are just audio data. Examples of event-based streams are MIDI files, or MOD music.
  71. Currently, only MOD, S3M, IT, and XM music is supported.
  72. Member Function Description
  73. ---------------------------
  74. .. _class_EventPlayer_set_stream:
  75. - void **set_stream** **(** :ref:`EventStream<class_eventstream>` stream **)**
  76. Set the :ref:`EventStream<class_eventstream>` this player will play.
  77. .. _class_EventPlayer_get_stream:
  78. - :ref:`EventStream<class_eventstream>` **get_stream** **(** **)** const
  79. Return the currently assigned stream.
  80. .. _class_EventPlayer_play:
  81. - void **play** **(** **)**
  82. Play the currently assigned stream.
  83. .. _class_EventPlayer_stop:
  84. - void **stop** **(** **)**
  85. Stop playing.
  86. .. _class_EventPlayer_is_playing:
  87. - :ref:`bool<class_bool>` **is_playing** **(** **)** const
  88. Return whether this player is playing.
  89. .. _class_EventPlayer_set_paused:
  90. - void **set_paused** **(** :ref:`bool<class_bool>` paused **)**
  91. Pause stream playback.
  92. .. _class_EventPlayer_is_paused:
  93. - :ref:`bool<class_bool>` **is_paused** **(** **)** const
  94. Return whether the playback is currently paused.
  95. .. _class_EventPlayer_set_loop:
  96. - void **set_loop** **(** :ref:`bool<class_bool>` enabled **)**
  97. Set whether the stream will be restarted at the end.
  98. .. _class_EventPlayer_has_loop:
  99. - :ref:`bool<class_bool>` **has_loop** **(** **)** const
  100. Return whether this player will be restart the playback at the end.
  101. .. _class_EventPlayer_set_volume:
  102. - void **set_volume** **(** :ref:`float<class_float>` volume **)**
  103. Set the playback volume for this player. This is a float between 0.0 (silent) and 1.0 (full volume). Values over 1.0 may amplify sound even more, but may introduce distortion. Negative values may just invert the output waveform, which produces no audible difference.
  104. The effect of these special values ultimately depends on the low-level implementation of the file format being played.
  105. .. _class_EventPlayer_get_volume:
  106. - :ref:`float<class_float>` **get_volume** **(** **)** const
  107. Return the playback volume for this player.
  108. .. _class_EventPlayer_set_pitch_scale:
  109. - void **set_pitch_scale** **(** :ref:`float<class_float>` pitch_scale **)**
  110. Set the pitch multiplier for all sounds coming from this stream. A value of 2.0 shifts all pitches one octave up, and a value of 0.5 shifts pitches one octave down.
  111. .. _class_EventPlayer_get_pitch_scale:
  112. - :ref:`float<class_float>` **get_pitch_scale** **(** **)** const
  113. Return the pitch scale factor for this player.
  114. .. _class_EventPlayer_set_tempo_scale:
  115. - void **set_tempo_scale** **(** :ref:`float<class_float>` tempo_scale **)**
  116. Set the tempo multiplier. This allows to slow down or speed up the music, without affecting its pitch.
  117. .. _class_EventPlayer_get_tempo_scale:
  118. - :ref:`float<class_float>` **get_tempo_scale** **(** **)** const
  119. Return the tempo multiplier.
  120. .. _class_EventPlayer_set_volume_db:
  121. - void **set_volume_db** **(** :ref:`float<class_float>` db **)**
  122. Set the playback volume for this player, in decibels. This is a float between -80.0 (silent) and 0.0 (full volume). Values under -79.0 get truncated to -80, but values over 0.0 do not, so the warnings for over amplifying (see :ref:`set_volume<class_EventPlayer_set_volume>`) still apply.
  123. .. _class_EventPlayer_get_volume_db:
  124. - :ref:`float<class_float>` **get_volume_db** **(** **)** const
  125. Return the playback volume for this player, in decibels.
  126. .. _class_EventPlayer_get_stream_name:
  127. - :ref:`String<class_string>` **get_stream_name** **(** **)** const
  128. Return the name of the currently assigned stream. This is not the file name, but a field inside the file. If no stream is assigned, if returns "<No Stream>".
  129. .. _class_EventPlayer_get_loop_count:
  130. - :ref:`int<class_int>` **get_loop_count** **(** **)** const
  131. Return the number of times the playback has looped.
  132. .. _class_EventPlayer_get_pos:
  133. - :ref:`float<class_float>` **get_pos** **(** **)** const
  134. Return the playback position. May be in seconds, but depends on the stream type.
  135. .. _class_EventPlayer_seek_pos:
  136. - void **seek_pos** **(** :ref:`float<class_float>` time **)**
  137. Set the playback position. May be in seconds, but depends on the stream type.
  138. .. _class_EventPlayer_get_length:
  139. - :ref:`float<class_float>` **get_length** **(** **)** const
  140. Return the song length. May be in seconds, but depends on the stream type.
  141. .. _class_EventPlayer_set_autoplay:
  142. - void **set_autoplay** **(** :ref:`bool<class_bool>` enabled **)**
  143. Set whether this player will start playing as soon as it enters the scene tree.
  144. .. _class_EventPlayer_has_autoplay:
  145. - :ref:`bool<class_bool>` **has_autoplay** **(** **)** const
  146. Return whether this player will start playing as soon as it enters the scene tree.
  147. .. _class_EventPlayer_set_channel_volume:
  148. - void **set_channel_volume** **(** :ref:`int<class_int>` channel, :ref:`float<class_float>` channel_volume **)**
  149. Set the volume scale for an individual channel of the stream, with the same value range as :ref:`set_volume<class_EventPlayer_set_volume>`. The channel number depends on the stream format. For example, MIDIs range from 0 to 15, and MODs from 0 to 63.
  150. Many stream formats are multichannel, so this allows to affect only a part of the music.
  151. .. _class_EventPlayer_get_channel_volume:
  152. - :ref:`float<class_float>` **get_channel_volume** **(** :ref:`int<class_int>` channel **)** const
  153. Return the volume scale for an individual channel of the stream.
  154. .. _class_EventPlayer_get_channel_last_note_time:
  155. - :ref:`float<class_float>` **get_channel_last_note_time** **(** :ref:`int<class_int>` channel **)** const
  156. Return the time at which the last note of a given channel in the stream plays.