seems working

This commit is contained in:
Lucas Cordiviola 2024-10-02 05:41:43 -03:00
parent 80461d11c8
commit 4cc0976f81
3 changed files with 44 additions and 13 deletions

View File

@ -28,7 +28,7 @@ DEBUG = TRUE
# 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 = FALSE
PROGRAMSARECHUNKS = TRUE
# Number of VST parameters (up to 128)
PARAMETERS = 1

View File

@ -625,20 +625,30 @@ bool pdvst::getOutputProperties(VstInt32 index, VstPinProperties* properties)
VstInt32 pdvst::getChunk (void** data, bool isPreset)
{
VstInt32 len;
//MessageBoxA(NULL, "getchunk call", "debug", MB_OK); // all host gets here
if(*data)
Chunk = new pdvstProgramAreChunks;
MessageBoxA(NULL, "getchunk call", "debug", MB_OK); // all host gets here
for (int i = 0; i < nParameters; i++)
{
Chunk->vstParam[i] = vstParam[i];
}
if(1)
{
//MessageBoxA(NULL, "getchunk if data", "debug", MB_OK); // not all hosts gets here
WaitForSingleObject(pdvstTransferMutex, 10);
{
//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);
memset(&Chunk->Data, '\0', MAXSTRLEN);
strcpy (Chunk->Data, pdvstData->datachunk.value.stringData);
ReleaseMutex(pdvstTransferMutex);
}
return len+1;
debugLog("luc:debug-size-of-chunk %d", sizeof(*Chunk));
*data = (void*)Chunk;
return sizeof(*Chunk);
}
else
return 0;
@ -649,17 +659,30 @@ VstInt32 pdvst::setChunk (void* data, VstInt32 byteSize, bool isPreset)
//MessageBoxA(NULL, "setchunk call", "debug", MB_OK);
if(byteSize)
{
Chunk = (pdvstProgramAreChunks*)data;
//MessageBoxA(NULL, "setchunk call if bytesize", "debug", MB_OK);
WaitForSingleObject(pdvstTransferMutex, 10);
{
pdvstData->datachunk.direction = PD_RECEIVE;
pdvstData->datachunk.type = STRING_TYPE;
memset(&pdvstData->datachunk.value.stringData, '\0', MAXSTRINGSIZE);
strncpy(pdvstData->datachunk.value.stringData,(char *)data, (size_t)byteSize);
memset(&pdvstData->datachunk.value.stringData, '\0', MAXSTRLEN);
strcpy(pdvstData->datachunk.value.stringData, Chunk->Data);
//memcpy(pdvstData->datachunk.value.stringData, Chunk->Data, MAXSTRLEN);
pdvstData->datachunk.updated = 1;
for (int i = 0; i < nParameters; i++)
{
pdvstData->vstParameters[i].type = FLOAT_TYPE;
pdvstData->vstParameters[i].value.floatData = Chunk->vstParam[i];
pdvstData->vstParameters[i].direction = PD_RECEIVE;
pdvstData->vstParameters[i].updated = 1;
}
ReleaseMutex(pdvstTransferMutex);
}
}
return 0;
}

View File

@ -53,6 +53,13 @@ typedef struct _pdvstProgram
float paramValue[MAXPARAMETERS];
} pdvstProgram;
/* for programsarechunks*/
typedef struct _pdvstProgramAreChunks
{
float vstParam[MAXPARAMETERS];
char Data[MAXSTRLEN];
} pdvstProgramAreChunks;
class pdVstBuffer
{
@ -128,6 +135,7 @@ protected:
char **vstParamName;
int nParameters;
pdvstProgram *program;
pdvstProgramAreChunks *Chunk;
int nPrograms;
int nChannels;
int nExternalLibs;