-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspatialaudio.py
More file actions
31 lines (25 loc) · 858 Bytes
/
spatialaudio.py
File metadata and controls
31 lines (25 loc) · 858 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from audio import Audio
from coordinates import Coordinates
import numpy as np
from copy import copy
from scipy.spatial import ConvexHull
class SpatialAudio(Audio):
coordinates = Coordinates()
class SOFA_Audio(SpatialAudio):
def __init__(self, filename):
import h5py
h5 = h5py.File(filename)
# [ind for ind in h5.iterkeys()]
self.filename = filename
self.samplingRate = h5['Data.SamplingRate'][:]
self.time = h5['Data.IR'][:]
self.coordinates = self._position2coordinates(h5['SourcePosition'])
self._sync()
# vis.BalloonGUI()
def _position2coordinates(self, pos):
p = pos[...,0] / 180 * np.pi
t = (90 - pos[...,1]) / 180 * np.pi
r = pos[...,2]
c = Coordinates()
c.sph = np.vstack((r,t,p)).T
return c