This module, placed in \mods\hot.mod\iff8svxloader.mod\iff8svxloader.bmx:
Appears to send BMK into an infinite memory consumptious loop ;] I left it running overnight because I just couldn't be bothered anymore and when I woke up in the morning Windows had popped up a low on virtmem error (keep in mind my max virtmem is set at 4gb:) and when I clicked OK to that, BMK promptly crashed. Ha!
So I'd like to know if I'm doing something horribly wrong or if it's a bug. Because I don't know any better.
It was compiling fine, before I put the For Local i=0 To... loop in. It used to just be the stream.readbytes command and that worked AOK. But I can't see anything wrong with the loop. It said in the docs that you can define a Local like that (in a For line) and I have Strict on so bmk will probably complain if I didn't... still... I don't see anything else that could be remotely classified as wrong. Help! =]
Strict Rem bbdoc: IFF8SVX loader End Rem Module HOT.IFF8SVXLoader ModuleInfo "Version: 1.00" ModuleInfo "Author: Hotcakes" ModuleInfo "License: Public Domain" ModuleInfo "Copyright: Toby Zuijdveld" ModuleInfo "Favourite Food: Pizza" Import BRL.AudioSample Import BRL.EndianStream 'Import BRL.Blitz 'Import BRL.Retro Private Function ReadTag$( stream:TStream ) Local tag:Byte[4] If stream.ReadBytes( tag,4 )<>4 Return Return Chr(tag[0])+Chr(tag[1])+Chr(tag[2])+Chr(tag[3]) End Function ' Stolen from Blitz Research Function SkipBytes(stream:TStream,count) stream.skipbytes(count) End Function ' This function wrapper is missing ;] Public Type TAudioSampleLoaderIFF8SVX Extends TAudioSampleLoader Method LoadAudioSample:TAudioSample( stream:TStream ) stream=BigEndianStream(stream) ' Motorola induced endianivity If ReadTag( stream )<>"FORM" Then Return ' Not an IFF file Local w_len=Readint(stream) If w_len+8>StreamSize(stream) If StreamSize(stream)>-1 Then Return ' Truncated file EndIf If ReadTag( stream )<>"8SVX" Then Return ' Not an 8SVX file If ReadTag( stream )<>"VHDR" Then Return ' Compulsory field ReadLong(stream);ReadLong(stream) ' 4 unimportant Ints Local w_hz=ReadShort(stream) If ReadByte(stream)>1 Then Return ' Multioctave not supported If ReadByte(stream) Then Return ' Compression not supported Local w_vol:Float=ReadShort(stream)+(ReadShort(stream)/$10000) ' That... uhhh... might work... ' It's supposed to be a 16bit.16bit floating point value, but I never understood floating point Repeat ' numbers =] Anyway, it's a volume adjustment value, which we'll be using later... If readtag(stream)="BODY" Then Exit ' That's what we're looking for skipbytes stream,Readint(stream) ' Skip the useless info stuff and, yes. Well, I'm rambling. Forever ' Forever w_len=Readint(stream) ' Length of the sample Local t:TAudioSample=TAudioSample.create(w_len,w_hz,SF_MONO8) Local buf:Byte Ptr=t.samples For Local i=0 To w_len ' Probably a cleaner way to do this, but I don't know it =] Local w_tmp=ReadByte(stream) If w_tmp>127 Then w_tmp:-128 Else w_tmp:+128 ' Signed-->Unsigned buf:+w_tmp Next ' i=0 To w_len ' stream.readbytes t.samples,w_len Return t ' Good to go. End Method End Type AddAudioSampleLoader New TAudioSampleLoaderIFF8SVX
Appears to send BMK into an infinite memory consumptious loop ;] I left it running overnight because I just couldn't be bothered anymore and when I woke up in the morning Windows had popped up a low on virtmem error (keep in mind my max virtmem is set at 4gb:) and when I clicked OK to that, BMK promptly crashed. Ha!
So I'd like to know if I'm doing something horribly wrong or if it's a bug. Because I don't know any better.
It was compiling fine, before I put the For Local i=0 To... loop in. It used to just be the stream.readbytes command and that worked AOK. But I can't see anything wrong with the loop. It said in the docs that you can define a Local like that (in a For line) and I have Strict on so bmk will probably complain if I didn't... still... I don't see anything else that could be remotely classified as wrong. Help! =]