i need some help to convert a source code from pure basic to db
Sub PlotSpectrum(byval hWnd as HWND, byval dc as HDC, byval mode as integer)
Dim as integer x,x1,y,y1
Dim as integer py,i
Dim fft(512) as single
Dim cor as COLORREF
'Get module FFT data
BASS_ChannelGetData( module, @fft(0), BASS_DATA_FFT1024 )
'Draw our background (display image)
GetDIBits( _
dc, _ ' handle of device context
hDisplayBMP, _ ' handle of bitmap
0, _ ' first scan line to set in destination bitmap
GRAPHICWINDOW_HEIGHT, _ ' number of scan lines to copy
@GraphicWindowBitmapData(0), _ ' address of array for bitmap bits
@GraphicWindowBitmap, _ ' address of structure with bitmap data
DIB_RGB_COLORS _ ' RGB or palette index
)
'Update music timer
UpdateMusicTime()
'Draw scroller text
DrawScrollerText()
'Choose one type of spectrum analyzer
if mode = 0 then
'Draw spectrum mode = 0 - Freq
for x = 0 to SPECWIDTH-1
y = Sqrt(fft(x + 1))* Sqrt(x/30) * 2 * SPECHEIGHT - 4 'scale it (sqrt to make low values more visible)
if (y > SPECHEIGHT-1) then y = SPECHEIGHT - 1
py = 0
for y1 = 0 to y-1
if(py > SPECHEIGHT-1) then py = SPECHEIGHT - 2
GraphicWindowBitmapData((GRAPHICWINDOW_WIDTH * py) + x).rgbRed = 0
GraphicWindowBitmapData((GRAPHICWINDOW_WIDTH * py) + x).rgbGreen = 0
GraphicWindowBitmapData((GRAPHICWINDOW_WIDTH * py) + x).rgbBlue = 0
py += 2
next
next
else
'Draw spectrum mode = 1 - Bars
Dim as integer BANDS = 30
Dim as integer Bar_W = SPECWIDTH/BANDS-5
Dim as double sum
Dim as integer sc,b0,b1
for x = 0 to BANDS-1
sum = 0
sc = 0
b1 = pow(2.0,(x*10.0/(BANDS-1)))
if (b1>511) then b1 = 511
if (b1<=b0) then b1 = b0 + 1
sc = 10 + b1 - b0
for b0 = b0 to b1-1
sum += fft(1 + b0)
next
y = (Sqrt(sum/log10(sc))*1.0*SPECHEIGHT)-4
if (y > SPECHEIGHT) then y = SPECHEIGHT
py = 0
for y1 = 0 to y-1
if(py > SPECHEIGHT-1) then py = SPECHEIGHT - 2
for x1 = 0 to Bar_W
GraphicWindowBitmapData((GRAPHICWINDOW_WIDTH * py)+x1 + x * (SPECWIDTH/BANDS)).rgbRed = 0
GraphicWindowBitmapData((GRAPHICWINDOW_WIDTH * py)+x1 + x * (SPECWIDTH/BANDS)).rgbGreen = 0
GraphicWindowBitmapData((GRAPHICWINDOW_WIDTH * py)+x1 + x * (SPECWIDTH/BANDS)).rgbBlue = 0
next
py += 2
next
next
end if
its a source code from a spectrum like winamp for a modplay (with permission from the author)
but im not hell enough for it...
my trans looks like this : (not WORKING)
spectrum:
for t = 0 to BANDS-1
sum = 0
sc = 0
b1 = 100+x/(bands-1) :rem (x+10.0/BANDS-1)
if b1>=511 then b1 = 511
if b1<=b0 then b1=b0+1
sc = 10+b1-b0
for asi = b0 to b1-1
sum = fft(1+b0)
next
y = (sqrt(sum/(sc))*1.0*specheight)-4
if y>= specheight-1 then py = specheight
py = 0
next
for asi1 = y1 to y-1
if py>= specheight-1 then py = specheigth -2
for asi2 = x1 to bar_W
rem
next
py = 2
next
rem Call Dll 1,"BASS_ChannelGetData",hmod,bank,BASS_DATA_FFT1024
return
many thx mcq