COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 08-07-2015, 04:54 AM   #1
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 279
Default AAX CompareState

I need some assistance to get this work properly.
I'm using chunks to store some arbitrary data beside the normal params. This worked fine so far in AU/VST and AAX builds. But it turns out that as soon as i add any parameter to my SerializeState() the ProTools compare is messed up.
For testing purpose I stripped it down to just implementing this in my .cpp
Code:
bool MyPlug::SerializeState(ByteChunk* pChunk)
{
  IMutexLock lock(this);
  //pChunk->Put(&test);      /* test declared as double in .h */
  return IPlugBase::SerializeParams(pChunk);
}


int MyPlug::UnserializeState(ByteChunk* pChunk, int startPos)
{
  IMutexLock lock(this);
  //startPos = pChunk->Get(&test, startPos);
  return IPlugBase::UnserializeParams(pChunk, startPos);
}


bool MyPlug::CompareState(const unsigned char* incomingState, int startPos)
{
  bool isEqual = true;
  //startPos = sizeof(double);  
  isEqual &= IPlugBase::CompareState(incomingState, startPos);  
  return isEqual;
}
As long as the lines are commented out everything works fine. Just serializing that one double makes the Compare button always lit. Seems like the startPos for IPlugBase::CompareState points to a wrong position?
However i can't get it work. What am i doing wrong?
stw is offline   Reply With Quote
Old 08-07-2015, 05:22 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

I have no hands on experience with this, but I think something like this might work:

Code:
bool MyPlug::CompareState(const unsigned char* incomingState, int startPos)
{
  bool isEqual = true;

  const double* pTest = (const double*)incomingState;
  isEqual &= *pTest == test; // Or: mTest, because it is a member variable
  startPos += sizeof(double);

  isEqual &= IPlugBase::CompareState(incomingState, startPos);  
  return isEqual;
}
BTW, I see IPlugBase::CompareState compares doubles as floats... I guess this is not necessary if you #define PLUG_DOES_STATE_CHUNKS 1, so a simple memcmp() might also do the trick.
Tale is offline   Reply With Quote
Old 08-07-2015, 06:02 AM   #3
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 279
Default

Hi Tale,
thanks for answering. I'll try your suggestions.
However the point in this case is not that something goes wrong with the comparison (of the test var) itself. In fact my approach should leave the serialized test variable out of the process since (at least this was my understanding) IPlugBase::CompareState(incomingState, startPos) should only test against all other regular params when startPos is set to sizeof(double). But maybe i'm totally wrong with that idea...

BTW: I did #define PLUG_DOES_STATE_CHUNKS 1
stw is offline   Reply With Quote
Old 08-07-2015, 06:11 AM   #4
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Quote:
Originally Posted by stw View Post
In fact my approach should leave the serialized test variable out of the process since (at least this was my understanding)
Ah I see. Well, then you should probably only do startPos += sizeof(double) before calling IPlugBase::CompareState().
Tale is offline   Reply With Quote
Old 08-07-2015, 06:24 AM   #5
stw
Human being with feelings
 
stw's Avatar
 
Join Date: Apr 2012
Posts: 279
Default

Quote:
Originally Posted by Tale View Post
Ah I see. Well, then you should probably only do startPos += sizeof(double) before calling IPlugBase::CompareState().
Yes, that's what i did .
I'm not sure if i should "+=", or "=" startPos though both should do the same in that case. If i follow the IPlugChunks example "=" would be correct.
stw is offline   Reply With Quote
Old 08-07-2015, 10:53 AM   #6
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,653
Default

Quote:
Originally Posted by stw View Post
I'm not sure if i should "+=", or "=" startPos though both should do the same in that case. If i follow the IPlugChunks example "=" would be correct.
Yeah, but I disagree with the example, because the related UnserializeState() doesn't necessarily start at 0. However, for CompareState() indeed it doesn't matter, because in the current implementation it does always start at 0.
Tale is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.