darn, i upgraded to fbc 0.10b and now the code gives a syntax error for mid$! it works (ok, compiles but doesn't work b/c of the tag thing) on 0.09b. is that just an error in fbc, or is it an error with me?
Code:
'Simple FMOD test for FB
'by Plasma [11-16-2004]
'adapted by the unknown qb programmer [1-6-2005] for more support / other cool things
'commands to fmod in comments are for mod/midi format files
'changelog:
'1-6-2005
'-added support for modes, different paths, different extensions
'-more stable
DefInt A-Z
'$Include: 'fmod.bi'
Declare Sub ErrorQuit (Message$)
declare sub menu()
randomize timer
const FALSE = 0
dim Shared Handle As Long, Channel As Integer,musicroot$,songnum#,extenstions$,a$
dim shared pointr as string,tag as string ptr,length as integer
line input "root folder? (enter for shared docs/my music):",musicroot$
if musicroot$="" then musicroot$="c:\documents and settings\all users\documents\my music"
line input "types to play? (use wildcards, like *.mp3, *.*, etc)(enter=*.mp3):",extensions$
if extensions$="" then extensions$="*.mp3"
mode#=1
a$ = chr$(34)
shell "dir "+a$+musicroot$+"\"+extensions$+a$+"/b/s > database.txt"
open "database.txt" for input as #1
while eof(1)=0
input #1, whatever$
numlines#=numlines#+1
wend
close #1
do
cls
select case mode#
case 1
songnum#=songnum#+1
if songnum#>numlines# then
songnum#=1
end if
case 2
songnum#=songnum#+1
if songnum#>numlines# then
exit do
end if
case 3
songnum#=int(numlines#*rnd+1)
case is > 20
songnum#=songnum#-1
if songnum#<1 then songnum#=1
mode#=mode#-20
case else
mode#=mode#-10
end select
open "database.txt" for input as #1
for x# = 1 to songnum#-1
input #1, whatever$
next
line input #1, MusicFile$
close #1
tehpos=1
while instr(tehpos,MusicFile$,"\")>0
tehpos=instr(tehpos,MusicFile$,"\")+1
wend
Name$=mid$(MusicFile$,tehpos) ' <--------------------------------------- here
If FSOUND_GetVersion <= FMOD_VERSION Then
ErrorQuit "FMOD version " + STR$(FMOD_VERSION) + " or greater required"
End If
If FSOUND_Init(44100, 32, 0) = FALSE Then
ErrorQuit "Can't initialize FMOD"
End If
'Handle = FMUSIC_LoadSong(MusicFile)
Handle = FSOUND_Sample_Load(FSOUND_FREE,MusicFile$,FSOUND_MPEGACCURATE,null,null)
If Handle = FALSE Then
print "Can't load music file " + CHR$(34) + MusicFile$ + CHR$(34) + ", skipping..."
End if
'FMUSIC_PlaySong(Handle)
Channel=FSOUND_PlaySound(FSOUND_FREE,Handle)
print "now playing: "; Name$
t%=FSOUND_Stream_FindTagField(Channel,FSOUND_TAGFIELD_TYPE,"Title",byval @pointr,byref length)
't%=FSOUND_Stream_GetTagField(Channel,0,FSOUND_TAGFIELD_TYPE,tag,pointr,length#)
print pointr
print "press any key to advance, m for menu, p for previous, or x to exit"
do
key$=inkey$
if key$="m" then menu
if key$="p" then mode#=mode#+20
loop while key$="" and FSOUND_IsPlaying(Channel)<>FALSE
loop while key$ <> "x"
'FMUSIC_FreeSong(Handle)
FSOUND_Sample_Free(Handle)
FSOUND_Close
End
Sub ErrorQuit (Message$)
print "ERROR: "; Message$
FMUSIC_FreeSong(Handle)
FSOUND_Close
sleep
End 1
End Sub
sub menu()
print
print
print "menu"
print "----"
print "(1) choose file #"
print "(2) view current playlist"
print "(3) new path/parameters"
print "(4) change mode"
print "(5) quit menu"
print
do
key$=inkey$
loop while key$=""
select case val(key$)
case 1
input "#";songnum#
mode#=mode#+10
case 2
open "database.txt" for input as #1
while eof(1)=0
linenum#=linenum#+1
line input #1, file$
print linenum#; file$
wend
close #1
case 3
line input "path (enter=keep current):";musicrot$
if musicrot$<>"" then musicroot$=musicrot$
input "extension (use wildcard chars, eg:*.mp3)(enter=keep current):",extensio$
if extensio$<>"" then extensions$=extensio$
shell "dir "+a$+musicroot$+"\"+extensions$+a$+"/b/s > database.txt"
open "database.txt" for input as #1
while eof(1)=0
input #1, whatever$
numlines#=numlines#+1
wend
close #1
case 4
print "(1) loop mode"
print "(2) one time mode"
print "(3) shuffle mode"
do
key$=inkey$
loop while key$=""
mode=val(key$)
end select
end sub