Haaa!!!! Found a trick to make it work!
It gives immediate results, doesn't crash, doesn't mess anything really :P Basically what it's doing to the buffer is empty it every 1/60th of a second (screen refresh).
Include "includes\bass.bb" Include "includes\bassrecord.bb" Const BASSMAXIMUM%=60 ;Spektrum-Balkenhöhe Const BASSSMOOTH#=4 ;Horizontale-Weichzeichnerstärke Const PEAKBASSAGRESSIVITY%=16 ;Peakagressivität spectrum = CreateBank(1024) ; bank for data transfer to make the visualisation NPeakBank= CreateBank(1024) ;Umgerechneter-Spectrumanalyser APeakBank= CreateBank(1024) ;Alter-[NPeakBank]-Für-Differenzberechnung LPeakBank= CreateBank(1024) ;Background-Falling-Lines-Position RXPosBank= CreateBank(256) ;Reale-Lese-Position-Einer-Bank*4 For Q=0 To 255 PokeByte(RXPosBank,Q,Floor(Q/8.0+(Q*Q*Q/106000))) Next Global buffersize% = 4096 Global volume = 100 Graphics 640,480,32,2 SetBuffer BackBuffer() Global myinput = 5 ; for my SBLIVE, default here HWND = BASS_HWND() BASS_Init(-1,44100,0,HWND,BASS_NULL) BASS_RecordInit (0) BASS_RecordSetInput (myinput,BASS_INPUT_ON) ; we switch to the input BassHandle% = BASS_RecordStartInt(44100,2,0,0,0) ; BASS_RecordStart but without callbacks Global in% = BASS_RecordGetDeviceCount() -1 ;the first input = 0 so -1 While Not KeyHit (1) Cls Color 255,0,0 Text 0,0,"Bass Record Tutorial 2" device$ = BASS_GetDeviceDescriptionString(1) Text 0,20,"First (real) Hardware : "+device ; the soundcart (1 = first because 0 = nosound Color 255,255,0 port$ = BASS_RecordGetDeviceDescriptionString(0); the selected hardware for inputs (0=first) Text 0,40,"Recording Hardware : " + port indev$ = BASS_RecordGetInputNameString(myinput) ; get the name of the selected input Text 0,60,"Selected Input : "+indev Switch() Text 0,410,"Use keys 1<->9 to select an input. Now you have input "+(myinput+1) +" of "+(in+1) BASS_RecordSetInputVolume (myinput,volume) ; 1.5 seconds delay. What you see is the end of the recording buffer. You can make other visualisations ; with the BASS_DATA_AVAILABLE flag, see the docs for this. buffersize = BASS_ChannelGetData(BassHandle,spectrum,BASS_DATA_FFT512 Or BASS_DATA_AVAILABLE) Text 0,80,"Buffer size :"+buffersize For Q=0 To 255 Step+1 PokeFloat(APeakBank,Q*4,PeekFloat(NPeakBank,Q*4)) RXPos=PeekByte(RXPosBank,Q)*4 PeakLevel# = PeekFloat(Spectrum,RXPos) PeakLevel# = PeakLevel * (5+RXPos/2) PeakLevel# = 1 - (1.0 / (1 + PeakLevel / (8.0/PEAKBASSAGRESSIVITY))) PokeFloat(NPeakBank,Q*4,PeakLevel) Next PeakLevel#=PeekFloat(NPeakBank,0)/2 For Q=0 To 255 Step+1 PeakLevel# = PeakLevel - (PeakLevel - PeekFloat(NPeakBank,Q*4)) / BASSSMOOTH PokeFloat(NPeakBank,Q*4,PeakLevel) Next For Q=255 To 0 Step-1 PeakLevel# = PeakLevel - (PeakLevel - PeekFloat(NPeakBank,Q*4)) / BASSSMOOTH PokeFloat(NPeakBank,Q*4,2+PeakLevel*BASSMAXIMUM) Next For Q=0 To 255 Step+1 APeak#=PeekFloat(APeakBank,Q*4) NPeak#=PeekFloat(NPeakBank,Q*4) LPeak#=PeekFloat(LPeakBank,Q*4) DiffPeak#=APeak-NPeak If APeak>NPeak Then NPeak=APeak-DiffPeak/BASSSMOOTH*1 PokeFloat(NPeakBank,Q*4,NPeak) End If BassVerstaerker# = 8 - (8-NPeak) / 20000.0 DiffPeak# = Abs(DiffPeak) * WHITEBASSAGRESSIVITY If NPeak > LPeak Then LPeak = NPeak LPeak#=LPeak-.02-BassVerstaerker/100.0 PokeFloat(LPeakBank,Q*4,LPeak) Color 255-Q+DiffPeak*(1+Q/40), NPeak*4+DiffPeak, Q+DiffPeak Rect Q*2, 256 - APeak * 3, 2, APeak * 3, 1 Rect Q*2, 256, 2, APeak * 3, 1 Next buffersize = BASS_ChannelGetData(BassHandle,spectrum,BASS_DATA_FFT512 Or BASS_DATA_AVAILABLE) If KeyHit (59) Then volume = volume - 5 If KeyHit (60) Then volume = volume + 5 If volume < 0 volume = 0 If volume > 100 Then volume = 100 Color 255,255,255 Text 0,430,"Use keys F1 and F2 to change the input volume : "+volume +" Text 0,450,"ESC to exit" Flip Wend FreeBank spectrum BASS_RecordFree() BASS_Free() End Function Switch() For i = 0 To in If KeyHit(i+1) Then myinput = i - 1 BASS_RecordSetInput (myinput,BASS_INPUT_ON) EndIf Next End Function
It gives immediate results, doesn't crash, doesn't mess anything really :P Basically what it's doing to the buffer is empty it every 1/60th of a second (screen refresh).