Debian Codegraph @

scene/audio/audio_stream_player_internal.h

raw symbols SCIP
1 /**************************************************************************/
2 /* audio_stream_player_internal.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/object/ref_counted.h"
34 #include "core/templates/safe_refcount.h"
35 #include "servers/audio/audio_server.h"
36
37 class AudioStream;
38 class AudioStreamPlayback;
39 class AudioSamplePlayback;
40 class Node;
41
42 class AudioStreamPlayerInternal : public Object {
43 GDCLASS(AudioStreamPlayerInternal, Object);
44
45 private:
46 struct ParameterData {
47 StringName path;
48 Variant value;
49 };
50
51 static inline const String PARAM_PREFIX = "parameters/";
52
53 Node *node = nullptr;
54 Callable play_callable;
55 Callable stop_callable;
56 bool physical = false;
57 AudioServer::PlaybackType playback_type = AudioServer::PlaybackType::PLAYBACK_TYPE_DEFAULT;
58
59 HashMap<StringName, ParameterData> playback_parameters;
60
61 void _set_process(bool p_enabled);
62 void _update_stream_parameters();
63
64 _FORCE_INLINE_ bool _is_sample() {
65 return (AudioServer::get_singleton()->get_default_playback_type() == AudioServer::PlaybackType::PLAYBACK_TYPE_SAMPLE && get_playback_type() == AudioServer::PlaybackType::PLAYBACK_TYPE_DEFAULT) || get_playback_type() == AudioServer::PlaybackType::PLAYBACK_TYPE_SAMPLE;
66 }
67
68 public:
69 Vector<Ref<AudioStreamPlayback>> stream_playbacks;
70 Ref<AudioStream> stream;
71
72 SafeFlag active;
73
74 float pitch_scale = 1.0;
75 float volume_db = 0.0;
76 bool autoplay = false;
77 StringName bus;
78 int max_polyphony = 1;
79
80 void process();
81 void ensure_playback_limit();
82
83 void notification(int p_what);
84 void validate_property(PropertyInfo &p_property) const;
85 bool set(const StringName &p_name, const Variant &p_value);
86 bool get(const StringName &p_name, Variant &r_ret) const;
87 void get_property_list(List<PropertyInfo> *p_list) const;
88
89 void set_stream(Ref<AudioStream> p_stream);
90 void set_pitch_scale(float p_pitch_scale);
91 void set_max_polyphony(int p_max_polyphony);
92
93 StringName get_bus() const;
94
95 Ref<AudioStreamPlayback> play_basic();
96 void seek(float p_seconds);
97 void stop_basic();
98 bool is_playing() const;
99 float get_playback_position();
100
101 void set_playing(bool p_enable);
102 bool is_active() const;
103
104 void set_stream_paused(bool p_pause);
105 bool get_stream_paused() const;
106
107 bool has_stream_playback();
108 Ref<AudioStreamPlayback> get_stream_playback();
109
110 void set_playback_type(AudioServer::PlaybackType p_playback_type);
111 AudioServer::PlaybackType get_playback_type() const;
112
113 AudioStreamPlayerInternal(Node *p_node, const Callable &p_play_callable, const Callable &p_stop_callable, bool p_physical);
114 };