better animations, individual tracks
This commit is contained in:
1 parent
7afda132ec
commit
06dc6d63b6
41 files changed
+795
-650
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#@tool
|
||||
#@icon(icon_path: String)
|
||||
class_name Conductor
|
||||
extends Musician
|
||||
## Documentation comments
|
||||
|
||||
## signal
|
||||
## enum
|
||||
## const
|
||||
## @export var
|
||||
## var
|
||||
## @onready var
|
||||
|
||||
## OVERRIDES
|
||||
|
||||
|
||||
## CORE
|
||||
|
||||
## PRIVATE/HELPER
|
||||
|
||||
## RECEIVERS
|
||||
|
||||
## SETTERS/GETTERS
|
||||
@@ -0,0 +1 @@
|
||||
uid://dppf0pasfnksi
|
||||
@@ -0,0 +1,53 @@
|
||||
#@tool
|
||||
#@icon(icon_path: String)
|
||||
#class_name MyNode
|
||||
extends Node2D
|
||||
## Documentation comments
|
||||
|
||||
## signal
|
||||
## enum
|
||||
## const
|
||||
|
||||
@onready var conductor: Conductor = %Conductor
|
||||
@onready var violinist: Musician = %Viol
|
||||
@onready var cellist: Musician = %Cello
|
||||
@onready var bassist: Musician = %Bass
|
||||
#@onready var rhythm_manager: RhythmManager = %RhythmManager
|
||||
#@onready var click_track: AudioStreamPlayer2D = %ClickTrack
|
||||
@onready var canvas_modulate: CanvasModulate = $CanvasModulate
|
||||
|
||||
## OVERRIDES
|
||||
|
||||
func _ready() -> void:
|
||||
canvas_modulate.visible = true
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ready"):
|
||||
conductor.enter_exit()
|
||||
if event.is_action_pressed("viol"):
|
||||
violinist.enter_exit()
|
||||
if event.is_action_pressed("cello"):
|
||||
cellist.enter_exit()
|
||||
if event.is_action_pressed("bass"):
|
||||
bassist.enter_exit()
|
||||
## CORE
|
||||
#
|
||||
#func enter_instrument(instrument: Node) -> void:
|
||||
#print("Now playing " + instrument.name)
|
||||
#var instrument_audio: AudioStreamPlayer2D = instrument.get_child(0)
|
||||
#var instrument_light: PointLight2D = instrument.get_child(1)
|
||||
#instrument.play("default")
|
||||
#instrument_audio.play()
|
||||
#instrument_light.visible = true
|
||||
|
||||
## PRIVATE/HELPER
|
||||
|
||||
## RECEIVERS
|
||||
|
||||
## SETTERS/GETTERS
|
||||
@@ -0,0 +1 @@
|
||||
uid://bjv7i1kmivfai
|
||||
@@ -0,0 +1,97 @@
|
||||
#@tool
|
||||
#@icon(icon_path: String)
|
||||
class_name RhythmManager
|
||||
extends Node2D
|
||||
## Documentation comments
|
||||
|
||||
signal song_started()
|
||||
## enum
|
||||
## const
|
||||
|
||||
@export var target_audio: AudioStreamPlayer2D
|
||||
@export var tempo: int = 120
|
||||
@export var beats_per_measure: int = 4
|
||||
|
||||
var beats_elapsed: int = 0
|
||||
var beat_time_start: float = 0.0
|
||||
var beat_time_elapsed: float = 0.0
|
||||
var seconds_per_beat: float
|
||||
var useconds_per_beat: float
|
||||
var song_time_elapsed: float = 0.0
|
||||
var total_time_elapsed: float = 0.0
|
||||
var is_running: bool = false
|
||||
var start_time: float
|
||||
var end_time: float
|
||||
var ready_time: float
|
||||
var click_track_stream: AudioStream
|
||||
#var delay_time: float
|
||||
|
||||
@onready var beat_bar: ProgressBar = %BeatBar
|
||||
#@onready var click_track: AudioStreamPlayer2D = %ClickTrack
|
||||
@onready var beat_time_value: Label = %BeatTimeValue
|
||||
@onready var volume_bar_left: ProgressBar = %VolumeBarLeft
|
||||
@onready var volume_bar_right: ProgressBar = %VolumeBarRight
|
||||
@onready var volume_value_left: Label = %VolumeValueLeft
|
||||
@onready var volume_value_right: Label = %VolumeValueRight
|
||||
|
||||
## OVERRIDES
|
||||
|
||||
func _ready() -> void:
|
||||
#click_track_stream = click_track.stream
|
||||
ready_time = Time.get_ticks_usec()
|
||||
print("Ready time: %s" % ready_time)
|
||||
print("Buses at index 0: %s" % AudioServer.get_bus_name(0))
|
||||
print("Channels on Bus 0: %s" % AudioServer.get_bus_channels(0))
|
||||
#var time_to_next_mix: float = AudioServer.get_time_to_next_mix()
|
||||
#var output_latency: float = AudioServer.get_output_latency()
|
||||
#var mix_rate: float = AudioServer.get_mix_rate()
|
||||
#delay_time = time_to_next_mix + output_latency
|
||||
seconds_per_beat = 60.0/float(tempo)
|
||||
useconds_per_beat = seconds_per_beat * 1000000.0
|
||||
beat_bar.max_value = useconds_per_beat
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
total_time_elapsed = Time.get_ticks_usec()
|
||||
if is_running:
|
||||
volume_bar_left.value = AudioServer.get_bus_peak_volume_left_db(0, 0)
|
||||
volume_bar_right.value = AudioServer.get_bus_peak_volume_right_db(0, 0)
|
||||
volume_value_left.text = str(snappedf(AudioServer.get_bus_peak_volume_left_db(0, 0), 0.1))
|
||||
volume_value_right.text = str(snappedf(AudioServer.get_bus_peak_volume_right_db(0, 0), 0.1))
|
||||
song_time_elapsed = total_time_elapsed - start_time
|
||||
#print("song time elapsed: %s" % song_time_elapsed)
|
||||
beat_time_elapsed = song_time_elapsed - beat_time_start
|
||||
beat_time_value.text = str(beat_time_elapsed) + " usec"
|
||||
beat_bar.value = beat_time_elapsed
|
||||
#print("beat time elapsed: %s" % beat_time_elapsed)
|
||||
#fmod = fmod(total_time_elapsed, useconds_per_beat)
|
||||
#print(fmod)
|
||||
if beat_time_elapsed >= useconds_per_beat:
|
||||
#print("This beat took %s useconds" % beat_time_elapsed)
|
||||
beats_elapsed += 1
|
||||
beat_time_elapsed = 0.0
|
||||
beat_time_start = song_time_elapsed
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("start"):
|
||||
if is_running == false:
|
||||
start_time = Time.get_ticks_usec()
|
||||
print("start time: %s" % start_time)
|
||||
is_running = true
|
||||
target_audio.play()
|
||||
else:
|
||||
target_audio.stop()
|
||||
is_running = false
|
||||
end_time = Time.get_ticks_usec()
|
||||
print("end_time: %s" % end_time)
|
||||
song_started.emit()
|
||||
|
||||
#func _physics_process(delta: float) -> void:
|
||||
#pass
|
||||
|
||||
## CORE
|
||||
|
||||
## PRIVATE/HELPER
|
||||
|
||||
## RECEIVERS
|
||||
|
||||
## SETTERS/GETTERS
|
||||
@@ -0,0 +1 @@
|
||||
uid://bhbfogebu1di5
|
||||
Reference in new issue
Block a user