Skip to content

Commit

Permalink
Add simple sound node
Browse files Browse the repository at this point in the history
  • Loading branch information
starnight committed Jun 14, 2024
1 parent 62e90bf commit 68e939e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
Binary file not shown.
19 changes: 19 additions & 0 deletions addons/block_code/simple_nodes/simple_sound/score.ogg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[remap]

importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://x1po1oxvsbrf"
path="res://.godot/imported/score.ogg-9db5b6cadacd012955645436b3f5312a.oggvorbisstr"

[deps]

source_file="res://addons/block_code/simple_nodes/simple_sound/score.ogg"
dest_files=["res://.godot/imported/score.ogg-9db5b6cadacd012955645436b3f5312a.oggvorbisstr"]

[params]

loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4
33 changes: 33 additions & 0 deletions addons/block_code/simple_nodes/simple_sound/simple_sound.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@tool
class_name SimpleSound
extends AudioStreamPlayer

var soundstream: AudioStream = load("res://addons/block_code/simple_nodes/simple_sound/score.ogg")


func _ready():
stream = soundstream


func get_class():
return "SimpleSound"


static func get_exposed_properties() -> Array[String]:
return ["stream"]


static func get_custom_blocks() -> Array[BlockCategory]:
var b: Block

# Play the sound
var sound_list: Array[Block] = []
b = CategoryFactory.BLOCKS["statement_block"].instantiate()
b.block_type = Types.BlockType.EXECUTE
b.block_format = "Play the sound, Volume dB {db: INT}"
b.statement = "volume_db=db\n" + "play()"
sound_list.append(b)

var sound_cat: BlockCategory = BlockCategory.new("PlaySound", sound_list, Color("e30fc0"))

return [sound_cat]
6 changes: 6 additions & 0 deletions addons/block_code/simple_nodes/simple_sound/simple_sound.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dnea31ja51r43"]

[ext_resource type="Script" path="res://addons/block_code/simple_nodes/simple_sound/simple_sound.gd" id="1_7dbg7"]

[node name="SimpleSound" type="AudioStreamPlayer"]
script = ExtResource("1_7dbg7")

0 comments on commit 68e939e

Please sign in to comment.