快速登录:  

Forum: VirtualDJ Plugins

话题: Question about "OnGetSongBuffer"

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

Hi,
I don't understand why the sound keep playing when I use this code with OnGetSongBuffer.
This function is not the equivalent of GetSongSample (SDK6) ?

///*******************************************************************************************************************************
short* VDJ_API CMyPlugin8::OnGetSongBuffer(int pos, int nb)
{
// ADD YOUR AUDIO TREATMENT CODE HERE USING THE AUDIO BUFFER *buffer OF 2*nb SHORT SAMPLES (STEREO SIGNAL)
HRESULT hr;
short* buffer;
hr = GetSongBuffer(pos, nb, (short**)&buffer);

//Déclaration des variables de lecture/écriture des buffers
float SampleIn_Left, SampleIn_Right;
float SampleOut_Left, SampleOut_Right;
int i;

for (i = 0; i < nb; i++)
{
SampleIn_Left = buffer[2 * i] * 0;
SampleIn_Right = buffer[2 * i + 1] * 0;

// Gestion du buffer de sortie
buffer[2 * i] = SampleIn_Left;
buffer[2 * i + 1] = SampleIn_Right;

}
return buffer;
}
 

发表时间 Wed 16 Sep 20 @ 7:31 pm
djcelPRO InfinityModeratorMember since 2004
1) First comment : you are mixing float and short in your example.

Float is for DSP vdj plugin (value between -1.0f and 1.0f)

Here is only short sample

2) yes it is different from SDK6
 

发表时间 Fri 18 Sep 20 @ 6:07 pm
Oups... of course.
I'm still so bad at programming ;-)
Thank you for your support DJCEL !
 

发表时间 Sat 19 Sep 20 @ 7:53 am
I made the corrections. I only use Short variables but it doesn't cut the sound.
The code comes from the example from Topics SKD Developper / Audio Plugin (Buffer DSP).
I don't understand why it doesn't work...


//*****************************************************************************************
short* VDJ_API CMyPlugin8::OnGetSongBuffer(int pos, int nb)
{
//example from Topics SKD Developper / Audio Plugin (Buffer DSP)

HRESULT hr;
short* bufferShort;
hr = GetSongBuffer(pos, nb, (short**)&bufferShort);

//Déclaration des variables de lecture/écriture des buffers
short ShortSampleIn_Left, ShortSampleIn_Right;

for (int i = 0; i < nb; i++)
{
ShortSampleIn_Left = bufferShort[2 * i] * 0;
ShortSampleIn_Right = bufferShort[2 * i + 1] * 0;

// Gestion du buffer de sortie
bufferShort[2 * i] = ShortSampleIn_Left;
bufferShort[2 * i + 1] = ShortSampleIn_Right;
}

return bufferShort;
}
 

发表时间 Sat 19 Sep 20 @ 10:08 am
AdionPRO InfinityCTOMember since 2006
Working with float during processing is fine too if required for your purpose of course.
Anyway, did you check if OnGetSongBuffer is called in the debugger? Maybe the initialization of your plugin is not set to buffer plugin?
 

发表时间 Sat 19 Sep 20 @ 10:17 am
djcelPRO InfinityModeratorMember since 2004
So
Quote :
class CMyPlugin8 : public IVdjPluginBufferDsp8


Quote :
if (memcmp(&rclsid,&CLSID_VdjPlugin8,sizeof(GUID))==0 && memcmp(&riid,&IID_IVdjPluginBuffer8,sizeof(GUID))==0)


And what do you have for this line?

Quote :
infos->Flags = 0x00; // you could also use VDJFLAG_PROCESSAFTERSTOP if you want to process sound when the deck is stopped

 

发表时间 Sat 19 Sep 20 @ 2:30 pm
Thank you guys for your message..

Sorry. I didn't notice that the main.cpp was different.
Thank you DJCEL.
 

发表时间 Tue 22 Sep 20 @ 8:04 pm


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