Commit Graph

156 Commits

Author SHA1 Message Date
Wierdox a3158d89bb Fix AudioStreamPlayer3D still processing when out of range 2024-09-19 22:16:59 -07:00
Raul Santos 7fd261c8c1
Expose `AudioStreamPlayer{2D,3D}::set_playing` and remove `AudioStreamPlayer::{2D,3D}::_is_active`
- The `_is_active` method seems to be unused, so it was removed.
- The `_set_playing` method is now exposed, as the setter of the `playing` property.
    - The `play` method can't be used as a setter because it takes a `float` parameter instead of a `bool` parameter.
2024-08-30 17:16:46 +02:00
Kusok 8c7dd3cb61 Add `stop_callable` to `AudioStreamPlayerInternal` 2024-08-11 20:27:15 +08:00
Adam Scott 52fa4f05f3
Add samples playback support 2024-06-18 11:06:31 -04:00
aaronp64 58931c073d Check for NaN in set_volume_db functions
Added check in AudioStreamPlayer, AudioStreamPlayer2D, and AudioStreamPlayer3D set_volume_db functions to prevent setting volume to NaN, and give an error.  Using NaN for volume and playing the AudioStreamPlayer could prevent all audio from playing, even from other AudioStreamPlayers.

Fixes #88133
2024-04-18 11:28:57 -04:00
smix8 35dafc9fa8 Split monolithic physics class files
Splits monolithic physics class files.
2024-02-27 11:18:16 +01:00
A Thousand Ships d8b29efe66
Fix member names of `AudioFrame` to match extension 2024-02-13 15:37:09 +01:00
Aaron Franke 35c99bbcc1
Change AudioStreamPlayer autoplay and GLTFBufferView getters to be const 2024-02-08 13:01:50 -06:00
Aaron Franke 52aa5668fe
Fix AudioStreamPlayer3D autoplay and internal notifications 2024-01-30 00:56:12 -06:00
A Thousand Ships 15369fdb1d
Remove unnecessary `this->` expressions 2024-01-29 09:59:18 +01:00
kobewi 0c7db3cdad Add AudioStreamPlayerInternal to unify stream players 2024-01-17 13:12:02 +01:00
Juan Linietsky a40fe16866 Implement audio stream playback parameters.
Implements a way for audio stream playback to be configured via parameters
directly in the edited AudioStreamPlayer[2D/3D].

Currently, configuring the playback stream is not possible (or is sometimes hacky
as the user has to obtain the currently played stream, which is not always immediately available).

This PR only implements this new feature to control looping in stream playback instances (a commonly requested feature, which was lost in the transition from Godot 2 to Godot 3).
But the idea is that it can do a lot more:

