0
0

Hey Folks!

So, I’ve been banging my head a little; trying to take a very simple s3m player; and make it work with a file in memory. (I’m trying to cook together a music disk). Anyway; my 8 channel music file doesn’t seem to load right. It doesn’t crash; and it gives back a non-null module; but it doesn’t play and it doesn’t show ‘8’ if I tell it to spit out the number of channels.

However FMUSIC_LoadSong works fine.
I just don’t get it. I’m using fmodapi370win32

Any suggestions / help would be great!

Mucho thanks!

[code:1q9v2ydn]
Dim mod_data() As Byte
Dim mod_play As Long
Dim mod_size As Long
Dim mod_name As String

Private Sub Form_Load()
FSOUND_Init 44100, 32, FSOUND_INIT_GLOBALFOCUS

mod_name = "2nd_pm.s3m"


Open mod_name For Binary Access Read As #1
    mod_size = LOF(1)
    ReDim mod_data(mod_size)
    Get #1, , mod_data
Close #1

‘mod_play = FMUSIC_LoadSong(mod_name) ‘ works
mod_play = FMUSIC_LoadSongEx(VarPtr(mod_data(0)), 0, mod_size, FSOUND_LOADMEMORY, 0, 0)’doesn’t work

Debug.Print "channels:", FMUSIC_GetNumChannels(mod_play)

 FMUSIC_PlaySong mod_play

End Sub

Private Sub Form_Unload(Cancel As Integer)
FMUSIC_StopSong mod_play
FSOUND_Close
End Sub
[/code:1q9v2ydn]

  • You must to post comments
0
0

HELP!HELP!HELP! ๐Ÿ˜€

I’m tryng Polaris’s code and got some problem:

Actualy I’m using fmod.dll and fmod.bas v3.74 and this is the Polaris’s code:

[code:3np08dr1]Private Sub Form_Load()

Dim mod_data() As Byte
Dim mod_play As Long
Dim mod_size As Long
Dim mod_name As String
Dim dummy_long As Long

FSOUND_Init 44100, 32, FSOUND_INIT_GLOBALFOCUS

mod_name = "muzic.dat"

Open mod_name For Binary Access Read As #1
    mod_size = LOF(1)
    ReDim mod_data(mod_size)
    Get #1, , mod_data
Close #1
dummy_long = 0

‘this works
‘mod_play = FMUSIC_LoadSong(mod_name)

‘this doesn’t
mod_play = FMUSIC_LoadSongEx2(mod_data(0), 0, mod_size, FSOUND_LOADMEMORY, ByVal 0, 0)

FMUSIC_PlaySong mod_play

End Sub[/code:3np08dr1]

Section with FMUSIC_LoadSong working fine and music play without problem, but there’s no way to play music with FMUSIC_LoadSongEx2

Can you help me?? I need to play music from memory and not from file!!

Thanks!!!

  • You must to post comments
0
0

Hey there,

I did eventually get this working, despite the solution felt much less satisfying. The key was placing a pause between
FMUSIC_LoadSongEx2 and
FMUSIC_PlaySong mod_play.

The fact that it would be time dependent is a bit freaky. In the end, I ended up coding my project in C++ instead of visual basic for other reasons… so I just kind of brushed it off.

I’d suggest trying a pause there (sleep(some value)), and see if that makes a difference.

Good luck!

  • You must to post comments
0
0

Oh you’ve right!!!
Now it works… Thanks!!! ๐Ÿ˜€

After 1 year I think your project is ready… I also think to code in C++ but for now VB is more user friendly… Btw, are u using VB6 or VB.NET ?? And witch king of project u are working on?? I mean game, app, intro….

  • You must to post comments
0
0

I put the last parameter as one – as I found a piece of source code on the internet (in c) that had one. I tried both – and had no success.

  • You must to post comments
0
0

Thanks!

  • enjoy! *

