I’m a huge fan of the iPlug2 framework and created a few basic plugins, testing out what I can create
On my latest project, I got stuck trying to load a sample that I can then play back with an oscillator.
What I managed to do:
- get the filepath from a sample that’s dragged onto an IControl
- parsing the header and loading the actual sample data into a buffer
- link a parameter to the IControl, so that SetParam() is executed in the IPlugInstrument_DSP.h file
I wanted to pass the buffer itself, but the params only include ints, doubles, percentage, etc.
So - I thought I could just use the pointer to the buffer data instead, and use that within the SetParam() function to ultimately pass the sample data to an oscillator.
This doesn’t work, however, because SetParam normalizes the value to [0.0,1.0], so even if I would convert the pointer to a “double” (shudders), pass that to the SetParam, and then convert it back to an int, it would never represent the original value.
Another option I thought of would be a global variable, that I could just access from within an oscillator… but that also feels terribly wrong, so I didn’t even attempt that so far.
I’d really like to do it in a proper, iPlug2-style way (admittedly, I’d even be happy if it’s just working at all)…
My question is - how can I pass the sample data that I loaded from a file via an IControl into an IOscillator? I’m confident that I can play back the samples from a buffer, once they are inside the oscillator, but I have no clue how to get them there.
I do not want to use a fixed resource folder, nor hard-code the sample buffer into the oscillator, since I really want to just drag/drop any sample from my disk into the plugin.
Any help would be appreciated