COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 01-26-2017, 08:23 AM   #1
$h@d0 link
Human being with feelings
 
Join Date: Jan 2017
Posts: 9
Default When I compile for vst 3 my plugin can't get the project tempo

Hello all! Would like to know if anyone has had a peculiar problem with getting the project tempo in your plugin when it is compiled for vst3? I run my app as a regular desktop app it gets 120, I run it inside ableton as a 32 bit vst2 plugin and it gets the right tempo, also works on vst2 64 bit. However when I try to get the tempo from the plugin when it is a vst3 either bit, it just gets either -inf as a value or -0.000. Why does it do this? I just can't imagine why that happens.
$h@d0 link is offline   Reply With Quote
Old 01-26-2017, 06:23 PM   #2
Tired_Joe
Human being with feelings
 
Join Date: Apr 2015
Posts: 55
Default

Can you give us some code? I have no problems getting the tempo in VST3
Tired_Joe is offline   Reply With Quote
Old 01-26-2017, 08:56 PM   #3
$h@d0 link
Human being with feelings
 
Join Date: Jan 2017
Posts: 9
Default Here tis

Code:
MyFirstPlugin::MyFirstPlugin(IPlugInstanceInfo instanceInfo)
  :	IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo)//, mGain(1.)
{
  TRACE;
  
  int inputBoxId;
  currBpm = 0;
  
  currBpm = GetTempo();

  if (currBpm == 0 || currBpm == NULL)
  {
	  currBpm = 120;
  }
  if (currBpm > MAX_BPM)
  {
	  currBpm = MAX_BPM;
  }
  if (currBpm < MIN_BPM)
  {
	  currBpm = MIN_BPM;
  }
  
    char array2[12] = { '\0' };
    sprintf(array2, "%.3f", currBpm);

  const IColor COLOR_LBLUE(203, 34, 156, 203);
  IText text(12, &COLOR_LBLUE, "Arial", IText::kStyleNormal, IText::kAlignNear, 0, IText::kQualityDefault);            

  pGraphics = MakeGraphics(this, kWidth, kHeight);
  pGraphics->AttachPanelBackground(&COLOR_WHITE);
  pGraphics->HandleMouseOver(true);

  IBitmap textBox = pGraphics->LoadIBitmap(TextBox_ID,TextBox_FN);
 
  w = labelBox.W;
  h = labelBox.H;
  inputBox = new IRECT(220, 78, (180 + w), (90 + h));
  inputControl = new ITextControl(this, *(inputBox), &inputtext, array2);
  pGraphics->AttachControl(inputControl);
 

  AttachGraphics(pGraphics);
  MakeDefaultPreset((char *) "-", kNumPrograms);
}
and my header file

Code:
class MyFirstPlugin : public IPlug
{
public:

  MyFirstPlugin(IPlugInstanceInfo instanceInfo);
  ~MyFirstPlugin();

  float currBpm;
  IGraphics* pGraphics;
  void Reset();
  void OnHostIdentified();
  void OnParamChange(int paramIdx);
  void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);
  void LoadResources();
 

private:

  IRECT* inputBox;
  IText inputTextPtr;
  ITextControl* inputControl;
  IBitmap* bitmapBuffer;

  
  int outputPrecision;
};

#endif
The only thing I can think of is that I need to call it somewhere else than my constructor, I tried putting it in Reset() with the same results.
$h@d0 link is offline   Reply With Quote
Old 01-27-2017, 12:15 AM   #4
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by $h@d0 link View Post
The only thing I can think of is that I need to call it somewhere else than my constructor, I tried putting it in Reset() with the same results.
I'm not sure, but I would assume that GetTempo() works only when called from ProcessDoubleReplacing().
Tale is offline   Reply With Quote
Old 01-27-2017, 01:01 AM   #5
earlevel
Human being with feelings
 
Join Date: Dec 2015
Posts: 331
Default

It should work, doesn't have to be from the audio thread (ProcessDoubleReplacing). That doesn't mean it does work. It wasn't implemented in AAX, for instance, I had to add stuff. It looks like the last line here is what sets the info (mProcessContext) that you later retrieve with GetTempo for VST3. I don't know what's calling Process, you're on your own from there, but it looks like GetTempo will not function if this hasn't run first.

Code:
tresult PLUGIN_API IPlugVST3::process(ProcessData& data)
{
  TRACE_PROCESS;

  IMutexLock lock(this);

  if(data.processContext)
    memcpy(&mProcessContext, data.processContext, sizeof(ProcessContext));
earlevel is offline   Reply With Quote
Old 01-27-2017, 09:19 AM   #6
$h@d0 link
Human being with feelings
 
Join Date: Jan 2017
Posts: 9
Default Wasn't able to figure it out

I was not able to figure anything out unfortunately, thanks for trying to help though! I suppose it's an issue with just IPlug's vst3 interface?
$h@d0 link is offline   Reply With Quote
Old 01-28-2017, 06:41 PM   #7
$h@d0 link
Human being with feelings
 
Join Date: Jan 2017
Posts: 9
Default

Quote:
Originally Posted by $h@d0 link View Post
I was not able to figure anything out unfortunately, thanks for trying to help though! I suppose it's an issue with just IPlug's vst3 interface?
I now figured it out, you just can't use GetTempo() from your constructor, I could only get it to work from OnParamChange(), didn't seem to work inside of Reset() or OnHostIdentified() or ProcessDoubleReplacing() but since my program doesn't do any processing maybe thats why.
$h@d0 link 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 08:20 AM.


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