From bea578104fd49308e8ce99ff503f0c6355c7128c Mon Sep 17 00:00:00 2001 From: Lucas Cordiviola Date: Sun, 21 Apr 2024 07:16:06 -0300 Subject: [PATCH] seems working --- .../Pd_Chunks-test/Pd_Chunks-test.pd | 11 +++++--- vst-scheduler/makefile | 4 +-- vst-scheduler/vstschedlib.c | 25 +++++++++++++++++++ vst-template/pdvst.cpp | 12 ++++++++- vst-template/pdvstTransfer.h | 1 + 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/build/Release64/Pd_Chunks-test/Pd_Chunks-test.pd b/build/Release64/Pd_Chunks-test/Pd_Chunks-test.pd index 0b97269..63d057c 100644 --- a/build/Release64/Pd_Chunks-test/Pd_Chunks-test.pd +++ b/build/Release64/Pd_Chunks-test/Pd_Chunks-test.pd @@ -1,4 +1,4 @@ -#N canvas 0 265 595 358 12; +#N canvas 0 265 818 358 12; #X obj 78 87 adc~, f 6; #X obj 73 241 loadbang; #X msg 73 271 \; pd dsp 1 \;; @@ -13,10 +13,13 @@ #X obj 242 263 dbtorms; #X obj 242 290 s gain; #X obj 300 225 s svstparameter0; -#X obj 277 75 vsl 50 128 0 1 0 0 empty empty empty 0 -9 0 10 -262144 --1 -1 0 1; +#X obj 277 75 vsl 50 128 0 1 0 0 empty empty empty 0 -9 0 10 #fcfcfc #000000 #000000 0 1; #X msg 277 42 set \$1; #X text 355 117 range is 0..1; +#X obj 498 10 r rvstplugname; +#X symbolatom 498 48 17 0 0 0 - - - 0; +#X obj 516 102 r rvstdata; +#X symbolatom 516 136 17 0 0 0 - - - 0; #X connect 0 0 7 0; #X connect 0 1 6 0; #X connect 1 0 2 0; @@ -33,3 +36,5 @@ #X connect 14 0 13 0; #X connect 14 0 10 0; #X connect 15 0 14 0; +#X connect 17 0 18 0; +#X connect 19 0 20 0; diff --git a/vst-scheduler/makefile b/vst-scheduler/makefile index 67997d0..7a25745 100644 --- a/vst-scheduler/makefile +++ b/vst-scheduler/makefile @@ -17,5 +17,5 @@ ALL: vstschedlib.c gcc -Wall -I$(PDDIR)src -I../vst-template vstschedlib.c -static-libgcc \ -shared -L$(PDDIR)bin -l:pd.dll -o vstschedlib.dll strip vstschedlib.dll - cp vstschedlib.dll ../build/pd-scheduler$(arch)/vstschedlib.dll - #cp vstschedlib.dll ../build/Release$(arch)/.pd/bin/vstschedlib.dll \ No newline at end of file + #cp vstschedlib.dll ../build/pd-scheduler$(arch)/vstschedlib.dll + cp vstschedlib.dll ../build/Release$(arch)/.pd/bin/vstschedlib.dll \ No newline at end of file diff --git a/vst-scheduler/vstschedlib.c b/vst-scheduler/vstschedlib.c index 4c34557..ce60617 100644 --- a/vst-scheduler/vstschedlib.c +++ b/vst-scheduler/vstschedlib.c @@ -70,6 +70,8 @@ typedef struct _vstGuiNameReceiver t_vstGuiNameReceiver *vstGuiNameReceiver; + + t_vstParameterReceiver *vstParameterReceivers[MAXPARAMETERS]; t_class *vstParameterReceiver_class; @@ -195,6 +197,19 @@ int setPdvstPlugName(char* instanceName) return 0; } +int setPdvstChunk(char* instanceName) +{ + t_symbol *tempSym; + tempSym = gensym("rvstdata"); + if (tempSym->s_thing) + { + pd_symbol(tempSym->s_thing, gensym(instanceName)); + return 1; + } + else + return 0; +} + int setPdvstFloatParameter(int index, float value) { @@ -262,6 +277,8 @@ void makePdvstGuiNameReceiver() + + void send_dacs(void) { int i, j, sampleCount, nChannels, blockSize; @@ -390,6 +407,14 @@ int scheduler() if (setPdvstPlugName((char*)pdvstData->plugName.value.stringData)) pdvstData->plugName.updated=0; } + + // lucarda get data chunk from file + if (pdvstData->datachunk.direction == PD_RECEIVE && \ + pdvstData->datachunk.updated) + { + if (setPdvstChunk((char*)pdvstData->datachunk.value.stringData)) + pdvstData->datachunk.updated=0; + } if (pdvstData->hostTimeInfo.updated) { diff --git a/vst-template/pdvst.cpp b/vst-template/pdvst.cpp index 617c74c..7ffbd83 100644 --- a/vst-template/pdvst.cpp +++ b/vst-template/pdvst.cpp @@ -227,6 +227,7 @@ pdvst::pdvst(audioMasterCallback audioMaster) timeFromStartup=GetTickCount(); // JYG } programsAreChunks(true); + sendPlugName(globalPluginName); } pdvst::~pdvst() @@ -609,7 +610,16 @@ VstInt32 pdvst::getChunk (void** data, bool isPreset) } VstInt32 pdvst::setChunk (void* data, VstInt32 byteSize, bool isPreset) -{ +{ + + WaitForSingleObject(pdvstTransferMutex, 10); + { + pdvstData->datachunk.direction = PD_RECEIVE; + pdvstData->datachunk.type = STRING_TYPE; + strcpy(pdvstData->datachunk.value.stringData,(char *)data); + pdvstData->datachunk.updated = 1; + ReleaseMutex(pdvstTransferMutex); + } MessageBox(0,"setchunk","debug",MB_OK); debugLog("setchunk: %s", data); return 1; diff --git a/vst-template/pdvstTransfer.h b/vst-template/pdvstTransfer.h index ec6f84a..41c5d3c 100644 --- a/vst-template/pdvstTransfer.h +++ b/vst-template/pdvstTransfer.h @@ -121,6 +121,7 @@ typedef struct _pdvstTransferData pdvstMidiMessage midiQueue[MAXMIDIQUEUESIZE]; pdvstParameter guiState; pdvstParameter plugName; // transmitted by host + pdvstParameter datachunk; // get/set chunk from .fxp file pdvstParameter guiName; // transmitted by pd : name of gui window to be embedded // #ifdef VSTMIDIOUTENABLE int midiOutQueueSize;