programsarechunks flag working

This commit is contained in:
Lucas Cordiviola 2024-04-22 09:17:15 -03:00
parent ba3b030e41
commit 665f7b281a
7 changed files with 55 additions and 25 deletions

View File

@ -25,6 +25,11 @@ DEBUG = TRUE
# ***OBSOLETE, use [declare] inside patch instead***
#LIB =
# Save and Get Pd lists in .fxp file via ([s svstdata] and [r rvstdata])
# Some hosts don't work correctly with this.
# If in doubt just use FALSE.
PROGRAMSARECHUNKS = TRUE
# Number of VST parameters (up to 128)
PARAMETERS = 1

View File

@ -294,8 +294,6 @@ void sendPdVstChunk(t_vstChunkReceiver *x, t_symbol *s, int argc, t_atom *argv)
t_atom at;
t_binbuf*bbuf = binbuf_new();
memset(&pdvstData->datachunk.value.stringData, '\0', MAXSTRINGSIZE);
SETSYMBOL(&at, s);
binbuf_add(bbuf, 1, &at);
binbuf_add(bbuf, argc, argv);
@ -303,11 +301,12 @@ void sendPdVstChunk(t_vstChunkReceiver *x, t_symbol *s, int argc, t_atom *argv)
binbuf_free(bbuf);
WaitForSingleObject(pdvstTransferMutex, INFINITE);
memset(&pdvstData->datachunk.value.stringData, '\0', MAXSTRINGSIZE);
pdvstData->datachunk.type = STRING_TYPE;
pdvstData->datachunk.direction = PD_SEND;
pdvstData->datachunk.updated = 1;
strcpy(pdvstData->datachunk.value.stringData,buf);
//memcpy(pdvstData->datachunk.value.stringData, buf, length);
//strcpy(pdvstData->datachunk.value.stringData,buf);
memcpy(pdvstData->datachunk.value.stringData, buf, length);
ReleaseMutex(pdvstTransferMutex);
freebytes(buf, length+1);
@ -492,7 +491,7 @@ int scheduler()
pdvstData->plugName.updated=0;
}
// lucarda get data chunk from file
// get data chunk from file
if (pdvstData->datachunk.direction == PD_RECEIVE && \
pdvstData->datachunk.updated)
{

View File

@ -56,6 +56,7 @@ extern char globalHostPdvstPath[MAXFILENAMELEN];
extern bool globalCustomGui;
extern int globalCustomGuiWidth;
extern int globalCustomGuiHeight;
extern bool globalProgramsAreChunks;
extern bool globalIsASynth;
extern pdvstProgram globalProgram[MAXPROGRAMS];
@ -226,7 +227,7 @@ pdvst::pdvst(audioMasterCallback audioMaster)
// {JYG see pdvst::setProgram below for explanation
timeFromStartup=GetTickCount();
// JYG }
programsAreChunks(false);
programsAreChunks(globalProgramsAreChunks);
sendPlugName(globalPluginName);
}
@ -604,19 +605,31 @@ bool pdvst::getOutputProperties(VstInt32 index, VstPinProperties* properties)
VstInt32 pdvst::getChunk (void** data, bool isPreset)
{
//MessageBox(NULL,"debug","getchunk",MB_OK);
VstInt32 len;
//MessageBoxA(NULL, "getchunk call", "debug", MB_OK);
if(*data)
{
//MessageBoxA(NULL, "getchunk if data", "debug", MB_OK);
WaitForSingleObject(pdvstTransferMutex, 10);
{
if(*data)
strcpy ((char *)*data, pdvstData->datachunk.value.stringData);
//strcpy ((char *)*data, pdvstData->datachunk.value.stringData);
*data = pdvstData->datachunk.value.stringData;
len = (VstInt32)strlen(pdvstData->datachunk.value.stringData);
//memcpy(*data, pdvstData->datachunk.value.stringData, (size_t)len+1);
ReleaseMutex(pdvstTransferMutex);
}
return strlen(pdvstData->datachunk.value.stringData);
return len+1;
}
else
return 0;
}
VstInt32 pdvst::setChunk (void* data, VstInt32 byteSize, bool isPreset)
{
MessageBox(NULL,"debug","setchunk",MB_OK);
//MessageBoxA(NULL, "setchunk call", "debug", MB_OK);
if(byteSize)
{
//MessageBoxA(NULL, "setchunk call if bytesize", "debug", MB_OK);
WaitForSingleObject(pdvstTransferMutex, 10);
{
pdvstData->datachunk.direction = PD_RECEIVE;
@ -626,7 +639,8 @@ VstInt32 pdvst::setChunk (void* data, VstInt32 byteSize, bool isPreset)
pdvstData->datachunk.updated = 1;
ReleaseMutex(pdvstTransferMutex);
}
return 1;
}
return 0;
}
VstInt32 pdvst::canDo(char* text)
@ -1124,7 +1138,7 @@ void pdvst::updatePdvstParameters()
if (pdvstData->datachunk.direction == PD_SEND && \
pdvstData->datachunk.updated)
{
if (pdvstData->datachunk.type = STRING_TYPE)
if (pdvstData->datachunk.type == STRING_TYPE)
{
pdvstData->datachunk.updated=0;
}

View File

@ -173,7 +173,6 @@ protected:
// JYG }
//void programsAreChunks (bool) {}
};
#endif

View File

@ -44,6 +44,7 @@ bool globalCustomGui = false;
int globalCustomGuiWidth= 320;
int globalCustomGuiHeight= 150;
pdvstProgram globalProgram[MAXPROGRAMS];
bool globalProgramsAreChunks = false;
char *trimWhitespace(char *str);
void parseSetupFile();
@ -376,6 +377,18 @@ void parseSetupFile()
globalProgram[progNum].paramValue[paramNum] = \
(float)atof(value);
}
// programsarechunks (save custom data in .fxp or .fxb file)
if (strcmp(param, "programsarechunks") == 0)
{
if (strcmp(strlwr(value), "true") == 0)
{
globalProgramsAreChunks = true;
}
else if (strcmp(strlwr(value), "false") == 0)
{
globalProgramsAreChunks = false;
}
}
}
}
}