Irrklang & Incbin / loading from stream

BlitzMax Forums/BlitzMax Programming/Irrklang & Incbin / loading from stream

Firstdeathmaker(Posted 2008) [#1]
Hi there,

I've got a problem: I'ld like to play my sounds out of incbin:: with Irrklang, does anybody know how to do this? Or is it not possible?

Alternatively I would like to play them out of a TStream or Bank (so I could encrypt them). The problem is, that I don't want the soundfiles laying around unsecured in my gamefolder's datadir.


plash(Posted 2008) [#2]
Here is typically how I would encrypt my data: Give your sound types the DeSerialize(TStream) and Serialize(TStream) methods, and have them save (Serialize) and load (DeSerialize) in the same order. So you could, for example, serialize the type into a bankstream (in memory) and encrypt the bankstream (using RC4) before outputting to the external file. When DeSerializing you just have to load the stream into a bankstream again and decrypt before passing it off to the DeSerialize type.

Here is some example code (progressive saving):


Now, I'm not certain the sound module has implemented the saving of sound data, if it does there should be a SoundDataType (or similar) global instance defined somewhere in one of the sound/audio modules - you might have to figure out how to save it without!

And loading a 'soundmap,' if you will, could be done with a While...Wend loop (TTile.Load() is a wrapper function for creating and DeSerializing a TTile):
'The TTileMap type..
		Method DeSerialize:TTileMap(stream:TStream)
			
			While Not stream.Eof()
				
				InsertTile(TTile.Load(stream))
				
			Wend
			
		   Return Self
		   
		End Method


A Serializing example:


I'll be releasing all the memcrypt modules within the next few weeks.


Firstdeathmaker(Posted 2008) [#3]
hmm, thanks, but my problem is, that the Irrklang module can't read from streams, just from strings (=filepath). But I just figured out that it is possible to use "incbin::" with the modules function Play2DSound(). So:

< PROBLEM SOLVED >

By the way, i read that you're working on memcrypt modules? A few weeks ago I released the fdm.tcrypt module here in the module section, with aes encryption. But sadly my implementation is too slow... Maybe you want to take a look on that?


plash(Posted 2008) [#4]
My current memcrypt code is basically just RC4_Bytes and CryptStream, which both work snappily.