mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2025-12-31 09:49:06 +03:00
Use match case instead of if else in Audio Mic Record demo (#1053)
* Use match case instead of if else This is my first pull request. * Apply suggestions from code review --------- Co-authored-by: Hugo Locurcio <hugo.locurcio@hugo.pro>
This commit is contained in:
@@ -59,29 +59,31 @@ func _on_SaveButton_pressed():
|
||||
|
||||
|
||||
func _on_MixRateOptionButton_item_selected(index: int) -> void:
|
||||
if index == 0:
|
||||
mix_rate = 11025
|
||||
elif index == 1:
|
||||
mix_rate = 16000
|
||||
elif index == 2:
|
||||
mix_rate = 22050
|
||||
elif index == 3:
|
||||
mix_rate = 32000
|
||||
elif index == 4:
|
||||
mix_rate = 44100
|
||||
elif index == 5:
|
||||
mix_rate = 48000
|
||||
match index:
|
||||
0:
|
||||
mix_rate = 11025
|
||||
1:
|
||||
mix_rate = 16000
|
||||
2:
|
||||
mix_rate = 22050
|
||||
3:
|
||||
mix_rate = 32000
|
||||
4:
|
||||
mix_rate = 44100
|
||||
5:
|
||||
mix_rate = 48000
|
||||
if recording != null:
|
||||
recording.set_mix_rate(mix_rate)
|
||||
|
||||
|
||||
func _on_FormatOptionButton_item_selected(index: int) -> void:
|
||||
if index == 0:
|
||||
format = AudioStreamWAV.FORMAT_8_BITS
|
||||
elif index == 1:
|
||||
format = AudioStreamWAV.FORMAT_16_BITS
|
||||
elif index == 2:
|
||||
format = AudioStreamWAV.FORMAT_IMA_ADPCM
|
||||
match index:
|
||||
0:
|
||||
format = AudioStreamWAV.FORMAT_8_BITS
|
||||
1:
|
||||
format = AudioStreamWAV.FORMAT_16_BITS
|
||||
2:
|
||||
format = AudioStreamWAV.FORMAT_IMA_ADPCM
|
||||
if recording != null:
|
||||
recording.set_format(format)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user