from gmisclib import cache
from gmisclib import gpkmisc
from gpk_voicing import percep_spec as PS

ROOT = '/tmp/cached_percep_spec'

def perceptual_spec(data, dt, Dt, bmin=PS.CBmin, bmax=PS.CBmax, db=PS.BBSZ,
			do_mod=0, do_dissonance=False, PlompBouman=True,
			do_peakalign=False, e=None, cache_info=None):
	ci = None
	if cache_info is not None:
		ci = cache_info.addinfo(dt, Dt, bmin, bmax, db, do_mod, do_dissonance,
						PlompBouman, do_peakalign, e, 'percep_spec', mod=PS)
		try:
			return ci.load()
		except ci.Errors:
			pass

	bctrs, neural, t0 = PS.perceptual_spec(data, dt, Dt, bmin=bmin, bmax=bmax, db=db,
						do_mod=do_mod, do_dissonance=do_dissonance,
						PlompBouman=PlompBouman,
						do_peakalign=do_peakalign, e=e)
	if ci is not None:
		ci.bg_dump((bctrs, neural, t0))
	return (bctrs, neural, t0)


