Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: MY C++ CODE ---- NEED ADVICE

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

So I've been asking for certain plugins that would help improve creativity in VDJ for quite a while and thought well I do have some knowledge of C++ however limited so I thought I would undertake it.

This is basically the scratch plugin with a revision it is going to apply alpha when the timecode speed goes below 50% that gradually fades to zero

Now the code for allot of part is boll*cks as I'm not a seasoned C++ programmer and I am goin to some help getting this cookie going

First of all though I need to know whether I can calculate speed from angulation to do this if say CEL could give me a little more info on how it works please!!!

Here is the code so far



#include <windows.h>
#include <math.h>
#include <stdlib.h>
#include "VdjDsp.h"
#include "vdjVideo"
//---------------------------------------------------------------------------
// I THINK I NEED TO #INCLUDE SOME DirectX FOR RENDER SECTION BUT NOT SURE WHAT YET!
//---------------------------------------------------------------------------

class MyPlugin : public IVdjPluginVideoTransition // THINK THIS IS THE CLASS OBJECT FOR VIDEO TRANSTION
{
public:
HRESULT __stdcall OnLoad(TPluginInfos *PluginInfos);
HRESULT __stdcall OnProvidedInterfaceInit(TProvidedInterfaceInit *Init);
HRESULT __stdcall OnCalculateOpacityInit(TCalculateOpacityInit *Init); // Calls for final Opacity calculations
HRESULT __stdcall OnRenderOrderInit(TRenderOrderInit *Init); // Calls for Render Order
HRESULT __stdcall OnRenderInit(TRenderInit *Init); // Calls for render

private:
int RENDERORDER // Defines which video should be rendered on top ALSO NOT SURE IF YOU DEFINE A DEFAULT VARIABLE HERE WETHER IT GETS OVERWRITTEN THE VERY NEXT LOOP OF THE CODE - HELP!!!!
float DECK_A_SPEED // Defines speed of left deck
float DECK_B_SPEED // Defines speed of right deck
int DECK_A_OPACITY // Defines opacity of left deck
int DECK_B_OPACITY // Defines opacity of right deck

};
//---------------------------------------------------------------------------
HRESULT __stdcall MyPlugin::OnLoad(TPluginInfos *PluginInfos)
{
PluginInfos->PluginVersion=VDJDSP_VERSION;
PluginInfos->Name="Ultimate Transition";
PluginInfos->Author="iKutZ";
PluginInfos->Processing=PROCESSING_NORMAL;
PluginInfos->Interface=INTERFACE_PROVIDED;
// I think i need to obtain the position of the video fader and channel faders here
return 0;
}
//---------------------------------------------------------------------------
HRESULT __stdcall MyPlugin::OnProvidedInterfaceInit(TProvidedInterfaceInit *Init)
{
// I believe this is for the graphical interface for
return 0;
}
//---------------------------------------------------------------------------
HRESULT __stdcall MyPlugin::OnCalculateOpacityInit(TCalculateOpacityInit *Init);
{
int speedofdeckA = GetInfo("action 1",Angle()); // Not sure on how angulation works so i need to know definitions to assertain speed
int speedofdeckB = GetInfo("action 2",Angle()); // Not sure on how angulation works so i need to know definitions to assertain speed

// I basically need a way of calculating the speed of deck (as a percentage) including negative, but once calculated the code for opacity calculation would look like this
// The opacity effect only kicks in when the speed of the deck is below 50%


if (speedofdeckA>50)
{
DECK_A_OPACITY = 100;
}
if (speedofdeckA<50)
{
DECK_A_OPACITY = speedofdeckA*2;
}

// The same for deck b

if (speedofdeckB>50)
{
DECK_B_OPACITY = 100;
}
if (speedofdeckB<50)
{
DECK_B_OPACITY = speedofdeckB*2;
}


// I was thinking this is where you could include the code for making the video transparent by using d3dcoolor

// Change decks opacity value into hex !!!!!! NEEDS REVISING AS I HAVE NOT TESTED AS MY C++ IS POOOOO!!!!!!!

char outStrA[128]
int inDec = DECK_A_OPACITY*2.56
VID_A_OPACITY = "0x" sprintf(outStr,"%x",inDec)

char outStrA[128]
int inDec = DECK_B_OPACITY*2.56
VID_B_OPACITY = "0x" sprintf(outStr,"%x",inDec)

// Then use D3D TO APPLY THE ALPHA CHANNEL

vertex[0][0].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_A_OPACITY);
vertex[0][1].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_A_OPACITY);
vertex[0][2].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_A_OPACITY);
vertex[0][3].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_A_OPACITY);

vertex[1][0].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_B_OPACITY);
vertex[1][1].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_B_OPACITY);
vertex[1][2].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_B_OPACITY);
vertex[1][3].color=D3DCOLOR_RGBA(0xFF,0xFF,0xFF,VID_B_OPACITY);