Dim mod_data() As Byte
Dim mod_play As Long
Dim mod_size As Long
Dim mod_name As String

Private Sub Form_Load()
FSOUND_Init 44100, 32, FSOUND_INIT_GLOBALFOCUS
‘mod_name = "2nd_pm.s3m"

‘Open mod_name For Binary As #1
‘ mod_size = LOF(1)
‘ ReDim mod_data(mod_size – 1)
‘ Get #1, , mod_data
‘ Close #1

mod_data= LoadResData("2nd_pm", "s3m") ‘custom your resourse music data
mod_size= UBound(mod_data)

mod_play = FMUSIC_LoadSongEx2(mod_data(0), 0, mod_size, FSOUND_LOADMEMORY, ByVal 0, 0)

‘ You’ll probably want to add a timeout to this as well
Do
DoEvents
Loop While FMUSIC_GetOpenState(mod_play)

FMUSIC_PlaySong mod_play

End Sub

Private Sub Form_Unload(Cancel As Integer)
FMUSIC_StopSong mod_play
FSOUND_Close
End Sub

  • You must to post comments
0
0

Well, I’ve updated the code above with my most recent attempt…. but alas – no dice; it doesn’t work with a download this morning (9:21 cst) sept 15th. Perhaps a bug still lurks?

As for the last parameter – I was trying to get it to work; and searched for sample code on the internet. This page has 1 as the last parameter… despite it didn’t make sense – I tried it…

http://www.icculus.org/homepages/trick/ … 6-20.patch

Arrg. Hope we figure this out soon. ๐Ÿ˜•

  • You must to post comments
0
0

Hey there.

