When I want to use these :
HRESULT (VDJ_API *GetSongSamples)(int pos,int nb,short **buffer);
#define LEFTCHAN(v) ((short)(v&0xFFFF))
#define RIGHTCHAN(v) ((short)(v>>16))
I declare for instance in the OnProcessSamples(int pos,int nb,short *buffer)
int *source ;
GetSongSamples(pos,ni,(short**)& source);
for(int i=0;i<nb;i++)
{
v= source [ i];
int l= LEFTCHAN(v) ;
int r= RIGHTCHAN(v)
}
and it works.
But now if I need to declare *source as a « short » instead of « int », LEFTCHAN and RIGHTCHAN don’t work anymore.
What could be the solution to make :
short *source ;
GetSongSamples(pos,ni,(short**)& source);
for(int i=0;i<nb;i++)
{
v= source [ i];
int l= LEFTCHAN(v) ;
int r= RIGHTCHAN(v)
}
HRESULT (VDJ_API *GetSongSamples)(int pos,int nb,short **buffer);
#define LEFTCHAN(v) ((short)(v&0xFFFF))
#define RIGHTCHAN(v) ((short)(v>>16))
I declare for instance in the OnProcessSamples(int pos,int nb,short *buffer)
int *source ;
GetSongSamples(pos,ni,(short**)& source);
for(int i=0;i<nb;i++)
{
v= source [ i];
int l= LEFTCHAN(v) ;
int r= RIGHTCHAN(v)
}
and it works.
But now if I need to declare *source as a « short » instead of « int », LEFTCHAN and RIGHTCHAN don’t work anymore.
What could be the solution to make :
short *source ;
GetSongSamples(pos,ni,(short**)& source);
for(int i=0;i<nb;i++)
{
v= source [ i];
int l= LEFTCHAN(v) ;
int r= RIGHTCHAN(v)
}
Posted Mon 12 Dec 11 @ 6:04 am
Be careful,
a mono sample is a short [16 bit] but a stereo sample (interlaced samples = a successive left and right mono sample) is {short + short} that's why you can use a DWORD (which is in fact an unsigned long) [32 bit]
#define LEFTCHAN(v) ((short)(v&0xFFFF))
#define RIGHTCHAN(v) ((short)(v>>16))
LEFTCHAN and RIGHTCHAN takes a stereo sample in parameter and returns a mono sample
GetSongSamples returns a buffer with '2 * nb' mono samples (ie a pointer from 0 to 2*nb-1) so 'nb' stereo samples (ie a pointer from 0 to nb-1) starting from the 'pos'-th sample.
In other words:
S(1),S(2),S(3),S(4), .... , S(2*nb-1), S(2*nb)
= L(1),R(1),L(2),R(2),...., L(nb),R(nb)
= V(1),V(2), .... , V(nb)
So you have to write
_____________________________________
fyi, if you only want to work in mono samples:
or another way to write it (if you define 'j' as if i=2*j):
a mono sample is a short [16 bit] but a stereo sample (interlaced samples = a successive left and right mono sample) is {short + short} that's why you can use a DWORD (which is in fact an unsigned long) [32 bit]
#define LEFTCHAN(v) ((short)(v&0xFFFF))
#define RIGHTCHAN(v) ((short)(v>>16))
LEFTCHAN and RIGHTCHAN takes a stereo sample in parameter and returns a mono sample
GetSongSamples returns a buffer with '2 * nb' mono samples (ie a pointer from 0 to 2*nb-1) so 'nb' stereo samples (ie a pointer from 0 to nb-1) starting from the 'pos'-th sample.
In other words:
S(1),S(2),S(3),S(4), .... , S(2*nb-1), S(2*nb)
= L(1),R(1),L(2),R(2),...., L(nb),R(nb)
= V(1),V(2), .... , V(nb)
So you have to write
short *source;
DWORD *stereo_source;
DWORD v;
short l,r;
unsigned int i;
GetSongSamples(pos,nb,(short**)& source);
stereo_source = (DWORD*) source;
for(i=0;i<nb;i++)
{
v = stereo_source [ i] ;
l = LEFTCHAN(v) ;
r = RIGHTCHAN(v);
}
_____________________________________
fyi, if you only want to work in mono samples:
short *source;
short l,r;
unsigned int i;
GetSongSamples(pos,nb,(short**)& source);
for(i=0;i<2*nb;i+=2) // reads 2 by 2
{
l = source[ i];
r = source[ i+1]
}
or another way to write it (if you define 'j' as if i=2*j):
short *source;
short l,r;
unsigned int j;
GetSongSamples(pos,nb,(short**)& source);
for(j=0;j<nb;j++)
{
l = source[2*j];
r = source[2*j+1]
}
Posted Mon 12 Dec 11 @ 9:17 am
Nice and clear explanation DJCEL
Thank you !
Thank you !
Posted Mon 12 Dec 11 @ 4:25 pm
You are welcome.
Posted Tue 13 Dec 11 @ 1:45 pm
I have a question, I recently got a VFX-1 controller but I am using VESTAX TYPHOON w/VDJ. can I use it toguether and if so where can I find a manual on how to plugg/use it?
Thanks
Thanks
Posted Mon 16 Sep 13 @ 5:46 pm
Please ask your question on the right forum: http://www.virtualdj.com/forums/31/Hardware_Technical_Support.html
Also don't ask on irrelevant threads!
Topic Locked!
Also don't ask on irrelevant threads!
Topic Locked!
Posted Tue 17 Sep 13 @ 1:03 am