return 0;
}
//---------------------------------------------------------------------------
HRESULT __stdcall MyPlugin::OnRenderOrderInit(TRenderOrderInit *Init)
{
int faderpos = GetInfo(VideoCrossfader()) // faderpos = the video cross fader postion

if (faderpos=0)
{
RENDERORDER=0; // Video fader over to the left, so left deck first
}

if (faderpos=4096)
{
RENDERORDER=1; // Video fader over to the right, so right deck first
}
return 0;
// Bescause this is equivilant to the scratch plugin we need to know when the video fader has been fully left of right to know which video channel render needs to happen first
}
//---------------------------------------------------------------------------
HRESULT __stdcall MyPlugin::OnRenderInit(TRenderInit *Init)
{
// CODE FOR RENDERER NEEDED but calculation of how the render works should look somthing like this

// NOT ACTUAL CODE...This is if the video fader is all the way over to the left

if (faderpos=0)
{
RenderSurface[0] // with opactiy DECK_A_OPACITY ;
}

// NOT ACTUAL CODE...This is if the video fader is all the way over to the right

if (faderpos=4096)
{
RenderSurface[1] // with opactiy DECK_A_OPACITY;
}

// NOT ACTUAL CODE...If the above conditions are not satisfied then the fader is in the middle somewhere
else
{
if (RENDERORDER=0) // Render left video first then overlay right video with its opacity variable. If the right video's opacity is 100% then only the right deck should be seen
{
RenderSurface[0]() // with opactiy DECK_A_OPACITY;
RenderSurface[1]() // with opactiy DECK_B_OPACITY;
}
if (RENDERORDER=1) // Render right video first then overlay left video with its opacity variable. If the left video's opacity is 100% then only the left deck should be seen
{
RenderSurface[1]() // with opactiy DECK_B_OPACITY;
RenderSurface[0]() // with opactiy DECK_A_OPACITY;
}


return 0;
}
 

Posted Wed 16 Jan 08 @ 5:04 am
SBDJPRO Infinity Member since 2006
Hello mate...

Good on you for giving it a go, you've started out with the hardest type of plugin too!! I can't yet advise on the timecode side of things I'm afraid - I've not done any development there. I've done a few video plugins now though :)

Looking through your code, I'm not sure where you've got your samples from or what version of SDK you are using? For example, I'm not sure where you've got those other public class functions from...

HRESULT __stdcall OnProvidedInterfaceInit(TProvidedInterfaceInit *Init);
HRESULT __stdcall OnCalculateOpacityInit(TCalculateOpacityInit *Init); // Calls for final Opacity calculations
HRESULT __stdcall OnRenderOrderInit(TRenderOrderInit *Init); // Calls for Render Order
HRESULT __stdcall OnRenderInit(TRenderInit *Init); // Calls for render

For a video transition, the rendering is done in:

HRESULT __stdcall Compose(int crossfader,HRESULT(__stdcall *RenderSurface[2])(),TVertex *vertices[2]);

...and those functions you listed about aren't anywhere in the latest SDK?

Nice idea for a plugin though, will be happy to hook my TC up and help you out where needed.

One question though - as you are going to Alpha based on speed, is this plugin designed to show one video, fade it out to black by killing one deck effectively revealing the other video underneath?

Regards,

Scott
 

Posted Wed 16 Jan 08 @ 8:57 am
Thats exactly what I'm trying to do... (these conditions)

The slower the deck goes the alpha channel drops revealing the layer underneath or other video
Exceptions when the videofader is either extreme left-right when just one channel is rendered.

It also means that if just one deck stopped either slowly or abrutly the channel will fade to black corrispondingly which i think would be advantagous in terms of the music being fused with audio.

It also means when your scratching and doing flare or tear type scrathes (anything that has a fake click), the click would regiester and visually react in time (one clicker flares still look horrible becasue of the syncapation used)

My end goal is to tie in a GetInfo() for video fx param (say 5 & 6) which can be controlled by midi and then VDJ has an Answer to V-SL's fade to black on the channel fader... (I think this could be very benifical to VDJ) Also because of the render order it could be useful for plain mixing i.e. The channel thats playing is the back layer because the crossfaders has been over that side last and the channel that you are bringing in would fadeout the underlying video... Hey Presto... You've got a video trainsition with upfaders. No extra video fading need (you can't say thats not worth somthing).

I apreciate any advice on this I havn't touched C++ in along time. I hav'nt even got the header files in the right place (using VS2008) any help just getting it working would be help (I have installed windows SDK and DX SDK) + what setting in VS2008 should I be using for a DLL... Hence why I was asking on a previous thread.

Some of the code I worte I tested in little console apps to make sure I got facts right and the code is skelital structure of the plugin. Kinda rough guide (I basically know how the plugin should work but I'm getting caught up in syntax and code) But I know the variable manipulation is sound.

So can anyone help with estimationg time code speed per deck and representing it as say a percentage... (thats one problem)
Anyone help to properly compile DLL's (thats my second)
Also if I asign a variable at the start of the code in private and give it a value does that code get reinitialised and the value reset if so do I do it in the onload section....

Cheers for help scott... Ignore the public class boll*cks I think I made half of them up to get my chain of thought right.
 

Posted Wed 16 Jan 08 @ 9:21 am
OK so Im making progress I'm just trying to compile the Brake.cpp in the developement SDK to see I can get somthing to successfully build and run in vdj... and I got down to 4 errors....... Anyone tell me what to do next?

1>------ Build started: Project: test5, Configuration: Debug Win32 ------
1>Compiling...
1>dlltester.cpp
1>c:\users\ik\documents\visual studio 2008\projects\test5\test5\dlltester.cpp(44) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [128]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\ik\documents\visual studio 2008\projects\test5\test5\dlltester.cpp(56) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\ik\documents\visual studio 2008\projects\test5\test5\dlltester.cpp(59) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [128]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:\users\ik\documents\visual studio 2008\projects\test5\test5\dlltester.cpp(68) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at "file://c:\Users\IK\Documents\Visual Studio 2008\Projects\test5\test5\Debug\BuildLog.htm"
1>test5 - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 

Posted Wed 16 Jan 08 @ 9:57 am
OK overcome that 1, stuff is compiling and working now so I'm half way there...
 

Posted Wed 16 Jan 08 @ 10:54 am
SBDJPRO Infinity Member since 2006
Cool, good luck :) Feel free to drop me a message if you need anything :)

Regards,

Scott
 

Posted Wed 16 Jan 08 @ 11:09 am
djcelPRO InfinityModeratorMember since 2004
Ian Knowles wrote :
OK so Im making progress I'm just trying to compile the Brake.cpp in the developement SDK to see I can get somthing to successfully build and run in vdj... and I got down to 4 errors....... Anyone tell me what to do next?

1>------ Build started: Project: test5, Configuration: Debug Win32 ------
1>Compiling...
1>dlltester.cpp
1>c:usersikdocumentsvisual studio 2008projectstest5test5dlltester.cpp(44) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [128]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:usersikdocumentsvisual studio 2008projectstest5test5dlltester.cpp(56) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:usersikdocumentsvisual studio 2008projectstest5test5dlltester.cpp(59) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [128]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>c:usersikdocumentsvisual studio 2008projectstest5test5dlltester.cpp(68) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to 'LPWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>Build log was saved at "file://c:UsersIKDocumentsVisual Studio 2008Projectstest5test5DebugBuildLog.htm"
1>test5 - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Apparently it was an UNICODE problem (change it in your project or adapt your C++ code)
 

Posted Wed 16 Jan 08 @ 11:29 am
Cheers guys,

I actually getting stuff working now so onwards and upwards

CEL
if you could tell me exactly what Angle() relates to... dont want to have to do a timer and position record to calc speed of deck if I dont have too!
 

Posted Wed 16 Jan 08 @ 11:38 am
djcelPRO InfinityModeratorMember since 2004
Ian Knowles wrote :

#include "VdjDsp.h"
#include "vdjVideo"

I see what you want to do but it can't work like that: it's either a dsp plugin either a video plugin but not both at the same time.
Because you will have a problem in DllGetClassObject() for *ppObject=new MyPlugin();


Ian Knowles wrote :

HRESULT __stdcall MyPlugin::OnLoad(TPluginInfos *PluginInfos)
{
PluginInfos->PluginVersion=VDJDSP_VERSION;
PluginInfos->Name="Ultimate Transition";
PluginInfos->Author="iKutZ";
PluginInfos->Processing=PROCESSING_NORMAL;
PluginInfos->Interface=INTERFACE_PROVIDED;
// I think i need to obtain the position of the video fader and channel faders here
return 0;
}

//---------------------------------------------------------------------------
HRESULT __stdcall MyPlugin::OnProvidedInterfaceInit(TProvidedInterfaceInit *Init)
{
// I believe this is for the graphical interface for
return 0;
}

Do you intend to use the old SDK of VirtualDJ?

If you use the new one, you have to write:

HRESULT __stdcall MyPlugin::OnGetPluginInfo(TVdjPluginInfo *infos)
{
infos->Author="iKutZ";
infos->PluginName="Ultimate Transition";
infos->Flag=0;
return S_OK;
}
 

Posted Wed 16 Jan 08 @ 11:41 am


(Old topics and forums are automatically closed)