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

Added missing files

parent b65e5dd0
No related branches found
No related tags found
No related merge requests found
/***************************************************************************
* gd4pd.h
* Part of GdPd
* 2023- see README for AUTHORS
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 130, Boston, MA 02111-1307, USA.
*/
#ifndef GDPD_CLASS_H
#define GDPD_CLASS_H
#ifdef WIN32
#include <windows.h>
#endif
#include <godot_cpp/classes/node3d.hpp>
#include <godot_cpp/classes/global_constants.hpp>
#include <godot_cpp/classes/viewport.hpp>
#include <godot_cpp/core/binder_common.hpp>
#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/classes/audio_stream_player.hpp>
#include "PdBase.hpp"
#include "RtAudio.h"
using namespace godot;
class GdPd : public AudioStreamPlayer, public pd::PdReceiver {
GDCLASS(GdPd, AudioStreamPlayer);
protected:
static void _bind_methods();
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:
GdPd();
virtual ~GdPd();
//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
#include "register_types.h"
#include <gdextension_interface.h>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>
#include "gdpd.h"
using namespace godot;
void initialize_gdpd_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
ClassDB::register_class<GdPd>();
}
void uninitialize_gdpd_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
}
extern "C" {
// Initialization.
GDExtensionBool GDE_EXPORT gdpd_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
init_obj.register_initializer(initialize_gdpd_module);
init_obj.register_terminator(uninitialize_gdpd_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();
}
}
#ifndef GD4PD_REGISTER_TYPES_H
#define GD4PD_REGISTER_TYPES_H
#include <godot_cpp/core/class_db.hpp>
using namespace godot;
void initialize_gdpd_module(ModuleInitializationLevel p_level);
void uninitialize_gdpd_module(ModuleInitializationLevel p_level);
#endif
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