0
0

first sorry for my poor english :roll: i am a Chinese user ๐Ÿ˜€

i want to protect my sound document so i encode them with password and save them on harddisk.
now when i try to play them, i should decode it right?
now here is a problem, for i should keep the security of the sound document so write it into a temp file is not a good way. i must use a buffer to save it.
fmod offers the stream_open in vb as open2 which is:
[quote:1qfxuprm]
Public Declare Function FSOUND_Stream_Open2 Lib “fmod.dll” Alias “_FSOUND_Stream_Open@16” (ByRef data As Byte, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long
[/quote:1qfxuprm]
here the first param is ByRef data As Byte, i don’t know how can i use this param and open the file in the memory.
anyone who got an idea?

regards, MeteorRain

  • You must to post comments
0
0

glad to see the reply.
now i use such statements:

[code:1qo2h7ua]Option Explicit
Private Declare Function GetData Lib "S:\字幕组\misldpr\mdpsrdr.dll" Alias "读取数据" _
(ByVal pBuffer As String, ByVal dType As Long, ByVal dLang As Long) As Long
Private Declare Function HeapAlloc Lib "kernel32" _
(ByVal hHeap As Long, ByVal dwFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function HeapCreate Lib "kernel32" _
(ByVal flOptions As Long, ByVal dwInitialSize As Long, ByVal dwMaximumSize As Long) As Long
Private Declare Function HeapFree Lib "kernel32" _
(ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long

Private Sub Command1_Click()
Dim lpMem As Long, hHeap As Long, pStream As Long
hHeap = HeapCreate(0, 128, 0)
lpMem = HeapAlloc(hHeap, 0, 3061537)
GetData lpMem, 0, 3 ‘use an extern and writes some binary data into the memory address
pStream = FSOUND_Stream_Open2(lpMem, FSOUND_LOADMEMORY Or FSOUND_MPEGACCURATE, 0, 0) [color=red]’ here i got an invalid type error by vb, it says you can’t convert a long type var into a byRef Byte type var. any idea?
FSOUND_Stream_Play FSOUND_FREE, pStream
FSOUND_Stream_Close (pStream)
HeapFree hHeap, 0, lpMem
End Sub
[/code:1qo2h7ua]

super regard!! MeteorRain ๐Ÿ˜›

  • You must to post comments
0
0

[quote:10lwzjby]pStream = FSOUND_Stream_Open2(lpMem, FSOUND_LOADMEMORY Or FSOUND_MPEGACCURATE, 0, 0)
[color=yellow:10lwzjby]’ here i got an invalid type error by vb, it says you can’t convert a long type var into a byRef Byte type var. any idea? [/color:10lwzjby]
[/quote:10lwzjby]

  • You must to post comments
0
0

hehe i know that problem. but i met the problem is it even couldn’t be compiled ’cause the varible type dismatch at the long -> ByRef byte.
the length you said can be easily resolved, right? …… :roll:

  • You must to post comments
0
0

Here is the declaration of FSOUND_Stream_Open2:
[code:3o354axq]Public Declare Function FSOUND_Stream_Open2 Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByRef data As Byte, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long[/code:3o354axq]
If you want to use it like this, you have to allocate your memory as follows:
[code:3o354axq]Dim memory() As Byte
Redim memory(memSizeInBytes)
...
FSOUND_Stream_Open2 (memory(0), ... )[/code:3o354axq]

If you want to directly pass the pointer to the memory (and I’m not sure it’s usefull to allocate your own memory, since it’s safer to let vb handle when it needs to be de-allocated, …)
You have to add a new declaration for FSOUND_Stream_Open as follows:
[code:3o354axq]Public Declare Function FSOUND_Stream_Open3 Lib "fmod.dll" Alias "_FSOUND_Stream_Open@16" (ByVal pointer As Long, ByVal mode As FSOUND_MODES, ByVal offset As Long, ByVal length As Long) As Long[/code:3o354axq]
and then you could just use FSOUND_Stream_Open3 and pass it your pointer.

  • You must to post comments
0
0

Thanks!!! i will try ^_^

  • You must to post comments
0
0

Private Sub Command1_Click()
Dim mems() As Byte, pStream As Long

ReDim mems(3061537)
GetData mems(0), 0, 3 'load mp3 file into memory

pStream = FSOUND_Stream_Open2(mems(0), FSOUND_LOADMEMORY, 0, 3061537)
Text1.Text = pStream 'return 0, or say NULL

'FSOUND_Stream_Play FSOUND_FREE, pStream
'FSOUND_Stream_Close (pStream)

End Sub

  • You must to post comments
0
0

just up, hope someone can help me…

  • You must to post comments
0
0

i found the problem. the mp3 file transfer from dll via byte array buffer lost some data (some chars becomes #0)

  • You must to post comments
Showing 8 results
Your Answer

Please first to submit.