Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. def getNearestUCDpulse(azimuth, elevation, h3D):
  2. """
  3. retrieves the impulse response from h3D that is closest to the specified
  4. azimuth and elevation (in degrees)
  5. h3D is the array containing all HRTFs for a given subject (left or right)
  6. """
  7.  
  8. elmax = 50
  9. elindices = np.arange(elmax)
  10. elevations = -45 + 5.625 * (elindices-1)
  11. azimuths = np.concatenate(([-80, -65, -55], np.arange(-45, 45+1, 5), [55, 65, 80]))
  12.  
  13. # el est est l'indice du plus proche de l'indicie elevation entré
  14. el = round ((elevation + 45) / 5.625 + 1)
  15. el = np.maximum(el, 1)
  16. el = np.minimum(el, elmax)
  17. elerr = el - (elevation + 45) / 5.625 + 1
  18.  
  19. # azim est l'indice du plus proche de l'indice azimuth entr�
  20. daz = abs(azimuths - azimuth)
  21. azim = np.argmin(daz)
  22. azerr = daz[azim]
  23.  
  24. print('les paramètres utilisés pour la HRTF sont:')
  25. print('\t azimuth: %i degrés' % azimuths[azim])
  26. print('\t élevation: %6.3f degrés' % (-45 + 5.625 * (el - 1)))
  27. print('les indices sont:')
  28. print('\t azim: %i' % azim)
  29. print('\t el: %d ' % el)
  30.  
  31. pulse = np.squeeze(h3D[azim,el,:])
  32. return pulse, azerr, elerr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement