27 lines
693 B
GDScript
27 lines
693 B
GDScript
extends Node
|
|
|
|
var ChordPlayer: AudioStreamPlayer
|
|
var ChordAudio: AudioStreamOggVorbis
|
|
|
|
func _ready():
|
|
ChordPlayer = get_node("/root/Control/ChordPlayer")
|
|
var resource_string = "res://audio/%s/%s-chord.ogg" % [self.name, self.name]
|
|
var resource = load(resource_string)
|
|
ChordAudio = resource
|
|
self.pressed.connect(button_pressed)
|
|
Global.loop_changed.connect(loop_changed)
|
|
Global.chord_volume.connect(change_volume)
|
|
|
|
func button_pressed():
|
|
ChordPlayer.stream = ChordAudio
|
|
ChordPlayer.play()
|
|
Global.chord_changed.emit(self.name)
|
|
|
|
func loop_changed(state: bool):
|
|
ChordAudio.loop = state
|
|
if (!state):
|
|
ChordPlayer.stop()
|
|
|
|
func change_volume(vol: float):
|
|
ChordPlayer.set_volume_db(vol)
|