快速登录:  

Forum: VirtualDJ Plugins

话题: PachN's noob questions

由于该帖子已年深日久,可能包含陈旧过时或描述错误的信息。

PachNPRO InfinityMember since 2009
Finally I had some time to start playing around with the plugin SDK...

I did the tutorial and created a basic plugin.
All the plugin does at the moment is starting deck 1.

This is what I added to the tutorial MyPlugin8.cpp

At OnLoad()

DeclareParameterButton(&m_Start, ID_BUTTON_2, "Start", "S");


At OnParameter(int id)

case ID_BUTTON_2:
if(m_Start == 1) {

SendCommand("deck 1 play");
}
break;



The plugin loads OK and I can start a deck, but everytime after using the plugin and trying to close VDJ I get this message.



What am I doing wrong?


EDIT: Okay, it seems it is not my code. If I uncomment (is that the right term?) the following, which is already in the SDK, I get the same error:

//HRESULT hr;
//hr = SendCommand("effect_slider 1 50%");


Second question:
Is there a way to debug the plugin in realtime? To set some breakpoints?
I tried to change the "internalPluginLocation" to my debug path and attach the VDJ8.exe process to the debugger.
But I can't see the plugin in VDJ then.

Currently I have to copy the DLL from my debug folder to the VDJ Plugins folder to see and run the plugin.
 

发表时间 Tue 11 Aug 15 @ 6:19 am
SBDJPRO Infinity Member since 2006
The error will be in your code. If you post the full thing it would be helpful.

In commenting example lines in the SDK can cause you major problems. Leave those files alone unless you have good reason :)

Debugging - set the output folder to the plugin folder and then set VDJ as the debugging executable in your project options.
 

发表时间 Tue 11 Aug 15 @ 8:06 am
PachNPRO InfinityMember since 2009
Okay, here is the whole code of MyPlugin8.cpp



#ifndef MYPLUGIN8_H
#define MYPLUGIN8_H

// we include stdio.h only to use the sprintf() function
// we define _CRT_SECURE_NO_WARNINGS for the warnings of the sprintf() function
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#include "vdjPlugin8.h"

class CMyPlugin8 : public IVdjPlugin8
{
public:
HRESULT VDJ_API OnLoad();
HRESULT VDJ_API OnGetPluginInfo(TVdjPluginInfo8 *infos);
ULONG VDJ_API Release();
HRESULT VDJ_API OnGetUserInterface(TVdjPluginInterface8 *pluginInterface);
HRESULT VDJ_API OnParameter(int id);
HRESULT VDJ_API OnGetParameterString(int id, char *outParam, int outParamSize);

private:
int m_Reset, m_Start;
float m_Dry;
float m_Wet;


bool isMasterFX(); // an example of additional function for the use of GetInfo()

protected:
typedef enum _ID_Interface
{
ID_BUTTON_1,
ID_BUTTON_2,
ID_SLIDER_1
} ID_Interface;
};

#endif


#include "MyPlugin8.h"


