mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 14:10:55 +03:00
Merge pull request #374 from aaronfranke/device-changer
Update Audio Device Changer demo to Godot 3.1.2
This commit is contained in:
43
audio/device_changer/Changer.gd
Normal file
43
audio/device_changer/Changer.gd
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
onready var itemList = get_node("ItemList")
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
for item in AudioServer.get_device_list():
|
||||||
|
itemList.add_item(item)
|
||||||
|
|
||||||
|
var device = AudioServer.get_device()
|
||||||
|
for i in range(itemList.get_item_count()):
|
||||||
|
if device == itemList.get_item_text(i):
|
||||||
|
itemList.select(i)
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
|
func _process(_delta):
|
||||||
|
var speakerMode = "Stereo"
|
||||||
|
|
||||||
|
if AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_31:
|
||||||
|
speakerMode = "Surround 3.1"
|
||||||
|
elif AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_51:
|
||||||
|
speakerMode = "Surround 5.1"
|
||||||
|
elif AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_71:
|
||||||
|
speakerMode = "Surround 7.1"
|
||||||
|
|
||||||
|
$DeviceInfo.text = "Current Device: " + AudioServer.get_device() + "\n"
|
||||||
|
$DeviceInfo.text += "Speaker Mode: " + speakerMode
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_button_down():
|
||||||
|
for item in itemList.get_selected_items():
|
||||||
|
var device = itemList.get_item_text(item)
|
||||||
|
AudioServer.set_device(device)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Play_Audio_button_down():
|
||||||
|
if $AudioStreamPlayer.playing:
|
||||||
|
$AudioStreamPlayer.stop()
|
||||||
|
$PlayAudio.text = "Play Audio"
|
||||||
|
else:
|
||||||
|
$AudioStreamPlayer.play()
|
||||||
|
$PlayAudio.text = "Stop Audio"
|
||||||
51
audio/device_changer/Changer.tscn
Normal file
51
audio/device_changer/Changer.tscn
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Changer.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://Intro.ogg" type="AudioStream" id=2]
|
||||||
|
|
||||||
|
[node name="Changer" type="Control"]
|
||||||
|
margin_right = 1023.0
|
||||||
|
margin_bottom = 598.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ItemList" type="ItemList" parent="."]
|
||||||
|
margin_left = 57.0
|
||||||
|
margin_top = 33.0
|
||||||
|
margin_right = 960.0
|
||||||
|
margin_bottom = 228.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="DeviceInfo" type="Label" parent="."]
|
||||||
|
margin_left = 321.0
|
||||||
|
margin_top = 248.0
|
||||||
|
margin_right = 660.0
|
||||||
|
margin_bottom = 284.0
|
||||||
|
align = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="SetDevice" type="Button" parent="."]
|
||||||
|
margin_left = 425.723
|
||||||
|
margin_top = 309.733
|
||||||
|
margin_right = 556.723
|
||||||
|
margin_bottom = 354.733
|
||||||
|
text = "Set Device"
|
||||||
|
|
||||||
|
[node name="PlayAudio" type="Button" parent="."]
|
||||||
|
margin_left = 424.0
|
||||||
|
margin_top = 373.0
|
||||||
|
margin_right = 557.0
|
||||||
|
margin_bottom = 414.0
|
||||||
|
text = "Play Audio"
|
||||||
|
|
||||||
|
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource( 2 )
|
||||||
|
volume_db = -6.0
|
||||||
|
[connection signal="button_down" from="SetDevice" to="." method="_on_Button_button_down"]
|
||||||
|
[connection signal="button_down" from="PlayAudio" to="." method="_on_Play_Audio_button_down"]
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
extends Control
|
|
||||||
|
|
||||||
onready var itemList = get_node("ItemList")
|
|
||||||
|
|
||||||
func _process(delta):
|
|
||||||
var speakerMode = "Stereo"
|
|
||||||
|
|
||||||
if (AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_51):
|
|
||||||
speakerMode = "Surround 5.1"
|
|
||||||
elif (AudioServer.get_speaker_mode() == AudioServer.SPEAKER_SURROUND_71):
|
|
||||||
speakerMode = "Surround 7.1"
|
|
||||||
|
|
||||||
$Device.text = "Current Device: " + AudioServer.get_device() + "\n"
|
|
||||||
$Device.text+= "Speaker Mode: " + speakerMode
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
var list = AudioServer.get_device_list()
|
|
||||||
for item in list:
|
|
||||||
itemList.add_item(item)
|
|
||||||
|
|
||||||
var device = AudioServer.get_device()
|
|
||||||
var i = 0
|
|
||||||
while (i < itemList.get_item_count()):
|
|
||||||
if (device == itemList.get_item_text(i)):
|
|
||||||
itemList.select(i)
|
|
||||||
break
|
|
||||||
i+= 1
|
|
||||||
|
|
||||||
func _on_Button_button_down():
|
|
||||||
var array = itemList.get_selected_items()
|
|
||||||
for item in array:
|
|
||||||
var device = itemList.get_item_text(item)
|
|
||||||
AudioServer.set_device(device)
|
|
||||||
|
|
||||||
func _on_Play_Audio_button_down():
|
|
||||||
if ($AudioStreamPlayer.playing):
|
|
||||||
$AudioStreamPlayer.stop()
|
|
||||||
$PlayAudio.text = "Play Audio"
|
|
||||||
else:
|
|
||||||
$AudioStreamPlayer.play()
|
|
||||||
$PlayAudio.text = "Stop Audio"
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
[gd_scene load_steps=3 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://Control.gd" type="Script" id=1]
|
|
||||||
[ext_resource path="res://Intro.ogg" type="AudioStream" id=2]
|
|
||||||
|
|
||||||
[node name="Control" type="Control"]
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_right = 1023.0
|
|
||||||
margin_bottom = 598.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
|
|
||||||
[node name="ItemList" type="ItemList" parent="."]
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 57.0
|
|
||||||
margin_top = 33.0
|
|
||||||
margin_right = 960.0
|
|
||||||
margin_bottom = 228.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = true
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
items = [ ]
|
|
||||||
select_mode = 0
|
|
||||||
allow_reselect = false
|
|
||||||
icon_mode = 1
|
|
||||||
fixed_icon_size = Vector2( 0, 0 )
|
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="."]
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 425.723
|
|
||||||
margin_top = 309.733
|
|
||||||
margin_right = 556.723
|
|
||||||
margin_bottom = 354.733
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
toggle_mode = false
|
|
||||||
enabled_focus_mode = 2
|
|
||||||
shortcut = null
|
|
||||||
group = null
|
|
||||||
text = "Set Device"
|
|
||||||
flat = false
|
|
||||||
align = 1
|
|
||||||
|
|
||||||
[node name="PlayAudio" type="Button" parent="."]
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 424.0
|
|
||||||
margin_top = 373.0
|
|
||||||
margin_right = 557.0
|
|
||||||
margin_bottom = 414.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
toggle_mode = false
|
|
||||||
enabled_focus_mode = 2
|
|
||||||
shortcut = null
|
|
||||||
group = null
|
|
||||||
text = "Play Audio"
|
|
||||||
flat = false
|
|
||||||
align = 1
|
|
||||||
|
|
||||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
|
||||||
stream = ExtResource( 2 )
|
|
||||||
volume_db = -6.0
|
|
||||||
pitch_scale = 1.0
|
|
||||||
autoplay = false
|
|
||||||
stream_paused = false
|
|
||||||
mix_target = 0
|
|
||||||
bus = "Master"
|
|
||||||
|
|
||||||
[node name="Device" type="Label" parent="."]
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 321.0
|
|
||||||
margin_top = 248.0
|
|
||||||
margin_right = 660.0
|
|
||||||
margin_bottom = 284.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 2
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 4
|
|
||||||
align = 1
|
|
||||||
percent_visible = 1.0
|
|
||||||
lines_skipped = 0
|
|
||||||
max_lines_visible = -1
|
|
||||||
|
|
||||||
[connection signal="button_down" from="Button" to="." method="_on_Button_button_down"]
|
|
||||||
[connection signal="button_down" from="PlayAudio" to="." method="_on_Play_Audio_button_down"]
|
|
||||||
@@ -1,102 +1,14 @@
|
|||||||
[gd_resource type="Environment" load_steps=2 format=2]
|
[gd_resource type="Environment" load_steps=2 format=2]
|
||||||
|
|
||||||
[sub_resource type="ProceduralSky" id=1]
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
radiance_size = 4
|
|
||||||
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
||||||
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
||||||
sky_curve = 0.25
|
sky_curve = 0.25
|
||||||
sky_energy = 1.0
|
|
||||||
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
||||||
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
||||||
ground_curve = 0.01
|
ground_curve = 0.01
|
||||||
ground_energy = 1.0
|
|
||||||
sun_color = Color( 1, 1, 1, 1 )
|
|
||||||
sun_latitude = 35.0
|
|
||||||
sun_longitude = 0.0
|
|
||||||
sun_angle_min = 1.0
|
|
||||||
sun_angle_max = 100.0
|
|
||||||
sun_curve = 0.05
|
|
||||||
sun_energy = 16.0
|
sun_energy = 16.0
|
||||||
texture_size = 2
|
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
|
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 1 )
|
background_sky = SubResource( 1 )
|
||||||
background_sky_custom_fov = 0.0
|
|
||||||
background_color = Color( 0, 0, 0, 1 )
|
|
||||||
background_energy = 1.0
|
|
||||||
background_canvas_max_layer = 0
|
|
||||||
ambient_light_color = Color( 0, 0, 0, 1 )
|
|
||||||
ambient_light_energy = 1.0
|
|
||||||
ambient_light_sky_contribution = 1.0
|
|
||||||
fog_enabled = false
|
|
||||||
fog_color = Color( 0.5, 0.6, 0.7, 1 )
|
|
||||||
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
|
|
||||||
fog_sun_amount = 0.0
|
|
||||||
fog_depth_enabled = true
|
|
||||||
fog_depth_begin = 10.0
|
|
||||||
fog_depth_curve = 1.0
|
|
||||||
fog_transmit_enabled = false
|
|
||||||
fog_transmit_curve = 1.0
|
|
||||||
fog_height_enabled = false
|
|
||||||
fog_height_min = 0.0
|
|
||||||
fog_height_max = 100.0
|
|
||||||
fog_height_curve = 1.0
|
|
||||||
tonemap_mode = 0
|
|
||||||
tonemap_exposure = 1.0
|
|
||||||
tonemap_white = 1.0
|
|
||||||
auto_exposure_enabled = false
|
|
||||||
auto_exposure_scale = 0.4
|
|
||||||
auto_exposure_min_luma = 0.05
|
|
||||||
auto_exposure_max_luma = 8.0
|
|
||||||
auto_exposure_speed = 0.5
|
|
||||||
ss_reflections_enabled = false
|
|
||||||
ss_reflections_max_steps = 64
|
|
||||||
ss_reflections_fade_in = 0.15
|
|
||||||
ss_reflections_fade_out = 2.0
|
|
||||||
ss_reflections_depth_tolerance = 0.2
|
|
||||||
ss_reflections_roughness = true
|
|
||||||
ssao_enabled = false
|
|
||||||
ssao_radius = 1.0
|
|
||||||
ssao_intensity = 1.0
|
|
||||||
ssao_radius2 = 0.0
|
|
||||||
ssao_intensity2 = 1.0
|
|
||||||
ssao_bias = 0.01
|
|
||||||
ssao_light_affect = 0.0
|
|
||||||
ssao_ao_channel_affect = 0.0
|
|
||||||
ssao_color = Color( 0, 0, 0, 1 )
|
|
||||||
ssao_quality = 0
|
|
||||||
ssao_blur = 3
|
|
||||||
ssao_edge_sharpness = 4.0
|
|
||||||
dof_blur_far_enabled = false
|
|
||||||
dof_blur_far_distance = 10.0
|
|
||||||
dof_blur_far_transition = 5.0
|
|
||||||
dof_blur_far_amount = 0.1
|
|
||||||
dof_blur_far_quality = 1
|
|
||||||
dof_blur_near_enabled = false
|
|
||||||
dof_blur_near_distance = 2.0
|
|
||||||
dof_blur_near_transition = 1.0
|
|
||||||
dof_blur_near_amount = 0.1
|
|
||||||
dof_blur_near_quality = 1
|
|
||||||
glow_enabled = false
|
|
||||||
glow_levels/1 = false
|
|
||||||
glow_levels/2 = false
|
|
||||||
glow_levels/3 = true
|
|
||||||
glow_levels/4 = false
|
|
||||||
glow_levels/5 = true
|
|
||||||
glow_levels/6 = false
|
|
||||||
glow_levels/7 = false
|
|
||||||
glow_intensity = 0.8
|
|
||||||
glow_strength = 1.0
|
|
||||||
glow_bloom = 0.0
|
|
||||||
glow_blend_mode = 2
|
|
||||||
glow_hdr_threshold = 1.0
|
|
||||||
glow_hdr_scale = 2.0
|
|
||||||
glow_bicubic_upscale = false
|
|
||||||
adjustment_enabled = false
|
|
||||||
adjustment_brightness = 1.0
|
|
||||||
adjustment_contrast = 1.0
|
|
||||||
adjustment_saturation = 1.0
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="StreamTexture"
|
type="StreamTexture"
|
||||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ _global_script_class_icons={
|
|||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Device Changer"
|
config/name="Audio Device Changer Demo"
|
||||||
run/main_scene="res://Control.tscn"
|
run/main_scene="res://Changer.tscn"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|||||||
Reference in New Issue
Block a user