How to use the munch.ITFloater function in munch

To help you get started, we’ve selected a few munch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iamgreaser / it2everything / munch.py View on Github external
self.dpos += 1
			self.brem = 8
			self.bpos = 0
		
		if width > 0:
			if self.dpos >= len(self.data):
				raise IT214Exception("unbalanced block end")
			
			v |= (ord(self.data[self.dpos])>>self.bpos)<
github iamgreaser / it2everything / munch.py View on Github external
sample.flags |= 8
				if using_it215:
					sample.cvt |= 4
			else:
				print "COMPRESSION SUCKED, USING NORMAL SAMPLE DATA"
				self.data = unpacked_data
		
		self.pack()
	
	def use(self, module):
		self.currently_used = True
	
	def pack(self):
		self.mask = [ord(v) for v in self.data]

class ITInstrument(ITFloater):
	def __init__(self, fp):
		imps = fp.read(4)
		if imps != "IMPI":
			print "WARNING: Instrument w/o IMPI header"
		self.filename = fp.read(13)
		if self.filename[-1] != "\x00":
			print "WARNING: Instrument filename w/o null terminator"
		self.nna, self.dct, self.dca, self.fadeout = struct.unpack("
github iamgreaser / it2everything / munch.py View on Github external
else:
			self.mask += [None]*8
		
		self.mask += [-1 if (self.flags & 1) else None]*4
		
		# TODO make suitable gap for vibrato type
		self.mask += [self.vis,self.vid,self.vir,self.vit]
	
	def saveptr(self, modmask):
		if self.smpdata:
			koffs = self.file_crap_offs+0x48
			for v in struct.pack("
github iamgreaser / it2everything / munch.py View on Github external
else:
					self.mask += [None]*2
				
				for i in xrange(25):
					if i < env[1]:
						self.mask += env[6][i]
					else:
						self.mask += [None]*3
			else:
				#self.mask += [0] + [None]*(25*3+5)
				# this can save schism & other things some serious grief
				self.mask += [0,2,None,None,None,None,64,0,0,64,100,0] + [None]*(23*3)
			
			self.mask += [None]

class ITSample(ITFloater):
	def __init__(self, fp):
		imps = fp.read(4)
		if imps != "IMPS":
			print "WARNING: Sample w/o IMPS header"
		self.filename = fp.read(13)
		if self.filename[-1] != "\x00":
			print "WARNING: Sample filename w/o null terminator"
		self.gvl, self.flags, self.vol = struct.unpack("
github iamgreaser / it2everything / munch.py View on Github external
self.kmp_search_tree[pos] = cnd
				pos += 1
			
			# second case: it doesn't, but we can fall back
			elif cnd > 0:
				cnd = self.kmp_search_tree[cnd]
			
			# third case: we have run out of candidates.  Note cnd = 0
			else:
				cnd = 0
				pos += 1



# TODO unravel patterns and repack them
class ITPattern(ITFloater):
	def __init__(self, fp):
		patlen, self.rows, _ = struct.unpack("= 64KB.
		# Plus there's plenty of checks and balances in everything ever.
		# Not sure about IT, sadly.
		
		# We'll calculate to check if it's correct, though.
		pdroot = fp.tell()
		
		self.data = [[[253,0,255,0,0] for i in xrange(64)] for r in xrange(self.rows)]
		
		# TODO? check what the defaults are?
		lmask = [-1 for i in xrange(64)]
		ldata = [[-1,-1,-1,-1,-1] for i in xrange(64)]
		
		for r in xrange(self.rows):