Well, I tried again. I dumped the memory to screen, and looked at the file on disk using a hex editor. I verified the SCRM; and the first bytes of what’s in memory compared to what’s on disk. The only thing I can figure is that I’m using the wrong technique to pass the pointer to the array (varptr(mod_data(0))… but If that’s the case – I’m not sure what I’m supposed to use.

Still stumped. ๐Ÿ˜ฅ
[code:3estcgfl]


*** From in the vb application (in dec – not hex) ***


: mod_data(0) : 85 : Byte : Form1.Form_Load
: mod_data(1) : 110 : Byte : Form1.Form_Load
: mod_data(2) : 114 : Byte : Form1.Form_Load
: mod_data(3) : 101 : Byte : Form1.Form_Load
: mod_data(4) : 97 : Byte : Form1.Form_Load
: mod_data(5) : 108 : Byte : Form1.Form_Load
: mod_data(6) : 32 : Byte : Form1.Form_Load
: mod_data(7) : 93 : Byte : Form1.Form_Load
: mod_data(8) : 91 : Byte : Form1.Form_Load
: mod_data(9) : 32 : Byte : Form1.Form_Load
: mod_data(10) : 47 : Byte : Form1.Form_Load
: mod_data(11) : 32 : Byte : Form1.Form_Load
: mod_data(12) : 80 : Byte : Form1.Form_Load
: mod_data(13) : 77 : Byte : Form1.Form_Load
: mod_data(14) : 0 : Byte : Form1.Form_Load
: mod_data(15) : 0 : Byte : Form1.Form_Load
: mod_data(16) : 0 : Byte : Form1.Form_Load
: mod_data(17) : 0 : Byte : Form1.Form_Load
: mod_data(18) : 0 : Byte : Form1.Form_Load
: mod_data(19) : 0 : Byte : Form1.Form_Load
: mod_data(20) : 0 : Byte : Form1.Form_Load
: mod_data(21) : 0 : Byte : Form1.Form_Load
: mod_data(21) : 0 : Byte : Form1.Form_Load
: mod_data(22) : 0 : Byte : Form1.Form_Load
: mod_data(23) : 0 : Byte : Form1.Form_Load
: mod_data(24) : 0 : Byte : Form1.Form_Load
: mod_data(25) : 0 : Byte : Form1.Form_Load
: mod_data(26) : 0 : Byte : Form1.Form_Load
: mod_data(27) : 0 : Byte : Form1.Form_Load
: mod_data(28) : 26 : Byte : Form1.Form_Load
: mod_data(29) : 16 : Byte : Form1.Form_Load
: mod_data(30) : 0 : Byte : Form1.Form_Load
: mod_data(31) : 0 : Byte : Form1.Form_Load
: mod_data(32) : 86 : Byte : Form1.Form_Load

*** From DISK (as hex) ***


From DISK (as hex)
55 6E 72 65 61
6C 20 5D 5B 20
2F 20 50 4D 00
00 00 00 00 00
00 00 00 00 00
00 00 00 1A 10


*** From DISK (as dec- converted) ***


85 110 114 101 97
108 32 93 91 32
47 32 80 77 0
0 0 0 0 0
0 0 0 0 0
0 0 0 26 16

[/code:3estcgfl]

  • You must to post comments
0
0

Oh, Varptr wont do you any good. You should be using CopyMemory to get a pointer to the array.

  • You must to post comments
0
0

Hey there…

Alright.. I’m confused. So… how would I use copy memory to get the pointer? Would I have to allocate using calloc or something like it?

Looking into it deeper after your sugession – I’ve found something interesting in the fmod.bas file. * FMUSIC_LoadSongEx2 *

It’s def’n:
[code:20e2coii]Public Declare Function FMUSIC_LoadSongEx2 Lib "fmod.dll" Alias "_FMUSIC_LoadSongEx@24" (ByRef data As Byte, ByVal offset As Long, ByVal length As Long, ByVal mode As FSOUND_MODES, ByRef sentencelist As Long, ByVal numitems As Long) As Long [/code:20e2coii]

It strikes me this is the function I should be using. Since it’s byref data as byte – rather than string… I should be able to pass the array in as such :
[code:20e2coii]
mod_play = FMUSIC_LoadSongEx2(mod_data(0), 0, mod_size, FSOUND_LOADMEMORY, 0, 0)
[/code:20e2coii]

Of course… it still doesn’t work. Does anyone have a valid example for using FMUSIC_LoadSongEx2?

  • You must to post comments
0
0

try ByVal VarPtr

  • You must to post comments
0
0

Okay… I tried this suggestion:
[quote:888rm4oz]
try ByVal VarPtr
[/quote:888rm4oz]

mod_play = FMUSIC_LoadSongEx2(ByVal VarPtr(mod_data(0)), mod_size, FSOUND_LOADMEMORY, 0, 0)

Kaboom…
Overflow
๐Ÿ˜ฅ

  • You must to post comments
0
0

Hey Folks!

So.. guess what! I finally got it working (well, someone from http://www.visualbasicforum.com/) solved it.

The key is… the load routine -> takes a period of time to init if from memory. So a straight play back doesn’t work. But this does:

  • enjoy! *

[code:vxkohw9i]
Dim mod_data() As Byte
Dim mod_play As Long
Dim mod_size As Long
Dim mod_name As String

Private Sub Form_Load()
FSOUND_Init 44100, 32, FSOUND_INIT_GLOBALFOCUS
mod_name = "2nd_pm.s3m"

Open mod_name For Binary As #1
mod_size = LOF(1)
ReDim mod_data(mod_size – 1)
Get #1, , mod_data
Close #1

mod_play = FMUSIC_LoadSongEx2(mod_data(0), 0, mod_size, FSOUND_LOADMEMORY, ByVal 0, 0)

‘ You’ll probably want to add a timeout to this as well
Do
DoEvents
Loop While FMUSIC_GetOpenState(mod_play)

FMUSIC_PlaySong mod_play

End Sub

Private Sub Form_Unload(Cancel As Integer)
FMUSIC_StopSong mod_play
FSOUND_Close
End Sub
[/code:vxkohw9i]

  • You must to post comments
Showing 12 results
Your Answer

Please first to submit.