0
0

I’ve fallen at the first hurdle trying to get the rather excellent FMODCE.DLL to work through EVB.

I can FSOUND_INIT fine, the declaration I am using is:
Declare Function FSOUND_Init Lib “fmodce.dll” (ByVal mixrate As Long, ByVal maxchannels As Long, ByVal Flags As Long) As Byte

But, when I try to use FSOUND_Stream_OpenFile I always get ‘File not found’. The declaration I am using is:
Declare Function FSOUND_Stream_OpenFile Lib “fmodce.dll” (ByVal Filename As String, ByVal mode As Long, ByVal memlength As Long) As Long

e.g.
PlaybackStream = FSOUND_Stream_OpenFile(Filename, FSOUND_2D, 0)
where filename is something like:
My DocumentsTest1.mp3

I am using the full version of FMODCE and can get it to work absolutely fine with the enclosed test application (ARM CPU, iPAQ3630)

I think it might be because EVB always treats strings as UNICODE and FMODCE wants ANSI.

If I’m right, how do I send a raw ANSI string to a DLL function that expects the String data type? Can I override it somehow and send raw ANSI characters?

Or am I completely wrong and doing something daft?

I would really appreciate any help from anyone who has tried to use FMODCE through EVB.

Regards,
Andy Mason

Disclaimer:
I realise that EVB is a very poor and lame language to use so please forgive me – I simply don’t have much time and the rest of my app is all EVB.

  • You must to post comments
0
0

Thanks for the reply Brett. Works a treat. :smile:

Here’s the EVB translation of my open function:

Private Sub cmdOpen_Click()
Dim sANSI As String ‘Variables are always declared as variants in EVB
Dim szbuf As Long ‘So the type names here are just for show

CommonDialog1.ShowOpen

'Get the length of the buffer we will need
szbuf = WideCharToMultiByte(CP_ACP, 0, CommonDialog1.Filename, -1, sANSI, 0, "", 0)

'Allocate memory for the buffer by creating an empty string of the right size
sANSI = Space(szbuf)

'Convert the UNICODE string into an ANSI string
Call WideCharToMultiByte(CP_ACP, 0, CommonDialog1.Filename, -1, sANSI, szbuf, "", 0)

'Open the streaming file
Stream1 = FSOUND_Stream_OpenFile(sANSI, FSOUND_2D, 0)

'Catch any error or display the filename opened if successfull
If Stream1 = 0 Then
    MsgBox "Error while opening file" & vbCrLf & FSOUND_GetErrorString(FSOUND_GetError)
    lblFile = "Error opening file - no File Opened"
Else
    lblFile = CommonDialog1.Filename
End If

End Sub

The .BAS file in your example VB project does need some adjustment to make it EVB compatible, namely:

  • Dll name (of course)
  • Function prototypes (not size decorated like in C DLL Exports, i.e. no _fnname#4 etc.)
  • No calculated constants
  • No Enums

e.g. the declares etc. I used with the code above were:

Public Declare Function WideCharToMultiByte Lib “coredll.dll” (ByVal CodePage As Long, ByVal dwFlags As Long, _
ByVal lpWideCharStr As String, ByVal cchWideChar As Long, ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long

Const CP_ACP = 0
Const FSOUND_FREE = -1
Const FSOUND_2D = &H2000
Const FSOUND_NORMAL = &H29 ‘because you can’t do evaluated consts

Declare Function FSOUND_Init Lib “fmodce.dll” (ByVal mixrate As Long, ByVal maxchannels As Long, ByVal Flags As Long) As Byte
Declare Function FSOUND_Close Lib “fmodce.dll” () As Long
Declare Function FSOUND_Stream_Play Lib “fmodce.dll” (ByVal channel As Long, ByVal stream As Long) As Long
Declare Function FSOUND_Stream_Stop Lib “fmodce.dll” (ByVal stream As Long) As Byte
Declare Function FSOUND_Stream_Close Lib “fmodce.dll” (ByVal stream As Long) As Byte
Declare Function FSOUND_Stream_OpenFile Lib “fmodce.dll” (ByVal Filename As String, ByVal mode As Long, ByVal memlength As Long) As Long
Declare Function FSOUND_GetError Lib “fmodce.dll” () As Long
Declare Function FSOUND_SetPaused Lib “fmodce.dll” (ByVal channel As Long, ByVal Paused As Byte) As Byte
Declare Function FSOUND_GetPaused Lib “fmodce.dll” (ByVal channel As Long) As Byte

If your are ever really bored you could do a Wide version of the functions that take strings (there’s only a few).

Thanks again for your help 😎

Andy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.