Hello!
I've now written a slipmode by my own in c++ and on one deck it is working quite good, but if i durn on on a second deck then all programmed sendcommand only work on deck 2 and not at deck 1 anymore. i havn't any idea how i could stop this.
Heare are the parts of the code if somebody wants to take a look:
Maybe someone can take a look, because it is also my first pluging, and maybe you got some advices or tips for me if i'm doing something wrong.
Big Thanks,
Best regards, C.Hackl
I've now written a slipmode by my own in c++ and on one deck it is working quite good, but if i durn on on a second deck then all programmed sendcommand only work on deck 2 and not at deck 1 anymore. i havn't any idea how i could stop this.
Heare are the parts of the code if somebody wants to take a look:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "vdjDsp.h"
// Plugin Interface ID
#define ID_SLIDER_1 0
#define ID_SLIDER_2 1
#define ID_STRING_1 3
#include <stdio.h>
//Variables for Slipmode
float deckspeed;
int pos_start;
double pos_cnt;
int slip;
int glob_deck;
//Variable gloabal script:
char cmd_loop[255]="";
char cmd_play[255]="";
char cmd_rev[255]="";
char cmd_pitch[255]="";
//Variables for VDJ Play, Loop, Reverse
TVdjQueryResult qRes;
HRESULT hr;
int loop;
int loop_pev;
int reverse;
int reverse_pev;
int buffer_samp;
//////////////////////////////////////////////////////////////////////////
// Class definition
//////////////////////////////////////////////////////////////////////////
class Cslipmode : public IVdjPluginDsp
{
public:
#define VDJ_API __stdcall
HRESULT VDJ_API OnLoad();
HRESULT VDJ_API OnGetPluginInfo(TVdjPluginInfo *infos);
ULONG VDJ_API Release();
HRESULT VDJ_API OnParameter(int id);
HRESULT VDJ_API OnStart(int pos,int deck);
HRESULT VDJ_API OnStop();
HRESULT VDJ_API OnProcessSamples(short *buffer,int nb,int pos);
// Stop Slip
void goto_pos(double pos,int deck)
{
pos = (pos*1000) / 44100;
int goto_time;
goto_time = pos;
char cmd[255]="";
_snprintf_s (cmd, (size_t)255, "%s %d %s %d%s", "deck", deck, "goto", goto_time, "ms");
_snprintf_s (string1, (size_t)255, "%s%d%s", "Jumped to ", goto_time, "ms");
SendCommand(cmd,1);
SendCommand("effect_redraw",0);
};
private:
// For example:
char string1[128];
};
//////////////////////////////////////////////////////////////////////////
// Initialization
//////////////////////////////////////////////////////////////////////////
HRESULT VDJ_API DllGetClassObject(const GUID &rclsid,const GUID &riid,void** ppObject)
{
// This is the standard DLL loader for COM object.
// You don't need to change anything in this function.
if(memcmp(&rclsid,&CLSID_VdjPlugin6,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
if(memcmp(&riid,&IID_IVdjPluginDsp,sizeof(GUID))!=0) return CLASS_E_CLASSNOTAVAILABLE;
*ppObject=new Cslipmode();
return NO_ERROR;
}
//------------------------------------------------------------------------
HRESULT VDJ_API Cslipmode::OnLoad()
{
// For example:
DeclareParameter(string1,VDJPARAM_STRING,ID_STRING_1,"Text1",sizeof(string1));
return S_OK;
}
//------------------------------------------------------------------------
HRESULT VDJ_API Cslipmode::OnGetPluginInfo(TVdjPluginInfo *infos)
{
infos->Author="Chackl";
infos->PluginName="slipmode";
infos->Description="This is a simulation of a Slipmode in loops or in reverse-play. Active it and your loops and reverses will slip. Make shure to turn off 'save'-Mode to get exact timing.";
infos->Bitmap=PLUGIN_BITMAP;
infos->Flag=0x00;
return S_OK;
}
//------------------------------------------------------------------------
ULONG VDJ_API Cslipmode::Release()
{
delete this;
return 0;
}
//------------------------------------------------------------------------
HRESULT VDJ_API Cslipmode::OnParameter(int id)
{
SendCommand("effect_redraw",0);
return S_OK;
}
//////////////////////////////////////////////////////////////////////////
// Sound processing
//////////////////////////////////////////////////////////////////////////
HRESULT VDJ_API Cslipmode::OnStart(int pos,int deck)
{
glob_deck = deck;
_snprintf_s (string1, (size_t)255, "%s %d", "Online on Deck", deck);
SendCommand("effect_redraw",0);
return S_OK;
}
//------------------------------------------------------------------------
HRESULT VDJ_API Cslipmode::OnStop()
{
return S_OK;
}
//------------------------------------------------------------------------
HRESULT VDJ_API Cslipmode::OnProcessSamples(short *buffer,int nb,int pos)
{
_snprintf_s(cmd_loop, (size_t)255, "%s %d %s", "deck", glob_deck, "loop");
_snprintf_s(cmd_play, (size_t)255, "%s %d %s", "deck", glob_deck, "play");
_snprintf_s(cmd_rev, (size_t)255, "%s %d %s", "deck", glob_deck, "reverse");
_snprintf_s(cmd_pitch, (size_t)255, "%s %d %s", "deck", glob_deck, "pitch");
buffer_samp = nb;
//Loops
loop_pev = loop;
hr=GetInfo(cmd_loop,&qRes);
if(hr==S_OK){loop = qRes.vint;}
if(loop==1 && loop_pev==0){
//Start Loop
pos_start = pos;
slip = 1;
pos_cnt = 0;
}
if(loop==0 && loop_pev==1){
//Stop Loop
int isPlaying;
hr=GetInfo(cmd_play,&qRes);
if(hr==S_OK){isPlaying = qRes.vint;}
if(isPlaying==1){
goto_pos(pos_start + pos_cnt,glob_deck);
pos_cnt = 0;
slip = 0;
}
}
//Reverse
reverse_pev = reverse;
hr=GetInfo(cmd_rev,&qRes);
if(hr==S_OK){reverse = qRes.vint;}
if(reverse==1 && reverse_pev==0){
//Start Reverse
pos_start = pos;
slip = 1;
pos_cnt = 0;
}
if(reverse==0 && reverse_pev==1){
//Stop Reverse
int isPlaying;
hr=GetInfo(cmd_play,&qRes);
if(hr==S_OK){isPlaying = qRes.vint;}
if(isPlaying==1){
goto_pos(pos_start + pos_cnt,glob_deck);
pos_cnt = 0;
slip = 0;
}
}
//Count Time
hr=GetInfo(cmd_pitch,&qRes);
if(hr==S_OK){deckspeed = qRes.vfloat;}
deckspeed = deckspeed * 2;
if(slip==1){
pos_cnt = pos_cnt + (double(buffer_samp) * double(deckspeed));
}
return S_OK;
}
Maybe someone can take a look, because it is also my first pluging, and maybe you got some advices or tips for me if i'm doing something wrong.
Big Thanks,
Best regards, C.Hackl
geposted Sat 22 Sep 12 @ 10:33 am
1) It's important to understand the concept of class in c++
have been defined outside the class. Add these lines in the 'private' section of you class.
(char cmd_loop[255]=""; , you have to remove ="" and then do a memset() or wsprintf(cmd_loop,"") in the OnLoad() function)
2) You use the new SDK so SendCommand("command", NOSYNC) without adding the deck
with "#define NOSYNC 0"
you can also write SendCommand("deck left command", NOSYNC) or SendCommand("deck 1 command", NOSYNC) if you want to specify the deck
3) For GetInfo(), I advise you
4)
5)
are not used in your code so you can remove these lines
6) you can replace
7)
Quote :
//Variables for Slipmode
float deckspeed;
int pos_start;
double pos_cnt;
int slip;
int glob_deck;
//Variable gloabal script:
char cmd_loop[255]="";
char cmd_play[255]="";
char cmd_rev[255]="";
char cmd_pitch[255]="";
//Variables for VDJ Play, Loop, Reverse
TVdjQueryResult qRes;
HRESULT hr;
int loop;
int loop_pev;
int reverse;
int reverse_pev;
int buffer_samp;
float deckspeed;
int pos_start;
double pos_cnt;
int slip;
int glob_deck;
//Variable gloabal script:
char cmd_loop[255]="";
char cmd_play[255]="";
char cmd_rev[255]="";
char cmd_pitch[255]="";
//Variables for VDJ Play, Loop, Reverse
TVdjQueryResult qRes;
HRESULT hr;
int loop;
int loop_pev;
int reverse;
int reverse_pev;
int buffer_samp;
have been defined outside the class. Add these lines in the 'private' section of you class.
(char cmd_loop[255]=""; , you have to remove ="" and then do a memset() or wsprintf(cmd_loop,"") in the OnLoad() function)
2) You use the new SDK so SendCommand("command", NOSYNC) without adding the deck
with "#define NOSYNC 0"
you can also write SendCommand("deck left command", NOSYNC) or SendCommand("deck 1 command", NOSYNC) if you want to specify the deck
3) For GetInfo(), I advise you
struct TVdjQueryResult qRes;
qRes.type = 0;
qRes.vint = 0;
HRESULT hr = GetInfo("play",&qRes);
if(hr==S_OK)
{
// Read 'type' if you don't know the type of value to read
// Then read the value
int status = (int) qRes.vfloat;
}
4)
Quote :
and #define VDJ_API __stdcall
Quote :
are already defined in VDJPlugin.h so you don't need to redefine them#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windows.h>
5)
Quote :
#define ID_SLIDER_1 0
#define ID_SLIDER_2 1
#define ID_SLIDER_2 1
are not used in your code so you can remove these lines
6) you can replace
Quote :
by the equivalent code:infos->Flag=0x00;
infos->Flag = VDJPLUGINFLAG_INPLACE | VDJPLUGINFLAG_CACHE | VDJPLUGINFLAG_PROCESSSONG;
7)
Quote :
is a 'private' function as you don't need to call it outside the class
void goto_pos(double pos,int deck)
geposted Sun 23 Sep 12 @ 9:09 am
Hello!
Thanks for help! and your advice ;)
This means now for me will do every dek in a loop and swich throu all decks. Ok i'll try that and i hope i have success ;)
Best regards,
C.Hackl
Thanks for help! and your advice ;)
This means now for me will do every dek in a loop and swich throu all decks. Ok i'll try that and i hope i have success ;)
Best regards,
C.Hackl
geposted Mon 24 Sep 12 @ 8:51 am
well actualy the Problem with slipmode scratch is because it is in API V5 because the API V6 does not give me the Status if the deck is scratched. and it seems there is no other way to use V5 at the Moment. As next it seems to me only two decks are controlled by Sendcommand. But deck 3 and above are not controlled. I don't think it is a bug but V5 got old now.
´
I hobe that it is possible to get back "Status" in vdj script so that i can port Slipmode vor Scratches on V6 as soon as possible.
This script which controlls the Loop and reverse slip will work on V6 multideck, i hop i can release a fixed Version before friday.
Regards,
C.Hackl
´
I hobe that it is possible to get back "Status" in vdj script so that i can port Slipmode vor Scratches on V6 as soon as possible.
This script which controlls the Loop and reverse slip will work on V6 multideck, i hop i can release a fixed Version before friday.
Regards,
C.Hackl
geposted Mon 24 Sep 12 @ 5:08 pm