|
1 | 1 | # API Reference |
2 | 2 |
|
3 | | -The FMOD GDExtension provides comprehensive API documentation directly within Godot 4.3+. This documentation appears in Godot's Help system and provides detailed information about all FMOD classes, methods, properties, and signals. |
| 3 | +The FMOD GDExtension provides a comprehensive set of classes and nodes for integrating FMOD Studio audio into your Godot projects. This reference covers all the major classes and their functionality. |
4 | 4 |
|
5 | | -## Accessing In-Engine Documentation |
| 5 | +## Core Classes |
| 6 | + |
| 7 | +### FmodServer |
| 8 | + |
| 9 | +The main singleton class that manages the FMOD Studio API integration. Access it with `FmodServer.get_singleton()`. |
| 10 | + |
| 11 | +**Key Methods:** |
| 12 | +- `init(p_settings: FmodGeneralSettings)` - Initialize the FMOD system |
| 13 | +- `load_bank(pathToBank: String, flag: int) -> FmodBank` - Load an FMOD bank file |
| 14 | +- `create_event_instance(eventPath: String) -> FmodEvent` - Create an event instance |
| 15 | +- `get_event(eventPath: String) -> FmodEventDescription` - Get event description |
| 16 | +- `get_bus(busPath: String) -> FmodBus` - Get bus by path |
| 17 | +- `get_vca(vcaPath: String) -> FmodVCA` - Get VCA by path |
| 18 | +- `play_one_shot(event_name: String)` - Play a one-shot event |
| 19 | +- `update()` - Update the FMOD system (call every frame) |
| 20 | +- `shutdown()` - Shutdown and cleanup FMOD |
6 | 21 |
|
7 | | -With the FMOD GDExtension enabled in your project, you can access comprehensive API documentation directly in Godot: |
| 22 | +**Global Parameters:** |
| 23 | +- `set_global_parameter_by_name(name: String, value: float)` - Set global parameter value |
| 24 | +- `get_global_parameter_by_name(name: String) -> float` - Get global parameter value |
8 | 25 |
|
9 | | -1. **Help Dock**: Open the Help dock in Godot (`Window` > `Help`) |
10 | | -2. **Search for Classes**: Type "Fmod" to see all available FMOD classes |
11 | | -3. **Browse Documentation**: Click on any class to view detailed documentation |
| 26 | +### FmodEvent |
12 | 27 |
|
13 | | -## Available Classes |
| 28 | +Represents an instance of an FMOD Studio event that can be played and controlled. |
14 | 29 |
|
15 | | -The following FMOD classes are fully documented in-engine: |
| 30 | +**Playback Control:** |
| 31 | +- `start()` - Start event playback |
| 32 | +- `stop(stopMode: int)` - Stop event with fade options |
| 33 | +- `set_paused(paused: bool)` - Pause/unpause the event |
| 34 | +- `release()` - Release the event instance |
| 35 | +- `event_key_off()` - Trigger key off for sustain points |
16 | 36 |
|
17 | | -### Core Classes |
18 | | -- **FmodServer** - Main singleton for audio system management |
19 | | -- **FmodEvent** - Event instances with playback and parameter control |
20 | | -- **FmodEventDescription** - Event metadata and factory methods |
| 37 | +**Parameters:** |
| 38 | +- `set_parameter_by_name(name: String, value: float)` - Set event parameter |
| 39 | +- `get_parameter_by_name(name: String) -> float` - Get event parameter |
| 40 | +- `set_parameter_by_id(id: int, value: float)` - Set parameter by ID |
21 | 41 |
|
22 | | -### Node Classes |
23 | | -- **FmodEventEmitter2D/3D** - Positioned audio emitters with automatic transform tracking |
24 | | -- **FmodListener2D/3D** - Audio listener nodes for spatial audio positioning |
25 | | -- **FmodBankLoader** - Utility node for automatic bank loading |
| 42 | +**Spatial Audio:** |
| 43 | +- `set_3d_attributes(transform: Transform3D)` - Set 3D position and rotation |
| 44 | +- `set_2d_attributes(position: Transform2D)` - Set 2D position |
| 45 | +- `set_node_attributes(node: Node)` - Attach to node's transform |
26 | 46 |
|
27 | | -### Audio System Classes |
28 | | -- **FmodBank** - Bank management with loading state and content inspection |
29 | | -- **FmodBus** - Audio bus controls for mixing and effects |
30 | | -- **FmodVCA** - Volume control automation for centralized volume management |
31 | | -- **FmodParameterDescription** - Parameter metadata for validation and UI |
| 47 | +**Properties:** |
| 48 | +- `get_playback_state() -> int` - Get current playback state |
| 49 | +- `get_volume() -> float` / `set_volume(volume: float)` - Volume control |
| 50 | +- `get_pitch() -> float` / `set_pitch(pitch: float)` - Pitch control |
32 | 51 |
|
33 | | -## Documentation Features |
| 52 | +### FmodEventDescription |
34 | 53 |
|
35 | | -Each class includes: |
| 54 | +Metadata and factory for FMOD Studio events. Obtained from `FmodServer.get_event()`. |
36 | 55 |
|
37 | | -- **Comprehensive class descriptions** explaining purpose and usage |
38 | | -- **Detailed method documentation** with parameter and return value descriptions |
39 | | -- **Property documentation** with default values and behavior information |
40 | | -- **Signal documentation** for callback events |
41 | | -- **Usage examples** and best practices |
| 56 | +**Instance Management:** |
| 57 | +- `create_instance() -> FmodEvent` - Create new event instance |
| 58 | +- `get_instance_count() -> int` - Get active instance count |
| 59 | +- `get_instance_list() -> Array` - Get all active instances |
| 60 | +- `release_all_instances()` - Release all instances |
42 | 61 |
|
43 | | -## Example: Getting Help |
| 62 | +**Properties:** |
| 63 | +- `is_3d() -> bool` - Check if event is 3D |
| 64 | +- `is_one_shot() -> bool` - Check if event is one-shot |
| 65 | +- `is_stream() -> bool` - Check if event streams audio |
| 66 | +- `get_length() -> int` - Get event length in milliseconds |
| 67 | +- `get_min_max_distance() -> Array` - Get 3D distance range |
| 68 | + |
| 69 | +**Parameters:** |
| 70 | +- `get_parameter_count() -> int` - Get number of parameters |
| 71 | +- `get_parameter_by_name(name: String) -> FmodParameterDescription` - Get parameter info |
| 72 | +- `get_parameters() -> Array` - Get all parameters |
| 73 | + |
| 74 | +### FmodBank |
| 75 | + |
| 76 | +Represents a loaded FMOD Studio bank containing audio content. |
| 77 | + |
| 78 | +**Content Access:** |
| 79 | +- `get_event_description_count() -> int` - Number of events in bank |
| 80 | +- `get_description_list() -> Array` - Get all event descriptions |
| 81 | +- `get_bus_count() -> int` - Number of buses in bank |
| 82 | +- `get_bus_list() -> Array` - Get all buses |
| 83 | +- `get_vca_count() -> int` - Number of VCAs in bank |
| 84 | +- `get_vca_list() -> Array` - Get all VCAs |
| 85 | + |
| 86 | +**State:** |
| 87 | +- `get_loading_state() -> int` - Check bank loading status |
| 88 | +- `update_bank_data()` - Force update cached data |
| 89 | + |
| 90 | +## Node Classes |
| 91 | + |
| 92 | +### FmodEventEmitter3D |
| 93 | + |
| 94 | +A 3D node for playing FMOD Studio events with automatic position tracking. |
| 95 | + |
| 96 | +**Properties:** |
| 97 | +- `event_name: String` - Path to FMOD event (e.g., "event:/Music/Level1") |
| 98 | +- `event_guid: String` - GUID of the event |
| 99 | +- `autoplay: bool` - Start playing when entering scene tree |
| 100 | +- `volume: float` - Volume multiplier (default: 1.0) |
| 101 | +- `attached: bool` - Auto-update position from node transform |
| 102 | + |
| 103 | +**Methods:** |
| 104 | +- `play(restart_if_playing: bool = true)` - Start event playback |
| 105 | +- `stop()` - Stop event (respects allow_fadeout setting) |
| 106 | +- `play_one_shot()` - Play as one-shot event |
| 107 | +- `set_parameter(name: String, value: Variant)` - Set event parameter |
| 108 | +- `get_parameter(name: String) -> Variant` - Get event parameter |
| 109 | +- `get_event() -> FmodEvent` - Get the underlying event instance |
| 110 | + |
| 111 | +**Signals:** |
| 112 | +- `started()` - Event started playing |
| 113 | +- `stopped()` - Event stopped |
| 114 | +- `restarted()` - Event restarted |
| 115 | +- `start_failed()` - Event failed to start |
| 116 | + |
| 117 | +### FmodEventEmitter2D |
| 118 | + |
| 119 | +A 2D node for playing FMOD Studio events with automatic position tracking. Has the same interface as FmodEventEmitter3D but works in 2D space. |
| 120 | + |
| 121 | +### FmodListener3D |
| 122 | + |
| 123 | +A 3D audio listener node that defines where the "ears" are located in 3D space. |
| 124 | + |
| 125 | +**Properties:** |
| 126 | +- `listener_index: int` - Listener index (0-7) |
| 127 | +- `listener_weight: float` - Listener influence weight |
| 128 | +- `locked: bool` - Lock position updates |
| 129 | + |
| 130 | +**Methods:** |
| 131 | +- `set_listener_index(index: int)` - Set listener index |
| 132 | +- `set_listener_weight(weight: float)` - Set listener weight |
| 133 | +- `set_locked(locked: bool)` - Lock/unlock position updates |
| 134 | + |
| 135 | +### FmodListener2D |
| 136 | + |
| 137 | +A 2D audio listener node. Has the same interface as FmodListener3D but works in 2D space. |
| 138 | + |
| 139 | +### FmodBankLoader |
| 140 | + |
| 141 | +Utility node for automatically loading FMOD Studio banks when entering the scene tree. |
| 142 | + |
| 143 | +**Properties:** |
| 144 | +- `bank_paths: Array` - Array of bank file paths to load |
| 145 | + |
| 146 | +**Methods:** |
| 147 | +- `set_bank_paths(paths: Array)` - Set banks to load |
| 148 | +- `get_bank_paths() -> Array` - Get current bank paths |
| 149 | + |
| 150 | +## Audio System Classes |
| 151 | + |
| 152 | +### FmodBus |
| 153 | + |
| 154 | +Audio bus for mixing and effects processing. |
| 155 | + |
| 156 | +**Volume Control:** |
| 157 | +- `get_volume() -> float` / `set_volume(volume: float)` - Bus volume |
| 158 | +- `get_mute() -> bool` / `set_mute(mute: bool)` - Mute control |
| 159 | +- `get_paused() -> bool` / `set_paused(paused: bool)` - Pause control |
| 160 | + |
| 161 | +**Event Management:** |
| 162 | +- `stop_all_events(stopMode: int)` - Stop all events on this bus |
| 163 | + |
| 164 | +### FmodVCA |
| 165 | + |
| 166 | +Volume Control Automation for centralized volume control across multiple buses. |
| 167 | + |
| 168 | +**Methods:** |
| 169 | +- `get_volume() -> float` / `set_volume(volume: float)` - VCA volume multiplier |
| 170 | + |
| 171 | +### FmodParameterDescription |
| 172 | + |
| 173 | +Describes the properties and constraints of an FMOD Studio event parameter. |
| 174 | + |
| 175 | +**Properties:** |
| 176 | +- `get_name() -> String` - Parameter name |
| 177 | +- `get_id() -> int` - Parameter ID |
| 178 | +- `get_minimum() -> float` - Minimum value |
| 179 | +- `get_maximum() -> float` - Maximum value |
| 180 | +- `get_default_value() -> float` - Default value |
| 181 | + |
| 182 | +**Flags:** |
| 183 | +- `is_global() -> bool` - Global parameter |
| 184 | +- `is_discrete() -> bool` - Discrete values only |
| 185 | +- `is_labeled() -> bool` - Has labeled values |
| 186 | +- `is_automatic() -> bool` - Automatic parameter |
| 187 | +- `is_read_only() -> bool` - Read-only parameter |
| 188 | + |
| 189 | +## Usage Examples |
| 190 | + |
| 191 | +### Basic Event Playback |
| 192 | + |
| 193 | +```gdscript |
| 194 | +# Get the FMOD server singleton |
| 195 | +var fmod_server = FmodServer.get_singleton() |
| 196 | +
|
| 197 | +# Play a simple one-shot event |
| 198 | +fmod_server.play_one_shot("event:/UI/ButtonClick") |
| 199 | +
|
| 200 | +# Create and control an event instance |
| 201 | +var music_event = fmod_server.create_event_instance("event:/Music/Level1") |
| 202 | +music_event.start() |
| 203 | +music_event.set_parameter_by_name("Intensity", 0.8) |
| 204 | +``` |
| 205 | + |
| 206 | +### Using 3D Event Emitters |
44 | 207 |
|
45 | 208 | ```gdscript |
46 | | -# Get help for any FMOD class directly in Godot |
47 | | -var server = FmodServer.get_singleton() # Press F1 to see documentation |
48 | | -var event = server.create_event_instance("event:/Music/Level1") # Method docs available |
| 209 | +# Add an FmodEventEmitter3D node to your scene |
| 210 | +var emitter = FmodEventEmitter3D.new() |
| 211 | +emitter.event_name = "event:/Ambient/Forest" |
| 212 | +emitter.autoplay = true |
| 213 | +emitter.volume = 0.7 |
| 214 | +add_child(emitter) |
| 215 | +
|
| 216 | +# Control parameters |
| 217 | +emitter.set_parameter("TimeOfDay", 0.5) |
49 | 218 | ``` |
50 | 219 |
|
51 | | -The documentation automatically loads when the FMOD GDExtension is enabled, providing immediate access to comprehensive help without external dependencies. |
| 220 | +### Bank Management |
| 221 | + |
| 222 | +```gdscript |
| 223 | +# Load a bank |
| 224 | +var bank = fmod_server.load_bank("res://audio/Master.bank", FMOD_STUDIO_LOAD_BANK_NORMAL) |
| 225 | +
|
| 226 | +# Wait for async loading |
| 227 | +while bank.get_loading_state() == FMOD_STUDIO_LOADING_STATE_LOADING: |
| 228 | + await get_tree().process_frame |
52 | 229 |
|
53 | | -## Source Files |
| 230 | +# Use events from the bank |
| 231 | +var event_desc = fmod_server.get_event("event:/Music/MainTheme") |
| 232 | +var event = event_desc.create_instance() |
| 233 | +``` |
| 234 | + |
| 235 | +### Bus and VCA Control |
| 236 | + |
| 237 | +```gdscript |
| 238 | +# Control bus volume |
| 239 | +var music_bus = fmod_server.get_bus("bus:/Music") |
| 240 | +music_bus.set_volume(0.5) |
| 241 | +
|
| 242 | +# Control VCA |
| 243 | +var master_vca = fmod_server.get_vca("vca:/Master") |
| 244 | +master_vca.set_volume(0.8) |
| 245 | +``` |
54 | 246 |
|
55 | | -The documentation is generated from XML files located in the `doc_classes/` directory of the FMOD GDExtension source code. These files follow Godot's class documentation schema and are automatically integrated into the Help system. |
| 247 | +This API reference provides the essential information for using the FMOD GDExtension. For complete method signatures and additional details, use Godot's built-in Help system when the extension is loaded. |
0 commit comments