mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-30 23:19:49 +00:00
Some code changes to allow for potential negative frames placement for audio
This woud allow audio to be placed in negative frames, which essentially means that audio would start before the first frame. This is not yet supported, however, because I don't know how to make it work with FFMPEG.
This commit is contained in:
parent
710f6d41e6
commit
a150b66fe7
|
@ -22,8 +22,11 @@ func position_in_seconds(project: Project, start_from := 0) -> float:
|
|||
var index := project.frames.find(self)
|
||||
if index > start_from:
|
||||
for i in range(start_from, index):
|
||||
var frame := project.frames[i]
|
||||
pos += frame.get_duration_in_seconds(project.fps)
|
||||
if i >= 0:
|
||||
var frame := project.frames[i]
|
||||
pos += frame.get_duration_in_seconds(project.fps)
|
||||
else:
|
||||
pos += 1.0 / project.fps
|
||||
else:
|
||||
if start_from >= project.frames.size():
|
||||
return -1.0
|
||||
|
|
|
@ -13,8 +13,13 @@ var audio: AudioStream: ## The audio stream of the layer.
|
|||
audio_changed.emit()
|
||||
var playback_position := 0.0: ## The time in seconds where the audio stream starts playing.
|
||||
get():
|
||||
var frame := project.frames[playback_frame]
|
||||
return frame.position_in_seconds(project)
|
||||
if playback_frame >= 0:
|
||||
var frame := project.frames[playback_frame]
|
||||
return frame.position_in_seconds(project)
|
||||
var pos := 0.0
|
||||
for i in absi(playback_frame):
|
||||
pos -= 1.0 / project.fps
|
||||
return pos
|
||||
var playback_frame := 0: ## The frame where the audio stream starts playing.
|
||||
set(value):
|
||||
playback_frame = value
|
||||
|
|
|
@ -76,7 +76,11 @@ func _on_cel_switched() -> void:
|
|||
audio_player.stop()
|
||||
return
|
||||
if animation_running:
|
||||
if Global.current_project.current_frame == layer.playback_frame:
|
||||
var current_frame := Global.current_project.current_frame
|
||||
if (
|
||||
current_frame == layer.playback_frame
|
||||
or (current_frame == 0 and layer.playback_frame < 0)
|
||||
):
|
||||
_play_audio(false)
|
||||
else:
|
||||
_play_audio(true)
|
||||
|
@ -90,7 +94,7 @@ func _on_animation_started(_dir: bool) -> void:
|
|||
func _on_animation_looped() -> void:
|
||||
var layer := Global.current_project.layers[layer_index]
|
||||
if layer is AudioLayer:
|
||||
if layer.playback_frame != 0 or not layer.is_visible_in_hierarchy():
|
||||
if layer.playback_frame > 0 or not layer.is_visible_in_hierarchy():
|
||||
if is_instance_valid(audio_player):
|
||||
audio_player.stop()
|
||||
|
||||
|
|
Loading…
Reference in a new issue