Skip to content
Snippets Groups Projects
Commit 51164ed1 authored by Florent Berthaut's avatar Florent Berthaut
Browse files

Fix fiddle fsqrt issue

parent 5351f61c
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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\")
......
......@@ -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"
......
#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
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment