FMOD: Improved Spectrum Analyser?

BlitzMax Forums/BlitzMax Programming/FMOD: Improved Spectrum Analyser?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi guys!

Anyone here that ever made a Winamp(tm) like spectrum anaylser with fmod?



So far I have only managed to come up with this. But that's not half as good as it should be... :/

Example: (you need a tune and the fmod.dll inside your folder!)
'Grisu's little & crappy Spectrum analyser using fmod 3.5

Graphics 800,600,0

FSOUND_Init(44100, 32,FSOUND_INIT_ACCURATEVULEVELS)
FSOUND_DSP_SetActive(FSOUND_DSP_GetFFTUnit(), True)

Function Refresh_Spectrum()
Local spec:Byte Ptr= FSOUND_DSP_GetSpectrum()
            Local bnk:TBank =Null
        	bnk:TBank = CreateStaticBank(spec,512*4)
            SetBlend Alphablend
			SetAlpha 0.6
			For Local x:Int=0 To 253 'Step 2
					Local yp:Int=(PeekFloat(bnk,x*4)*500)
					SetColor (x/8*32,x/8*16,(128)+x/8*2)
                    yp=yp*4 
                    If yp>60 Then yp=60
					DrawLine 40+x,274+60-yp,40+x,274+60
			Next
End Function  

Music=FSOUND_Stream_Open("trailer_120.ogg",FSOUND_LOOP,0,0) ' <- Insert a tune here!
FSOUND_Stream_Play(FSOUND_FREE,music)

Repeat
	
	Cls()

	SetAlpha 0.1 ' Draw grey rectangle area of maximum visualisation.
    SetColor 255,255,255
	DrawRect 40,0,336,336

    Refresh_Spectrum()	
	
	Flip()
	
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

FSOUND_Stream_Close(music)
Fsound_Close()

End


Another problem is that when I turn down the volume of a tune the size of the spectrum bars shrinks accordingly. Any way to prevent that from happening? (So that the maximum width and height stay the same all time.)

Thanks in advance!
Grisu