mise en place de fade sonores pour les dialogues, suppression des oiseaux de l'ambiance de Demeter
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
importer="oggvorbisstr"
|
importer="oggvorbisstr"
|
||||||
type="AudioStreamOggVorbis"
|
type="AudioStreamOggVorbis"
|
||||||
uid="uid://dyv128cll6e15"
|
uid="uid://6yx6txbgc6pt"
|
||||||
path="res://.godot/imported/ambiance_astra.ogg-c1e9bdfc0ebfa9518b0518ec57815251.oggvorbisstr"
|
path="res://.godot/imported/ambiance_astra.ogg-c1e9bdfc0ebfa9518b0518ec57815251.oggvorbisstr"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
importer="oggvorbisstr"
|
importer="oggvorbisstr"
|
||||||
type="AudioStreamOggVorbis"
|
type="AudioStreamOggVorbis"
|
||||||
uid="uid://ca8n3mvauex0w"
|
uid="uid://c8gbtdul2x8ws"
|
||||||
path="res://.godot/imported/ambiance_borea.ogg-bdd873a3b02e98a2b30b14228d0c975e.oggvorbisstr"
|
path="res://.godot/imported/ambiance_borea.ogg-bdd873a3b02e98a2b30b14228d0c975e.oggvorbisstr"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|||||||
Binary file not shown.
@@ -5,10 +5,10 @@
|
|||||||
[ext_resource type="AudioStream" uid="uid://bm0tdi6bd2e65" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_2.ogg" id="3_7uv4r"]
|
[ext_resource type="AudioStream" uid="uid://bm0tdi6bd2e65" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_2.ogg" id="3_7uv4r"]
|
||||||
[ext_resource type="AudioStream" uid="uid://b1hut6lc1jevh" path="res://common/audio_manager/assets/morceaux/niveau/mines_phase_2.ogg" id="4_2fduo"]
|
[ext_resource type="AudioStream" uid="uid://b1hut6lc1jevh" path="res://common/audio_manager/assets/morceaux/niveau/mines_phase_2.ogg" id="4_2fduo"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dftxjfdqgsbd3" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_3.ogg" id="4_tuvql"]
|
[ext_resource type="AudioStream" uid="uid://dftxjfdqgsbd3" path="res://common/audio_manager/assets/ambiance/niveau/ambiance_phase_3.ogg" id="4_tuvql"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dyv128cll6e15" path="res://common/audio_manager/assets/ambiance/astra/ambiance_astra.ogg" id="5_8204s"]
|
[ext_resource type="AudioStream" uid="uid://6yx6txbgc6pt" path="res://common/audio_manager/assets/ambiance/astra/ambiance_astra.ogg" id="5_8204s"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dcbuhtc085q2x" path="res://common/audio_manager/assets/morceaux/niveau/mines_phase_1.ogg" id="5_ajci6"]
|
[ext_resource type="AudioStream" uid="uid://dcbuhtc085q2x" path="res://common/audio_manager/assets/morceaux/niveau/mines_phase_1.ogg" id="5_ajci6"]
|
||||||
[ext_resource type="AudioStream" uid="uid://cwu71o0sl2vto" path="res://common/audio_manager/assets/ambiance/dialogues/ambiance_Demeter.ogg" id="6_8204s"]
|
[ext_resource type="AudioStream" uid="uid://cwu71o0sl2vto" path="res://common/audio_manager/assets/ambiance/dialogues/ambiance_Demeter.ogg" id="6_8204s"]
|
||||||
[ext_resource type="AudioStream" uid="uid://ca8n3mvauex0w" path="res://common/audio_manager/assets/ambiance/borea/ambiance_borea.ogg" id="7_spekb"]
|
[ext_resource type="AudioStream" uid="uid://c8gbtdul2x8ws" path="res://common/audio_manager/assets/ambiance/borea/ambiance_borea.ogg" id="7_spekb"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bpf6witukorka" path="res://common/audio_manager/assets/morceaux/menu/main_menu.ogg" id="7_tuvql"]
|
[ext_resource type="AudioStream" uid="uid://bpf6witukorka" path="res://common/audio_manager/assets/morceaux/menu/main_menu.ogg" id="7_tuvql"]
|
||||||
[ext_resource type="AudioStream" uid="uid://bmwaw1yb8hucf" path="res://common/audio_manager/assets/ambiance/vaisseau/ship_music.ogg" id="8_tuvql"]
|
[ext_resource type="AudioStream" uid="uid://bmwaw1yb8hucf" path="res://common/audio_manager/assets/ambiance/vaisseau/ship_music.ogg" id="8_tuvql"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dsphn6dbbd55a" path="res://common/audio_manager/assets/morceaux/niveau/forest_phase_1.ogg" id="9_am7i4"]
|
[ext_resource type="AudioStream" uid="uid://dsphn6dbbd55a" path="res://common/audio_manager/assets/morceaux/niveau/forest_phase_1.ogg" id="9_am7i4"]
|
||||||
|
|||||||
@@ -11,217 +11,245 @@ var music_action : AudioAction
|
|||||||
var ambiance_action : AudioAction
|
var ambiance_action : AudioAction
|
||||||
var playing_music : AudioStreamPlayer = null
|
var playing_music : AudioStreamPlayer = null
|
||||||
var playing_ambiance : AudioStreamPlayer = null
|
var playing_ambiance : AudioStreamPlayer = null
|
||||||
|
var is_in_timeline := false
|
||||||
|
var timeline_ambiance : AudioStreamPlayer = null
|
||||||
|
|
||||||
var default_volumes := {}
|
var default_volumes := {}
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
for player in get_all_players():
|
for player in get_all_players():
|
||||||
player.stop()
|
player.stop()
|
||||||
|
|
||||||
fetch_default_volumes()
|
fetch_default_volumes()
|
||||||
# setup_players_bus()
|
# setup_players_bus()
|
||||||
settings.sound_changed.connect(
|
settings.sound_changed.connect(
|
||||||
func(_s) : setup_players_bus()
|
func(_s) : setup_players_bus()
|
||||||
)
|
)
|
||||||
SceneManager.scene_loaded.connect(_on_change_scene)
|
SceneManager.scene_loaded.connect(_on_change_scene)
|
||||||
Dialogic.timeline_started.connect(_on_timeline_started)
|
Dialogic.timeline_started.connect(_on_timeline_started)
|
||||||
Dialogic.timeline_ended.connect(_on_timeline_ended)
|
Dialogic.timeline_ended.connect(_on_timeline_ended)
|
||||||
|
|
||||||
func _process(_d):
|
func _process(_d):
|
||||||
if music_action:
|
if music_action:
|
||||||
playing_music = process_audio_action(
|
playing_music = process_audio_action(
|
||||||
music_action,
|
music_action,
|
||||||
%Musics,
|
%Musics,
|
||||||
playing_music
|
playing_music
|
||||||
)
|
)
|
||||||
music_action = null
|
music_action = null
|
||||||
|
|
||||||
if ambiance_action:
|
if ambiance_action:
|
||||||
playing_ambiance = process_audio_action(
|
playing_ambiance = process_audio_action(
|
||||||
ambiance_action,
|
ambiance_action,
|
||||||
%Ambiance,
|
%Ambiance,
|
||||||
playing_ambiance
|
playing_ambiance
|
||||||
)
|
)
|
||||||
ambiance_action = null
|
ambiance_action = null
|
||||||
|
|
||||||
func process_audio_action(
|
func process_audio_action(
|
||||||
audio_action : AudioAction,
|
audio_action : AudioAction,
|
||||||
player_search_node: Node,
|
player_search_node: Node,
|
||||||
current_player: AudioStreamPlayer = null
|
current_player: AudioStreamPlayer = null
|
||||||
) -> AudioStreamPlayer:
|
) -> AudioStreamPlayer:
|
||||||
if audio_action is AudioLaunch:
|
if audio_action is AudioLaunch:
|
||||||
return process_audio_launch(audio_action, player_search_node, current_player)
|
return process_audio_launch(audio_action, player_search_node, current_player)
|
||||||
elif audio_action is AudioStop and current_player and current_player.playing:
|
elif audio_action is AudioStop and current_player and current_player.playing:
|
||||||
stop_player(current_player)
|
stop_player(current_player)
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
|
||||||
func process_audio_launch(
|
func process_audio_launch(
|
||||||
audio_launch : AudioLaunch,
|
audio_launch : AudioLaunch,
|
||||||
player_search_node: Node,
|
player_search_node: Node,
|
||||||
current_player: AudioStreamPlayer = null,
|
current_player: AudioStreamPlayer = null,
|
||||||
) -> AudioStreamPlayer:
|
) -> AudioStreamPlayer:
|
||||||
var player = player_search_node.find_child(audio_launch.player_name)
|
var player = player_search_node.find_child(audio_launch.player_name)
|
||||||
if not player:
|
if not player:
|
||||||
printerr("Player %s not found in category %s" % [audio_launch.player_name, player_search_node.name])
|
printerr("Player %s not found in category %s" % [audio_launch.player_name, player_search_node.name])
|
||||||
return null
|
return null
|
||||||
if current_player and current_player.playing and current_player.name == audio_launch.player_name:
|
if current_player and current_player.playing and current_player.name == audio_launch.player_name:
|
||||||
return current_player
|
return current_player
|
||||||
elif current_player:
|
elif current_player:
|
||||||
stop_player(current_player)
|
stop_player(current_player)
|
||||||
|
|
||||||
start_player(player, audio_launch.from_random_time, audio_launch.fade_time)
|
start_player(player, audio_launch.from_random_time, audio_launch.fade_time)
|
||||||
return player
|
return player
|
||||||
|
|
||||||
func _on_change_scene(scene : Scene):
|
func _on_change_scene(scene : Scene):
|
||||||
stop_ambiance()
|
|
||||||
|
|
||||||
match scene.scene_id:
|
if not is_in_timeline:
|
||||||
"TITLE":
|
stop_ambiance()
|
||||||
play_music("Title", false, 0.0)
|
|
||||||
"INTRO":
|
match scene.scene_id:
|
||||||
stop_music()
|
"TITLE":
|
||||||
"REGION":
|
play_music("Title", false, 0.0)
|
||||||
play_music("Region", true)
|
"INTRO":
|
||||||
play_ambiance("Exterior")
|
stop_music()
|
||||||
"COCKPIT":
|
"REGION":
|
||||||
play_music("Ship")
|
play_music("Region", true)
|
||||||
"ASTRA":
|
play_ambiance("Exterior")
|
||||||
stop_music()
|
"COCKPIT":
|
||||||
play_ambiance("Astra")
|
play_music("Ship")
|
||||||
"GARAGE":
|
"ASTRA":
|
||||||
stop_music()
|
stop_music()
|
||||||
play_ambiance("Astra")
|
play_ambiance("Astra")
|
||||||
"BOREA":
|
"GARAGE":
|
||||||
stop_music()
|
stop_music()
|
||||||
play_ambiance("Borea")
|
play_ambiance("Astra")
|
||||||
|
"BOREA":
|
||||||
|
stop_music()
|
||||||
|
play_ambiance("Borea")
|
||||||
|
|
||||||
func _on_timeline_started():
|
func _on_timeline_started():
|
||||||
var timeline_name = Dialogic.current_timeline.resource_path.split("/")[-1].trim_suffix(".dtl")
|
var timeline_name = Dialogic.current_timeline.resource_path.split("/")[-1].trim_suffix(".dtl")
|
||||||
stop_ambiance()
|
|
||||||
|
|
||||||
match timeline_name:
|
if timeline_name in [
|
||||||
"demeter_astra_failed":
|
"demeter_astra_failed",
|
||||||
play_ambiance("Demeter")
|
"demeter_ship_presentation",
|
||||||
"demeter_ship_presentation":
|
"demeter_intro",
|
||||||
play_ambiance("Demeter")
|
"demeter_post_tutorial",
|
||||||
"demeter_intro":
|
"demeter_outro"
|
||||||
play_ambiance("Demeter")
|
]:
|
||||||
"demeter_post_tutorial":
|
start_timeline_ambiance("Demeter")
|
||||||
play_ambiance("Demeter")
|
|
||||||
"demeter_outro":
|
|
||||||
play_ambiance("Demeter")
|
|
||||||
|
|
||||||
func _on_timeline_ended():
|
func _on_timeline_ended():
|
||||||
if SceneManager.actual_scene:
|
|
||||||
_on_change_scene(SceneManager.actual_scene)
|
# Stop ambiance timeline proprement
|
||||||
|
if timeline_ambiance:
|
||||||
|
await set_volume(timeline_ambiance, MIN_VOLUME, 0.5).finished
|
||||||
|
timeline_ambiance.stop()
|
||||||
|
timeline_ambiance = null
|
||||||
|
|
||||||
|
# Restore ambiance principale si elle existe
|
||||||
|
if playing_ambiance and playing_ambiance.playing:
|
||||||
|
set_volume(playing_ambiance, get_volume(playing_ambiance), 0.5)
|
||||||
|
|
||||||
|
is_in_timeline = false
|
||||||
|
|
||||||
|
if SceneManager.actual_scene:
|
||||||
|
_on_change_scene(SceneManager.actual_scene)
|
||||||
|
|
||||||
func play_music(player_name : String = "", from_random_time := false, fade_time := DEFAULT_FADE_TIME):
|
func play_music(player_name : String = "", from_random_time := false, fade_time := DEFAULT_FADE_TIME):
|
||||||
music_action = AudioLaunch.new(
|
music_action = AudioLaunch.new(
|
||||||
player_name,
|
player_name,
|
||||||
from_random_time,
|
from_random_time,
|
||||||
fade_time
|
fade_time
|
||||||
)
|
)
|
||||||
|
|
||||||
func stop_music():
|
func stop_music():
|
||||||
music_action = AudioStop.new()
|
music_action = AudioStop.new()
|
||||||
|
|
||||||
func play_ambiance(player_name : String = "", from_random_time := false, fade_time := DEFAULT_FADE_TIME):
|
func play_ambiance(player_name : String = "", from_random_time := false, fade_time := DEFAULT_FADE_TIME):
|
||||||
ambiance_action = AudioLaunch.new(
|
ambiance_action = AudioLaunch.new(
|
||||||
player_name,
|
player_name,
|
||||||
from_random_time,
|
from_random_time,
|
||||||
fade_time
|
fade_time
|
||||||
)
|
)
|
||||||
|
|
||||||
func stop_ambiance():
|
func stop_ambiance():
|
||||||
ambiance_action = AudioStop.new()
|
ambiance_action = AudioStop.new()
|
||||||
|
|
||||||
func fetch_default_volumes():
|
func fetch_default_volumes():
|
||||||
var all_players := get_all_players()
|
var all_players := get_all_players()
|
||||||
|
|
||||||
for player in all_players:
|
for player in all_players:
|
||||||
default_volumes[player] = player.volume_db
|
default_volumes[player] = player.volume_db
|
||||||
|
|
||||||
func setup_players_bus():
|
func setup_players_bus():
|
||||||
for player in get_all_players():
|
for player in get_all_players():
|
||||||
if player.get_parent() == %Musics:
|
if player.get_parent() == %Musics:
|
||||||
player.bus = (AudioServer.get_bus_name(SettingsData.MUSIC_BUS_ID))
|
player.bus = (AudioServer.get_bus_name(SettingsData.MUSIC_BUS_ID))
|
||||||
elif player.get_parent() == %Sfx:
|
elif player.get_parent() == %Sfx:
|
||||||
player.bus = (AudioServer.get_bus_name(SettingsData.SFX_BUS_ID))
|
player.bus = (AudioServer.get_bus_name(SettingsData.SFX_BUS_ID))
|
||||||
elif player.get_parent() == %Ambiance:
|
elif player.get_parent() == %Ambiance:
|
||||||
player.bus = (AudioServer.get_bus_name(SettingsData.AMBIANCE_BUS_ID))
|
player.bus = (AudioServer.get_bus_name(SettingsData.AMBIANCE_BUS_ID))
|
||||||
|
|
||||||
func get_volume(player : AudioStreamPlayer) -> float:
|
func get_volume(player : AudioStreamPlayer) -> float:
|
||||||
return default_volumes[player]
|
return default_volumes[player]
|
||||||
|
|
||||||
func get_all_players() -> Array[AudioStreamPlayer]:
|
func get_all_players() -> Array[AudioStreamPlayer]:
|
||||||
var players : Array[AudioStreamPlayer] = []
|
var players : Array[AudioStreamPlayer] = []
|
||||||
players.append_array(get_players_from_node(%Musics))
|
players.append_array(get_players_from_node(%Musics))
|
||||||
players.append_array(get_players_from_node(%Ambiance))
|
players.append_array(get_players_from_node(%Ambiance))
|
||||||
players.append_array(get_players_from_node(%Sfx))
|
players.append_array(get_players_from_node(%Sfx))
|
||||||
|
|
||||||
return players
|
return players
|
||||||
|
|
||||||
func get_players_from_node(node : Node) -> Array[AudioStreamPlayer]:
|
func get_players_from_node(node : Node) -> Array[AudioStreamPlayer]:
|
||||||
var streams : Array[AudioStreamPlayer] = []
|
var streams : Array[AudioStreamPlayer] = []
|
||||||
|
|
||||||
for c in node.get_children():
|
for c in node.get_children():
|
||||||
if c is AudioStreamPlayer:
|
if c is AudioStreamPlayer:
|
||||||
streams.append(c)
|
streams.append(c)
|
||||||
return streams
|
return streams
|
||||||
|
|
||||||
func set_volume(player : AudioStreamPlayer, to : float, fade_time = DEFAULT_FADE_TIME) -> Tween:
|
func set_volume(player : AudioStreamPlayer, to : float, fade_time = DEFAULT_FADE_TIME) -> Tween:
|
||||||
var fade_tween : Tween = get_tree().create_tween()
|
var fade_tween : Tween = get_tree().create_tween()
|
||||||
|
|
||||||
fade_tween.tween_property(player, "volume_db", to, fade_time)
|
fade_tween.tween_property(player, "volume_db", to, fade_time)
|
||||||
|
|
||||||
return fade_tween
|
return fade_tween
|
||||||
|
|
||||||
func start_player(player: AudioStreamPlayer, from_random_time = false, fade_time = DEFAULT_FADE_TIME):
|
func start_player(player: AudioStreamPlayer, from_random_time = false, fade_time = DEFAULT_FADE_TIME):
|
||||||
if player and not player.playing:
|
if player and not player.playing:
|
||||||
player.play(
|
player.play(
|
||||||
0.0 if not from_random_time
|
0.0 if not from_random_time
|
||||||
else randf_range(0.0, player.stream.get_length())
|
else randf_range(0.0, player.stream.get_length())
|
||||||
)
|
)
|
||||||
if fade_time > 0.0:
|
if fade_time > 0.0:
|
||||||
player.volume_db = MIN_VOLUME
|
player.volume_db = MIN_VOLUME
|
||||||
await set_volume(player, get_volume(player), fade_time).finished
|
await set_volume(player, get_volume(player), fade_time).finished
|
||||||
|
|
||||||
func stop_player(player : AudioStreamPlayer, fade_time = DEFAULT_FADE_TIME):
|
func stop_player(player : AudioStreamPlayer, fade_time = DEFAULT_FADE_TIME):
|
||||||
if player and player.playing:
|
if player and player.playing:
|
||||||
if fade_time > 0.0:
|
if fade_time > 0.0:
|
||||||
await set_volume(player, MIN_VOLUME, fade_time).finished
|
await set_volume(player, MIN_VOLUME, fade_time).finished
|
||||||
player.stop()
|
player.stop()
|
||||||
player.volume_db = get_volume(player)
|
player.volume_db = get_volume(player)
|
||||||
|
|
||||||
func reset_volume(player : AudioStreamPlayer):
|
func reset_volume(player : AudioStreamPlayer):
|
||||||
player.volume_db = get_volume(player)
|
player.volume_db = get_volume(player)
|
||||||
|
|
||||||
func play_sfx(sfx_name : String):
|
func play_sfx(sfx_name : String):
|
||||||
print(sfx_name)
|
print(sfx_name)
|
||||||
var player := %Sfx.find_child(sfx_name) as AudioStreamPlayer
|
var player := %Sfx.find_child(sfx_name) as AudioStreamPlayer
|
||||||
if player:
|
if player:
|
||||||
player.play()
|
player.play()
|
||||||
else:
|
else:
|
||||||
printerr("Sfx %s not found" % sfx_name)
|
printerr("Sfx %s not found" % sfx_name)
|
||||||
|
|
||||||
|
func start_timeline_ambiance(player_name: String):
|
||||||
|
|
||||||
|
var player := %Ambiance.find_child(player_name) as AudioStreamPlayer
|
||||||
|
if not player:
|
||||||
|
printerr("Timeline ambiance %s not found" % player_name)
|
||||||
|
return
|
||||||
|
|
||||||
|
if playing_ambiance and playing_ambiance.playing:
|
||||||
|
set_volume(playing_ambiance, -20.0, 0.5)
|
||||||
|
|
||||||
|
timeline_ambiance = player
|
||||||
|
timeline_ambiance.volume_db = MIN_VOLUME
|
||||||
|
timeline_ambiance.play()
|
||||||
|
set_volume(timeline_ambiance, get_volume(timeline_ambiance), 0.5)
|
||||||
|
|
||||||
class AudioAction:
|
class AudioAction:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class AudioLaunch extends AudioAction:
|
class AudioLaunch extends AudioAction:
|
||||||
var player_name : String
|
var player_name : String
|
||||||
var from_random_time : bool
|
var from_random_time : bool
|
||||||
var fade_time : float
|
var fade_time : float
|
||||||
|
|
||||||
func _init(
|
func _init(
|
||||||
_player_name : String,
|
_player_name : String,
|
||||||
_from_random_time := false,
|
_from_random_time := false,
|
||||||
_fade_time := DEFAULT_FADE_TIME,
|
_fade_time := DEFAULT_FADE_TIME,
|
||||||
):
|
):
|
||||||
player_name = _player_name
|
player_name = _player_name
|
||||||
from_random_time = _from_random_time
|
from_random_time = _from_random_time
|
||||||
fade_time = _fade_time
|
fade_time = _fade_time
|
||||||
|
|
||||||
|
|
||||||
class AudioStop extends AudioAction:
|
class AudioStop extends AudioAction:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user