Main Content

interauralTimeDifference

Interaural time difference

Since R2024a

    Description

    itd = interauralTimeDifference(s) computes the interaural time difference of the HRTF measurements in the horizontal plane at zero elevation. The interaural time difference is a binaural localization cue.

    example

    itd = interauralTimeDifference(s,Name=Value) specifies options using one or more name-value arguments.

    example

    [itd,ang] = interauralTimeDifference(___) also returns the angles corresponding to the measurements.

    example

    interauralTimeDifference(___) with no output arguments plots the interaural time difference.

    example

    Examples

    collapse all

    Read in a SOFA file containing HRTF measurements.

    s = sofaread("ReferenceHRTF.sofa");

    Compute the interaural time difference of the HRTF data in the horizontal plane.

    [itd,azi] = interauralTimeDifference(s);

    Call interauralTimeDifference with no output arguments to plot the interaural time difference of the HRTF data in the horizontal plane. See how the time difference increases with the distance of the source from the median plane.

    interauralTimeDifference(s)

    Figure contains an axes object. The axes object with title Horizontal Plane Interaural Time Difference, xlabel Azimuth (degrees), ylabel ITD (s) contains an object of type line.

    Read in a SOFA file containing HRTF measurements.

    s = sofaread("ReferenceHRTF.sofa");

    Call interauralTimeDifference with Specification set to "measurements" to compute the interaural time difference of all HRTF measurements in the SOFA file.

    itd = interauralTimeDifference(s,Specification="measurements");

    Call interauralTimeDifference with no output arguments to visualize the interaural time difference of all measurements.

    interauralTimeDifference(s,Specification="measurements");

    Figure contains an axes object. The axes object with title Interaural Time Difference, xlabel X (meters), ylabel Y (meters) contains an object of type patch.

    Input Arguments

    collapse all

    SOFA object, specified as a SimpleFreeFieldHRIR object.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: interauralTimeDifference(s,Specification="measurements")

    Plane to compute the interaural time difference, specified as "horizontal", "median", or "sagittal".

    This argument applies only when Specification is "plane".

    Data Types: char | string

    Plane offset angle in degrees, specified as a value in the range [-90,90]. This angle specifies the offset by which the Plane is shifted.

    This argument only applies to the horizontal and sagittal planes. For the horizontal plane, the offset corresponds to the elevation angle. For the sagittal plane, the offset corresponds to the lateral angle.

    This argument applies only when Specification is "plane".

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Angle tolerance in degrees, specified as a positive scalar. The function computes the interaural time difference of the measurements within the tolerance of the plane specified by Plane and PlaneOffsetAngle.

    This argument applies only when Specification is "plane".

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Use interpolated HRTF measurements, corresponding to 100 uniformly-spaced points in the specified plane, to compute the interaural time difference. Set this argument to true if the plane specified by Plane, PlaneOffsetAngle, and AngleTolerance does not contain a sufficient number of HRTF measurements. The function uses the bilinear interpolation method.

    This argument applies only when Specification is "plane".

    Data Types: logical

    Measurements specification, specified as "plane" or "measurements". Set this argument to "plane" to use Plane, PlaneOffsetAngle, and AngleTolerance to specify the plane over which to compute the interaural time difference. Set this argument to "measurements" to use MeasurementIndex to select the specific measurements for which to compute the interaural time difference.

    Data Types: char | string

    Indices of measurements to use, specified as a vector of positive integers. The indices must correspond to measurements in the data of the SOFA object s. By default, the function includes all measurements.

    This argument only applies when you set Specification to "measurements".

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Apply a lowpass filter to the HRTF data, specified as true or false.

    Data Types: logical

    Cutoff frequency for the lowpass filter, specified as a positive scalar.

    This argument only applies when you set ApplyLowpassFilter to true.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Onset threshold in dB used to determine the arrival time at each ear, specified as a scalar less than or equal to zero. The arrival time corresponds to the first sample exceeding M+T, where M is the maximum value of the impulse response (in dB), and T is the onset threshold.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Output Arguments

    collapse all

    Interaural time difference in seconds, returned as a vector of length M, where M is the number of specified measurements.

    Angles in degrees corresponding to the measurements used to compute the interaural time difference, returned as a vector. The interpretation of the angles depends on the specified Plane.

    • For the horizontal plane, the angles correspond to the azimuth.

    • For the median plane, the angles correspond to the elevation.

    • For the sagittal plane, the angles correspond to the polar angles.

    The interauralTimeDifference function only returns this argument when Specification is "plane".

    More About

    collapse all

    Interaural Time Difference

    The interaural time difference is the difference in arrival time of sounds at the left and right ears. This provides a strong binaural localization cue for frequencies below 1500 Hz.

    At frequencies above 1500 Hz, the interauralLevelDifference provides a better binaural localization cue.

    Algorithms

    The interauralTimeDifference function calculates the interaural time difference according the onset threshold method described in [1].

    References

    [1] Andreopoulou, Areti, and Brian F. G. Katz. “Identification of Perceptually Relevant Methods of Inter-Aural Time Difference Estimation.” The Journal of the Acoustical Society of America 142, no. 2 (August 1, 2017): 588–98. https://doi.org/10.1121/1.4996457.

    Version History

    Introduced in R2024a