OmnichordGodot/scripts/NoteController.gd

21 lines
552 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)
2024-06-26 23:49:24 -03:00
self.pressed.connect(button_pressed)
2024-06-26 23:09:42 -03:00
func button_pressed():
# Play chord
NotePlayer.stream = NoteAudio
NotePlayer.play()
func chord_changed(chord):
2024-06-26 23:49:24 -03:00
var resource_string = "res://audio/%s/%s%s.ogg" % [chord, chord, self.name]
2024-06-26 23:09:42 -03:00
var resource = load(resource_string)
NoteAudio = resource