OmnichordGodot/NoteController.gd

21 lines
560 B
GDScript3
Raw Normal View History

2024-06-26 23:09:42 -03:00
extends Node
var NotePlayer: AudioStreamPlayer
var NoteAudio: AudioStreamOggVorbis
# Called when the node enters the scene tree for the first time.
func _ready():
NotePlayer = get_node("/root/Control/NotePlayer")
Global.chord_changed.connect(chord_changed)
self.connect("pressed", self.button_pressed)
func button_pressed():
# Play chord
NotePlayer.stream = NoteAudio
NotePlayer.play()
func chord_changed(chord):
var resource_string = "res://audio/%s/%s%s.wav" % [chord, chord, self.name]
var resource = load(resource_string)
NoteAudio = resource