diff --git a/GdpdExample/addons/gdpd/bin/osx/libgdpd.dylib b/GdpdExample/addons/gdpd/bin/osx/libgdpd.dylib index 40765a5..af7b66c 100755 Binary files a/GdpdExample/addons/gdpd/bin/osx/libgdpd.dylib and b/GdpdExample/addons/gdpd/bin/osx/libgdpd.dylib differ diff --git a/bin (with gui, use pd 0.53-1)/gdpd.gdns b/bin (with gui, use pd 0.53-1)/gdpd.gdns deleted file mode 100644 index 869b3c3..0000000 --- a/bin (with gui, use pd 0.53-1)/gdpd.gdns +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="NativeScript" load_steps=2 format=2] - -[ext_resource path="res://addons/gdpd/bin/libgdpd.gdnlib" type="GDNativeLibrary" id=1] - -[resource] -resource_name = "gdpd" -class_name = "Gdpd" -library = ExtResource( 1 ) diff --git a/bin (with gui, use pd 0.53-1)/libgdpd.gdnlib b/bin (with gui, use pd 0.53-1)/libgdpd.gdnlib deleted file mode 100644 index 048e4af..0000000 --- a/bin (with gui, use pd 0.53-1)/libgdpd.gdnlib +++ /dev/null @@ -1,18 +0,0 @@ -[general] - -singleton=false -load_once=false -symbol_prefix="godot_" -reloadable=true - -[entry] - -X11.64="res://addons/gdpd/bin/x11/libgdpd.so" -Windows.64="res://addons/gdpd/bin/win/libgdpd.dll" -OSX.64="res://addons/gdpd/bin/osx/libgdpd.dylib" - -[dependencies] - -X11.64=[ ] -Windows.64=[ ] -OSX.64=[ ] diff --git a/bin (with gui, use pd 0.53-1)/osx/libgdpd.dylib b/bin (with gui, use pd 0.53-1)/osx/libgdpd.dylib deleted file mode 100755 index 40765a5..0000000 Binary files a/bin (with gui, use pd 0.53-1)/osx/libgdpd.dylib and /dev/null differ diff --git a/bin (without gui)/gdpd.gdns b/bin (without gui)/gdpd.gdns deleted file mode 100644 index 869b3c3..0000000 --- a/bin (without gui)/gdpd.gdns +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="NativeScript" load_steps=2 format=2] - -[ext_resource path="res://addons/gdpd/bin/libgdpd.gdnlib" type="GDNativeLibrary" id=1] - -[resource] -resource_name = "gdpd" -class_name = "Gdpd" -library = ExtResource( 1 ) diff --git a/bin (without gui)/libgdpd.gdnlib b/bin (without gui)/libgdpd.gdnlib deleted file mode 100644 index 048e4af..0000000 --- a/bin (without gui)/libgdpd.gdnlib +++ /dev/null @@ -1,18 +0,0 @@ -[general] - -singleton=false -load_once=false -symbol_prefix="godot_" -reloadable=true - -[entry] - -X11.64="res://addons/gdpd/bin/x11/libgdpd.so" -Windows.64="res://addons/gdpd/bin/win/libgdpd.dll" -OSX.64="res://addons/gdpd/bin/osx/libgdpd.dylib" - -[dependencies] - -X11.64=[ ] -Windows.64=[ ] -OSX.64=[ ] diff --git a/bin (without gui)/osx/libgdpd.dylib b/bin (without gui)/osx/libgdpd.dylib deleted file mode 100755 index af2da4d..0000000 Binary files a/bin (without gui)/osx/libgdpd.dylib and /dev/null differ diff --git a/src/gdpd.cpp b/src/gdpd.cpp index e6185f1..8d23b1c 100644 --- a/src/gdpd.cpp +++ b/src/gdpd.cpp @@ -7,6 +7,7 @@ void Gdpd::_register_methods() { register_method("get_available_output_devices", &Gdpd::get_available_output_devices); register_method("init_devices", &Gdpd::init_devices); register_method("init", &Gdpd::init); + register_method("streamstart", &Gdpd::streamstart); register_method("stop", &Gdpd::stop); register_method("openPatch", &Gdpd::openPatch); register_method("closePatch", &Gdpd::closePatch); @@ -17,7 +18,9 @@ void Gdpd::_register_methods() { register_method("add_symbol", &Gdpd::add_symbol); register_method("add_float", &Gdpd::add_float); register_method("finish_list", &Gdpd::finish_list); + register_method("computeAudio", &Gdpd::computeAudio); register_method("set_volume", &Gdpd::set_volume); + register_method("set_gui_path", &Gdpd::set_gui_path); } int Gdpd::audioCallback(void *outputBuffer, void *inputBuffer, @@ -29,7 +32,7 @@ int Gdpd::audioCallback(void *outputBuffer, void *inputBuffer, return 0; } -Gdpd::Gdpd() : m_vol(1) { +Gdpd::Gdpd() : m_vol(0), m_gui_path("") { //create message array m_messages = new Array(); m_init=false; @@ -117,12 +120,12 @@ int Gdpd::start() { //libpd_set_verbose(1); -#if defined(WITH_GUI) - libpd_start_gui((char*)"/Applications/Pd-0.53-1.app/Contents/Resources"); -#endif + if (m_gui_path != "") { + libpd_start_gui((char*)m_gui_path.c_str()); + } //start dsp - m_pd.computeAudio(true); + // m_pd.computeAudio(true); //intialize rtaudio if(m_audio.getDeviceCount()==0){ @@ -140,8 +143,8 @@ int Gdpd::start() { m_audio.openStream(&outParams, NULL, RTAUDIO_FLOAT32, m_sampleRate, &m_bufferFrames, &audioCallback, this, &options); - m_audio.startStream(); - print("Stream started"); + // m_audio.startStream(); + // print("Stream started"); } catch(RtAudioError& e) { Godot::print(e.getMessage().c_str()); @@ -151,8 +154,8 @@ int Gdpd::start() { m_audio.openStream(&outParams, &inpParams, RTAUDIO_FLOAT32, m_sampleRate, &m_bufferFrames, &audioCallback, this, &options); - m_audio.startStream(); - print("Stream started"); + // m_audio.startStream(); + // print("Stream started"); } catch(RtAudioError& e) { Godot::print(e.getMessage().c_str()); @@ -169,15 +172,20 @@ int Gdpd::start() { return 0; } +void Gdpd::streamstart() { + m_audio.startStream(); + print("Stream started"); +} + void Gdpd::stop() { m_audio.stopStream(); m_audio.closeStream(); m_pd.computeAudio(false); print("Stopped"); -#if defined(WITH_GUI) - libpd_stop_gui(); -#endif + if (m_gui_path != "") { + libpd_stop_gui(); + } } void Gdpd::processAudio(void *outputBuffer, void *inputBuffer, @@ -291,3 +299,14 @@ void Gdpd::receiveList(const std::string& dest, const pd::List& list) { void Gdpd::set_volume(float vol) { m_vol=vol; } + +void Gdpd::set_gui_path(godot::String pathStr) { + std::wstring pathWs = pathStr.unicode_str(); + std::string pathS(pathWs.begin(), pathWs.end()); + + m_gui_path = pathS; +} + +void Gdpd::computeAudio(bool state) { //[; pd dsp 0/1 ( + m_pd.computeAudio(state); +} diff --git a/src/gdpd.hpp b/src/gdpd.hpp index f3466ff..975a9a8 100644 --- a/src/gdpd.hpp +++ b/src/gdpd.hpp @@ -13,8 +13,6 @@ #include "PdReceiver.hpp" #include "RtAudio.h" -// #define WITH_GUI - namespace godot { class Gdpd : public godot::AudioStreamPlayer, public pd::PdReceiver { @@ -35,6 +33,7 @@ private: int m_inputDevice; int m_outputDevice; std::map m_patchsMap; + std::string m_gui_path; bool m_init; @@ -52,6 +51,7 @@ public: int init_devices(String inputDevice, String outputDevice); int init(int nbInputs, int nbOutputs, int sampleRate, int bufferSize); int start(); + void streamstart(); void stop(); int openPatch(String basename, String dirname); void closePatch(int id); @@ -69,6 +69,8 @@ public: void receiveList(const std::string& dest, const pd::List& list); //godot functions + void computeAudio(bool state); //[; pd dsp 0/1 ( + void set_gui_path(godot::String path); void set_volume(float vol); inline const float& get_volume(){ return m_vol; diff --git a/src/rtaudio/RtAudio.os b/src/rtaudio/RtAudio.os index 578ba8b..98b15ed 100644 Binary files a/src/rtaudio/RtAudio.os and b/src/rtaudio/RtAudio.os differ diff --git a/update.sh b/update.sh index 20dc781..b70a526 100755 --- a/update.sh +++ b/update.sh @@ -1,6 +1,6 @@ #!/bin/bash git submodule update --init --recursive cd src/godot-cpp -scons platform=$1 generate_bindings=yes +scons platform=$1 target=$2 generate_bindings=yes cd ../.. -scons platform=$1 +scons platform=$1 target=$2