Skip to content

Commit

Permalink
Move resource check to the Audio subsystem.
Browse files Browse the repository at this point in the history
  • Loading branch information
CakeVR committed Jan 9, 2024
1 parent 25f925a commit 88cdce5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 1 addition & 11 deletions addons/dialogic/Modules/Audio/event_music.gd
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,11 @@ var loop: bool = true
################################################################################

func _execute() -> void:

if not _is_playing_resource_already():
if not dialogic.Audio.is_music_playing_resource():
dialogic.Audio.update_music(file_path, volume, audio_bus, fade_length, loop)

finish()


## Returns whether the currently playing audio resource is the same as this
## event's [member file_path].
func _is_playing_resource_already() -> bool:
var music_player: AudioStreamPlayer = dialogic.Audio.base_music_player

return music_player.is_playing() and music_player.stream.resource_path == file_path


################################################################################
## INITIALIZE
################################################################################
Expand Down
10 changes: 10 additions & 0 deletions addons/dialogic/Modules/Audio/subsystem_audio.gd
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,15 @@ func stop_all_sounds() -> void:
if "Sound" in node.name:
node.queue_free()


func interpolate_volume_linearly(value :float, node:Node) -> void:
node.volume_db = linear_to_db(value)


## Returns whether the currently playing audio resource is the same as this
## event's [param resource_path].
func is_music_playing_resource(resource_path: String) -> bool:
var is_playing_resource: bool = (base_music_player.is_playing()
and base_music_player.stream.resource_path == resource_path)

return is_playing_resource

0 comments on commit 88cdce5

Please sign in to comment.