diff --git a/src/cpp/ViPER4Android.cpp b/src/cpp/ViPER4Android.cpp index 2a4bff8..9556792 100644 --- a/src/cpp/ViPER4Android.cpp +++ b/src/cpp/ViPER4Android.cpp @@ -143,10 +143,38 @@ static int32_t Viper_ICommand(effect_handle_t self, } case EFFECT_CMD_SET_PARAM: { auto pCmdParam = (effect_param_t *) pCmdData; + // The value offset of an effect parameter is computed by rounding up + // the parameter size to the next 32 bit alignment. + uint32_t vOffset = ((pCmdParam->psize + sizeof(int32_t) - 1) / sizeof(int32_t)) * sizeof(int32_t); + int param = *(int *) (pCmdParam->data); + *(int *) pReplyData = 0; - - // TODO: implement + int *intValues = (int *) (pCmdParam->data + vOffset); + if (pCmdParam->vsize == sizeof(int)) { + pContext->viper->DispatchCommand(param, intValues[0], 0, 0, 0, 0, nullptr); + return 0; + } else if (pCmdParam->vsize == sizeof(int) * 2) { + pContext->viper->DispatchCommand(param, intValues[0], intValues[1], 0, 0, 0, nullptr); + return 0; + } else if (pCmdParam->vsize == sizeof(int) * 3) { + pContext->viper->DispatchCommand(param, intValues[0], intValues[1], intValues[2], 0, 0, nullptr); + return 0; + } else if (pCmdParam->vsize == sizeof(int) * 4) { + pContext->viper->DispatchCommand(param, intValues[0], intValues[1], intValues[2], intValues[3], 0, nullptr); + return 0; + } else if (pCmdParam->vsize == 256 || pCmdParam->vsize == 1024) { + uint32_t arrSize = *(uint32_t *) (pCmdParam->data + vOffset); + signed char *arr = (signed char *) (pCmdParam->data + vOffset + sizeof(uint32_t)); + pContext->viper->DispatchCommand(param, 0, 0, 0, 0, arrSize, arr); + return 0; + } else if (pCmdParam->vsize == 8192) { + int value1 = *(int *) (pCmdParam->data + vOffset); + uint32_t arrSize = *(uint32_t *) (pCmdParam->data + vOffset + sizeof(int)); + signed char *arr = (signed char *) (pCmdParam->data + vOffset + sizeof(int) + sizeof(uint32_t)); + pContext->viper->DispatchCommand(param, value1, 0, 0, 0, arrSize, arr); + return 0; + } } case EFFECT_CMD_GET_PARAM: { auto *pCmdParam = reinterpret_cast(pCmdData); diff --git a/src/cpp/viper/ViPER.cpp b/src/cpp/viper/ViPER.cpp index df1df13..3b5a59b 100644 --- a/src/cpp/viper/ViPER.cpp +++ b/src/cpp/viper/ViPER.cpp @@ -204,8 +204,8 @@ void ViPER::processBuffer(float *buffer, uint32_t size) { } -void ViPER::DispatchCommand(int param_1, int param_2, int param_3, int param_4, int param_5, int param_6, - int param_7) { +void ViPER::DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize, + signed char *arr) { // TODO } diff --git a/src/cpp/viper/ViPER.h b/src/cpp/viper/ViPER.h index fb6e5f8..6a21930 100644 --- a/src/cpp/viper/ViPER.h +++ b/src/cpp/viper/ViPER.h @@ -29,7 +29,7 @@ public: void processBuffer(float *buffer, uint32_t size); // TODO: Parameter types/names - void DispatchCommand(int param_1, int param_2, int param_3, int param_4, int param_5, int param_6, int param_7); + void DispatchCommand(int param, int val1, int val2, int val3, int val4, uint32_t arrSize, signed char *arr); void ResetAllEffects(); bool update_status;