Reorganize

This commit is contained in:
2024-06-26 23:49:24 -03:00
parent 1c3d8546bd
commit 736344e8ad
12 changed files with 462 additions and 403 deletions

View File

@ -0,0 +1,25 @@
extends Node
# Add asset here
var ChordPlayer: AudioStreamPlayer
var ChordAudio: AudioStreamOggVorbis
# Called when the node enters the scene tree for the first time.
func _ready():
ChordPlayer = get_node("/root/Control/ChordPlayer")
var resource_string = "res://audio/%s/%s-chord.ogg" % [self.name, self.name]
var resource = load(resource_string)
ChordAudio = resource
self.pressed.connect(button_pressed)
Global.loop_changed.connect(loop_changed)
func button_pressed():
# Play chord
ChordPlayer.stream = ChordAudio
ChordPlayer.play()
Global.chord_changed.emit(self.name)
func loop_changed(state: bool):
ChordAudio.loop = state
if (!state):
ChordPlayer.stop()

10
scripts/Global.gd Normal file
View File

@ -0,0 +1,10 @@
extends Node
signal chord_changed(chord: String)
signal loop_changed(state: bool)
signal note_volume(vol: float)
signal chord_volume(vol: float)
signal rhythm_volume(vol: float)
signal rhythm_tempo(tempo: float)

View File

@ -0,0 +1,8 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
self.toggled.connect(on_toggle)
func on_toggle(state: bool):
Global.loop_changed.emit(state)

20
scripts/NoteController.gd Normal file
View File

@ -0,0 +1,20 @@
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.pressed.connect(button_pressed)
func button_pressed():
# Play chord
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

View File

@ -0,0 +1,19 @@
extends Node
# Add asset here
var RhythmPlayer: AudioStreamPlayer
var RhythmAudio: AudioStreamOggVorbis
# Called when the node enters the scene tree for the first time.
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)
func button_pressed():
# Play chord
RhythmPlayer.stream = RhythmAudio
RhythmAudio.loop = true
RhythmPlayer.play()

13
scripts/StopController.gd Normal file
View File

@ -0,0 +1,13 @@
extends Node
# Add asset here
var RhythmPlayer: AudioStreamPlayer
# Called when the node enters the scene tree for the first time.
func _ready():
RhythmPlayer = get_node("/root/Control/RhythmPlayer")
self.pressed.connect(button_pressed)
func button_pressed():
# Play chord
RhythmPlayer.stop()