Upload folder using huggingface_hub
Browse files- README.md +109 -0
- hrir_spatial_map.npz +3 -0
- metadata.json +67 -0
README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- audio
|
| 5 |
+
- binaural
|
| 6 |
+
- hrtf
|
| 7 |
+
- hrir
|
| 8 |
+
- spatial-audio
|
| 9 |
+
- asmr
|
| 10 |
+
language:
|
| 11 |
+
- en
|
| 12 |
+
- ja
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Binaural HRIR Spatial Map
|
| 16 |
+
|
| 17 |
+
Head-Related Impulse Response (HRIR) lookup table for real-time binaural audio rendering.
|
| 18 |
+
|
| 19 |
+
## Grid Specification
|
| 20 |
+
|
| 21 |
+
| Parameter | Value |
|
| 22 |
+
|---|---|
|
| 23 |
+
| Azimuth | 0°–355° (Δ5.0°, 72 points) |
|
| 24 |
+
| Distance | 0.10m–2.00m (26 points) |
|
| 25 |
+
| Elevation | 0.0° (fixed) |
|
| 26 |
+
| Total points | 1,872 |
|
| 27 |
+
| IR length | 512 samples (10.7 ms) |
|
| 28 |
+
| Sample rate | 48000 Hz |
|
| 29 |
+
| Dtype | float32 |
|
| 30 |
+
|
| 31 |
+
### Distance Grid (near-field dense)
|
| 32 |
+
|
| 33 |
+
```
|
| 34 |
+
0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.22, 0.25, 0.28, 0.30, 0.33, 0.36, 0.40, 0.45, 0.50, 0.60, 0.75, 1.00, 1.25, 1.50, 2.00
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
- 10–20 cm: 1 cm step (11 points) — near-field, high HRTF variation
|
| 38 |
+
- 20–40 cm: 2–3 cm step (7 points)
|
| 39 |
+
- 40 cm–1 m: 5–15 cm step (4 points)
|
| 40 |
+
- 1–2 m: 25–50 cm step (4 points)
|
| 41 |
+
|
| 42 |
+
## HRTF Model
|
| 43 |
+
|
| 44 |
+
Rigid sphere model with:
|
| 45 |
+
- Spherical wave expansion (near-field)
|
| 46 |
+
- Ear canal resonance (angle/distance dependent)
|
| 47 |
+
- Pinna diffraction
|
| 48 |
+
- Interaural Time Difference (ITD)
|
| 49 |
+
- Torso reflection
|
| 50 |
+
- Air absorption
|
| 51 |
+
|
| 52 |
+
## Usage
|
| 53 |
+
|
| 54 |
+
```python
|
| 55 |
+
import numpy as np
|
| 56 |
+
|
| 57 |
+
data = np.load("hrir_spatial_map.npz")
|
| 58 |
+
azimuths = data["azimuths"] # (72,) float32 — [0, 5, 10, ..., 355]
|
| 59 |
+
distances = data["distances"] # (26,) float32 — [0.10, 0.11, ..., 2.00]
|
| 60 |
+
hrir_L = data["hrir_L"] # (72, 26, 512) float32
|
| 61 |
+
hrir_R = data["hrir_R"] # (72, 26, 512) float32
|
| 62 |
+
|
| 63 |
+
# Look up HRIR for azimuth=270° (right), distance=0.10m
|
| 64 |
+
az_idx = int(270 / 5) # = 54
|
| 65 |
+
dist_idx = 0 # = 0.10m
|
| 66 |
+
ir_L = hrir_L[az_idx, dist_idx] # (512,) float32
|
| 67 |
+
ir_R = hrir_R[az_idx, dist_idx] # (512,) float32
|
| 68 |
+
|
| 69 |
+
# Binaural rendering via direct convolution
|
| 70 |
+
out_L = np.convolve(mono_audio, ir_L, mode="full")[:len(mono_audio)]
|
| 71 |
+
out_R = np.convolve(mono_audio, ir_R, mode="full")[:len(mono_audio)]
|
| 72 |
+
stereo = np.stack([out_L, out_R], axis=-1)
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
### Interpolation for arbitrary positions
|
| 76 |
+
|
| 77 |
+
```python
|
| 78 |
+
def interpolate_hrir(hrir_L, hrir_R, azimuths, distances, az_deg, dist_m):
|
| 79 |
+
az_step = azimuths[1] - azimuths[0]
|
| 80 |
+
az_idx_f = (az_deg % 360) / az_step
|
| 81 |
+
az_i0 = int(az_idx_f) % len(azimuths)
|
| 82 |
+
az_i1 = (az_i0 + 1) % len(azimuths)
|
| 83 |
+
az_alpha = az_idx_f - int(az_idx_f)
|
| 84 |
+
|
| 85 |
+
dist_m = np.clip(dist_m, distances[0], distances[-1])
|
| 86 |
+
d_idx = np.searchsorted(distances, dist_m, side="right") - 1
|
| 87 |
+
d_idx = np.clip(d_idx, 0, len(distances) - 2)
|
| 88 |
+
d_alpha = (dist_m - distances[d_idx]) / (distances[d_idx + 1] - distances[d_idx])
|
| 89 |
+
|
| 90 |
+
L00 = hrir_L[az_i0, d_idx]
|
| 91 |
+
L01 = hrir_L[az_i0, d_idx + 1]
|
| 92 |
+
L10 = hrir_L[az_i1, d_idx]
|
| 93 |
+
L11 = hrir_L[az_i1, d_idx + 1]
|
| 94 |
+
L = (1 - az_alpha) * ((1 - d_alpha) * L00 + d_alpha * L01) \
|
| 95 |
+
+ az_alpha * ((1 - d_alpha) * L10 + d_alpha * L11)
|
| 96 |
+
|
| 97 |
+
R00 = hrir_R[az_i0, d_idx]
|
| 98 |
+
R01 = hrir_R[az_i0, d_idx + 1]
|
| 99 |
+
R10 = hrir_R[az_i1, d_idx]
|
| 100 |
+
R11 = hrir_R[az_i1, d_idx + 1]
|
| 101 |
+
R = (1 - az_alpha) * ((1 - d_alpha) * R00 + d_alpha * R01) \
|
| 102 |
+
+ az_alpha * ((1 - d_alpha) * R10 + d_alpha * R11)
|
| 103 |
+
|
| 104 |
+
return L.astype(np.float32), R.astype(np.float32)
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## License
|
| 108 |
+
|
| 109 |
+
MIT
|
hrir_spatial_map.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bba8a10360110aa80428674da5e10583a0b5f288d9dc1cfd930d66e60b6b3dd1
|
| 3 |
+
size 7147591
|
metadata.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"description": "HRIR spatial map for binaural audio rendering",
|
| 3 |
+
"model": "rigid sphere + ear canal + pinna + torso + air absorption",
|
| 4 |
+
"grid": {
|
| 5 |
+
"azimuth_step_deg": 5.0,
|
| 6 |
+
"azimuth_range": [
|
| 7 |
+
0.0,
|
| 8 |
+
355.0
|
| 9 |
+
],
|
| 10 |
+
"n_azimuths": 72,
|
| 11 |
+
"distances_m": [
|
| 12 |
+
0.10000000149011612,
|
| 13 |
+
0.10999999940395355,
|
| 14 |
+
0.11999999731779099,
|
| 15 |
+
0.12999999523162842,
|
| 16 |
+
0.14000000059604645,
|
| 17 |
+
0.15000000596046448,
|
| 18 |
+
0.1599999964237213,
|
| 19 |
+
0.17000000178813934,
|
| 20 |
+
0.18000000715255737,
|
| 21 |
+
0.1899999976158142,
|
| 22 |
+
0.20000000298023224,
|
| 23 |
+
0.2199999988079071,
|
| 24 |
+
0.25,
|
| 25 |
+
0.2800000011920929,
|
| 26 |
+
0.30000001192092896,
|
| 27 |
+
0.33000001311302185,
|
| 28 |
+
0.36000001430511475,
|
| 29 |
+
0.4000000059604645,
|
| 30 |
+
0.44999998807907104,
|
| 31 |
+
0.5,
|
| 32 |
+
0.6000000238418579,
|
| 33 |
+
0.75,
|
| 34 |
+
1.0,
|
| 35 |
+
1.25,
|
| 36 |
+
1.5,
|
| 37 |
+
2.0
|
| 38 |
+
],
|
| 39 |
+
"n_distances": 26,
|
| 40 |
+
"elevation_deg": 0.0
|
| 41 |
+
},
|
| 42 |
+
"audio": {
|
| 43 |
+
"sample_rate": 48000,
|
| 44 |
+
"ir_length_samples": 512,
|
| 45 |
+
"ir_length_ms": 10.67,
|
| 46 |
+
"dtype": "float32"
|
| 47 |
+
},
|
| 48 |
+
"shape": {
|
| 49 |
+
"hrir_L": [
|
| 50 |
+
72,
|
| 51 |
+
26,
|
| 52 |
+
512
|
| 53 |
+
],
|
| 54 |
+
"hrir_R": [
|
| 55 |
+
72,
|
| 56 |
+
26,
|
| 57 |
+
512
|
| 58 |
+
]
|
| 59 |
+
},
|
| 60 |
+
"total_points": 1872,
|
| 61 |
+
"npz_size_bytes": 7147591,
|
| 62 |
+
"head_params": {
|
| 63 |
+
"head_radius_m": 0.0875,
|
| 64 |
+
"ear_canal_length_m": 0.025
|
| 65 |
+
},
|
| 66 |
+
"usage": "data = np.load('hrir_spatial_map.npz'); hrir_L = data['hrir_L'][az_idx, dist_idx]; output = np.convolve(mono, hrir_L)"
|
| 67 |
+
}
|