PYIN Parameters » History » Version 39

Version 38 (Chris Cannam, 2019-11-18 03:18 PM) → Version 39/42 (Chris Cannam, 2019-11-18 03:19 PM)

h1. PYIN Parameters

h3. The pYIN plugin

Tony uses a Vamp plugin called "pYIN":/projects/pyin for pitch and note analysis.

The plugin can be used in other Vamp plugin hosts as well: see the "pYIN project page":/projects/pyin to download the plugin separately from Tony.

This page may be helpful if you need to get results from pYIN that match those generated in Tony (or vice versa).

h3. pYIN parameters that Tony uses

pYIN has a number of processing parameters which can be adjusted, and Tony contains a number of options (on the Analysis menu) which adjust some of them. However, the names, identifiers, and default values of the pYIN parameters do not match those used in Tony. Generally this is because the parameters found in pYIN are continuous value ranges, while the settings in Tony are all on-off toggles.

Here is a table showing the correspondence between Tony menu options and pYIN parameters, as of Tony v2.1 and pYIN v1.1.

|*Tony option*|*pYIN parameter name*|*pYIN parameter id*|*pYIN parameter type*|*pYIN default value*|*Value when Tony option is on*|*Value when Tony option is off*|*Tony option default*|
|Unbiased Timing (slow)|Use non-standard precise YIN timing (slow)|@precisetime@|Toggle|Off|On|Off|Off|
|Penalise Soft Pitches|Suppress low amplitude pitch estimates|@lowampsuppression@|Range 0.0-1.0|0.1|0.2|0.0|On|
|High Onset Sensitivity|Onset sensitivity|@onsetsensitivity@|Range 0.0-1.0|0.7|0.7|0.0|On|
|Drop Short Notes|Duration pruning threshold|@prunethresh@|Range 0.0-0.2|0.1|0.1|0.0|On|

*Note*: There is a bug in Tony v2.1 (as well as earlier releases) in the handling of the "Penalise Soft Pitches" option. When you first run the application, this option is shown as ticked in the menu, but it is not actually activated when running pYIN (the pYIN parameter is instead set to 0.0). If you switch the option off and on again in the menu, or select "Reset Options to Defaults", then the parameter will subsequently be set correctly. This state is remembered in subsequent runs, so you only have to do this once. The bug will be fixed in Tony v2.1.1. This does unfortunately mean the behaviour of v2.1.1 "out of the box" will differ slightly from the (erroneous) first-run behaviour of v2.1.

h3. Other pYIN parameters

There are also some parameters in pYIN that cannot be changed in Tony - the application leaves these all at their default values. They are:

|*pYIN parameter name*|*pYIN parameter id*|*pYIN parameter type*|*Default*|
|Yin threshold distribution|@threshdistr@|8 distinct options|"Beta (mean 0.15)"|
|Fixed-lag smoothing|@fixedlag@|Toggle|On|
|Output estimates classified as unvoiced?|@outputunvoiced@|Three-way toggle|Off|

h3. How to set these parameters when using Sonic Annotator

(See also the "Sonic Annotator documentation":/projects/sonic-annotator/wiki)

You can specify a plugin for Sonic Annotator using the @-d@ (default) flag, which tells it to run a plugin with the default parameters:

<pre>
$ sonic-annotator -d vamp:pyin:pyin:smoothedpitchtrack audio.wav -w csv --csv-one-file output.csv --csv-stdout
</pre>

But if you want to set any parameters to non-default values, you need a transform specification file. You can create a skeleton and then edit it:

<pre>
$ sonic-annotator -s vamp:pyin:pyin:smoothedpitchtrack > pitchtrack.ttl
</pre>

Then edit the file @pitchtrack.ttl@ and change the parameter values in it. For example, you might change this block

<pre>
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "onsetsensitivity" ] ;
vamp:value "0.7"^^xsd:float ;
] ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "outputunvoiced" ] ;
vamp:value "0"^^xsd:float ;
] ;
</pre>

to

<pre>
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "onsetsensitivity" ] ;
vamp:value "0.0"^^xsd:float ;
] ;
vamp:parameter_binding [
vamp:parameter [ vamp:identifier "outputunvoiced" ] ;
vamp:value "2"^^xsd:float ;
] ;
</pre>

to adjust the onset sensitivity and also tell pYIN to return negative values for unvoiced frames. Then run Sonic Annotator with this transform file:

<pre>
$ sonic-annotator -t pitchtrack.ttl audio.wav -w csv --csv-one-file output.csv --csv-stdout
</pre>

h3. Screenshots

|*Options in the Analysis menu of Tony that control pYIN parameters*|*Options available when using pYIN directly in Sonic Visualiser*|
|!Screenshot_2019-11-18_13-03-34.png!|!Screenshot_2019-11-18_13-04-25.png!|