diff --git a/gsrp_tdoa_hyperres.py b/gsrp_tdoa_hyperres.py index 27f8d05f6dcb5eee4137c2c3cca1913c80d069f6..73836c15f6c1ae55c4632ad18e366432857ae943 100755 --- a/gsrp_tdoa_hyperres.py +++ b/gsrp_tdoa_hyperres.py @@ -173,21 +173,28 @@ def main(args): raise ValueError(f'Error: hop size {args.stride} is neither an existing file nor a float') print("Computing TDOAs...") - result1 = corr(sound, pos, int(sr * args.frame_size), max_tdoa=int(np.ceil(sr * args.max_tdoa)), + results = corr(sound, pos, int(sr * args.frame_size), max_tdoa=int(np.ceil(sr * args.max_tdoa)), decimate=args.decimate if not args.temporal else 1, mode=args.mode, hyper=not args.no_hyperes) - + if args.no_hyperres: + result1 = results + else: + result1, result2 =results # compute additional non-independent TDOAs additional1 = [(b - a) for a, b in itertools.combinations(result1.T[2:], 2)] result1 = np.hstack((result1,) + tuple(a[:, np.newaxis] for a in additional1)) - additional2 = [(b - a) for a, b in itertools.combinations(result2.T[1:], 2)] - result2 = np.hstack((result2,) + tuple(a[:, np.newaxis] for a in additional2)) + if not args.no_hyperres: + additional2 = [(b - a) for a, b in itertools.combinations(result2.T[2:], 2)] + result2 = np.hstack((result2,) + tuple(a[:, np.newaxis] for a in additional2)) if args.outfile.endswith('.npy'): np.save(args.outfile, result1) - np.save(args.outfile[:-4] + '_2.npy', result2) + if not args.no_hyperres: + np.save(args.outfile[:-4] + '_2.npy', result2) else: np.savetxt(args.outfile, result1, delimiter=',') - np.savetxt((lambda x1, x2, x3: x1 + '_2' + x2 + x3)(*args.outfile.rpartition('.', 1)), result2, delimiter=',') + if not args.no_hyperres: + np.savetxt((lambda x1, x2, x3: x1 + '_2' + x2 + x3)(*args.outfile.rpartition('.', 1)), + result2, delimiter=',') print("Done.") return 0