0
0

Hey,
I am trying to load a mp3 into memory and then play it. (In Visual Basic)
It works with a regular wav file, but it doesn’t work with mp3 files.
I do the following :
Stream = FSOUND_Stream_OpenFile2(MP3Memory(0), FSOUND_LOADMEMORY Or FSOUND_2D, UBound(MP3Memory))
Channel = FSOUND_Stream_Play(fsound_free, Stream)

As I said, it works with wavs (when specifying FSOUND_16bit and FSOUND_STEREO), but it doesn’t recognize mp3’s, it always plays raw data withouth decoding.
Now in the documentation it says :
[quote:3izlt728]FSOUND_MPEGACCURATE is to be used cautiously. … A way to speed up this process would be to load the compressed mp3 into memory first, and use the FSOUND_LOADMEMORY flag with this function.[/quote:3izlt728]
So it should be possible to load a mp3 into memory, but I don’t know what flags to add to the mode I think. (I use FMod v3.5)

  • You must to post comments
0
0

You can also make your own “very large” numbers using a technique similar to LARGE_INTEGER.
[code:1zhyfjbx]Public Type LongLong ‘ virtual 64-bit
High As Long
Low As Long
End Type
Public Type LongLongLong ‘ virtual 128-bit
High As LongLong
Low As LongLong
End Type
Public Type LongLongLongLong ‘ virtual 256-bit
High As LongLongLong
Low As LongLongLong
End Type
// etc.[/code:1zhyfjbx]

  • You must to post comments
0
0

-sigh-
As far as I can tell this is a Visual Basic Bug!
The problem is that the constant FSOUND_LOADMEMORY is set to &H8000 which should be correct.
When I print the actual value (in decimal) it seems Visual Basic translates this to -32767 instead of +32767.
It’s really weird because &H10000 and higher give the expected results also.
Anyway, I’ve changed the value &H8000 in fmod.bas to 32767 and now my program is working fine.
I have Visual Studio SP5. I don’t know if this bug is fixed in SP6…

  • You must to post comments
0
0

I think it is because VB doesn’t support signed int, i read it in a MS doc some years ago.

<font size=-1>[ This Message was edited by: KarLKoX on 2002-02-16 08:21 ]</font>

  • You must to post comments
0
0

Yes, that’s what I meant :smile:
I haven’t found problems with the other values yet, but I guess it wouldn’t hurt to change them to decimal values too.

  • You must to post comments
0
0

Greetings !

I have also the same problem with streaming mp3’s from memory. If I load wav’s from memory everything is cool but is does not work correctly with mp3’s.

I use Free Pascal 32 Bit (delphi mode)…

Don’t know what’s wrong, it is as if the
song is forwarded when I try to play it
and then only plays the last seconds.

Very mysterious, hope anybody of you
knows the problem ?

  • You must to post comments
0
0

Hi Folks,

This is not a bug of VB, but rather a small mistake made by the one who has developed fmod.bas. As serac (a guy of this forum) pointed it out in another topic, the problem comes from the fact that &H8000 is interpreted in VB as a signed value, therefore all bit combinations expected bigger in value than the middle of the domain covered by the 2 bytes turn to negative values.

So what you have to do is to modify &H8000 to &H8000& (add an extra ampersand to the end) that indicates that the value preceding it should be considered as an unsigned value.

Therefore you’ll get 32768 instead of the really improper -32767.

Thanks to the serac, who initially made this kind of note, neither I knew about it before.

  • You must to post comments
0
0

Thanks for remembering my post, e-Musty… I feared I would have to re-post it. :-)

Technically, adding the ampersand doesn’t make the number signed. Rather it actually makes the number a Long integer (32-bit). (All numbers in VB are signed, except Byte which can only be unsigned.) Without the ampersand, you are left with a “short” Integer (16-bit), which of course cannot have the value 32768.

The best trick is to assume all “flag-like” constants are Long and to always include the trailing ampersand.

Edit:
Note that even with “Long”s… &H80000000& (2147483648) is actually -2147483647.

Edit:
Sorry… I’ve got my math wrong… The value is -2147483648. (Dunno why I thought to subtract one.)

  • You must to post comments
0
0

[quote="Megelan":1803l82e]Greetings !

I have also the same problem with streaming mp3’s from memory. If I load wav’s from memory everything is cool but is does not work correctly with mp3’s.

I use Free Pascal 32 Bit (delphi mode)…

Don’t know what’s wrong, it is as if the
song is forwarded when I try to play it
and then only plays the last seconds.

Very mysterious, hope anybody of you
knows the problem ?

[/quote:1803l82e]

I have not encountered this problem when playing MP3s from memory in Delphi. Perhaps you could post some sample code that exhibits the problem?

  • You must to post comments
0
0

Serac, what about declaring those constants with explicit type declaration? Why not to write [code:3glomra7]Private Const aVariable As Long = &H800000&[/code:3glomra7]

Wouldn’ it solve our problem? If yes, I think I’d change all such definitions in fmod.bas and send it back to Brett to include it in future versions of FMOD.

Sorry Sly, I’ve never used Delphi, so I can’t help you, but if you find some others encountering the problem, you might check for the correctness of your header (or header-like) file shipped with FMOD. Since all of us are human, the folks at FMOD might also missed some characters at some point, since this is a very large system :-)

  • You must to post comments
0
0

(Without testing first…) The following lines of code should be interpreted differently.
[code:24onxjm3]Public Const MyConstant As Long = &H8000 ‘ Should equal &Hffff8000& in the end.
Public Const MyConstant As Long = &H8000& ‘ Should equal &H00008000& in the end.[/code:24onxjm3]
This is because “&H8000” and “&H8000&” are literals. “MyConstant” is being declared as a Long, so that means the literal on the other side of the equals should be converted (if needed) to a Long type. So adding “As Long” should not have any direct effect on the literal. Only a trailing ampersand can ensure it is interpreted as a Long.

Now, I’ve not tested this. I’m running on memory here.

  • You must to post comments
0
0

Well, man, it seems that most likely we have only one option. Let’s develop a petition to be issued to Microsoft and claiming for introducing a new type, called VeryLong to be introduced into VB :-)

  • You must to post comments
Showing 11 results
Your Answer

Please first to submit.