OmnichordGodot/scripts/NoteController.gd

25 lines
636 B
GDScript

extends Node
var NotePlayer: AudioStreamPlayer
var NoteAudio: AudioStreamOggVorbis
func _ready():
# Make new player each so notes can overlap
NotePlayer = AudioStreamPlayer.new()
add_child(NotePlayer)
Global.chord_changed.connect(chord_changed)
self.pressed.connect(button_pressed)
Global.note_volume.connect(change_volume)
func button_pressed():
NotePlayer.stream = NoteAudio
NotePlayer.play()
func chord_changed(chord):
var resource_string = "res://audio/%s/%s%s.ogg" % [chord, chord, self.name]
var resource = load(resource_string)
NoteAudio = resource
func change_volume(vol: float):
NotePlayer.set_volume_db(vol)