* If effects are bundled to the stream, control per playback instance parameters such as cutoff or resoance, or any other exposed effect parameter per playback instance.
* For the upcoming interactive music PR (#64488), this exposes an easy way to change the active clip, which was not possible before.
* For the upcoming parametrizable audio support (https://github.com/godotengine/godot-proposals/issues/3394) this allows editing and animating audio graph parameters.

In any case, this PR is required to complete #64488.

Update modules/vorbis/audio_stream_ogg_vorbis.h

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>

Update modules/minimp3/audio_stream_mp3.h

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>

Update modules/minimp3/audio_stream_mp3.h

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>

Update modules/vorbis/audio_stream_ogg_vorbis.h

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>

Update doc/classes/AudioStream.xml

Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-01-16 10:31:52 +01:00
A Thousand Ships 72fccd82c5 [Audio] Fix pausing stream on entering tree
The paused notifications are only sent when pause status is changed,
this ensures that streams that are non-processing do not play when added
to the tree. Also ensures that the `process_mode` property applies
generally.
2023-10-22 22:35:32 +02:00
MewPurPur f29b6e73c2 Add a bus_renamed AudioServer signal 2023-09-15 13:02:03 +03:00
Hugo Locurcio 49b6067aba Use StringName consistently to refer to the Master audio bus name 2023-08-07 18:06:17 +02:00
Rémi Verschelde 9583c20171
Merge pull request #70515 from stmSi/fix-hanging-audio-pitch-scale
Fix hanging if audiostream's pitch_scale is NaN
2023-02-17 14:06:55 +01:00
Markus Sauermann 826e54fa73 Some code simplifications
1. `number_width` isn't used later
2. `return_type` is used only once
3. AudioServer::get_singleton()->get_channel_count() always returns a channel_count of 1 or larger
4. negative `aa->backward` conditional
5. `current_canvas` == `find_world_2d()->get_canvas()`
6. identical if `render_shadows`
2023-02-07 14:30:16 +01:00
Silc Renew 75330887d7 Implement blending audio feature to AnimationTree 2023-01-28 20:08:29 +09:00
Rémi Verschelde 1891d9fdf1
Merge pull request #71801 from akien-mga/codespell-en-GB-to-en-US
Convert en_GB spelling to en_US with codespell
2023-01-23 11:08:55 +01:00
Rémi Verschelde 5b1df48c6c
Convert en_GB spelling to en_US with codespell 2023-01-23 11:02:20 +01:00
Juan Linietsky 4383b5ab1e Simplify AudioStreamPolyphonic
* Make AudioStreamPolyphonic not requre a polling thread (simpler, faster)
* Improve error reporting in AudioStreamPlayer*::get_stream_playback() error reporting to improve usability.
2023-01-23 10:47:01 +01:00
Rémi Verschelde d95794ec8a
One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
stmSi 2041616934 Fix Editor hanging if audiostream's pitch_scale is NaN 2022-12-24 12:39:48 +06:30
Micky b6db09968d Fix AudioStreamPlayer2D and 3D's `playing` not updating right away 2022-11-22 15:46:28 +01:00
kobewi e48c5daddf Unify usage of GLOBAL/EDITOR_GET 2022-10-18 19:01:48 +02:00
Rémi Verschelde 6d534f6e89 Merge pull request #66221 from Mickeon/painstakingly-appending-ds-en-you-tea-es
Rename remaining "*_enable" to "*_enabled"
2022-10-11 16:17:02 +02:00
Micky c1b5b68eee Rename remaining "*_enable" to "*_enabled"
Material.`proximity_fade_enable` -> `proximity_fade_enabled`
Material.`set_proximity_fade` -> `set_proximity_fade_enabled`
(Material.`is_proximity_fade_enabled` is unchanged)

Area3D.`reverb_bus_enable` -> `reverb_bus_enabled`
(`set_use_reverb_bus` & `is_using_reverb_bus` are unchanged)

RDPipelineRasterizationState:
`depth_bias_enable` -> `depth_bias_enabled`
`set_depth_bias_enable` -> `set_depth_bias_enabled`
`get_depth_bias_enable` -> `get_depth_bias_enabled`

Bonus:
Area3D.`set_reverb_bus` -> `set_reverb_bus_name`
Area3D.`get_reverb_bus` -> `set_get_reverb_bus_name`
2022-09-21 22:47:46 +02:00
Micky eb0cc08a23 Rename AudioStreamPlayer3D's `unit_db` to `volume_db`
AudioStreamPlayer3D.`unit_db` -> `volume_db`

Now matches the same name AudioStreamPlayer and AudioStreamPlayer2D use.
2022-09-17 16:06:30 +02:00
Micky a7ce7b1d3f Fix AudioStreamPlayer not resuming after returning to SceneTree 2022-09-05 16:52:46 +02:00
Micky 59e11934d8 Rename `str2var` to `str_to_var` and similar
Affects the Math class, a good chunk of the audio code, and a lot of other miscellaneous classes, too.

- `var2str` -> `var_to_str`
- `str2var` -> `str_to_var`
- `bytes2var` -> `bytes_to_var`
- `bytes2var_with_objects` -> `bytes_to_var_with_objects`
- `var2bytes` -> `var_to_bytes`
- `var2bytes_with_objects` -> `var_to_bytes_with_objects`
- `linear2db` -> `linear_to_db`
- `db2linear` -> `db_to_linear`
- `deg2rad` -> `deg_to_rad`
- `rad2deg` -> `rad_to_deg`

- `dict2inst` -> `dict_to_inst`
- `inst2dict` -> `inst_to_dict`
2022-08-26 14:58:22 +02:00
Yuri Sizov 1a24c9e14b Make `_validate_property` a multilevel method 2022-08-22 18:35:11 +03:00
reduz d1ddee2258 Implement BPM support
Based on #62896, only implements the BPM support part.

* Implements BPM support in the AudioStreamOGG/MP3 importers.
* Can select BPM/Bar Size and total beats in a song file, as well as edit looping points.
* Looping is now BPM aware
* Added a special importer UI for configuring this.
* Added a special preview showing the audio waveform as well as the playback position in the resource picker.
* Renamed `AudioStream::instance` to `instantiate` for correctness.
2022-07-23 07:31:17 +02:00
Ellen Poe d384d84f45 Audio: Expose 2D/3D panning strength parameters 2022-06-17 13:08:48 +02:00
Hugo Locurcio 93933e4085
Add a gizmo to visualize AudioStreamPlayer3D's audible radius
The ring's color changes depending on the attenuation model chosen,
and whether Max Distance is capping the distance the sound can be
heard at.

Cold colors are used when the volume cap is a "soft" cap (the sound
can still be heard past the distance, but only faintly).

Warm colors are used when the volume cap is a "hard" cap (the sound
can't be heard past the distance at all).

White is used for linear fade performed when the attenuation model
is Disabled and Max Distance is greater than 0.

No ring is drawn when the attenuation model is Disabled and Max Distance
is equal to 0 (since the sound can be heard from anywhere).
2022-05-26 20:53:07 +02:00
Lyuma 1f02bc0e3e Only call _update_panning during _physics_process. 2022-05-25 14:14:22 -07:00
reduz 45af29da80 Add a new HashSet template
* Intended to replace RBSet in most cases.
* Optimized for iteration speed
2022-05-20 22:40:38 +02:00
Aaron Franke 5dc3bfb80e
Use suffixes for units in nodes and resources 2022-05-19 14:34:27 -05:00
reduz 746dddc067 Replace most uses of Map by HashMap
* Map is unnecessary and inefficient in almost every case.
* Replaced by the new HashMap.
* Renamed Map to RBMap and Set to RBSet for cases that still make sense
  (order matters) but use is discouraged.

There were very few cases where replacing by HashMap was undesired because
keeping the key order was intended.
I tried to keep those (as RBMap) as much as possible, but might have missed
some. Review appreciated!
2022-05-16 10:37:48 +02:00
Aaron Franke fa7a7795f0
Rename Basis get_axis to get_column, remove redundant methods 2022-05-03 09:37:47 -05:00
Rémi Verschelde 0f5455230c
Use `switch` consistently in `_notification` (`scene` folder) 2022-02-15 18:44:55 +01:00
Rémi Verschelde fe52458154
Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
Rémi Verschelde ede7614fe2
Merge pull request #55544 from V-Sekai/audio_camera_null_mitigation 2021-12-06 14:19:40 +01:00
Lightning_A e078f970db Rename `remove()` to `remove_at()` when removing by index 2021-11-23 18:58:57 -07:00
PouleyKetchoupp acbd24ea84 Use parameter classes instead of arguments for all physics queries
Same as what is already done for shape queries, applied to point and ray
queries. Easier to document and more flexible to add more parameters.

Also expose intersect_point method to script in 3D.
Remove intersect_point_on_canvas in 2D, replaced with a parameter.
2021-11-04 11:44:39 -07:00
Lyuma c088a2dd89 Fix crash due to reentrancy in AudioStreamPlayer* finished signal.
This crash occurred when an audio stream finished playing in NOTIFICATION_INTERNAL_PROCESS,
during which it would iterate through a loop of playbacks,
leading to a "finished" signal, which removed the audio player from the tree
which led to a NOTIFICATION_EXIT_TREE,
which would mutate the array of playbacks while within the above loop.

This moves the signal callback outside of the loop which avoids the crash.
Note: previously, the signal was called multiple times if the same player finishes multiple times in one frame. Now it is at most once per frame.

Affects AudioStreamPlayer, AudioStreamPlayer2D and AudioStreamPlayer3D
2021-10-28 19:45:29 -07:00
Lyuma 601a0722a7 Mitigate crash in AudioStreamPlayer3D when a camera has null viewport 2021-10-27 16:06:09 -07:00
reduz d03b7fbe09 Refactored Node3D rotation modes
* Made the Basis euler orders indexed via enum.
* Node3D has a new rotation_order property to choose Euler rotation order.
* Node3D has also a rotation_mode property to choose between Euler, Quaternion and Basis

Exposing these modes as well as the order makes Godot a lot friendlier for animators, which can choose the best way to interpolate rotations.
The new *Basis* mode makes the (exposed) transform property obsolete, so it was removed (can still be accessed by code of course).
2021-10-25 14:34:00 -03:00
Rémi Verschelde 015e0c9fd8
Merge pull request #52773 from Calinou/audiostreamplayer3d-tweak-max-distance 2021-10-18 10:49:01 +02:00
Douglas Leão 39a90751dc Allow AudioStreamPlayer(2D) to provide `pitch_scale` on playback 2021-10-10 18:52:29 -03:00
Hugo Locurcio b383181851
Tweak AudioStreamPlayer3D property hints for usability
This also improves the documentation for the `max_distance` property.
2021-09-25 12:24:30 +02:00