How should I be doing this? Any help greatly appreciated.
Cheers, 3
Code: Select all
APlugin=class(AudioEffectX)
...
public
...
function getChunk(var data: pointer; isPreset: Boolean): longint; override;
function setChunk(data: pointer; byteSize: longint; isPreset: Boolean): longint; override;
...
constructor APlugin.CreateAPlugin(audioMaster:TAudioMasterCallbackFunc);
var
...
cChunk: string;
pChunk: PChar;
begin
inherited Create(audioMaster,knumprograms,kNumParams);
...
// send chunk
cChunk := 'Parsnip'; //test string to store in chunk
GetMem(pChunk, Length(cChunk)); //allocate buffer
pChunk := StrPCopy(pChunk, cChunk); //copy string to buffer
setChunk(pChunk, Length(cChunk), false); //send buffer as chunk
FreeMem(pChunk, Length(cChunk)); //deallocate buffer
...
end;
procedure TPluginEditorWindow.Button1Click(Sender: TObject);
var
cChunk: string;
pChunk: PChar;
begin
// retrieve chunk
GetMem(pChunk, 255); //allocate buffer
Effect.getChunk(pointer(pChunk), false); //receive chunk into buffer
cChunk := PChar(pChunk); //get string from buffer
Messagebox(0, PChar(cChunk), Nil, MB_OK); //display string
FreeMem(pChunk, 255); //deallocate buffer
end;