bah.fmod: FMod & Unicode problem

BlitzMax Forums/Brucey's Modules/bah.fmod: FMod & Unicode problem

Space Fractal(Posted 2008) [#1]
I have tried to change the fmod CreateStreamURLto accept unicode filename using FMOD_UNICODE constant.

It seen I diddent go that to work, so I have not a glue what it wrong here, since unicode is very important in this app I have (im are currectly checking this wrapper out).

Her is the code I tried:

Import Pub.Win32
Import Bah.FMod
Global SoundSystem:TFMODSystem = New TFMODSystem.Create()
SoundSystem.Init(32)

Local sound1:TFMODSound = SoundSystem.CreateStreamURL("d:\some\path\to\unicode\based\file.mp3", FMOD_SOFTWARE & FMOD_UNICODE)
If sound1<>Null
	Print "unicode file sound could open"
	sound1.SoundRelease()
Else
	Print "unicode file could Not open"
EndIf

sound1:TFMODSound = SoundSystem.CreateStreamURL(Unicode2AscII$("d:\some\path\to\unicode\based\file.mp3"), FMOD_SOFTWARE & FMOD_UNICODE)
If sound1<>Null
	Print "unicode file 2 sound could open"
	sound1.SoundRelease()
Else
	Print "unicode file 2 could not open"
EndIf
	
sound1:TFMODSound = SoundSystem.CreateStreamURL("c:\works\fine.mp3", FMOD_SOFTWARE & FMOD_CREATESTREAM)
If sound1<>Null
	Print "ascII file sound could open"
	sound1.SoundRelease()
Else
	Print "ascII file could not open"
EndIf

sound1:TFMODSound = SoundSystem.CreateStreamURL("c:\works\fine.mp3", FMOD_SOFTWARE & FMOD_CREATESTREAM)
If sound1<>Null
	Print "ascII file sound could open"
	sound1.SoundRelease()
Else
	Print "ascII file could not open"
EndIf

SoundSystem.Close()
SoundSystem.SystemRelease()

Function Unicode2AscII$(a$)
	For Local i = 1 To Len(a$)
		Local char$=Mid(a$, i, 1)
		Local B$=Bin$(Asc(Char$))
		Local Le$=Mid$(B$, 17, 8)
		Local Ri$=Mid$(B$, 25, 8)
		Result$=Result$+Chr$(Int("%"+Le$))+Chr$(Int("%"+Ri$))
	Next
	Return A$
EndFunction


Another request is possible to change soundcard (but that part os not important to been useable in my application here).

NB. I do known BlitzMax itself dosent support unicode at file level, but I got a workaround this limit by using a Pure Basic wrapper which I can't release it here (because it a direct command wrapper).

NNB. This would never have a issue in Linux, since it use UTF8 instead, so it only a Windows issue.


Brucey(Posted 2008) [#2]
I've added some support for FMOD_UNICODE. It will convert the filename string to be 16-bit characters. I haven't tested it though, so if you can let me know if it works okay? :-)


plash(Posted 2008) [#3]
Using the '&' operator works for combining flags? I thought the only one you could use was '|'


Brucey(Posted 2008) [#4]
Using the '&' operator works for combining flags?

Nope.

But the filenames wouldn't have worked any way, I figure.


Space Fractal(Posted 2008) [#5]
It its via SVN? Look like I need to find out how to use that.

Either | or & works (also not the fixed try), but I testing the new code. I have some filename that is in 16 bit filename string, but not far all does that


Brucey(Posted 2008) [#6]
Plash means, you should use

FMOD_SOFTWARE | FMOD_CREATESTREAM

rather than

FMOD_SOFTWARE & FMOD_CREATESTREAM


It its via SVN

Yes. I have not made an "official" release of FMOD yet.


Space Fractal(Posted 2008) [#7]
Sorry for this question:

I got TortoiseSVN to work and find the develpoment version of BlitzMax, but there is no mods? I think I just missing the url, and could not find any url in any sticky post.

____

NEVER MIND. I think you should set this to sticky?
http://www.blitzmax.com/Community/posts.php?topic=80221


Space Fractal(Posted 2008) [#8]
Bingo. The above example works fine in Windows. Thanks.

I have not tested this on Linux which use UTF8 (ASCII) instead of 16 bit filenames. There is code in code archives to convert UTF8 to Unicode anyway. I haven't access to that yet and tried on Linux.

Just to info that.


Brucey(Posted 2008) [#9]
I have not tested this on Linux which use UTF8 (ASCII) instead of 16 bit filenames.

The FMOD docs don't mention UTF-8 (from what I've found).
You should probably not have to change anything for Linux, if you think your are going to have non-ascii filenames.

Strings in BlitzMax are already 16-bit. I do conversions between Max Strings and UTF-8 in other modules on-the-fly, but I do not think this is required for FMOD. (I'm happy to be proven wrong though)


Space Fractal(Posted 2008) [#10]
FMOD_UNICODE is not required to Linux, since Linux's filesystem use UTF8 instead (at least on my system).

But I do that to make it sure to open the file, I coded that if it cant open the file without FMOD_UNICODE, I try again with FMOD_UNICODE....

Now I look on readtags.bmx which did not support unicode, but I here is a primary change to support 2 of the 3 unicode string types (Big Endian unicode version is still missing):

http://www.spacefractal.com/Temp/readtags.bmx

EDIT: There was a bug in line 101, which is now corrected in above example.

For Local i:Int=2 To tag.getDataLength() Step 2

should have been

For Local i:Int=2 To tag.getDataLength()-2 Step 2


Space Fractal(Posted 2008) [#11]
This seen is a good and completly useable wrapper, even it still missing few features, which was used by my application (no need to ads it here), But one of them did I added by my self (setposition()), due to a clean code.

I just need to get Big Endian based Unicode tags to work in the example, but this not important at all.

Good work.