-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from Maaack/audio-input-option
Audio input option
- Loading branch information
Showing
9 changed files
with
154 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
extends ListOptionControl | ||
|
||
func _set_input_device(): | ||
var current_setting = _get_setting(default_value) | ||
if current_setting is bool: | ||
current_setting = &"Default" | ||
AudioServer.input_device = _get_setting(default_value) | ||
|
||
func _add_microphone_audio_stream() -> void: | ||
var instance = AudioStreamPlayer.new() | ||
instance.stream = AudioStreamMicrophone.new() | ||
instance.autoplay = true | ||
add_child.call_deferred(instance) | ||
instance.ready.connect(_set_input_device) | ||
|
||
func _ready(): | ||
if ProjectSettings.get_setting("audio/driver/enable_input", false): | ||
if AudioServer.input_device.is_empty(): | ||
_add_microphone_audio_stream() | ||
else: | ||
_set_input_device() | ||
if not Engine.is_editor_hint(): | ||
option_values = AudioServer.get_input_device_list() | ||
else: | ||
hide() | ||
super._ready() | ||
|
||
func _on_setting_changed(value): | ||
if value >= option_values.size(): return | ||
AudioServer.input_device = option_values[value] | ||
super._on_setting_changed(value) | ||
|
||
func _value_title_map(value : Variant) -> String: | ||
if value is String: | ||
return value | ||
else: | ||
return super._value_title_map(value) |
21 changes: 21 additions & 0 deletions
21
...aaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dxj1gsxtlp6v0"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://b6bl3n5mp3m1e" path="res://addons/maaacks_game_template/base/scenes/Menus/OptionsMenu/OptionControl/ListOptionControl.tscn" id="1_0vgeo"] | ||
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.gd" id="2_6qeue"] | ||
|
||
[node name="AudioInputOptionControl" instance=ExtResource("1_0vgeo")] | ||
script = ExtResource("2_6qeue") | ||
option_name = "Input Device" | ||
option_section = 2 | ||
key = "InputDevice" | ||
section = "AudioSettings" | ||
property_type = 4 | ||
default_value = "Default" | ||
|
||
[node name="OptionLabel" parent="." index="0"] | ||
text = "Input Device :" | ||
|
||
[node name="OptionButton" parent="." index="1"] | ||
size_flags_horizontal = 3 | ||
text_overrun_behavior = 1 | ||
clip_text = true |
6 changes: 5 additions & 1 deletion
6
addons/maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dmgla7rq1g2cc"] | ||
[gd_scene load_steps=4 format=3 uid="uid://dmgla7rq1g2cc"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://c8vnncjwqcpab" path="res://addons/maaacks_game_template/base/scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.tscn" id="1_ro573"] | ||
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.gd" id="2_g4nfi"] | ||
[ext_resource type="PackedScene" uid="uid://dxj1gsxtlp6v0" path="res://scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.tscn" id="3_tfrh8"] | ||
|
||
[node name="Audio" instance=ExtResource("1_ro573")] | ||
script = ExtResource("2_g4nfi") | ||
|
||
[node name="AudioInputOptionControl" parent="VBoxContainer" index="2" instance=ExtResource("3_tfrh8")] | ||
layout_mode = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
extends ListOptionControl | ||
|
||
func _set_input_device(): | ||
var current_setting = _get_setting(default_value) | ||
if current_setting is bool: | ||
current_setting = &"Default" | ||
AudioServer.input_device = _get_setting(default_value) | ||
|
||
func _add_microphone_audio_stream() -> void: | ||
var instance = AudioStreamPlayer.new() | ||
instance.stream = AudioStreamMicrophone.new() | ||
instance.autoplay = true | ||
add_child.call_deferred(instance) | ||
instance.ready.connect(_set_input_device) | ||
|
||
func _ready(): | ||
if ProjectSettings.get_setting("audio/driver/enable_input", false): | ||
if AudioServer.input_device.is_empty(): | ||
_add_microphone_audio_stream() | ||
else: | ||
_set_input_device() | ||
if not Engine.is_editor_hint(): | ||
option_values = AudioServer.get_input_device_list() | ||
else: | ||
hide() | ||
super._ready() | ||
|
||
func _on_setting_changed(value): | ||
if value >= option_values.size(): return | ||
AudioServer.input_device = option_values[value] | ||
super._on_setting_changed(value) | ||
|
||
func _value_title_map(value : Variant) -> String: | ||
if value is String: | ||
return value | ||
else: | ||
return super._value_title_map(value) |
21 changes: 21 additions & 0 deletions
21
scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dxj1gsxtlp6v0"] | ||
|
||
[ext_resource type="PackedScene" uid="uid://b6bl3n5mp3m1e" path="res://addons/maaacks_game_template/base/scenes/Menus/OptionsMenu/OptionControl/ListOptionControl.tscn" id="1_0vgeo"] | ||
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.gd" id="2_6qeue"] | ||
|
||
[node name="AudioInputOptionControl" instance=ExtResource("1_0vgeo")] | ||
script = ExtResource("2_6qeue") | ||
option_name = "Input Device" | ||
option_section = 2 | ||
key = "InputDevice" | ||
section = "AudioSettings" | ||
property_type = 4 | ||
default_value = "Default" | ||
|
||
[node name="OptionLabel" parent="." index="0"] | ||
text = "Input Device :" | ||
|
||
[node name="OptionButton" parent="." index="1"] | ||
size_flags_horizontal = 3 | ||
text_overrun_behavior = 1 | ||
clip_text = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://c8cehdleoso6q"] | ||
|
||
[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.tscn" id="1_7b5yq"] | ||
[ext_resource type="Script" path="res://scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.gd" id="2_17u6b"] | ||
[ext_resource type="PackedScene" uid="uid://c8vnncjwqcpab" path="res://addons/maaacks_game_template/base/scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.tscn" id="1_ro573"] | ||
[ext_resource type="Script" path="res://addons/maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioOptionsMenu.gd" id="2_g4nfi"] | ||
[ext_resource type="PackedScene" uid="uid://dxj1gsxtlp6v0" path="res://addons/maaacks_game_template/examples/scenes/Menus/OptionsMenu/Audio/AudioInputOptionControl.tscn" id="3_tfrh8"] | ||
|
||
[node name="Audio" instance=ExtResource("1_7b5yq")] | ||
script = ExtResource("2_17u6b") | ||
[node name="Audio" instance=ExtResource("1_ro573")] | ||
script = ExtResource("2_g4nfi") | ||
|
||
[node name="AudioInputOptionControl" parent="VBoxContainer" index="2" instance=ExtResource("3_tfrh8")] | ||
layout_mode = 2 |