SpHr_CrossingCarrierCues [ Flags ] CFs, srcFilterBank
Spatial cues are obtained using the zero-crossings of waveform derivatives (i.e., zero-crossings corresponding to waveform maxima). Cue times correspond to the latter of the two interpolated zero-crossings that define each ITD.
Parameters
CFs Bank of center frequencies (Hz). See SpHr_FilterCenterFreqs. Cues for individual bands may be excluded by setting values to NaN. Passed frequencies are used to determine the maximum number of crossings expected.
srcFilterBank Specifies the single precision 'filter bank' for which cues are obtained. See SpHr_FilterBankBiquad. Left channel frequency bands are specified by columns in layer 0. Right channel frequency bands are specified by columns in layer 1.
srcFilterBank(startX, endX) Specifies an x-range in the source wave.
srcFilterBank[startP,endP] Specifies a point-range in the source wave.
Flags
/F = maxFreq
Maximum center frequency (CFs value) for which carrier cues are found.
/F = {minFreq, maxFreq}
minimum and maximum center frequencies (CFs values) for which carrier cues are found.
/Type = [ type ]
Calculate cues using zero crossings of waveforms or waveform derivatives.
/Type=0: (Default) Cues calculated using waveform zero crossings. Same as no /Type flag if /ABL, /En, and /dtEn flags are omitted.
/Type=1: Cues calculated using zero crossings of waveform derivatives. Same as /Type alone if /ABL, /En, and /dtEn flags are omitted.
Calculating derivatives is desirable when absolute ABL or amplitude envelope values are required, see /ABL, /En, and /dtEn flags. Derivatives are automatically calculated when these flags are present unless type = 0. Note that ABL and amplitude envelope values are still accurate on a relative scale when type = 0 (values are scaled relative to each other).
/Type=1: (Default) Same as /Type flag alone or no /Type flag, if /ABL, /En, or /dtEn flag is present.
/Type=0: Derivatives are not calculated even if the /ABL, /En, or /dtEn flag is present.
/X = [ destWaveName ]
Times when ITDs and other corresponding cues were found are written to the wave specified by destWaveName. If destWaveName is omitted, the destination wave uses the name of srcWaveName or nameStr (see /N flag) as a prefix and appends '_Xs'. The wave is single precision and always overwritten. Values are written only to layer 0.
/XN = [ destWaveName ]
Number of of zero-crossings found for each frequency band. If destWaveName is omitted, the destination wave uses the name of srcWaveName or nameStr (see /N flag) as a prefix and appends '_Ns'. The wave is single precision and always overwritten.
/ITD = [ destWaveName ]
Interaural time differences (ITD) in seconds. If destWaveName is omitted, the destination wave uses srcWaveName or nameStr (see /N flag) as a prefix and appends '_ITDs'. The wave single precision and is always overwritten.
/IPD = [ destWaveName ]
Interaural phase differences (IPD) in cycles. If destWaveName is omitted, the destination wave uses srcWaveName or nameStr (see /N flag) as a prefix and appends '_IPDs'. The wave single precision and is always overwritten.
/ILD = [ destWaveName ]
Interaural level differences (ILD) in decibels (dB). If destWaveName is omitted, the destination wave uses srcWaveName or nameStr (see /N flag) as a prefix and appends '_ILDs'. The wave single precision and is always overwritten.
/ABL = [ destWaveName ]
Average binaural level (ABL) in decibels (dB). If destWaveName is omitted, the destination wave uses srcWaveName or nameStr (see /N flag) as a prefix and appends '_ABLs'. Values are always in decibels re: 20 µPa, ABL = 20*log((Env[p][q][0]+Env[p][q][1])/(0.00002*2)) The wave single precision and is always overwritten.
/En = [ { dB, destWaveName } ]
Zero-crossing envelopes. Values in layer 0 correspond to the left channel. Values in layer 1 correspond to the right channel. Note that times obtained using the /X flag corresponding to these values are in a single layer. This wave is single precision and always overwritten.
/dB= 0: Envelopes are linearly scaled in Pascals (Pa).
/dB= 1: Envelopes are scaled in decibels (20*log(En)/20 µPa).
If destWaveName is omitted, the destination wave uses srcWaveName or nameStr (see /N flag) as a prefix and appends '_Envs'.
/dtEn = [ { dB, interp, destWaveName } ]
Derivatives of zero-crossing envelopes. Values in layer 0 correspond to the left channel. Values in layer 1 correspond to the right channel. Note that times obtained using the /X flag corresponding to these values are in a single layer. This wave is single precision and always overwritten.
/dB= 0: Envelope derivatives are linearly scaled in Pascals (Pa).
/dB= 1: Envelope derivatives are scaled in decibels (20*log(En)/20 µPa).
/interp= 0: (default) Envelope derivatives correspond to values contributing to each ITD and other corresponding cues. The derivatives therefore scatter when cues per cycle (see /CPC flag) is set to 2 or 3.
/interp= 1: (default) Envelope derivatives correspond to the condition when only one cue per cycle is registered. When cues per cycle > 1, envelope derivatives at the times of additional ITD and corresponding cues are interpolated using a cubic spline. This flag does nothing when CPC = 1.
If destWaveName is omitted, the destination wave uses srcWaveName or nameStr (see /N flag) as a prefix and appends '_dtEnvs'.
/AWts = { amplitudeLimit, derivativeLimit, destWaveName }
Envelope weights, averaged across the left and right channels, are calculated and written to the wave specified by destWaveName. The wave is single precision and always overwritten. Weights obtained using this flag should be equivalent to weights computed using the /AWts flag of the SpHr_CrossingEnvelopeWeights operation (which provides additional output options).
amplitudeLimit Neural activity limit for envelope amplitude weights. Values do not contribute to destWaveName if amplitudeLimit is <= 0. Use the /dB flag or the dB parameter of the /En flag to compute the weights in decibels. This is the same as passing the destination of this operation's /En flag to the SpHr_CrossingEnvelopeWeights operation via the Ys parameter.
derivativeLimit Neural activity limit for envelope derivative weights. Values do not contribute to destWaveName if derivativeLimit <= 0. Use the /dtdB flag or the dB paramter of the /dtEn flag to compute the weights in decibels. This is the same as passing the destination of this operation's /dtEn flag to the SpHr_CrossingEnvelopeWeights operation via the Ys parameter.
If amplitudeLimit and derivativeLimit both exceed 0, both types of weights are calculated and averaged.
/TR = [ tr ] Truncate the number of rows in destination waves to the number of crossings found. Otherwise, the number of rows remains equal to the maximum number of crossing expected.
/TR=0: Rows are not truncated.
/TR=1: Same as /TR alone or no /TR flag. (Default)
/CPC = [cpc]
Approximate number of ITDs, and other corresponding cues, registered per waveform cycle. Values between 1 and 3 are accepted.
/CPC=1: Default. Same as no /CPC flag. One cue is obtained for each zero-crossing. There are 2 crossings per cycle and therefore 2 cues registered per waveform cycle. ITD, IPD, and the timing of other cue values reflect only the shortest ITD found per zero-crossing.
/CPC=2: Two cues are obtained for each zero-crossing. There are 2 crossings per cycle and therefore 4 cues registered per waveform cycle. ITD, IPD, and the timing of other cue values reflect the 1st and 2nd shortest ITDs found per zero-crossing.
/CPC=3: Three cues are obtained for each zero-crossing. There are 2 crossings per cycle and therefore 6 cues registered per waveform cycle. ITD, IPD, and the timing of other cue values reflect the 1st, 2nd, and 3rd shortest ITDs found per zero-crossing.
/DF = dfRef dfRef is an optional datafolder reference. Destination waves are written to this existing datafolder, overriding any datafolder specified by destWaveNames. Waves are written to the current datafolder if not specified here or in destWaveNames.
/N = nameStr optional string to take the place of srcWaveName if destWaveNames are not specified.
/Cues = bitMask
Bit mask used to determine which cues are generated. Set bit 0 for Xs, bit 1 for Ns, bit 2 for ITDs, bit 3 for IPDs, bit 4 for ILDs, bit 5 for ABLs, (bit 6 is reserved), bit 7 for envelopes, bit 8 for envelope derivatives.
/dB = [ db ]
Filter bank envelopes (see /En) flag are scaled in decibels re: 20 µPa. Without this flag, envelopes are linearly scaled (Pa). This flag may be overridden by the first parameter of the /En flag and is meant to be used with the /Cues flag or when the /En flag passes no parameters.
/dB=0: Envelopes are linearly scaled in Pascals (Pa). Default.
/dB=1: Same as /dB alone. Values are in decibels. 20*log(En)/20 µPa.
/dtdB = [ dtdb ]
Filter bank envelope derivatives (see /dtEn flag) are scaled in decibels re: 20 µPa. Without this flag, envelope derivatives are linearly scaled (Pa). This flag may be overridden by the first parameter of the /dtEn flag and is meant to be used with the /Cues flag or when the /dtEn flag passes no parameters.
/dtdb =0: Envelope derivativesare linearly scaled in Pascals (Pa). Default.
/dtdb =1: Same as /dB alone. Values are in decibels. 20*log(En)/20 µPa.
/idt = [ interp ]
Interpolate filter bank envelope derivatives (see /dtEn flag). This flag may be overridden by the second parameter of the /dtEn flag and is meant to be used with the /Cues flag or when the /dtEn flag passes no parameters.
/interp= 0: Envelope derivatives correspond to values contributing to each ITD. The derivatives therefore scatter when cues per cycle is set to 2 or 3 (see /CPC flag). Default when /idt flag is omitted.
/interp= 1: Envelope derivatives correspond to the condition when only one cue per cycle is registered. When cues per cycle > 1, envelope derivatives at the times of additional ITD and corresponding cues are interpolated using a cubic spline. Same as /idt flag alone.
/SPks = [ pks, pkXs ]
pks 'Signed peaks' possibly useful when evaluating the zero-crossings algorithm.
pkXs Times corresponding to the signed peaks.
If the /SPks flag is passed with no destination waves specified, waves are generated with the name of srcFilterBank as a prefix, or the string passed by the /N flag. The signed peaks wave is then appended with the suffix '_SignedPeaks' and the wave of corresponding times is appended with the suffix '_SignedPeak_Xs'.
Notes:
Cues and envelopes are computed only for waveform maxima above a threshold of -20 dB re: 20 µPa. If lower amplitude values precede a sound of interest, values may be poorly defined, especially if the /AWts flag is used.
Example
Function SpHr_CrossingCarrierCues_Example()
variable fs = 48000
// Generate binaural noise burst in independent background signal
SpHr_SignalBinaural/ms=400/Ramp=20/dB=30/HP=50/Sp=1/Ind=1 fs, NoiseBurst
variable ITD = 0.2 // ms
SpHr_SignalBinaural/Sum/ms=200/Ramp=20/dB=70/HP=50/Buff={100,100}/Sp=1/Ind=0/ITD={ITD,1} fs, NoiseBurst
// Generate filter bank
SpHr_FilterCenterFreqs/R/Type=(2) 100, 500, 3, CFs // log
SpHr_FilterBankBiquadCoefs 48000, CFs, coefBank
SpHr_FilterBankBiquad /RMS/Dest=FilterBanks CFs, coefBank, NoiseBurst
killwaves/Z coefBank, NoiseBurst
// Generate ITDs using zero crossings
SpHr_CrossingCarrierCues/ITD=ITDs/X=Xs CFs, FilterBanks
killwaves/Z FilterBanks
Display/K=1/W=(35,45,553,311) as "Carrier ITDs"
AppendToGraph ITDs[][0] /TN=Hz_100 vs Xs[][0]
AppendToGraph ITDs[][1] /TN=Hz_224 vs Xs[][1]
AppendToGraph ITDs[][2] /TN=Hz_500 vs Xs[][2]
ModifyGraph mode=3,marker=19,msize=1.5
ModifyGraph rgb(Hz_100)=(0,0,65535),rgb(Hz_224)=(2,39321,1)
SetAxis left -0.001,0.001
ModifyGraph zero(left)=1,zeroThick(left)=0.5
Label left "ITD (\\U)"
Label bottom "time (\\U)"
TextBox/C/N=text0/F=0/B=1/H={15,0,5}/A=MT/X=0.00/Y=0.00 "\\sb+06\\Z10CF (Hz)\r\\s(Hz_100) 100\r\\s(Hz_224) 224\r\\s(Hz_500) 500"
SetDrawEnv ycoord= left,dash= 2,linethick= 0.50
DrawLine 0,ITD/1000,1,ITD/1000
End