Skip to content

Tartini's confidence output is different on macOS (vDSP) and other platforms (FFTW) #447

Description

@dyfer

Yes, this has been an issue for ten years now. I have only seen it with Tartini. I use several other FFT-based UGens elsewhere in this application, and I have seen no other issues with regard to vDSP vs FFTW.

So, here is the SynthDef where I call on Tartini:

		///////////////////////////////////////////////////////////////////////////////////////////////////////
		// Analyze Audio SynthDef
		///////////////////////////////////////////////////////////////////////////////////////////////////////  ;
		SynthDef.new(nameAnalyzeAudio,
			{ | aiBusConditionedMic,
				coBusFrequency,
				coBusAmplitude,
				coBusClarity,
				coBusCrest,
				coBusSB |

				var in, inrms, amp, freq, freqOut, crest, gate, clarity, specBal;

				in = In.ar(aiBusConditionedMic);
				#inrms, crest = CrestCycles.ar(in);
				specBal = SpectrumBalance.ar(in);

				// The following line serves only to guard against true-zero audio in test files
				amp = Select.kr(InRange.kr(inrms, -1.0, 0.0), [inrms.ampdb, DC.kr(-100)]);

				// Integrator brings down the HF - but is that needed?
				# freq, clarity = Tartini.kr(Integrator.ar(in, 0.995), n: 2048, k: 0, overlap: 1024);
				freq = Sanitize.kr(freq.cpsmidi, 20);

				Out.kr(coBusFrequency, [freq]);
				Out.kr(coBusAmplitude, [amp]);
				Out.kr(coBusClarity, [clarity]);
				Out.kr(coBusCrest, [crest]);
				Out.kr(coBusSB, [specBal]);
			}
		).add(libname);

The first screenshot below is the result when using the PitchDetection.scx as distributed, with vDSP. The signal is a woman reading a text. The relevant curve is the red one, which is the verbatim value of Tartini's "clarity" output. I use this clarity value as a gate that blocks further analysis if it is below a threshold. The problem is that it is 1 or nearly 1 almost all the time. This also means that the voice map to the right contains a lot of invalid data, because unvoiced segments have been included.

Image

The second screenshot below is a result when using the PitchDetection.scx re-linked with FFTW. This is the correct result, and it is bit-exactly the same as I get on Windows.

Image

Notice how the red clarity curve now descends at the onset and offset of voiced segments. We see also that the voice maps are much cleaner and contain only the parts that were actually spoken.

I did not want to try to debug Tartini since re-linking solved the problem. But it means that on Mac, my install script has to replace the standard PitchDetection.scx with the re-linked version, and then restore it on the uninstall. So if this could be fixed, that would be wonderful.

I agree that re-linking statically with FFTW would be more robust, but this makes the plugin several MB larger, and it is still non-standard with respect to the ordinary SC3-plugins distribution.

For more info about voice mapping and FonaDyn, you are welcome to visit the User's Forum.

Cheers,
sternsc

Originally posted by @sternsc in #7543

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions