0
0

I really need to use Winamp plugins with FMOD, please someone save me !

// FMOD
FSOUND_STREAM *STRM;
FSOUND_DSPUNIT *DSP;
int channel;
static signed short *pcmBuffer=NULL;
static int iBufferOffset =0; // offset in the buffer

void* dsp_vis_callback(void *originalbuffer, void *newbuffer, int length, int param)
{
//int mixertype = FSOUND_GetMixer();
int count; // our counter
int totalblocks; // don’t exced the totalbock calculated from the buffersize
signed short *dest; // destination pointer in wich we stock our data
signed short *src = (signed short *)newbuffer; // source pointer from the data

totalblocks = FSOUND_DSP_GetBufferLengthTotal() / FSOUND_DSP_GetBufferLength(); 
    dest = &pcmBuffer[iBufferOffset * FSOUND_DSP_GetBufferLength()];
    for (count=0; count < length; count++)
    {
        //  (((int)src[count << 1] + (int)src[(count << 1) + 1]) >> 1);     <-- TEST : 16 bits mono
        dest[count] = (signed short)(src[count]);                       //<-- 16 bits stereo 
    }   



//iBufferOffset += length*2;                                                
iBufferOffset++;
if (iBufferOffset >= totalblocks)
{
    iBufferOffset = 0;
}


// the buffer is not altered, so keep it clean and return it
return newbuffer;

}

/*———————————————————————————-

The main timer where we render the Data, it must be well coded for speed reasons …
Intervall is set from the DelayMS member of the VisModule member

———————————————————————————-*/
BOOL CALLBACK vis_time_event(UINT uId, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{

INT  id, offset;
HWND LB_Hwnd = GetDlgItem(mainhwnd,IDC_PLUGINSLIST);
INT  rendered;
signed short *src;
//signed char *dest;
HWND hCombo = GetDlgItem(mainhwnd,IDC_COMBO1);  
INT  module = SendMessage(hCombo, CB_GETCURSEL, 0, 0 );


// we have at least ONE module 
if ( module < 0 ) module = 0;

id = SendMessage(LB_Hwnd, LB_GETCURSEL, 0, 0);

// Very important : we MUST test this flag !
if (Vis_Enable_Rendering = 1)
{

//    The next pcmblock (iBufferOffset + 1) is the one that is audible.

offset = (iBufferOffset + 1) * FSOUND_DSP_GetBufferLength();
if (offset >= FSOUND_DSP_GetBufferLengthTotal())
{
    offset -= FSOUND_DSP_GetBufferLengthTotal();
}

src = &pcmBuffer[offset];           // <-- TEST : seeking for speed improvement ...

//OK : convert the data to 8 bit then send it to the plugin
Cnv16to8(&pcmBuffer[offset], &gs_vWinAmpProps[id].pModule->getModule(0)->waveformData[0][0], vis_Plugin_Samples);
Cnv16to8(&pcmBuffer[offset]+2, &gs_vWinAmpProps[id].pModule->getModule(0)->waveformData[1][0], vis_Plugin_Samples);


    rendered = gs_vWinAmpProps[id].pModule->getModule(0)->Render(gs_vWinAmpProps[id].pModule->getModule(0));
    //if ( rendered = 1) PostThreadMessage(dwVis_hThreadId, WM_QUIT, 0, 0); <-- in theory it is the right way, doesn't work ..

}


return FALSE;

}

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.