Posts: 489
Threads: 34
Joined: Jan 2005
how do i use the function FSOUND_Stream_FindTagField? the syntax is :
signed char F_API FSOUND_Stream_FindTagField(
FSOUND_STREAM *stream,
int type,
const char *name,
void **value,
int *length
);
but how would i do this in fb? i tried
Code: dim shared pointr as byte ptr,tag as string ptr,length as double ptr
t%=FSOUND_Stream_FindTagField(Channel,FSOUND_TAGFIELD_TYPE,"Title",pointr,length)
but it crashes.
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 6,419
Threads: 74
Joined: Mar 2002
Why don't you use the included header for FMOD? It was adapted from the VB module included in the FMOD win32 package and it works.
Posts: 922
Threads: 15
Joined: Jun 2003
Seems to be a pointer to pointer, you should pass @pointr -- i'm guessing the prototype is right, didn't check it -- if it's not BYVAL, you must do BYVAL @pointr when calling the proc.
Posts: 489
Threads: 34
Joined: Jan 2005
gah...
tried out what both of you said, both caused a crash...
i looked in the include file and found the line
Code: Declare Function FSOUND_Stream_FindTagField Alias "_FSOUND_Stream_FindTagField@20" (ByVal stream As Integer, ByVal tagtype As Integer, ByVal name As String, ByRef value As Integer, ByRef length As Integer) As Byte
so i tried
Code: dim shared pointr as integer,tag as string ptr,length as integer
t%=FSOUND_Stream_FindTagField(Channel,FSOUND_TAGFIELD_TYPE,"Title",byref pointr,byref length)
but that crashed quickly.
so then i tried
Code: dim shared pointr as integer,tag as string ptr,length as integer
t%=FSOUND_Stream_FindTagField(Channel,FSOUND_TAGFIELD_TYPE,"Title",byval @pointr,byval @length)
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 489
Threads: 34
Joined: Jan 2005
could someone maybe give me a working example? please?
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 489
Threads: 34
Joined: Jan 2005
i found a c++ funciton for this. i think the problem is that the tag needs the type "void" but fb doesn't support this type. in other examples i found, a c-style cast (void **) was used, but i don't think fb allows this either. does anyone know a workaround?
Code: 00765 bool getTag (std::string &result, const char *tag, FSOUND_STREAM *stream)
00766 {
00767 void *name;
00768 int size;
00769 char tmp[512];
00770 int types[]=
00771 {
00772 FSOUND_TAGFIELD_ID3V1,
00773 FSOUND_TAGFIELD_ID3V2,
00774 FSOUND_TAGFIELD_VORBISCOMMENT,
00775 };
00776 uint i;
00777 for (i=0; i<sizeof(types)/sizeof(int); i++)
00778 {
00779 if (FSOUND_Stream_FindTagField(stream, types[i], tag, &name, &size))
00780 {
00781 strncpy (tmp, (const char*)name, min((int)sizeof(tmp),size));
00782 result = trim(tmp);
00783 return true;
00784 }
00785 }
00786 return false;
00787 }
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 489
Threads: 34
Joined: Jan 2005
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
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 922
Threads: 15
Joined: Jun 2003
NAME is a reserved word (it was misdeclared as RENAME on older versions).
Name$ = and FB thinks you are trying to use the NAME statement, change it to MusicName$ or something.
Btw, FSOUND_Stream_GetTagField wants a STREAM, not a CHANNEL, that code will crash.
Posts: 489
Threads: 34
Joined: Jan 2005
thanks a lot! it works now. my corrected code follows for anyone interested:
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 num as integer,tag as string ptr,byt as byte ptr
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
musicname$=mid$(MusicFile$,tehpos)
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_Stream_Open(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_Stream_Play(FSOUND_FREE,Handle)
print "now playing: "; musicname$
FSOUND_Stream_GetNumTagFields(Handle,num)
for i% = 0 to num-1
FSOUND_Stream_GetTagField(Handle,i%,tagtype%,naem%,pointr%,length%)
if tagtype%=2 then exit for
j%=0
tagname$=""
do
byt=naem%+j%
tagname$=tagname$+chr$(*byt)
j%=j%+1
loop while *byt<>0
tagdata$=""
for j% = 0 to length%-1
byt=pointr%+j%
tagdata$=tagdata$+chr$(*byt)
next
print lcase$(tagname$); " : "; lcase$(tagdata$)
'print naem$;*tag;tagtype%;pointr%;length%
next
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_Stream_Stop(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
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Posts: 544
Threads: 27
Joined: Jan 2005
Quote:NAME is a reserved word (it was misdeclared as RENAME on older versions).
Name$ = and FB thinks you are trying to use the NAME statement, change it to MusicName$ or something.
Btw, FSOUND_Stream_GetTagField wants a STREAM, not a CHANNEL, that code will crash.
I noticed that, in the Command Reference, NAME (or NAME$) is not listed. However, under PRINT, I found this:
name$ = "Linus"
print "Name: "; name$
Am I totally missing this?
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
|