OmnichordGodot/scripts/RhythmController.gd

25 lines
653 B
GDScript

extends Node
var RhythmPlayer: AudioStreamPlayer
var RhythmAudio: AudioStreamOggVorbis
func _ready():
RhythmPlayer = get_node("/root/Control/RhythmPlayer")
var resource_string = "res://audio/rhythm/%s.ogg" % self.name
var resource = load(resource_string)
RhythmAudio = resource
self.pressed.connect(button_pressed)
Global.rhythm_volume.connect(change_volume)
Global.rhythm_tempo.connect(change_tempo)
func button_pressed():
RhythmPlayer.stream = RhythmAudio
RhythmAudio.loop = true
RhythmPlayer.play()
func change_volume(vol: float):
RhythmPlayer.set_volume_db(vol)
func change_tempo(tempo: float):
RhythmPlayer.set_pitch_scale(tempo)