2024-06-26 23:09:42 -03:00
|
|
|
extends Node
|
|
|
|
|
|
|
|
var ChordPlayer: AudioStreamPlayer
|
|
|
|
var ChordAudio: AudioStreamOggVorbis
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
ChordPlayer = get_node("/root/Control/ChordPlayer")
|
2024-06-26 23:49:24 -03:00
|
|
|
var resource_string = "res://audio/%s/%s-chord.ogg" % [self.name, self.name]
|
2024-06-26 23:09:42 -03:00
|
|
|
var resource = load(resource_string)
|
|
|
|
ChordAudio = resource
|
2024-06-26 23:49:24 -03:00
|
|
|
self.pressed.connect(button_pressed)
|
|
|
|
Global.loop_changed.connect(loop_changed)
|
2024-06-27 01:11:23 -03:00
|
|
|
Global.chord_volume.connect(change_volume)
|
2024-06-26 23:09:42 -03:00
|
|
|
|
|
|
|
func button_pressed():
|
|
|
|
ChordPlayer.stream = ChordAudio
|
|
|
|
ChordPlayer.play()
|
|
|
|
Global.chord_changed.emit(self.name)
|
2024-06-26 23:49:24 -03:00
|
|
|
|
|
|
|
func loop_changed(state: bool):
|
|
|
|
ChordAudio.loop = state
|
|
|
|
if (!state):
|
|
|
|
ChordPlayer.stop()
|
2024-06-27 01:11:23 -03:00
|
|
|
|
|
|
|
func change_volume(vol: float):
|
|
|
|
ChordPlayer.set_volume_db(vol)
|