object Pitch extends ProductReader[Pitch] with Serializable
An autocorrelation based pitch following UGen. It is more accurate than
ZeroCrossing , but more also more CPU costly. For most purposes the default
settings can be used and only in needs to be supplied.
The UGen has two outputs: The first output is the frequency estimate in Hertz,
the second output is a toggle hasFreq , which tells whether a pitch was found
(1) or not (0). If the clarify argument is used, hasFreq has more fine
grained information.
The pitch follower executes periodically at the rate specified by execFreq in
cps. First it detects whether the input peak to peak amplitude is above the
ampThresh . If it is not then no pitch estimation is performed, the hasFreq
output is set to zero and the freq output is held at its previous value.
Otherwise, the autocorrelation is calculated, and the first peak after the peak
around the lag of zero that is above peakThresh times the amplitude of the
peak at lag zero is reported.
Examples
// pitch-follower resynthesizing with saw tooth play { // be careful and use headphones! val in = Mix(PhysicalIn.ar(0, 2)) val amp = Amplitude.kr(in, 0.05, 0.05) val p = Pitch.kr(in, ampThresh = 0.02, median = 7) val saw = Mix(VarSaw.ar(p.freq * Seq(0.5, 1, 2), 0, LFNoise1.kr(0.3,0.1,0.1)) * amp) Mix.fold(saw, 6) { res => AllpassN.ar(res, 0.040, Rand(0, 0.040), Rand(0, 0.040), 2) } }
- Alphabetic
- By Inheritance
- Pitch
- Serializable
- ProductReader
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def kr(in: GE, initFreq: GE = 440.0f, minFreq: GE = 60.0f, maxFreq: GE = 4000.0f, execFreq: GE = 100.0f, binsPerOct: GE = 16, median: GE = 1, ampThresh: GE = 0.01f, peakThresh: GE = 0.5f, downSample: GE = 1, clarity: GE = 0): Pitch
- in
The signal to be analyzed.
- initFreq
The initial value of the
freqoutput, until the first valid pitch is found. (init-time only)- minFreq
The minimum frequency in Hertz to be considered for reporting. (init-time only)
- maxFreq
The maximum frequency in Hertz to be considered for reporting. (init-time only)
- execFreq
The frequency at which the pitch is estimated. This will be automatically clipped to be between
minFreqandmaxFreq. (init-time only)- binsPerOct
A value which guides the search for the peak frequency in the first coarse step. Its setting does *not* affect the final pitch resolution; setting it larger will cause the coarse search to take longer, and setting it smaller will cause the fine search to take longer. (init-time only)
- median
This specifies the length of a median filter applied to the frequency output estimation. With the default value of
1the filter is defeated. Median filtering can help eliminating single spikes and jitter. This will however add latency to the output. (init-time only)- ampThresh
The minimum amplitude threshold above which the pitch follower operates. An input signal below this threshold is not analyzed. (init-time only)
- peakThresh
This is a threshold used to find the first peak in the autocorrelation signal which gives the reported frequency. It is a factor of the energy of the signal (autocorrelation coefficient at zero). Set this value higher (e.g. to
1) to eliminate false frequencies corresponding to overtones. (init-time only)- downSample
An integer factor by which the input signal is down sampled to reduce CPU overhead. This will also reduce the pitch resolution. The default value of
1means that the input signal is not down sampled. (init-time only)- clarity
If the
clarityargument is greater than zero (it is zero by default) then thehasFreqoutput is given additional detail. Rather than simply being 1 when a pitch is detected, it is a "clarity" measure in the range between zero and one. (Technically, it's the height of the autocorrelation peak normalised by the height of the zero-lag peak.) It therefore gives a kind of measure of "purity" of the pitched signal. (init-time only)
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def read(in: RefMapIn, key: String, arity: Int): Pitch
- Definition Classes
- Pitch → ProductReader
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated