Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: How to write a CUEing plugin

This topic is old and might contain outdated or incorrect information.

nzdjHome userMember since 2007
I've gone through the examples and header files but I'm still a bit lost on this

what I want to do is to make VirtualDJ interact with a DMX control appication, I've got the control part figured out, but my problem is where to start with writing the plugin for VirtualDJ

what I need is a function that is continuously called and checks for the song position which would be compared against a file with cue points for DMX effects

Which type of plugins would that fit under (e.g. sound, video, device)? and how do I go about only getting the song position?

I tried modifying the supplied brake plugin but it seems to ruin the samples, I don't want to pass any samples back I only need to read the song position and figure out which deck the slider is leaning towards so I can feed the cue list off the song playing there

any help or examples would be greatly appreciated

cheers

Sam
 

Posted Thu 04 Sep 08 @ 5:23 am
nzdjHome userMember since 2007
Thanks heaps for your replies I really appreciate it

I was inclined towards the 100ms option as well since I'm not too confident of my multi-threading skills :)

but are you referring to the onTimer() function in the PluginDevice class? or just a CALLBACK windows timer?

the problem is if I make the plugin inherit the Dsp2 class then it expects me to recalculate the samples otherwise it kills the audio

if I try multiple inheritance of both the dsp and the device class then it gets slightly upset with double declaration of certain things

any ideas?

Thanks again

Sam
 

Posted Fri 05 Sep 08 @ 6:39 am
SBDJPRO Infinity Member since 2006
Yes, use a callback timer. Don't try and declare two classes, just use the dsp class.

If you don't do anything to the buffer, then it shouldn't affect the audio.

I've just created a blank DSP project, run it, and sound was unaffected without my doing any processing...

Regards,

Scott
 

Posted Fri 05 Sep 08 @ 9:15 am
nzdjHome userMember since 2007
Thanks for the info SBDJ

I found an example of CALLBACK timers posted on the forums which I've copied below, I almost got it to work but it fires only once

I declared the function outside the plugin class and I put the constructor in onLoad and the destructor in onRelease

is that correct?

* a Timer:

// Declaration
void CALLBACK TimerProc(HWND, UINT, UINT, DWORD);
UINT uTimer;
DWORD speed; // (in ms)

// Constructor
uTimer = (UINT) SetTimer(NULL, NULL, speed, (TIMERPROC)TimerProc);

// Desctructor
KillTimer(NULL, uTimer);

// Your function
void CALLBACK TimerProc(HWND, UINT, UINT, DWORD)
{
// write here to do each 'speed' ms
}
 

Posted Fri 05 Sep 08 @ 7:22 pm
nzdjHome userMember since 2007
ok correction now I got it to work thanks for all your help

is the structure I mentioned in my last message still correct though?

and also another problem, if I declare the CALLBACK function outside the class then I can't use the plugin functions such as GetInfo ??
 

Posted Fri 05 Sep 08 @ 7:25 pm
nzdjHome userMember since 2007
update: I tried writing a wrapper function for timerproc and it worked :) thanks again for your help
 

Posted Fri 05 Sep 08 @ 10:32 pm
djcelPRO InfinityModeratorMember since 2004
You can also add the word "static" for the CALLBACK.


For example, here is a solution to include Dialog CALLBACK in a class:


class CDialog
{
public:
VOID Create();

private:
HWND hMainDlg;
static BOOL CALLBACK DialogProcStatic(HWND, UINT, WPARAM, LPARAM);
virtual BOOL DialogProc(HWND, UINT, WPARAM, LPARAM);
};

//----------------------------------------------------------------------------------------
VOID CDialog::Create()
{
hMainDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), hWndParent, DialogProcStatic, (LPARAM)this);
}
//----------------------------------------------------------------------------------------
BOOL CALLBACK CDialog::DialogProcStatic(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
if (message == WM_INITDIALOG)
{
SetWindowLongPtr(hDlg, GWL_USERDATA, (LONG) lParam);
}

LPARAM pThis = GetWindowLongPtr(hDlg, GWL_USERDATA);
if (!pThis) return FALSE;

return (((CDialog*)pThis)->DialogProc(hDlg, message, wParam, lParam));
}
//----------------------------------------------------------------------------------------
BOOL CDialog::DialogProc(HWND hDlg,UINT message,WPARAM wParam,LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
break;

default:
return FALSE;
}
return TRUE;
}
 

Posted Sun 07 Sep 08 @ 12:28 pm
 

Posted Thu 05 Mar 09 @ 3:42 pm
SBDJPRO Infinity Member since 2006
I'm fairly sure djcel told me the function isnt threadsafe, and I've had it dump more than once on me through trying.

If you need to call GetInfo, you're better off with a standard timer.
 

Posted Thu 05 Mar 09 @ 11:05 pm
OK, can you provide an example of code using a "standard timer" ?

I'm using now SetTimer/KillTimer - see code excerpt below - and that causes dumps:

class Cmyplugin : public IVdjPlugin
{
public:
HRESULT __stdcall OnLoad();
HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
HRESULT __stdcall OnParameter(int id);
ULONG __stdcall Release();

char String1[128];
static void CALLBACK TimerProc_Wrapper( HWND hwnd, UINT uMsg,
UINT idEvent, DWORD dwTime );
void TimerProc( HWND hwnd,
UINT uMsg, UINT idEvent, DWORD dwTime );

private:
UINT uTimer;
};
static void *pObjectje;
//////////////////////////////////////////////////////////////////////////
// Initialization
///////////////////////////////////////////////////////////////////////
HRESULT __stdcall DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
if(memcmp(&rclsid,&CLSID_VdjPlugin,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
*ppObject=new Cmyplugin();
return NO_ERROR;
}

HRESULT __stdcall Cmyplugin::OnLoad()
{
pObjectje=this;
uTimer = SetTimer(NULL, NULL, 2000, TimerProc_Wrapper);

return S_OK;
}

void CALLBACK Cmyplugin::TimerProc_Wrapper( HWND hwnd, UINT uMsg,
UINT idEvent, DWORD dwTime ) {
Cmyplugin *pSomeClass = (Cmyplugin*)pObjectje;
pSomeClass->TimerProc(hwnd, uMsg, idEvent, dwTime);
}
void Cmyplugin::TimerProc(HWND, UINT, UINT, DWORD)
{
char author[255];
char title[255];
char comment[255];
char s[255];
FILE * pFile;

pFile = fopen ("C:\\testje_timer.txt","a");
if (pFile!=NULL)
{
GetInfo("Author",&author);
GetInfo("Title",&title);
GetInfo("Comment",&comment);
sprintf(s,"%s|%s|%s\n",author , title ,comment );
fputs (s,pFile);
fclose (pFile);
}

}
 

Posted Fri 06 Mar 09 @ 12:29 pm
crookoHome userMember since 2011
How to create plugin in c# and use VdjPlugin.h in c#.
 

Posted Mon 18 Jul 11 @ 11:13 pm
taylaPRO InfinityMember since 2007
crooko, stop asking the same question in multiple threads, you have already opened a thread from 2005, made a new thread and even opened this one from 2009, be patient someone with the knowledge will answer you.
 

Posted Tue 19 Jul 11 @ 4:01 am


(Old topics and forums are automatically closed)