Hey, am I using BASS correctly?
Strict
Framework maxgui.win32maxgui
Import bah.bass
Import brl.directsoundaudio
Import brl.eventqueue
SetAudioDriver "directsound"
If Not tbass.init(-1,44100,0,Null,Null)
End
EndIf
Local window:tgadget=CreateWindow("WINDOW",0,0,320,240,Desktop(),1+WINDOW_TOOL+WINDOW_CENTER)
Local playb:tgadget=CreateButton("Play",5,5,50,24,window)
Local stopb:tgadget=CreateButton("Stop",60,5,50,24,window)
Local openb:tgadget=CreateButton("Open",115,5,50,24,window)
Local stream:tbasschannel
Local playing:Int
Local active:Int
Local musicbass:Int=False
Repeat
WaitEvent()
Select EventID()
Case event_windowclose
Select EventSource()
Case window
tbass.free()
End
EndSelect
Case event_gadgetaction
Select EventSource()
Case openb
Local f:String=RequestFile("Open","MP3 Files:mp3")
If f
If playing=True
stream.stop()
EndIf
stream=New tbassstream.CreateFile(f,0,0,0)
If Not stream
stream=New tbassmusic.fileload(f,0,0,BASS_MUSIC_RAMPS|BASS_MUSIC_PRESCAN,0)
If Not stream
tbass.free()
End
Else
musicbass=True
EndIf
EndIf
If Not stream.play(False)
Notify "Cannot play!",True
tbass.free()
End
EndIf
playing=True
EndIf
Case stopb
If stream.isactive()
stream.stop()
EndIf
Case playb
If stream
stream.play()
EndIf
EndSelect
EndSelect
If playing=True
If Not stream.isactive()
playing=False
EndIf
EndIf
Forever
|