Пример #1
0
	def setbandsperoctave(self, bandsperoctave):
		self.bandsperoctave = bandsperoctave
		self.nbands = NOCTAVE*self.bandsperoctave
		self.fi, self.flow, self.fhigh = octave_frequencies(self.nbands, self.bandsperoctave)
		[self.boct, self.aoct, fi, flow, fhigh] = generated_filters.params['%d' %bandsperoctave]

		#z, p, k = tf2zpk(self.bdec, self.adec)
		#print "poles", p, abs(p)**2
		#print "zeros", z, abs(z)**2
		#for b, a in zip(self.boct, self.aoct):
			#z, p, k = tf2zpk(b, a)
			#print "poles", p, abs(p)**2
			#print "zeros", z, abs(z)**2
			
		#[self.b_nodec, self.a_nodec, fi, fl, fh] = octave_filters(self.nbands, self.bandsperoctave)
		
		f = self.fi
		Rc = 12200.**2*f**2 / ((f**2 + 20.6**2)*(f**2 + 12200.**2))
		Rb = 12200.**2*f**3 / ((f**2 + 20.6**2)*(f**2 + 12200.**2)*((f**2 + 158.5**2)**0.5))
		Ra = 12200.**2*f**4 / ((f**2 + 20.6**2)*(f**2 + 12200.**2)*((f**2 + 107.7**2)**0.5) * ((f**2 + 737.9**2)**0.5))         
		self.C = 0.06 + 20.*log10(Rc)
		self.B = 0.17 + 20.*log10(Rb)
		self.A = 2.0  + 20.*log10(Ra)
		#self.zfs = None
		self.zfs = octave_filter_bank_decimation_filtic(self.bdec, self.adec, self.boct, self.aoct)
Пример #2
0
	def setbandsperoctave(self, bandsperoctave):
		self.bandsperoctave = bandsperoctave
		self.nbands = NOCTAVE*self.bandsperoctave
		self.fi, self.flow, self.fhigh = octave_frequencies(self.nbands, self.bandsperoctave)
		[self.boct, self.aoct, fi, flow, fhigh] = generated_filters.params['%d' %bandsperoctave]

		#z, p, k = tf2zpk(self.bdec, self.adec)
		#print "poles", p, abs(p)**2
		#print "zeros", z, abs(z)**2
		#for b, a in zip(self.boct, self.aoct):
			#z, p, k = tf2zpk(b, a)
			#print "poles", p, abs(p)**2
			#print "zeros", z, abs(z)**2
			
		#[self.b_nodec, self.a_nodec, fi, fl, fh] = octave_filters(self.nbands, self.bandsperoctave)
		
		f = self.fi
		Rc = 12200.**2*f**2 / ((f**2 + 20.6**2)*(f**2 + 12200.**2))
		Rb = 12200.**2*f**3 / ((f**2 + 20.6**2)*(f**2 + 12200.**2)*((f**2 + 158.5**2)**0.5))
		Ra = 12200.**2*f**4 / ((f**2 + 20.6**2)*(f**2 + 12200.**2)*((f**2 + 107.7**2)**0.5) * ((f**2 + 737.9**2)**0.5))         
		self.C = 0.06 + 20.*log10(Rc)
		self.B = 0.17 + 20.*log10(Rb)
		self.A = 2.0  + 20.*log10(Ra)
		#self.zfs = None
		self.zfs = octave_filter_bank_decimation_filtic(self.bdec, self.adec, self.boct, self.aoct)

		if bandsperoctave == 1:
			basis = renard.R5
		elif bandsperoctave == 3:
			basis = renard.R10
		elif bandsperoctave == 6:
			basis = renard.R20
		elif bandsperoctave == 12:
			basis = renard.R40
		elif bandsperoctave == 24:
			basis = renard.R80
		else:
			raise Exception("Unknown bandsperoctave: %d" %(bandsperoctave))

		# search the index of 1 kHz, the reference
		i = where(self.fi == 1000.)[0][0]

		# build the frequency scale
		self.f_nominal = []

		k = 0
		while len(self.f_nominal) < len(self.fi) - i:
			self.f_nominal += ["{0:.{width}f}k".format(10**k*f, width=2-k) for f in basis]
			k += 1
		self.f_nominal = self.f_nominal[:len(self.fi) - i]

		k = 0
		while len(self.f_nominal) < len(self.fi):
			self.f_nominal = ["%d" %(10**(2-k)*f) for f in basis] + self.f_nominal
			k += 1
		self.f_nominal = self.f_nominal[-len(self.fi):]