コード例 #1
0
def equivalentFile(database, speakers, component) :
	dboptions = dict(
		kreuzer="--kreuzer",
		mitFull="",
		mitDiffuse="--mitdiffuse",
		)
	databasefile = bmaudio.selectHrtfDatabase( [dboptions[database], "--speakers", str(speakers) ])
	return bmaudio.hrtfDatabaseToEquivalentPath(databasefile, component)
コード例 #2
0
ファイル: aproximateCoherence.py プロジェクト: rolodub/thesis
#!/usr/bin/env python

import sys, os
sys.path.append(os.path.join(os.path.dirname(__file__),"../../../src/libs/python"))
import bmaudio
import Gnuplot
import numpy
import math
import re

def fileToSpectrum(file) :
	samplerate, wave = bmaudio.loadWave(file)
	return numpy.fft.rfft(wave)

databaseFile = bmaudio.selectHrtfDatabase(sys.argv)
hrtfDatabase = bmaudio.HrtfDatabase(databaseFile)
Iw = [ fileToSpectrum(file) for elevationDegrees, azimuthDegrees, file in hrtfDatabase._data ]
Iwsum = sum(abs(iw) for iw in Iw)/len(Iw)

Ew = fileToSpectrum(hrtfDatabase.equivalentPath("w"))
Ex = fileToSpectrum(hrtfDatabase.equivalentPath("x"))
Ey = fileToSpectrum(hrtfDatabase.equivalentPath("y"))
Ez = fileToSpectrum(hrtfDatabase.equivalentPath("z"))
nBins = len(Ew)
c=343
standardDistanceError=0.0067
# exp( (sigma*w)^2/2); sigma=d/c; w=i*spectralRange*pi/nBins/180
a=standardDistanceError*2*math.pi*22050/nBins/c
exponential = numpy.array([math.exp(-(a*n)**2/2) for n in xrange(0,nBins)])
normFactor = sum(1/exponential)