KeyExtractor
extends BaseAlgorithm
in package
KeyExtractor
Inputs:
[vector_real] audio - the audio input signal
Outputs:
[string] key - See Key algorithm documentation [string] scale - See Key algorithm documentation [real] strength - See Key algorithm documentation
Parameters:
averageDetuningCorrection: bool ∈ {true,false} (default = true) shifts a pcp to the nearest tempered bin
frameSize: integer ∈ (0,inf) (default = 4096) the framesize for computing tonal features
hopSize: integer ∈ (0,inf) (default = 4096) the hopsize for computing tonal features
hpcpSize: integer ∈ [12,inf) (default = 12) the size of the output HPCP (must be a positive nonzero multiple of 12)
maxFrequency: real ∈ (0,inf) (default = 3500) max frequency to apply whitening to [Hz]
maximumSpectralPeaks: integer ∈ (0,inf) (default = 60) the maximum number of spectral peaks
minFrequency: real ∈ (0,inf) (default = 25) min frequency to apply whitening to [Hz]
pcpThreshold: real ∈ [0,1] (default = 0.20000000298) pcp bins below this value are set to 0
profileType: string ∈ {diatonic,krumhansl,temperley,weichai,tonictriad,temperley2005,thpcp,shaath,gomez,noland,faraldo,pentatonic,edmm,edma,bgate,braw} (default = "bgate") the type of polyphic profile to use for correlation calculation
sampleRate: real ∈ (0,inf) (default = 44100) the sampling rate of the audio signal [Hz]
spectralPeaksThreshold: real ∈ (0,inf) (default = 9.99999974738e-05) the threshold for the spectral peaks
tuningFrequency: real ∈ (0,inf) (default = 440) the tuning frequency of the input signal
weightType: string ∈ {none,cosine,squaredCosine} (default = "cosine") type of weighting function for determining frequency contribution
windowType: string ∈ {hamming,hann,hannnsgcq,triangular,square,blackmanharris62,blackmanharris70,blackmanharris74,blackmanharris92} (default = "hann") the window type
Description:
This algorithm extracts key/scale for an audio signal. It computes HPCP frames for the input signal and applies key estimation using the Key algorithm.
The algorithm allows tuning correction using two complementary methods:
- Specify the expected
tuningFrequencyfor the HPCP computation. The algorithm will adapt the semitone crossover frequencies for computing the HPCPs accordingly. If not specified, the default tuning is used. Tuning frequency can be estimated in advance using TuningFrequency algorithm. - Apply tuning correction posterior to HPCP computation, based on peaks in
the HPCP distribution (
averageDetuningCorrection). This is possible when hpcpSize > 12.
For more information, see the HPCP and Key algorithms.
Category: Extractor Mode: standard
Table of Contents
Properties
- $algorithmName : string
- $category : string
- $essentia : EssentiaFFI
- $mode : string
- $parameters : array<string|int, mixed>
- $algorithmHandle : CData|null
- $configured : bool
Methods
- __construct() : mixed
- __destruct() : mixed
- compute() : array<string|int, mixed>
- getAlgorithmName() : string
- getCategory() : string
- getMode() : string
- getParameters() : array<string|int, mixed>
- setParameter() : self
- configure() : void
- isValidParameter() : bool
- validateInput() : void
- cleanupAlgorithm() : void
- configureAlgorithmParameters() : void
- estimateOutputSize() : int
- executeAlgorithm() : array<string|int, mixed>
- executeGenericAlgorithm() : array<string|int, mixed>
- executeSpecificAlgorithm() : array<string|int, mixed>
- getAlgorithmCreateFunction() : string
- getValidParameters() : array<string|int, mixed>
- initializeAlgorithm() : void
- prepareInput() : mixed
- processOutput() : array<string|int, mixed>
- processRhythmOutput() : array<string|int, mixed>
- processSpectralOutput() : array<string|int, mixed>
- processStatsOutput() : array<string|int, mixed>
- processTemporalOutput() : array<string|int, mixed>
- processTonalOutput() : array<string|int, mixed>
- setAlgorithmParameter() : void
- setArrayParameter() : void
- validateAlgorithmInput() : void
Properties
$algorithmName
protected
string
$algorithmName
= 'KeyExtractor'
$category
protected
string
$category
= 'Extractor'
$essentia
protected
EssentiaFFI
$essentia
$mode
protected
string
$mode
= 'standard'
$parameters
protected
array<string|int, mixed>
$parameters
= []
$algorithmHandle
private
CData|null
$algorithmHandle
= null
$configured
private
bool
$configured
= false
Methods
__construct()
public
__construct([array<string|int, mixed> $parameters = [] ]) : mixed
Parameters
- $parameters : array<string|int, mixed> = []
__destruct()
public
__destruct() : mixed
compute()
public
compute(mixed $input) : array<string|int, mixed>
Parameters
- $input : mixed
Return values
array<string|int, mixed>getAlgorithmName()
public
getAlgorithmName() : string
Return values
stringgetCategory()
public
getCategory() : string
Return values
stringgetMode()
public
getMode() : string
Return values
stringgetParameters()
public
getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>setParameter()
public
setParameter(string $key, mixed $value) : self
Parameters
- $key : string
- $value : mixed
Return values
selfconfigure()
protected
configure(array<string|int, mixed> $parameters) : void
Parameters
- $parameters : array<string|int, mixed>
isValidParameter()
protected
isValidParameter(string $parameter) : bool
Parameters
- $parameter : string
Return values
boolvalidateInput()
protected
validateInput(mixed $input, string $expectedType) : void
Parameters
- $input : mixed
- $expectedType : string
cleanupAlgorithm()
private
cleanupAlgorithm() : void
configureAlgorithmParameters()
private
configureAlgorithmParameters() : void
estimateOutputSize()
private
estimateOutputSize(mixed $input) : int
Parameters
- $input : mixed
Return values
intexecuteAlgorithm()
private
executeAlgorithm(mixed $input) : array<string|int, mixed>
Parameters
- $input : mixed
Return values
array<string|int, mixed>executeGenericAlgorithm()
private
executeGenericAlgorithm(FFI $ffi, mixed $input) : array<string|int, mixed>
Parameters
- $ffi : FFI
- $input : mixed
Return values
array<string|int, mixed>executeSpecificAlgorithm()
private
executeSpecificAlgorithm(FFI $ffi, mixed $input) : array<string|int, mixed>
Parameters
- $ffi : FFI
- $input : mixed
Return values
array<string|int, mixed>getAlgorithmCreateFunction()
private
getAlgorithmCreateFunction() : string
Return values
stringgetValidParameters()
private
getValidParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>initializeAlgorithm()
private
initializeAlgorithm() : void
prepareInput()
private
prepareInput(mixed $input) : mixed
Parameters
- $input : mixed
processOutput()
private
processOutput(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
- $result : array<string|int, mixed>
Return values
array<string|int, mixed>processRhythmOutput()
private
processRhythmOutput(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
- $result : array<string|int, mixed>
Return values
array<string|int, mixed>processSpectralOutput()
private
processSpectralOutput(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
- $result : array<string|int, mixed>
Return values
array<string|int, mixed>processStatsOutput()
private
processStatsOutput(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
- $result : array<string|int, mixed>
Return values
array<string|int, mixed>processTemporalOutput()
private
processTemporalOutput(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
- $result : array<string|int, mixed>
Return values
array<string|int, mixed>processTonalOutput()
private
processTonalOutput(array<string|int, mixed> $result) : array<string|int, mixed>
Parameters
- $result : array<string|int, mixed>
Return values
array<string|int, mixed>setAlgorithmParameter()
private
setAlgorithmParameter(FFI $ffi, string $key, mixed $value) : void
Parameters
- $ffi : FFI
- $key : string
- $value : mixed
setArrayParameter()
private
setArrayParameter(FFI $ffi, string $key, array<string|int, mixed> $value) : void
Parameters
- $ffi : FFI
- $key : string
- $value : array<string|int, mixed>
validateAlgorithmInput()
private
validateAlgorithmInput(mixed $input) : void
Parameters
- $input : mixed