diff --git a/templates/worldscene1/addons/gdpd/bin/osx/libgdpd.dylib b/templates/worldscene1/addons/gdpd/bin/osx/libgdpd.dylib index af7b66c..a8021de 100755 Binary files a/templates/worldscene1/addons/gdpd/bin/osx/libgdpd.dylib and b/templates/worldscene1/addons/gdpd/bin/osx/libgdpd.dylib differ diff --git a/templates/worldscene1/autoload/Global.gd b/templates/worldscene1/autoload/Global.gd index cd68aec..f9b2265 100644 --- a/templates/worldscene1/autoload/Global.gd +++ b/templates/worldscene1/autoload/Global.gd @@ -7,7 +7,7 @@ var _patches = [] export (bool) var _enable_gui = false export (String) var _gui_path = "/Applications/Pd-0.53-1.app/Contents/Resources" - +export (bool) var _verbose = false export (float) var _sample_rate = 48000 export (int) var _blocksize = 256 @@ -17,6 +17,7 @@ func _ready(): # set gui path to activate gui window (otherwise, nogui) _gdpd.set_gui_path(_gui_path) _gdpd.set_volume(1) # by default, volume(gain) == 0 + _gdpd.set_verbose(_verbose) # by default, suppress 'print' _gdpd.init(0, 2, _sample_rate, _blocksize) _gdpd.computeAudio(true) # [; pd dsp 1 ( _gdpd.subscribe("toGodot") diff --git a/templates/worldscene1/export_presets.cfg b/templates/worldscene1/export_presets.cfg new file mode 100644 index 0000000..2d3b85b --- /dev/null +++ b/templates/worldscene1/export_presets.cfg @@ -0,0 +1,73 @@ +[preset.0] + +name="Mac OSX" +platform="Mac OSX" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="./Sands and Waves (worldscene1).dmg" +script_export_mode=1 +script_encryption_key="" + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +application/name="" +application/info="Made with Godot Engine" +application/icon="" +application/identifier="in.dianaband.worldscene1" +application/signature="" +application/app_category="Games" +application/short_version="1.0" +application/version="1.0" +application/copyright="" +display/high_res=false +privacy/microphone_usage_description="" +privacy/camera_usage_description="" +privacy/location_usage_description="" +privacy/address_book_usage_description="" +privacy/calendar_usage_description="" +privacy/photos_library_usage_description="" +privacy/desktop_folder_usage_description="" +privacy/documents_folder_usage_description="" +privacy/downloads_folder_usage_description="" +privacy/network_volumes_usage_description="" +privacy/removable_volumes_usage_description="" +codesign/enable=true +codesign/identity="" +codesign/timestamp=false +codesign/hardened_runtime=false +codesign/replace_existing_signature=true +codesign/entitlements/custom_file="" +codesign/entitlements/allow_jit_code_execution=false +codesign/entitlements/allow_unsigned_executable_memory=false +codesign/entitlements/allow_dyld_environment_variables=false +codesign/entitlements/disable_library_validation=true +codesign/entitlements/audio_input=false +codesign/entitlements/camera=false +codesign/entitlements/location=false +codesign/entitlements/address_book=false +codesign/entitlements/calendars=false +codesign/entitlements/photos_library=false +codesign/entitlements/apple_events=false +codesign/entitlements/debugging=false +codesign/entitlements/app_sandbox/enabled=false +codesign/entitlements/app_sandbox/network_server=false +codesign/entitlements/app_sandbox/network_client=false +codesign/entitlements/app_sandbox/device_usb=false +codesign/entitlements/app_sandbox/device_bluetooth=false +codesign/entitlements/app_sandbox/files_downloads=0 +codesign/entitlements/app_sandbox/files_pictures=0 +codesign/entitlements/app_sandbox/files_music=0 +codesign/entitlements/app_sandbox/files_movies=0 +codesign/custom_options=PoolStringArray( ) +notarization/enable=false +notarization/apple_id_name="" +notarization/apple_id_password="" +notarization/apple_team_id="" +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false diff --git a/templates/worldscene1/main-earplug.pd b/templates/worldscene1/main-earplug.pd new file mode 100644 index 0000000..df864f6 --- /dev/null +++ b/templates/worldscene1/main-earplug.pd @@ -0,0 +1,55 @@ +#N canvas 108 222 456 518 12; +#X obj 361 21 loadbang; +#X msg 361 51 \; pd dsp 1; +#X floatatom 21 198 5 0 0 0 - - - 0; +#X obj 21 22 r fromGodot\$0; +#X obj 21 46 list trim; +#X obj 199 467 dac~ 1 2; +#X obj 199 407 *~; +#X obj 189 264 line~; +#X msg 189 240 \$1 100; +#X obj 189 127 unpack f f; +#X floatatom 189 177 5 0 0 0 - - - 0; +#X obj 21 256 noise~; +#X obj 21 286 bp~ 500 1000; +#X obj 21 70 route freq gain panvol; +#X obj 21 316 *~; +#X msg 296 338 \$1 100; +#X floatatom 296 159 5 0 0 0 - - - 0; +#X obj 199 437 earplug~ 0 0; +#X obj 296 362 line; +#X obj 132 310 switch~; +#X obj 132 286 tgl 19 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000 0 1; +#X obj 132 262 change; +#X text 89 155 switch on/off before 0 to stop startup pops, f 12; +#X obj 189 216 max 0; +#X obj 132 238 > -0.3; +#X obj 296 248 expr 360-$f1; +#X obj 296 182 expr $f1*180/3.141592; +#X connect 2 0 12 1; +#X connect 3 0 4 0; +#X connect 4 0 13 0; +#X connect 6 0 17 0; +#X connect 7 0 6 1; +#X connect 8 0 7 0; +#X connect 9 0 10 0; +#X connect 9 1 16 0; +#X connect 10 0 23 0; +#X connect 10 0 24 0; +#X connect 11 0 12 0; +#X connect 12 0 14 0; +#X connect 13 0 2 0; +#X connect 13 1 14 1; +#X connect 13 2 9 0; +#X connect 14 0 6 0; +#X connect 15 0 18 0; +#X connect 16 0 26 0; +#X connect 17 0 5 0; +#X connect 17 1 5 1; +#X connect 18 0 17 1; +#X connect 20 0 19 0; +#X connect 21 0 20 0; +#X connect 23 0 8 0; +#X connect 24 0 21 0; +#X connect 25 0 15 0; +#X connect 26 0 25 0; diff --git a/templates/worldscene1/main.gd b/templates/worldscene1/main.gd index 345e780..e687d16 100644 --- a/templates/worldscene1/main.gd +++ b/templates/worldscene1/main.gd @@ -1,9 +1,13 @@ extends RigidBody -export (String, MULTILINE) var patch = "" export (float, 0, 100) var audible_range_max = 10.0 +export (float, 1, 12) var preset = 1 + +export (bool) var use_embeded_patch = false +export (String, MULTILINE) var patch = "" var _my_patch = "res://main.pd" +#var _my_patch = "res://main-earplug.pd" var _my_id = 0 func set_size(size): @@ -23,17 +27,40 @@ func set_gain(gain): Global._gdpd.add_float(gain) Global._gdpd.finish_list("fromGodot" + String(_my_id)) +func set_param(param): + Global._gdpd.start_message(param.size()+1) + Global._gdpd.add_symbol("param") + for i in range(param.size()): + Global._gdpd.add_float(param[i]) + Global._gdpd.finish_list("fromGodot" + String(_my_id)) + +func set_preset(prs): + preset = prs + Global._gdpd.start_message(2) + Global._gdpd.add_symbol("preset") + Global._gdpd.add_float(prs) + Global._gdpd.finish_list("fromGodot" + String(_my_id)) + func set_color(color): $MeshInstance.material_override = SpatialMaterial.new() $MeshInstance.material_override.albedo_color = color func _ready(): + # save patch (for export) + if use_embeded_patch: + assert(_my_patch.substr(0, 7) == "user://", "use userpath with embeded_patch enabled !") + assert(patch != "", "patch is empty?") + _save_patch() + # load patch _my_id = Global.load_patch(ProjectSettings.globalize_path(_my_patch)) # listen 'player_transform_updated' event Events.connect("player_transform_updated", self, "_on_Events_player_transform_updated") + # send 'preset' + set_preset(preset) + func _on_Events_player_transform_updated(playerpos, playerheading): var mypos = get_global_translation() var mypos2d = Vector2(mypos.x, mypos.z) @@ -47,7 +74,7 @@ func _on_Events_player_transform_updated(playerpos, playerheading): # (check) # print(str(_my_id) +" : ("+ str(distance) +","+ str(angle) +")") # calculate gain - var gain = max(1 - distance/audible_range_max, 0) + var gain = 1 - distance/audible_range_max # send to the patch Global._gdpd.start_message(3) Global._gdpd.add_symbol("panvol") @@ -58,3 +85,16 @@ func _on_Events_player_transform_updated(playerpos, playerheading): func _exit_tree(): Global.close_patch(_my_id) + +func _save_patch(): + # save patch + # prepare directory + var patch_name = _my_patch.split("/")[-1] + var patch_dir = _my_patch.trim_suffix(patch_name) + var dir = Directory.new() + dir.make_dir_recursive(patch_dir) + # save to file + var file = File.new() + file.open(_my_patch, File.WRITE) + file.store_string(patch) + file.close() diff --git a/templates/worldscene1/main.pd b/templates/worldscene1/main.pd index 3599db2..9d95dfc 100644 --- a/templates/worldscene1/main.pd +++ b/templates/worldscene1/main.pd @@ -1,9 +1,25 @@ -#N canvas 574 271 456 518 12; +#N canvas 126 281 456 518 12; #X obj 361 21 loadbang; #X msg 361 51 \; pd dsp 1; #X floatatom 21 198 5 0 0 0 - - - 0; #X obj 21 22 r fromGodot\$0; #X obj 21 46 list trim; +#X obj 199 467 dac~ 1 2; +#X obj 199 407 *~; +#X obj 189 264 line~; +#X msg 189 240 \$1 100; +#X obj 189 127 unpack f f; +#X floatatom 189 177 5 0 0 0 - - - 0; +#X obj 21 256 noise~; +#X obj 21 286 bp~ 500 1000; +#X obj 21 70 route freq gain panvol; +#X obj 21 316 *~; +#X obj 132 310 switch~; +#X obj 132 286 tgl 19 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000 0 1; +#X obj 132 262 change; +#X text 89 155 switch on/off before 0 to stop startup pops, f 12; +#X obj 189 216 max 0; +#X obj 132 238 > -0.3; #X obj 303 253 hsl 100 20 -1 1 0 0 empty empty empty -2 -10 0 12 #fcfcfc #000000 #000000 0 1; #X obj 300 349 line~; #X msg 300 325 \$1 100; @@ -29,41 +45,36 @@ #X connect 7 0 0 0; #X connect 8 0 1 0; #X restore 199 437 pd pan2~; -#X obj 199 467 dac~ 1 2; -#X obj 199 407 *~; -#X obj 189 230 line~; -#X msg 189 206 \$1 100; -#X obj 189 127 unpack f f; #X floatatom 296 159 5 0 0 0 - - - 0; #X obj 296 182 sin; #X floatatom 296 206 5 0 0 0 - - - 0; -#X floatatom 189 177 5 0 0 0 - - - 0; -#X obj 21 256 noise~; -#X obj 21 286 bp~ 500 1000; -#X obj 21 70 route freq gain panvol; -#X obj 21 316 *~; -#X connect 2 0 21 1; +#X connect 2 0 12 1; #X connect 3 0 4 0; -#X connect 4 0 22 0; -#X connect 5 0 8 0; -#X connect 6 0 10 1; -#X connect 7 0 6 0; -#X connect 8 0 9 0; -#X connect 9 0 7 0; -#X connect 10 0 11 0; -#X connect 10 1 11 1; -#X connect 12 0 10 0; -#X connect 13 0 12 1; -#X connect 14 0 13 0; -#X connect 15 0 19 0; -#X connect 15 1 16 0; -#X connect 16 0 17 0; -#X connect 17 0 18 0; -#X connect 18 0 5 0; -#X connect 19 0 14 0; -#X connect 20 0 21 0; -#X connect 21 0 23 0; -#X connect 22 0 2 0; -#X connect 22 1 23 1; -#X connect 22 2 15 0; -#X connect 23 0 12 0; +#X connect 4 0 13 0; +#X connect 6 0 26 0; +#X connect 7 0 6 1; +#X connect 8 0 7 0; +#X connect 9 0 10 0; +#X connect 9 1 27 0; +#X connect 10 0 19 0; +#X connect 10 0 20 0; +#X connect 11 0 12 0; +#X connect 12 0 14 0; +#X connect 13 0 2 0; +#X connect 13 1 14 1; +#X connect 13 2 9 0; +#X connect 14 0 6 0; +#X connect 16 0 15 0; +#X connect 17 0 16 0; +#X connect 19 0 8 0; +#X connect 20 0 17 0; +#X connect 21 0 24 0; +#X connect 22 0 26 1; +#X connect 23 0 22 0; +#X connect 24 0 25 0; +#X connect 25 0 23 0; +#X connect 26 0 5 0; +#X connect 26 1 5 1; +#X connect 27 0 28 0; +#X connect 28 0 29 0; +#X connect 29 0 21 0; diff --git a/templates/worldscene1/osc-earplug.pd b/templates/worldscene1/osc-earplug.pd new file mode 100644 index 0000000..9cfb577 --- /dev/null +++ b/templates/worldscene1/osc-earplug.pd @@ -0,0 +1,53 @@ +#N canvas 650 226 456 518 12; +#X obj 361 21 loadbang; +#X msg 361 51 \; pd dsp 1; +#X obj 50 277 osc~ 440; +#X floatatom 21 198 5 0 0 0 - - - 0; +#X obj 21 22 r fromGodot\$0; +#X obj 21 46 list trim; +#X obj 199 467 dac~ 1 2; +#X obj 199 407 *~; +#X obj 189 127 unpack f f; +#X obj 21 70 route freq gain panvol; +#X obj 50 301 *~; +#X msg 296 338 \$1 100; +#X floatatom 296 159 5 0 0 0 - - - 0; +#X obj 199 437 earplug~ 0 0; +#X obj 296 362 line; +#X obj 189 264 line~; +#X msg 189 240 \$1 100; +#X floatatom 189 177 5 0 0 0 - - - 0; +#X obj 132 310 switch~; +#X obj 132 286 tgl 19 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000 0 1; +#X obj 132 262 change; +#X text 89 155 switch on/off before 0 to stop startup pops, f 12; +#X obj 189 216 max 0; +#X obj 132 238 > -0.3; +#X obj 296 248 expr 360-$f1; +#X obj 296 182 expr $f1*180/3.141592; +#X connect 2 0 10 0; +#X connect 3 0 2 0; +#X connect 4 0 5 0; +#X connect 5 0 9 0; +#X connect 7 0 13 0; +#X connect 8 0 17 0; +#X connect 8 1 12 0; +#X connect 9 0 3 0; +#X connect 9 1 10 1; +#X connect 9 2 8 0; +#X connect 10 0 7 0; +#X connect 11 0 14 0; +#X connect 12 0 25 0; +#X connect 13 0 6 0; +#X connect 13 1 6 1; +#X connect 14 0 13 1; +#X connect 15 0 7 1; +#X connect 16 0 15 0; +#X connect 17 0 22 0; +#X connect 17 0 23 0; +#X connect 19 0 18 0; +#X connect 20 0 19 0; +#X connect 22 0 16 0; +#X connect 23 0 20 0; +#X connect 24 0 11 0; +#X connect 25 0 24 0; diff --git a/templates/worldscene1/osc.gd b/templates/worldscene1/osc.gd index fa52052..ca0b6f9 100644 --- a/templates/worldscene1/osc.gd +++ b/templates/worldscene1/osc.gd @@ -1,10 +1,13 @@ extends RigidBody -export (String, MULTILINE) var patch = "" export (float, 0, 100) var audible_range_max = 10.0 export (float, 1, 12) var preset = 1 +export (bool) var use_embeded_patch = false +export (String, MULTILINE) var patch = "" + var _my_patch = "res://osc.pd" +#var _my_patch = "res://osc-earplug.pd" var _my_id = 0 func set_size(size): @@ -44,7 +47,10 @@ func set_color(color): func _ready(): # save patch (for export) -# _save_patch() + if use_embeded_patch: + assert(_my_patch.substr(0, 7) == "user://", "use userpath with embeded_patch enabled !") + assert(patch != "", "patch is empty?") + _save_patch() # load patch _my_id = Global.load_patch(ProjectSettings.globalize_path(_my_patch)) @@ -68,7 +74,7 @@ func _on_Events_player_transform_updated(playerpos, playerheading): # (check) # print(str(_my_id) +" : ("+ str(distance) +","+ str(angle) +")") # calculate gain - var gain = max(1 - distance/audible_range_max, 0) + var gain = 1 - distance/audible_range_max # send to the patch Global._gdpd.start_message(3) Global._gdpd.add_symbol("panvol") @@ -79,17 +85,16 @@ func _on_Events_player_transform_updated(playerpos, playerheading): func _exit_tree(): Global.close_patch(_my_id) - pass -#func _save_patch(): -# # save patch -# # prepare directory -# var patch_name = _my_patch.split("/")[-1] -# var patch_dir = _my_patch.trim_suffix(patch_name) -# var dir = Directory.new() -# dir.make_dir_recursive(patch_dir) -# # save to file -# var file = File.new() -# file.open(_my_patch, File.WRITE) -# file.store_string(patch) -# file.close() +func _save_patch(): + # save patch + # prepare directory + var patch_name = _my_patch.split("/")[-1] + var patch_dir = _my_patch.trim_suffix(patch_name) + var dir = Directory.new() + dir.make_dir_recursive(patch_dir) + # save to file + var file = File.new() + file.open(_my_patch, File.WRITE) + file.store_string(patch) + file.close() diff --git a/templates/worldscene1/osc.pd b/templates/worldscene1/osc.pd index c8439dc..922e97f 100644 --- a/templates/worldscene1/osc.pd +++ b/templates/worldscene1/osc.pd @@ -1,10 +1,24 @@ -#N canvas 116 274 456 518 12; +#N canvas 659 277 456 518 12; #X obj 361 21 loadbang; #X msg 361 51 \; pd dsp 1; -#X obj 80 277 osc~ 440; +#X obj 50 277 osc~ 440; #X floatatom 21 198 5 0 0 0 - - - 0; #X obj 21 22 r fromGodot\$0; #X obj 21 46 list trim; +#X obj 199 467 dac~ 1 2; +#X obj 199 407 *~; +#X obj 189 127 unpack f f; +#X obj 21 70 route freq gain panvol; +#X obj 50 301 *~; +#X obj 189 264 line~; +#X msg 189 240 \$1 100; +#X floatatom 189 177 5 0 0 0 - - - 0; +#X obj 132 310 switch~; +#X obj 132 286 tgl 19 0 empty empty empty 0 -10 0 12 #fcfcfc #000000 #000000 0 1; +#X obj 132 262 change; +#X text 89 155 switch on/off before 0 to stop startup pops, f 12; +#X obj 189 216 max 0; +#X obj 132 238 > -0.3; #X obj 303 253 hsl 100 20 -1 1 0 0 empty empty empty -2 -10 0 12 #fcfcfc #000000 #000000 0 1; #X obj 300 349 line~; #X msg 300 325 \$1 100; @@ -30,38 +44,35 @@ #X connect 7 0 0 0; #X connect 8 0 1 0; #X restore 199 437 pd pan2~; -#X obj 199 467 dac~ 1 2; -#X obj 199 407 *~; -#X obj 189 230 line~; -#X msg 189 206 \$1 100; -#X obj 189 127 unpack f f; #X floatatom 296 159 5 0 0 0 - - - 0; #X obj 296 182 sin; #X floatatom 296 206 5 0 0 0 - - - 0; -#X floatatom 189 177 5 0 0 0 - - - 0; -#X obj 21 70 route freq gain panvol; -#X obj 80 301 *~; -#X connect 2 0 22 0; +#X connect 2 0 10 0; #X connect 3 0 2 0; #X connect 4 0 5 0; -#X connect 5 0 21 0; -#X connect 6 0 9 0; -#X connect 7 0 11 1; -#X connect 8 0 7 0; -#X connect 9 0 10 0; -#X connect 10 0 8 0; -#X connect 11 0 12 0; -#X connect 11 1 12 1; -#X connect 13 0 11 0; -#X connect 14 0 13 1; +#X connect 5 0 9 0; +#X connect 7 0 25 0; +#X connect 8 0 13 0; +#X connect 8 1 26 0; +#X connect 9 0 3 0; +#X connect 9 1 10 1; +#X connect 9 2 8 0; +#X connect 10 0 7 0; +#X connect 11 0 7 1; +#X connect 12 0 11 0; +#X connect 13 0 18 0; +#X connect 13 0 19 0; #X connect 15 0 14 0; -#X connect 16 0 20 0; -#X connect 16 1 17 0; -#X connect 17 0 18 0; -#X connect 18 0 19 0; -#X connect 19 0 6 0; -#X connect 20 0 15 0; -#X connect 21 0 3 0; -#X connect 21 1 22 1; -#X connect 21 2 16 0; -#X connect 22 0 13 0; +#X connect 16 0 15 0; +#X connect 18 0 12 0; +#X connect 19 0 16 0; +#X connect 20 0 23 0; +#X connect 21 0 25 1; +#X connect 22 0 21 0; +#X connect 23 0 24 0; +#X connect 24 0 22 0; +#X connect 25 0 6 0; +#X connect 25 1 6 1; +#X connect 26 0 27 0; +#X connect 27 0 28 0; +#X connect 28 0 20 0;