1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
long __stdcall PROCESSING_MyCallback(void * lpUser, long nCommand, void * lpData, long nnn)
{
float gain,fzero=0.0f;
float * lpBufferIn;
float * lpBufferOut;
float signal;
int nuChannel,nbs, nuIn, nuOut;
LPT_APP_CONTEXT lpapp;
LPT_AUDIODSDPCTX lpctx;
VBVMR_LPT_AUDIOINFO pinfo;
VBVMR_LPT_AUDIOBUFFER lpa;
lpapp = (LPT_APP_CONTEXT)lpUser;
lpctx = &(lpapp->dsp);
switch(nCommand)
{
//--------------------------------------
// Init/End your object and allocate your memory
//--------------------------------------
case VBVMR_CBCOMMAND_STARTING:
pinfo = (VBVMR_LPT_AUDIOINFO)lpData;
break;
case VBVMR_CBCOMMAND_ENDING:
pinfo = (VBVMR_LPT_AUDIOINFO)lpData;
break;
case VBVMR_CBCOMMAND_CHANGE:
pinfo = (VBVMR_LPT_AUDIOINFO)lpData;
PostMessage(lpapp->hwnd_MainWindow,WM_COMMAND, IDM_RESTART,0);
break;
//--------------------------------------
// process buffer for Output INSERT
//--------------------------------------
case VBVMR_CBCOMMAND_BUFFER_OUT:
lpa =(VBVMR_LPT_AUDIOBUFFER)lpData;
nuChannel = lpctx->nuBusSelected * 8;
if ((nuChannel+8) > (lpa->audiobuffer_nbi-1)) break; //check that the given channels are existing
for (nuOut=0;nuOut<8;nuOut++)
{
//get pointer on output related to channel nuChannel
lpBufferOut = lpa->audiobuffer_w[nuChannel+nuOut];
//reset output bus
for (nbs=0;nbs < lpa->audiobuffer_nbs; nbs++) lpBufferOut[nbs]=fzero;
//compute bus from 8 input according gain matrix
for (nuIn=0;nuIn<8;nuIn++)
{
gain = lpctx->matrix_gain[nuOut][nuIn];
lpBufferIn = lpa->audiobuffer_r[nuChannel+nuIn]; //get pointer on input related to channel nuChannel
for (nbs=0;nbs < lpa->audiobuffer_nbs; nbs++)
{
signal= lpBufferIn[nbs] * gain; //apply gain to sample
lpBufferOut[nbs] +=signal; //accumulate in bus
}
}
}
//copy other channels (otherwise there will be no sound in other busses.
for (nuOut =0; nuOut < lpa->audiobuffer_nbi; nuOut++)
{
if ((nuOut < nuChannel) || (nuOut >= (nuChannel+8)))
{
lpBufferIn = lpa->audiobuffer_r[nuOut];
lpBufferOut = lpa->audiobuffer_w[nuOut];
for (nbs=0;nbs < lpa->audiobuffer_nbs; nbs++) lpBufferOut[nbs]=lpBufferIn[nbs];
}
}
break;
}
return 0;
} |
Partager