From fe478d2f12b8216962b309cdc44753a15b838c4e Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Sun, 5 May 2019 16:54:33 +0100 Subject: [PATCH] almost finished pitch helpfile --- .../HelpSource/Classes/FluidPitch.schelp | 62 ++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/release-packaging/HelpSource/Classes/FluidPitch.schelp b/release-packaging/HelpSource/Classes/FluidPitch.schelp index 8aa60e4..257dda8 100644 --- a/release-packaging/HelpSource/Classes/FluidPitch.schelp +++ b/release-packaging/HelpSource/Classes/FluidPitch.schelp @@ -6,7 +6,7 @@ RELATED:: Guides/FluCoMa, Guides/FluidDecomposition, Classes/Pitch DESCRIPTION:: This class implements three popular pitch descriptors, computed as frequency and the confidence in its value. It is part of the Fluid Decomposition Toolkit of the FluCoMa project.FOOTNOTE:: This was made possible thanks to the FluCoMa project ( http://www.flucoma.org/ ) funded by the European Research Council ( https://erc.europa.eu/ ) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 725899).:: - The process will return a multichannel control steam with [pitch, confidence] values, which will be repeated if no change happens within the algorythm, i.e. when the hopSize is larger than the server's kr period. + The process will return a multichannel control steam with [pitch, confidence] values, which will be repeated if no change happens within the algorithm, i.e. when the hopSize is larger than the server's kr period. CLASSMETHODS:: @@ -83,26 +83,72 @@ r = Routine { }.play ) -//test signals +//test signals, all in one synth ( x = { - arg freq=220, type = 0; - var source = Select.ar(type,[SinOsc.ar(freq,mul:0.1), VarSaw.ar(freq,mul:0.1), Saw.ar(freq,0.1), Pulse.ar(freq,mul:0.1)]); + arg freq=220, type = 0, noise = 0; + var source = PinkNoise.ar(noise) + Select.ar(type,[SinOsc.ar(freq,mul:0.1), VarSaw.ar(freq,mul:0.1), Saw.ar(freq,0.1), Pulse.ar(freq,mul:0.1), Mix.new(Array.fill(8, {arg i; SinOsc.ar(LFNoise1.kr(0.1.rand,10,220*(i+1)),mul:(i+1).reciprocal * 0.1)}))]); Out.kr(b, FluidPitch.kr(source) ++ Pitch.kr(source)); source.dup; }.play; ) -// comments on digital test signals being better in time domain and how real ones will collapse +// the built-in is slightly worse on pure sinewaves x.set(\freq, 220) x.set(\freq, 440) -x.set(\freq, 11000) +// adding harmonics, by changing to triangle (1), saw (2) or square (3) shows that spectral algo are more resilient when signal are richer +x.set(\type, 1) +x.set(\type, 2) +x.set(\type, 3) -x.set(\type, 0) +// adding noise shows the comparative sturdiness of the spectral pitch tracker +x.set(\noise, 0.05) :: STRONG::a more musical example:: CODE:: -// to be translated from max (and compare to the vanilla one) +// play a noisy synth file +b = Buffer.read(s,File.realpath(FluidPitch.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-ASWINE-ScratchySynth-M.wav"); +b.play(true); + +//insert a selective reverb - sending only the material with very high pitch confidence +( +f = {var source, rev; + source = In.ar(0,2); + rev = FreeVerb.ar(DelayN.ar(source,delaytime:1024/s.sampleRate) * Lag.kr((FluidPitch.kr(source.sum)[1] > 0.98),0.01), 1); + ReplaceOut.ar(0, rev+ source); +}.play(addAction:\addToTail); +) + +// free the effect +f.free + +// insert a stereo delay instead (as well) using the same +( +f = { + var source, todelay, delay1, delay2, delay3, feedback, mod1, mod2, mod3, mod4; + //read the source + source = In.ar(0,2); + + // generate modulators that are coprime in frequency + mod1 = SinOsc.ar(1, 0, 0.001); + mod2 = SinOsc.ar(((617 * 181) / (461 * 991)), 0, 0.001); + mod3 = SinOsc.ar(((607 * 193) / (491 * 701)), 0, 0.001); + mod4 = SinOsc.ar(((613 * 191) / (463 * 601)), 0, 0.001); + + // gate the signal to send to the delays + todelay = DelayN.ar(source,delaytime:1024/s.sampleRate) * Lag.kr((FluidPitch.kr(source.sum)[1] > 0.98),0.01); + + // delay network + feedback = LocalIn.ar(3);// take the feedback in for the delays + delay1 = DelayC.ar(BPF.ar(todelay+feedback[1]+(feedback[2] * 0.3), 987, 6.7,0.35),0.123,0.122+(mod1*mod2)); + delay2 = DelayC.ar(BPF.ar(todelay+feedback[0]+(feedback[2] * 0.3), 1987, 6.7,0.35),0.345,0.344+(mod3*mod4)); + delay3 = DelayC.ar(BPF.ar(todelay+feedback[1], 1456, 6.7,0.35),0.567,0.566+(mod1*mod3),0.6); + LocalOut.ar([delay1,delay2, delay3]); // write the feedback for the delays + + ReplaceOut.ar(0, source + [delay1+delay3,delay2+delay3]); +}.play(addAction:\addToTail); +) + ::