OmnichordGodot/scripts/RhythmController.gd

25 lines
653 B
GDScript3
Raw Permalink Normal View History

2024-06-26 23:09:42 -03:00
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
2024-06-26 23:49:24 -03:00
self.pressed.connect(button_pressed)
2024-06-27 01:11:23 -03:00
Global.rhythm_volume.connect(change_volume)
Global.rhythm_tempo.connect(change_tempo)
2024-06-26 23:09:42 -03:00
func button_pressed():
RhythmPlayer.stream = RhythmAudio
2024-06-26 23:49:24 -03:00
RhythmAudio.loop = true
2024-06-26 23:09:42 -03:00
RhythmPlayer.play()
2024-06-27 01:11:23 -03:00
func change_volume(vol: float):
RhythmPlayer.set_volume_db(vol)
func change_tempo(tempo: float):
RhythmPlayer.set_pitch_scale(tempo)