SpHr_CrossingEnvelope [ Flags ]  srcWaveName [ , srcWaveName2


Obtains amplitude envelopes using zero-crossings or their derivatives.


Parameters

srcWaveName  Specifies the single precision wave for which envelopes are obtained using zero-crossings. The function is applied across rows and is multithreaded if srcWaveName consists of more than one column, layer, or chuck.


srcWaveName(startX, endX)  Specifies an x-range in the source wave.


srcWaveName[startP, endP]  Specifies a point-range in the source wave.


[srcWaveName2]  Second, optional, source wave for which envelopes are obtained. When included, srcWaveName and srcWaveName2 must both have (1) one dimension (no columns), (2) the same x-scaling, and (3) the same number of points. Envelopes for srcWaveName and srcWaveName2 are written to the first two columns of one or more multidimensional destination waves (see destination flags). Because SpHr_CrossingEnvelope is multithreaded, this is slightly faster than calling the function separately for each wave.


Flags

/X = [destWaveName]

    x-values corresponding to the times of envelope crossings. Destination envelopes should be displayed and analyzed versus these values. If destWaveName is omitted, the destination wave uses the name of srcWaveName as a prefix and appends '_EnvX'. This wave is always overwritten.


/XN = [destWaveName]    

    Number of envelope zero-crossings. If destWaveName is omitted, the destination wave uses the name of srcWaveName as a prefix and appends '_EnvN'. This wave is always overwritten.


/dB = [destWaveName]

    Amplitude envelopes are scaled in decibels (20*log[Pa]). If destWaveName is omitted, the destination wave uses the name of srcWaveName as a prefix and appends '_EnvdB'. This wave is always overwritten.


/dtdB = [destWaveName]

    Derivatives of amplitude envelopes scaled in decibels (20*log[Pa]). If destWaveName is omitted, the destination wave uses the name of srcWaveName as a prefix and appends '_EnvdtdB'. This wave is always overwritten.


/Pa = [destWaveName]

    Amplitude envelopes are linearly scaled (units are in Pascals, assuming srcWaveName is sound). If destWaveName is omitted, the destination wave uses the name of srcWaveName as a prefix and appends '_EnvPa'. This wave is always overwritten.


/dtPa = [destWaveName]

    Derivatives of linearly scaled amplitude envelopes. If destWaveName is omitted, the destination wave uses the name of srcWaveName as a prefix and appends '_EnvdtPa'. This wave is always overwritten.


/CF = cf

    Center frequency (Hz). See SpHr_FilterBiquad. cf is used to estimate the number of crossings expected. If omitted, cf is assumed to be half of srcWaveName's sampling frequency, possibly generating long waves during execution (before destination waves are truncated to the number of crossings actually found).


/CFs = cfs

    Filter bank center frequencies (Hz). See SpHr_FilterCenterFreqs. Envelopes for individual bands may be excluded by setting values to NaN. Frequencies are used to determine the maximum number of crossings expected. If omitted, the highest frequency is assumed to be half of srcWaveName's sampling frequency.


/DF = dfRef

    dfRef is an optional datafolder reference. Destination waves are written to this existing datafolder, overriding any datafolder specified by destWaveName. Waves are written to the current datafolder if not specified here or in destWaveName.


/N = nameStr    

    optional string to take the place of srcWaveName if destWaveName is not specified.


/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)


Examples

Function SpHr_CrossingEnvelope_Example()

    variable fs = 48000

    SpHr_SignalGaussian/ms=50/Sp=0/dB=70/Ramp=10/Buff={0,20} fs, Noise

    variable Hz = 500

    SpHr_FilterBiquad /CF=(Hz)/Dest=filteredNoise Noise

    SpHr_CrossingEnvelope/CF=(Hz)/X=EnvelopeXs/Pa=Envelope filteredNoise

    Display/K=1 filteredNoise

    AppendToGraph Envelope vs EnvelopeXs

    ModifyGraph lsize=0.5,rgb(filteredNoise)=(34952,34952,34952),mode(Envelope)=4

    ModifyGraph marker(Envelope)=19,msize(Envelope)=1,rgb(Envelope)=(0,0,0)

    Label left "amplitude (\\U)"

    Label bottom "time (\\U)"

End

Contact: Brian