Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "audioeffectx.h"
- #include <stdlib.h>
- #include <string.h>
- class Processor : public AudioEffectX
- {
- public:
- enum Params
- {
- kResonance,
- kCutoff,
- };
- Processor(audioMasterCallback cb)
- : AudioEffectX(cb, 2, 2), stateData()
- {
- // move this into a .cpp file to avoid cyclical dependency, obviously.
- setEditor(new GUI(this));
- // experiment with this:
- //programsAreChunks(true);
- }
- struct Data
- {
- // program data:
- float params[2];
- // state data - not public to the host:
- float curve;
- int someOtherData;
- } stateData;
- void setCurve(float curve)
- {
- stateData.curve = curve;
- }
- VstInt32 getChunk(void ** data, bool preset) override
- {
- // save all data, even including the non-parameters.
- *data = malloc(sizeof(Data)); // can't remember where to free() this.
- memcpy(*data, &stateData, sizeof(Data));
- return sizeof(Data);
- }
- VstInt32 setChunk(void * data, VstInt32 dataSize, bool preset) override
- {
- // some error checking goes here.
- memcpy(&stateData, data, sizeof(Data));
- }
- void setParameter(VstInt32 index, float value) override
- {
- stateData.params[index] = value;
- }
- float getParameter(VstInt32 index) override
- {
- return stateData.params[index];
- }
- // rest of code, processing, etc.
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement