class_audiostreammp3.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AudioStreamMP3.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AudioStreamMP3:
  6. AudioStreamMP3
  7. ==============
  8. **Inherits:** :ref:`AudioStream<class_AudioStream>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  9. MP3 audio stream driver.
  10. Description
  11. -----------
  12. MP3 audio stream driver. See :ref:`data<class_AudioStreamMP3_property_data>` if you want to load an MP3 file at run-time.
  13. Properties
  14. ----------
  15. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  16. | :ref:`int<class_int>` | :ref:`bar_beats<class_AudioStreamMP3_property_bar_beats>` | ``4`` |
  17. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  18. | :ref:`int<class_int>` | :ref:`beat_count<class_AudioStreamMP3_property_beat_count>` | ``0`` |
  19. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  20. | :ref:`float<class_float>` | :ref:`bpm<class_AudioStreamMP3_property_bpm>` | ``0.0`` |
  21. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  22. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`data<class_AudioStreamMP3_property_data>` | ``PackedByteArray()`` |
  23. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  24. | :ref:`bool<class_bool>` | :ref:`loop<class_AudioStreamMP3_property_loop>` | ``false`` |
  25. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  26. | :ref:`float<class_float>` | :ref:`loop_offset<class_AudioStreamMP3_property_loop_offset>` | ``0.0`` |
  27. +-----------------------------------------------+---------------------------------------------------------------+-----------------------+
  28. Property Descriptions
  29. ---------------------
  30. .. _class_AudioStreamMP3_property_bar_beats:
  31. - :ref:`int<class_int>` **bar_beats**
  32. +-----------+----------------------+
  33. | *Default* | ``4`` |
  34. +-----------+----------------------+
  35. | *Setter* | set_bar_beats(value) |
  36. +-----------+----------------------+
  37. | *Getter* | get_bar_beats() |
  38. +-----------+----------------------+
  39. ----
  40. .. _class_AudioStreamMP3_property_beat_count:
  41. - :ref:`int<class_int>` **beat_count**
  42. +-----------+-----------------------+
  43. | *Default* | ``0`` |
  44. +-----------+-----------------------+
  45. | *Setter* | set_beat_count(value) |
  46. +-----------+-----------------------+
  47. | *Getter* | get_beat_count() |
  48. +-----------+-----------------------+
  49. ----
  50. .. _class_AudioStreamMP3_property_bpm:
  51. - :ref:`float<class_float>` **bpm**
  52. +-----------+----------------+
  53. | *Default* | ``0.0`` |
  54. +-----------+----------------+
  55. | *Setter* | set_bpm(value) |
  56. +-----------+----------------+
  57. | *Getter* | get_bpm() |
  58. +-----------+----------------+
  59. ----
  60. .. _class_AudioStreamMP3_property_data:
  61. - :ref:`PackedByteArray<class_PackedByteArray>` **data**
  62. +-----------+-----------------------+
  63. | *Default* | ``PackedByteArray()`` |
  64. +-----------+-----------------------+
  65. | *Setter* | set_data(value) |
  66. +-----------+-----------------------+
  67. | *Getter* | get_data() |
  68. +-----------+-----------------------+
  69. Contains the audio data in bytes.
  70. You can load a file without having to import it beforehand using the code snippet below. Keep in mind that this snippet loads the whole file into memory and may not be ideal for huge files (hundreds of megabytes or more).
  71. .. tabs::
  72. .. code-tab:: gdscript
  73. func load_mp3(path):
  74. var file = File.new()
  75. file.open(path, File.READ)
  76. var sound = AudioStreamMP3.new()
  77. sound.data = file.get_buffer(file.get_length())
  78. file.close()
  79. return sound
  80. .. code-tab:: csharp
  81. public AudioStreamMP3 LoadMP3(string path)
  82. {
  83. var file = new File();
  84. file.Open(path, File.READ);
  85. var sound = new AudioStreamMP3();
  86. sound.Data = file.GetBuffer(file.GetLength());
  87. file.Close();
  88. return sound;
  89. }
  90. ----
  91. .. _class_AudioStreamMP3_property_loop:
  92. - :ref:`bool<class_bool>` **loop**
  93. +-----------+-----------------+
  94. | *Default* | ``false`` |
  95. +-----------+-----------------+
  96. | *Setter* | set_loop(value) |
  97. +-----------+-----------------+
  98. | *Getter* | has_loop() |
  99. +-----------+-----------------+
  100. If ``true``, the stream will automatically loop when it reaches the end.
  101. ----
  102. .. _class_AudioStreamMP3_property_loop_offset:
  103. - :ref:`float<class_float>` **loop_offset**
  104. +-----------+------------------------+
  105. | *Default* | ``0.0`` |
  106. +-----------+------------------------+
  107. | *Setter* | set_loop_offset(value) |
  108. +-----------+------------------------+
  109. | *Getter* | get_loop_offset() |
  110. +-----------+------------------------+
  111. Time in seconds at which the stream starts after being looped.
  112. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  113. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  114. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  115. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  116. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  117. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`