0
0

I am looking to integrate fmod with my visual basic project but am running into some questions as I progress.

1) how do you play wmas? I see it mentioned constantly that you can do it, but it doesn’t work in the vb demos on the site, and when I swap in a wma in place of an .ogg that did work I get nothing, so there must be a trick.

2) Can you play sounds from a resource file? Currently I am playing wavs with sndplaysound using a loadresdata function to populate an an array. Obviously you don’t want your sound files exposed (this is a game) so I need to play from a resource.

Thanks for the help,
Pete

  • You must to post comments
0
0

[quote="Paranoid_Android":irwed65a]
I agree, I’d be happy to make new VB examples for you. The current ones are out of date and they arent coded very well. Email me if you are interested.[/quote:irwed65a]
I have already started working on new examples, and have sent the first one to brett.
He said he was going to add it soon.

As for the problem of loading the files :
If you are using the latest fmod 3.70 dll, you should also be using the fmod.bas that came with it. FSOUND_Stream_Open2 should have an extra parameter.
So instead of
[code:irwed65a]FSOUND_Stream_Open2(SoundArray(0), FSOUND_LOADMEMORY, UBound(SoundArray)[/code:irwed65a]
You should have
[code:irwed65a]FSOUND_Stream_Open2(SoundArray(0), FSOUND_LOADMEMORY, 0, UBound(SoundArray)+1)[/code:irwed65a]

  • You must to post comments
0
0

if either of you guys would be willing to send me your example demos you can send them to pete @ gagelabs . com (without the spaces)

Thanks alot
Pete

p.s. I am unfamiliar with fsb but if thats an external resource file, thats fine…the main issue is I don’t want my sounds all exposed in my data directory.

  • You must to post comments
0
0

[quote="pgage":2h39yi76]
p.s. I am unfamiliar with fsb but if thats an external resource file, thats fine…the main issue is I don’t want my sounds all exposed in my data directory.[/quote:2h39yi76]

If you look in your FMOD directory under the Tools folder you should find fsbank.exe. Open it, first set the source directory (where all of your sounds are located) and then set the destination directory (where it will be compiled to) and then just click build. It will build 1 FSB file containing all of your sounds. And in VB to play your sounds first open it as a stream, then use FSOUND_Stream_SetSubStream(Stream, Index), where index is the index number of the sound you want to play. Then simply use Fsound_Stream_Play.

  • You must to post comments
0
0

thanks for the response, brett.

I looked into playing from a resource. I use LoadResData(index, format) to get the wav data into an array, but from their I don’t know how to determine its length as required by FSOUND_Sample_Load. For that matter I don’t even know if its in the right format. I couldn’t find a demonstration of this anywhere, although I found mention that it should “only take a line of code.” hmmm.

Your comment about the codec raises a question – is there a codec or external resource required to play a wma? The reason I ask is for distribution – I tried fmod on a stock windows 98 system and it played an .ogg fine, but if there is more needed to play a wma I will just stick with .ogg. I would prefer .wma for file size but its not that big of a difference, and being compatible with old systems is much more of an issue.

Thanks,
Pete

edit: on the playing a .wma issue, I am basically copying the code from the sample
[code:1s759645]
Public stream1 As Long ‘the stream we open
Public channel1 As Long ‘the channel we play the stream in

If FSOUND_Init(44100, 32, FSOUND_INIT_GLOBALFOCUS) = 0 Then
‘Error
MsgBox "An error occured initializing fmod" & vbCrLf & FSOUND_GetErrorString(FSOUND_GetError)
End
End If
stream1 = FSOUND_Stream_OpenFile(App.Path & "/data/test.wma", FSOUND_2D, 0)
channel1 = FSOUND_Stream_Play(FSOUND_FREE, stream1)
[/code:1s759645]

the above code works fine with test.ogg, but not the wma. I actually couldn’t get the program in samples/fmod to play either format. And for what its worth I am using XP home, and have no problem with either format using media player.

  • You must to post comments
0
0

thanks android, I will give that a try.

Tell me though, don’t I want to play sounds like button clicks from memory rather than stream it each time? Obviously streaming the music oggs make sense.

Pete

  • You must to post comments
0
0

Hi Pgage,

Don’t bother using WMAs, just stick with OGG,
about file size vs. quality OGG doens’t give in to
WMAs.
OGG is free to use, WMA I don’t know for sure
but since it is Micro$oft$ I don’t think it can be
used without paying.
And the best part, we all (at least I think) love
OGG more then we hate WMA.

Good Luck.

  • You must to post comments
0
0

once again I am stymied.

This works:
stream1 = FSOUND_Stream_Open(App.Path & “/data/int.wav”, FSOUND_2D, 0, 0)
channel1 = FSOUND_Stream_Play(FSOUND_FREE, stream1)

but this doesn’t

stream2 = FSOUND_Stream_Open(App.Path & "/data/boozle.fsb", FSOUND_2D, 0, 0)
  samplehandle = FSOUND_Stream_SetSubStream(stream2, 1)

channel2 = FSOUND_Stream_Play(FSOUND_FREE, samplehandle)

the fsb seems to compile fine…it should be finding it…no errors, but no sound :(

Pete

  • You must to post comments
0
0

well thats ok for wma then. I will just use ogg, which is fine.

I would like to be pointed in the direction of some info on how to use fmod with sound files saved to the resource file though.

I am using LoadResData(index, format) to get the data into a byte array but from there I am not sure what to do to get fmod to be able to deal with it.

I tried replacing my existing sndplaysound commands with the fmod equivalent…

[code:1c0frh28] SoundArray = LoadResData("mouseover2", "WAVE")
‘comment out> RetValue = sndPlaySound(SoundArray(0), SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)

stream1 = FSOUND_Sample_Load(FSOUND_FREE, SoundArray, FSOUND_LOADMEMORY, UBound(SoundArray))
channel1 = FSOUND_Stream_Play(FSOUND_FREE, stream1)

[/code:1c0frh28]

but with no success :(

Pete

  • You must to post comments
0
0

you have to play the stream the second time.
As you can see at http://52.88.2.202/docs/HTML/FSOUND_St … tream.html

This function only returns true or false. You will have to use the stream handle ‘stream2’ to actually play it.

  • You must to post comments
0
0

well my hope was that ubound(soundarray) would return the length of the array. I can’t find any information on getting the length of the data block for the individual files in resource. Thus my difficulty…

the sndPlaySound(SoundArray(0), SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
command didn’t need the length to play the sound so it wasn’t an issue. I would just continue using sndplaysound, since it works for playing wavs, and use fmod for .oggs, but fmod seems to take over the soundcard in some instances, so the 2 can’t coexist. Fmod would be a better solution all around anyway – I just need to be able to play from a resource file.

thanks for the help,
Pete

  • You must to post comments
0
0

[code:27nvcgxy] stream2 = FSOUND_Stream_Open(App.Path & "/data/boozle.fsb", FSOUND_2D, 0, 0)
samplehandle = FSOUND_Stream_SetSubStream(stream2, 1)
channel2 = FSOUND_Stream_Play(FSOUND_FREE, stream2)[/code:27nvcgxy]

doesn’t seem to work either…

Pete[/code]

  • You must to post comments
0
0

[quote="pgage":1cg1zlil]well thats ok for wma then. I will just use ogg, which is fine.

I would like to be pointed in the direction of some info on how to use fmod with sound files saved to the resource file though.

I am using LoadResData(index, format) to get the data into a byte array but from there I am not sure what to do to get fmod to be able to deal with it.

I tried replacing my existing sndplaysound commands with the fmod equivalent…

[code:1cg1zlil] SoundArray = LoadResData("mouseover2", "WAVE")
‘comment out> RetValue = sndPlaySound(SoundArray(0), SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)

stream1 = FSOUND_Sample_Load(FSOUND_FREE, SoundArray, FSOUND_LOADMEMORY, UBound(SoundArray))
channel1 = FSOUND_Stream_Play(FSOUND_FREE, stream1)

[/code:1cg1zlil]

but with no success :(

Pete[/quote:1cg1zlil]

A problem that I see is that you use FSOUND_Sample_Load to open it, yet use FSOUND_Stream_Play to play.

For music you will probably want a stream, so you should use FSOUND_Stream_Open2 (the 2 is the second declaration of this function in vb, which doesn’t require a filename, but the first entry from your array.
UBound(SoundArray) will give you the length of the array, and the array is an array of bytes, so this will give you the size of the resource data.
You have to remember though, that Visual Basic’s arrays start at index 0, and go up to UBound(SoundArray), so there are UBound(SoundArray) + 1 bytes in total in the array.
This is what you should pass as the size.

  • You must to post comments
0
0

hey it works :)

And it plays pretty fast streaming, although I still think I will want to set it up to play from memory.

thanks for the help everyone
Pete

  • You must to post comments
0
0

Thanks for the info, Albion,

I triedd this:
[code:nbst763k]
SoundArray = LoadResData("mouseover2", "WAVE")
stream1 = FSOUND_Stream_OpenFile(SoundArray(0), FSOUND_LOADMEMORY, UBound(SoundArray) + 1)
channel1 = FSOUND_Stream_Play(FSOUND_FREE, stream1)[/code:nbst763k]
and
[code:nbst763k] SoundArray = LoadResData(“mouseover2”, “WAVE”)
stream1 = FSOUND_Stream_Open2(SoundArray(0), FSOUND_LOADMEMORY, UBound(SoundArray) + 1)
channel1 = FSOUND_Stream_Play(FSOUND_FREE, stream1)[/code:nbst763k]
and wasn’t able to get any sound out of either instance. You mentioned I would want to stream music-which is true, but in this case I am trying to play ingame sounds (like a mouseover beep) so would prefer not streaming these sounds from disk. Though I think the first step is just getting them to play, regardless of the method.

Thanks,
Pete

  • You must to post comments
0
0

[quote="brett":2g4v758u]I dont think the VB examples are written to well as i get some issues as well trying to get them to work, i think we need to replace these with some simpler examples that do 1 thing like play a stream, like the C examples.[/quote:2g4v758u]

I agree, I’d be happy to make new VB examples for you. The current ones are out of date and they arent coded very well. Email me if you are interested.

  • You must to post comments
0
0

[quote="pgage":2hkj1t2g] I am trying to play ingame sounds (like a mouseover beep) so would prefer not streaming these sounds from disk. Though I think the first step is just getting them to play, regardless of the method.
[/quote:2hkj1t2g]

I’m not sure if it was meant for this but what you could do is compile an FSB file with all of your ingame sounds. You would have to open it in FMOD as a stream and use FSOUND_Stream_SetSubStream to seek through the file and find whatever sound you need during your game. Since FSB files are only supported through FMOD it could be an alternative to using a resource file.

  • You must to post comments
Showing 16 results
Your Answer

Please first to submit.