add keyboard controlls
This commit is contained in:
parent
36a3175cbd
commit
50c27743ec
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://b4fgp0mhbgkfw"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://b4fgp0mhbgkfw"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/StopController.gd" id="1_5jtep"]
|
||||
[ext_resource type="Script" path="res://scripts/ChordVolume.gd" id="1_fjurg"]
|
||||
[ext_resource type="Script" path="res://scripts/KeyboardController.gd" id="1_wynm3"]
|
||||
[ext_resource type="Script" path="res://scripts/RhythmController.gd" id="2_3cx1r"]
|
||||
[ext_resource type="Script" path="res://scripts/NoteVolume.gd" id="2_3uvfe"]
|
||||
[ext_resource type="Script" path="res://scripts/LoopController.gd" id="3_5v5ci"]
|
||||
@ -20,9 +21,6 @@ grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="NotePlayer" type="AudioStreamPlayer" parent="."]
|
||||
max_polyphony = 2
|
||||
|
||||
[node name="ChordPlayer" type="AudioStreamPlayer" parent="."]
|
||||
|
||||
[node name="RhythmPlayer" type="AudioStreamPlayer" parent="."]
|
||||
@ -40,29 +38,73 @@ offset_right = 262.5
|
||||
offset_bottom = 78.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_wynm3")
|
||||
|
||||
[node name="Sliders" type="HBoxContainer" parent="App"]
|
||||
[node name="Sliders" type="GridContainer" parent="App"]
|
||||
layout_mode = 2
|
||||
columns = 2
|
||||
|
||||
[node name="GridContainer" type="HBoxContainer" parent="App/Sliders"]
|
||||
[node name="ChordVolumeBox" type="VBoxContainer" parent="App/Sliders"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="ChordVolume" type="HSlider" parent="App/Sliders/GridContainer"]
|
||||
[node name="Label" type="Label" parent="App/Sliders/ChordVolumeBox"]
|
||||
layout_mode = 2
|
||||
text = "Chord Volume"
|
||||
|
||||
[node name="ChordVolume" type="HSlider" parent="App/Sliders/ChordVolumeBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = -5.0
|
||||
max_value = 5.0
|
||||
step = 0.1
|
||||
script = ExtResource("1_fjurg")
|
||||
|
||||
[node name="NoteVolume" type="HSlider" parent="App/Sliders/GridContainer"]
|
||||
[node name="NoteVolumeBox" type="VBoxContainer" parent="App/Sliders"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="App/Sliders/NoteVolumeBox"]
|
||||
layout_mode = 2
|
||||
text = "Note Volume"
|
||||
|
||||
[node name="NoteVolume" type="HSlider" parent="App/Sliders/NoteVolumeBox"]
|
||||
layout_mode = 2
|
||||
min_value = -5.0
|
||||
max_value = 5.0
|
||||
step = 0.1
|
||||
script = ExtResource("2_3uvfe")
|
||||
|
||||
[node name="RhythmVolume" type="HSlider" parent="App/Sliders/GridContainer"]
|
||||
[node name="RhythmVolumeBox" type="VBoxContainer" parent="App/Sliders"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="App/Sliders/RhythmVolumeBox"]
|
||||
layout_mode = 2
|
||||
text = "Rythm Volume"
|
||||
|
||||
[node name="RhythmVolume" type="HSlider" parent="App/Sliders/RhythmVolumeBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = -5.0
|
||||
max_value = 5.0
|
||||
step = 0.1
|
||||
script = ExtResource("3_m8wj7")
|
||||
|
||||
[node name="RhythmTempo" type="HSlider" parent="App/Sliders/GridContainer"]
|
||||
[node name="RhythmTempoBox" type="VBoxContainer" parent="App/Sliders"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="App/Sliders/RhythmTempoBox"]
|
||||
layout_mode = 2
|
||||
text = "Rythm Tempo"
|
||||
|
||||
[node name="RhythmTempo" type="HSlider" parent="App/Sliders/RhythmTempoBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
min_value = 0.5
|
||||
max_value = 4.0
|
||||
step = 0.1
|
||||
value = 1.0
|
||||
script = ExtResource("4_auq1v")
|
||||
|
||||
[node name="Buttons" type="HBoxContainer" parent="App"]
|
||||
|
@ -10,6 +10,7 @@ func _ready():
|
||||
ChordAudio = resource
|
||||
self.pressed.connect(button_pressed)
|
||||
Global.loop_changed.connect(loop_changed)
|
||||
Global.chord_volume.connect(change_volume)
|
||||
|
||||
func button_pressed():
|
||||
ChordPlayer.stream = ChordAudio
|
||||
@ -20,3 +21,6 @@ func loop_changed(state: bool):
|
||||
ChordAudio.loop = state
|
||||
if (!state):
|
||||
ChordPlayer.stop()
|
||||
|
||||
func change_volume(vol: float):
|
||||
ChordPlayer.set_volume_db(vol)
|
||||
|
96
scripts/KeyboardController.gd
Normal file
96
scripts/KeyboardController.gd
Normal file
@ -0,0 +1,96 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
func _input(event):
|
||||
if event is InputEventKey and event.pressed:
|
||||
# Major (Top Row)
|
||||
if event.keycode == KEY_Q:
|
||||
$"Buttons/Chords/eb".button_pressed()
|
||||
if event.keycode == KEY_W:
|
||||
$"Buttons/Chords/bb".button_pressed()
|
||||
if event.keycode == KEY_E:
|
||||
$"Buttons/Chords/f".button_pressed()
|
||||
if event.keycode == KEY_R:
|
||||
$"Buttons/Chords/c".button_pressed()
|
||||
if event.keycode == KEY_T:
|
||||
$"Buttons/Chords/g".button_pressed()
|
||||
if event.keycode == KEY_Y:
|
||||
$"Buttons/Chords/d".button_pressed()
|
||||
if event.keycode == KEY_U:
|
||||
$"Buttons/Chords/a".button_pressed()
|
||||
if event.keycode == KEY_I:
|
||||
$"Buttons/Chords/e".button_pressed()
|
||||
if event.keycode == KEY_O:
|
||||
$"Buttons/Chords/b".button_pressed()
|
||||
# Minor (Middle Row)
|
||||
if event.keycode == KEY_A:
|
||||
$"Buttons/Chords/ebm".button_pressed()
|
||||
if event.keycode == KEY_S:
|
||||
$"Buttons/Chords/bbm".button_pressed()
|
||||
if event.keycode == KEY_D:
|
||||
$"Buttons/Chords/fm".button_pressed()
|
||||
if event.keycode == KEY_F:
|
||||
$"Buttons/Chords/cm".button_pressed()
|
||||
if event.keycode == KEY_G:
|
||||
$"Buttons/Chords/gm".button_pressed()
|
||||
if event.keycode == KEY_H:
|
||||
$"Buttons/Chords/dm".button_pressed()
|
||||
if event.keycode == KEY_J:
|
||||
$"Buttons/Chords/am".button_pressed()
|
||||
if event.keycode == KEY_K:
|
||||
$"Buttons/Chords/em".button_pressed()
|
||||
if event.keycode == KEY_L:
|
||||
$"Buttons/Chords/bm".button_pressed()
|
||||
# 7th (Bottom Row)
|
||||
if event.keycode == KEY_Z:
|
||||
$"Buttons/Chords/eb7".button_pressed()
|
||||
if event.keycode == KEY_X:
|
||||
$"Buttons/Chords/bb7".button_pressed()
|
||||
if event.keycode == KEY_C:
|
||||
$"Buttons/Chords/f7".button_pressed()
|
||||
if event.keycode == KEY_V:
|
||||
$"Buttons/Chords/c7".button_pressed()
|
||||
if event.keycode == KEY_B:
|
||||
$"Buttons/Chords/g7".button_pressed()
|
||||
if event.keycode == KEY_N:
|
||||
$"Buttons/Chords/d7".button_pressed()
|
||||
if event.keycode == KEY_M:
|
||||
$"Buttons/Chords/a7".button_pressed()
|
||||
if event.keycode == KEY_COMMA:
|
||||
$"Buttons/Chords/e7".button_pressed()
|
||||
if event.keycode == KEY_PERIOD:
|
||||
$"Buttons/Chords/b7".button_pressed()
|
||||
# Notes (Keypad)
|
||||
if event.keycode == KEY_1 or event.keycode == KEY_KP_1:
|
||||
$"Buttons/Notes/0".button_pressed()
|
||||
if event.keycode == KEY_2 or event.keycode == KEY_KP_2:
|
||||
$"Buttons/Notes/1".button_pressed()
|
||||
if event.keycode == KEY_3 or event.keycode == KEY_KP_3:
|
||||
$"Buttons/Notes/2".button_pressed()
|
||||
if event.keycode == KEY_4 or event.keycode == KEY_KP_4:
|
||||
$"Buttons/Notes/3".button_pressed()
|
||||
if event.keycode == KEY_5 or event.keycode == KEY_KP_5:
|
||||
$"Buttons/Notes/4".button_pressed()
|
||||
if event.keycode == KEY_6 or event.keycode == KEY_KP_6:
|
||||
$"Buttons/Notes/5".button_pressed()
|
||||
if event.keycode == KEY_7 or event.keycode == KEY_KP_7:
|
||||
$"Buttons/Notes/6".button_pressed()
|
||||
if event.keycode == KEY_8 or event.keycode == KEY_KP_8:
|
||||
$"Buttons/Notes/7".button_pressed()
|
||||
if event.keycode == KEY_9 or event.keycode == KEY_KP_9:
|
||||
$"Buttons/Notes/8".button_pressed()
|
||||
if event.keycode == KEY_0 or event.keycode == KEY_KP_DIVIDE:
|
||||
$"Buttons/Notes/9".button_pressed()
|
||||
if event.keycode == KEY_MINUS or event.keycode == KEY_KP_MULTIPLY:
|
||||
$"Buttons/Notes/10".button_pressed()
|
||||
if event.keycode == KEY_EQUAL or event.keycode == KEY_KP_SUBTRACT:
|
||||
$"Buttons/Notes/11".button_pressed()
|
@ -4,9 +4,12 @@ var NotePlayer: AudioStreamPlayer
|
||||
var NoteAudio: AudioStreamOggVorbis
|
||||
|
||||
func _ready():
|
||||
NotePlayer = get_node("/root/Control/NotePlayer")
|
||||
# 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
|
||||
@ -16,3 +19,6 @@ 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)
|
||||
|
@ -9,8 +9,16 @@ func _ready():
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user