Skip to content

Commit 0b6b0bc

Browse files
committed
Add audio system
1 parent 59721cf commit 0b6b0bc

13 files changed

Lines changed: 119 additions & 1 deletion
3 KB
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[remap]
2+
3+
importer="mp3"
4+
type="AudioStreamMP3"
5+
uid="uid://cw4wnu0n1bds1"
6+
path="res://.godot/imported/u_iozlfd2w96-bubble-pop-283674.mp3-08c237791abaee58b50a9590494886b2.mp3str"
7+
8+
[deps]
9+
10+
source_file="res://audio/assets/u_iozlfd2w96-bubble-pop-283674.mp3"
11+
dest_files=["res://.godot/imported/u_iozlfd2w96-bubble-pop-283674.mp3-08c237791abaee58b50a9590494886b2.mp3str"]
12+
13+
[params]
14+
15+
loop=false
16+
loop_offset=0
17+
bpm=0
18+
beat_count=0
19+
bar_beats=4

audio/audio_system.gd

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
extends Node
2+
3+
enum AudioBus {
4+
MASTER = 0,
5+
MUSIC = 1,
6+
SFX = 2,
7+
}
8+
9+
var _sound_playback: AudioStreamPlaybackPolyphonic
10+
var _music_playback: AudioStreamPlaybackInteractive
11+
12+
@onready var _sfx_stream_player: AudioStreamPlayer = %SFXStreamPlayer
13+
@onready var _music_stream_player: AudioStreamPlayer = %MusicStreamPlayer
14+
15+
16+
func _ready() -> void:
17+
_music_stream_player.play()
18+
_music_playback = _music_stream_player.get_stream_playback()
19+
_music_stream_player.stop()
20+
21+
_sfx_stream_player.play()
22+
_sound_playback = _sfx_stream_player.get_stream_playback()
23+
24+
25+
func play_sfx(audio_stream: AudioStream) -> void:
26+
_sound_playback.play_stream(audio_stream)
27+
28+
func play_music(music_name: String) -> void:
29+
if not _music_stream_player.playing:
30+
_music_stream_player.play()
31+
32+
_music_playback.switch_to_clip_by_name(music_name)

audio/audio_system.gd.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://7unumgeixwyb

audio/audio_system.tscn

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[gd_scene format=3 uid="uid://cxa6mvxw3hrjy"]
2+
3+
[ext_resource type="Script" uid="uid://7unumgeixwyb" path="res://audio/audio_system.gd" id="1_q3cvo"]
4+
5+
[sub_resource type="AudioStreamPolyphonic" id="AudioStreamPolyphonic_q3cvo"]
6+
7+
[sub_resource type="AudioStreamInteractive" id="AudioStreamInteractive_q3cvo"]
8+
9+
[node name="AudioSystem" type="Node" unique_id=1661046486]
10+
process_mode = 3
11+
script = ExtResource("1_q3cvo")
12+
13+
[node name="SFXStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=1541610063]
14+
unique_name_in_owner = true
15+
stream = SubResource("AudioStreamPolyphonic_q3cvo")
16+
17+
[node name="MusicStreamPlayer" type="AudioStreamPlayer" parent="." unique_id=1257754447]
18+
unique_name_in_owner = true
19+
stream = SubResource("AudioStreamInteractive_q3cvo")

audio/default_bus_layout.tres

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[gd_resource type="AudioBusLayout" format=3 uid="uid://dyq71t4hqle5t"]
2+
3+
[sub_resource type="AudioEffectCompressor" id="AudioEffectCompressor_j3pel"]
4+
resource_name = "Compressor"
5+
threshold = -3.0
6+
7+
[sub_resource type="AudioEffectHardLimiter" id="AudioEffectHardLimiter_j3pel"]
8+
resource_name = "HardLimiter"
9+
10+
[resource]
11+
bus/0/effect/0/effect = SubResource("AudioEffectCompressor_j3pel")
12+
bus/0/effect/0/enabled = true
13+
bus/0/effect/1/effect = SubResource("AudioEffectHardLimiter_j3pel")
14+
bus/0/effect/1/enabled = true
15+
bus/1/name = &"Music"
16+
bus/1/solo = false
17+
bus/1/mute = false
18+
bus/1/bypass_fx = false
19+
bus/1/volume_db = 0.0
20+
bus/1/send = &"Master"
21+
bus/2/name = &"SFX"
22+
bus/2/solo = false
23+
bus/2/mute = false
24+
bus/2/bypass_fx = false
25+
bus/2/volume_db = 0.0
26+
bus/2/send = &"Master"

audio/music.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class_name Music
2+
extends RefCounted
3+
4+
#const MAIN_MENU = "main_menu"

audio/music.gd.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://camnxbg84y3be

audio/sounds.gd

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class_name Sounds
2+
extends RefCounted
3+
4+
#class UI extends RefCounted:
5+
const BUBBLE_POP = preload("res://audio/assets/u_iozlfd2w96-bubble-pop-283674.mp3")

audio/sounds.gd.uid

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://m31h60b2w5f5

0 commit comments

Comments
 (0)