Skip to content

Instantly share code, notes, and snippets.

@pushkarsingh019
Created November 17, 2024 06:20
Show Gist options
  • Select an option

  • Save pushkarsingh019/bad0ae23bf8f2bfa30b1e6cc62571385 to your computer and use it in GitHub Desktop.

Select an option

Save pushkarsingh019/bad0ae23bf8f2bfa30b1e6cc62571385 to your computer and use it in GitHub Desktop.
ITD CUES SOUND
def get_angled_sound(angle, sound, externalise, frequency):
"""
This function takes in azimuth angle and monoaural sound and returns sound with the specified angle.
Angle : azimuth angle. Where 0 is the center. So one posituve integer.
Sound : the sound on which you want to get the angled sound.
externalise : Boolean. If the function should externalise sound or not.
frequency : Frequency of the sound to calculate ITD.
head_size : Optional. In case you want calculate ITD specific to head sizes.
Returns : Two slab.Binaural instances with left and right versions of the sound.
"""
# calculating ITD
itd = sound.azimuth_to_itd(angle, frequency = frequency)
# applying itd to sound
right = sound.itd(duration = itd)
left = sound.itd(duration = -itd)
if externalise:
right = right.externalize()
left = left.externalize()
right.level = level
left.level = level
return left, right
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment