From 51164ed10dd3423d3a14a8b3128feb5feb00f8ee Mon Sep 17 00:00:00 2001 From: Florent Berthaut <florent.berthaut@univ-lille.fr> Date: Sat, 30 Dec 2023 23:57:33 +0100 Subject: [PATCH] Fix fiddle fsqrt issue --- SConstruct | 7 ++-- demo/Main.tscn | 17 ++++---- demo/project.godot | 2 +- src/gdpd.hpp | 87 ----------------------------------------- src/rtaudio/RtAudio.os | Bin 74776 -> 74776 bytes 5 files changed, 13 insertions(+), 100 deletions(-) delete mode 100644 src/gdpd.hpp diff --git a/SConstruct b/SConstruct index edc9ec7..1a43d50 100644 --- a/SConstruct +++ b/SConstruct @@ -10,10 +10,9 @@ fiddle_lines = fiddle_file.readlines() fiddle_file.close() out_lines = [] for l in fiddle_lines: - if l == "#define fsqrt sqrt\n" : - out_lines.append("//#define fsqrt sqrt\n") - else : - out_lines.append(l) + if l == "#define flog log\n" : + out_lines.append("#include <math.h>\n") + out_lines.append(l) fiddle_file = open("src/libpd/pure-data/extra/fiddle~/fiddle~.c","w") fiddle_file.writelines(out_lines) fiddle_file.close() diff --git a/demo/Main.tscn b/demo/Main.tscn index 7bedbd4..37ec47b 100644 --- a/demo/Main.tscn +++ b/demo/Main.tscn @@ -9,37 +9,38 @@ func _ready(): pass func _process(delta): + # Get messages from the patch while _gdpd.has_message() : var msg = _gdpd.get_next() print(\"got message from pd \", msg) pass func _load_patch(pd_patch) : - #separate file name from directory + # separate file name from directory var patch_name = pd_patch.split(\"/\")[-1] var patch_dir = pd_patch.trim_suffix(patch_name) - #load patch + # load patch _gdpd.openfile(patch_name, patch_dir) func _on_Start_pressed() : - #retrieve the list of available input and outputs + # retrieve the list of available input and outputs var inps = _gdpd.get_available_input_devices() var outs = _gdpd.get_available_output_devices() - #initialise the first ones + # initialise the first ones _gdpd.init_devices(inps[0], outs[0]) - #the patch path should be the absolute one + # the patch path should be absolute _load_patch(ProjectSettings.globalize_path(\"res://patch1.pd\")) _load_patch(ProjectSettings.globalize_path(\"res://patch2.pd\")) - #send message to [receive from_godot] with one symbol + # send message to [receive from_godot] with one symbol _gdpd.start_message(1) _gdpd.add_symbol(\"hello\") _gdpd.finish_list(\"from_godot\") - #listen to messages sent with [send to_godot] + # listen to messages sent with [send to_godot] _gdpd.subscribe(\"to_godot\") func _on_Stop_pressed(): @@ -48,7 +49,7 @@ func _on_Stop_pressed(): _gdpd.stop() func _on_HSlider_value_changed(value): - #send message to [receive from_godot] with three elements + # send message to [receive from_godot] with three elements _gdpd.start_message(3) _gdpd.add_symbol(\"patch1\") _gdpd.add_symbol(\"pitch\") diff --git a/demo/project.godot b/demo/project.godot index acda1c8..c1177ea 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="GdPd" run/main_scene="res://Main.tscn" -config/features=PackedStringArray("4.1") +config/features=PackedStringArray("4.2") run/low_processor_mode=true config/icon="res://icon.png" diff --git a/src/gdpd.hpp b/src/gdpd.hpp deleted file mode 100644 index 9069ffe..0000000 --- a/src/gdpd.hpp +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef GDPD_H -#define GDPD_H - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <map> -#include <algorithm> - -#include <Godot.hpp> -#include <AudioStreamPlayer.hpp> - -#include "PdBase.hpp" -#include "PdReceiver.hpp" -#include "RtAudio.h" - -namespace godot { - -class Gdpd : public godot::AudioStreamPlayer, public pd::PdReceiver { - GODOT_CLASS(Gdpd, AudioStreamPlayer) - -private: - float *m_inBuf; - float *m_outBuf; - Array* m_messages; - pd::PdBase m_pd; - pd::Patch m_patch; - RtAudio m_audio; - unsigned int m_bufferFrames; - float m_vol; - int m_nbInputs; - int m_nbOutputs; - int m_sampleRate; - int m_inputDevice; - int m_outputDevice; - std::map<std::string, pd::Patch> m_patchsMap; - - bool m_init; - -public: - static void _register_methods(); - - Gdpd(); - ~Gdpd(); - - void _init(); - - //libpd functions - Array get_available_input_devices(); - Array get_available_output_devices(); - int init_devices(String inputDevice, String outputDevice); - int init(int nbInputs, int nbOutputs, int sampleRate, int bufferSize); - int start(); - void stop(); - void openfile(String basename, String dirname); - void closefile(String basename); - bool has_message(); - Array get_next(); - int blocksize(); - void subscribe(String symbStr); - int start_message(int nbValues); - void add_symbol(String symbStr); - void add_float(float val); - int finish_list(String destStr); - - //libpd hooks - virtual void print(const std::string& message); - void receiveList(const std::string& dest, const pd::List& list); - - //godot functions - void set_volume(float vol); - inline const float& get_volume(){return m_vol;} - - - //rtaudio - static int audioCallback(void *outputBuffer, void *inputBuffer, - unsigned int nBufferFrames, double streamTime, - RtAudioStreamStatus status, void *userData); - void processAudio(void *outputBuffer, void *inputBuffer, - unsigned int nBufferFrames, double streamTime, - RtAudioStreamStatus status, void *userData); - -}; - -} - -#endif diff --git a/src/rtaudio/RtAudio.os b/src/rtaudio/RtAudio.os index e0e26cd99c52ff7282b073612d40934fb6cdd3fa..a5bc4699ab088cd25dc56c9930a9e76e7e118ffb 100644 GIT binary patch delta 16 YcmbPnf@Q`DmJPMVjHa9Gif3&A06&@sjQ{`u delta 16 YcmbPnf@Q`DmJPMVj3%4wif3&A06&xmi~s-t -- GitLab