//-----------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnLoad()
{
// ADD YOUR CODE HERE WHEN THE PLUGIN IS CALLED
m_Reset = 0;
m_Dry = 0.0f;
m_Wet = 0.0f;
m_Start = 0;

bool bMasterFX = isMasterFX();


DeclareParameterButton(&m_Reset,ID_BUTTON_1,"Reset","R");
DeclareParameterButton(&m_Start, ID_BUTTON_2, "Start", "S");
DeclareParameterSlider(&m_Wet,ID_SLIDER_1,"Dry/Wet","D/W",1.0f);

OnParameter(ID_SLIDER_1);

return S_OK;
}
//-----------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnGetPluginInfo(TVdjPluginInfo8 *infos)
{
infos->PluginName = "MyPlugin8";
infos->Author = "Atomix Productions";
infos->Description = "My first VirtualDJ 8 plugin";
infos->Version = "1.0";
infos->Flags = 0x00;
infos->Bitmap = NULL;

return S_OK;
}
//---------------------------------------------------------------------------
ULONG VDJ_API CMyPlugin8::Release()
{
// ADD YOUR CODE HERE WHEN THE PLUGIN IS RELEASED

delete this;
return 0;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnGetUserInterface(TVdjPluginInterface8 *pluginInterface)
{
pluginInterface->Type = VDJINTERFACE_DEFAULT;

return S_OK;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnParameter(int id)
{
switch(id)
{
case ID_BUTTON_1:
if(m_Reset == 1)
{
m_Wet = 0.5f;
//HRESULT hr;
//hr = SendCommand("effect_slider 1 50%");
}
break;

case ID_BUTTON_2:
if(m_Start == 1) {

SendCommand("deck 1 play");
}
break;
case ID_SLIDER_1:
m_Dry = 1 - m_Wet;
break;
}

return S_OK;
}
//---------------------------------------------------------------------------
HRESULT VDJ_API CMyPlugin8::OnGetParameterString(int id, char *outParam, int outParamSize)
{
switch(id)
{
case ID_SLIDER_1:
sprintf(outParam,"+%.0f%%", m_Wet*100);
break;

}
return S_OK;
}

//-------------------------------------------------------------------------------------------------------------------------------------
// BELOW, ADDITIONAL FUNCTIONS ONLY TO EXPLAIN SOME FEATURES (CAN BE REMOVED)
//-------------------------------------------------------------------------------------------------------------------------------------
bool CMyPlugin8::isMasterFX()
{
double qRes;
HRESULT hr = S_FALSE;

hr = GetInfo("get_deck 'master' ? true : false", &qRes);

if(qRes==1.0f) return true;
else return false;
}


You see it is nothing more than described here
http://virtualdj.com/wiki/Plugins_SDKv8_Example.html
+ the additional code I posted above.

 

发表时间 Tue 11 Aug 15 @ 8:53 am
djcelPRO InfinityModeratorMember since 2004
It's a stupid question but i prefer to ask it. have you merged .h and .cpp files in the same file or is it just a copy paste error?

Which version of Visual C++ ou Visual Studio are you using? Same question for the Windows SDK?

Do you compile in 32 bit? unicode?
 

发表时间 Tue 11 Aug 15 @ 8:08 pm
PachNPRO InfinityMember since 2009
Oh stupid me... It seems that is indeed a copy&paste error.
Yes, as it is now, .h and .cpp are merged.
Although a dedicated .h with the correct content exists.

I'll clean the .cpp and report back.

I'm using VS2012 ultimate at the moment.
Windows SDK version? I don't know. Where and how can I check that?
32 bit, yes.
Unicode, I think yes, but have to check.
I'm using the default values VS creates for an empty Win32 C++ project.
I haven't changed anything here, except the output path for the .DLL.
 

发表时间 Wed 12 Aug 15 @ 8:06 am
djcelPRO InfinityModeratorMember since 2004
Visual Studio installs by default the Windows SDK version but personnally I use an external folder for all the updates (D:\Microsoft Windows SDK\Windows\v8.1\ => the last number gives the Windows SDK version). Anyway, it should work with VS2012 ultimate.

Also check the project (my example was with VS2005 but it should update with VS2012 when you open it)
http://virtualdj.com/wiki/Plugins_SDKv8_ExampleVCProject.html
 

发表时间 Wed 12 Aug 15 @ 11:21 pm
I recently had to go from VS2005 to VS2010. I may go to VS2012 or higher but I can't speak for those at the moment. With VS2010, it targets Vista or higher by default. I needed to take special care for it to compile for XP. It needed to have the build tools for VS2008 etc and this was a separate install. Maybe they cleared this up with higher versions but I do not know at the moment. VS2010 was already installed on the this computer and I have not upgraded it yet. The Platform Toolset in Configuration Properties / General had to be set to v90 and not the default of v100. If you don't use or test with XP this is easy to miss.
 

发表时间 Thu 13 Aug 15 @ 4:19 pm
AdionPRO InfinityCTOMember since 2006
Not sure why you had to do that, even Visual Studio 2015 can be used with Platform Toolset v140_xp and still compile programs compatible with xp.
 

发表时间 Thu 13 Aug 15 @ 5:11 pm
Like I said can't speak for higher than 2010. It is what I had to do for that. It was such a pain that I have to believe they improved it after that.
 

发表时间 Thu 13 Aug 15 @ 5:19 pm
PachNPRO InfinityMember since 2009
Just a feedback, deleting the header file code from .cpp fixed the "problem" with heap corruption.
So, thanks for the hint. I sat there for an hour staring at my code and really didn't recognize I did such a simple and stupid mistake...
 

发表时间 Fri 14 Aug 15 @ 8:35 am
PachNPRO InfinityMember since 2009
Okay, next problem.
As soon as I try to use that part of code


void CMyPlugin8::WaitForDel() {

do{

std::this_thread::sleep_for(std::chrono::milliseconds(100));
ascii = getch();
if(ascii == 0x53) {
SendCommand("deck 1 play");
}

} while (m_Exit != true);
}


VDJ / the master effect process will lock up as soon as I try to access the GUI of my plugin.
I'm calling the function "WaitForDel" in the OnLoad function of the plugin.

Maybe it's not a good approach, so I'll describe what I want to achieve.
The Plugin should only wait for the "del" key to be pressed and if it was pressed, delete the currently selected file in the browser.

Any ideas why it locks up? CPU usage is at 3%.
Maybe I should use something like a background worker thread instead of a do-while...
 

发表时间 Tue 18 Aug 15 @ 9:32 am
SBDJPRO Infinity Member since 2006
Yes, you need to thread that - whatever function calls WaitForDel will be tied up until that returns.
 

发表时间 Tue 18 Aug 15 @ 10:32 am
AdionPRO InfinityCTOMember since 2006
Also getch reads from the console, I doubt it will work for capturing any key press.

If you want to be able to capture key presses globally, you may need something such as this:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx

A simpler approach may be to declare a parameter in your plugin, and then simply use the keyboard mapper in vdj to map the delete key to the button in your plugin.
 

发表时间 Tue 18 Aug 15 @ 12:50 pm
PachNPRO InfinityMember since 2009
Good idea adion.
Would be indeed simpler.
I'll try it that way.
 

发表时间 Tue 18 Aug 15 @ 4:12 pm


(陈旧帖子或论坛版块会自动关闭)