29-01-2015, 10:46 AM
شكرا حقيقه لم افلح هذا الكود كاملا في السي
كود :
// scan the peaks
void __cdecl ScanPeaks(void *p)
{
DWORD decoder=(DWORD)p;
DWORD pos=0;
float spp=BASS_ChannelBytes2Seconds(decoder,bpp); // seconds per pixel
while (!killscan) {
float peak[2];
if (spp>1) { // more than 1 second per pixel, break it down...
float todo=spp;
peak[1]=peak[0]=0;
do {
float level[2],step=(todo<1?todo:1);
BASS_ChannelGetLevelEx(decoder,level,step,BASS_LEVEL_STEREO); // scan peaks
if (peak[0]<level[0]) peak[0]=level[0];
if (peak[1]<level[1]) peak[1]=level[1];
todo-=step;
} while (todo>0);
} else
BASS_ChannelGetLevelEx(decoder,peak,spp,BASS_LEVEL_STEREO); // scan peaks
{
DWORD a;
for (a=0;a<peak[0]*(HEIGHT/2);a++)
wavebuf[(HEIGHT/2-1-a)*WIDTH+pos]=1+a; // draw left peak
for (a=0;a<peak[1]*(HEIGHT/2);a++)
wavebuf[(HEIGHT/2+1+a)*WIDTH+pos]=1+a; // draw right peak
}
pos++;
if (pos>=WIDTH) break; // reached end of display
if (!BASS_ChannelIsActive(decoder)) break; // reached end of channel
}
if (!killscan) {
DWORD size;
BASS_ChannelSetPosition(decoder,(QWORD)-1,BASS_POS_BYTE|BASS_POS_SCAN); // build seek table (scan to end)
size=BASS_ChannelGetAttributeEx(decoder,BASS_ATTRIB_SCANINFO,0,0); // get seek table size
if (size) { // got it
void *info=malloc(size); // allocate a buffer
BASS_ChannelGetAttributeEx(decoder,BASS_ATTRIB_SCANINFO,info,size); // get the seek table
BASS_ChannelSetAttributeEx(chan,BASS_ATTRIB_SCANINFO,info,size); // apply it to the playback channel
free(info);
}
}
BASS_StreamFree(decoder); // free the decoder
scanthread=0;
}
سبحان الله و بحمده سبحان الله العظيم

