Creating Modules (BASS Mod)

BlitzMax Forums/BlitzMax Programming/Creating Modules (BASS Mod)

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.

Seem crash with blitzmax 1.22, after a while :( any idea ?


Strict

Import "bass.bmx"

'Ohne Win32 hinter der Funktion gibt es einen Absturz da sich die Aufrufkonventionen sonst unterscheiden
Function SaveMusicCallback(buffer:Byte Ptr, length:Int, user:Int)"Win32"
   Global FileStream:TStream
   
   If FileStream = Null
      FileStream = WriteFile("c:\dateidownload.mp3")
   EndIf
   
   If buffer = Null
      CloseFile(FileStream)
   Else
      For Local i:Int = 0 Until length
         WriteByte(FileStream, buffer[i])
      Next
   EndIf
   
End Function



Graphics 640,480,0


If not BASS_Init(1, 44100, 0, 0, Null)
   Notify("Fehler bei der Initialisierung")
   End
EndIf




'Beliebige MP3, MP2, MP1, OGG oder WAV Datei kann geladen werden

'Global MusicStream:Int = BASS_StreamCreateUrl("http://www.rektor.no/filarkiv/princesstream.mp3",0, BASS_STREAM_META|BASS_STREAM_STATUS,SaveMusicCallback,0)
Global MusicStream:Int = BASS_StreamCreateUrl("http://64.236.34.4:80/stream/1018",0, BASS_STREAM_META|BASS_STREAM_STATUS,SaveMusicCallback,0)
'Global MusicStream:Int = BASS_StreamCreateUrl("http://www.blitz3dfr.com/tempo/Andreas%20Vollenweider%20-%20Ascent%20From%20The%20Circle.mp3",0, BASS_STREAM_META|BASS_STREAM_STATUS,SaveMusicCallback,0)

If MusicStream = 0
   Notify("Musik konnte nicht geladen werden")
   End
EndIf

BASS_ChannelPlay(MusicStream,0)      


Repeat
   Cls
   
   Local Level:Int = BASS_ChannelGetLevel(MusicStream)
   Local LeftLevel:Float = LoWord(Level)/100.0
   Local RightLevel:Float = HiWord(Level)/100.0
   
   
   
   SetColor 255,0,0
   DrawRect 30,GraphicsHeight()-50, 100, -LeftLevel
   
   SetColor 0,255,0
   DrawRect GraphicsWidth()-160,GraphicsHeight()-50, 100, -RightLevel
   
   
   
   SetColor 255,255,255
   DrawText "BASS CPU: "+BASS_GetCPU(),10,10
   DrawText "Linker Level: "+LoWord(Level),10,30
   DrawText "Rechter Level: "+HiWord(Level),10, 50
   
   Flip
Until KeyDown(KEY_ESCAPE)