MusicTempo | API Document

    import MusicTempo from 'music-tempo/src/MusicTempo.js'

public class | source

# MusicTempo

Class combines the work of all the steps of tempo extraction

## Constructor Summary

Public Constructor
public | constructor(audioData: Float32Array, params: Object) Constructor |

## Member Summary

Public Members
public | agents: Array Agents array |
public | beatInterval: Number Inter-beat interval |
public | beats: Array Beat times array |
public | bestAgent: Agent The agent with the highest score |
public | events: Array Onsets times array |
public | peaks: Array Spectral flux peaks indexes |
public | spectralFlux: Array Spectral flux |
public | tempo: Number The tempo value in beats per minute |
public | tempoList: Array Tempo hypotheses array |

## Public Constructors

### public constructor(audioData: Float32Array, params: Object) source

Constructor

#### Params:

Name | Type | Attribute | Description
audioData | Float32Array |  | non-interleaved IEEE 32-bit linear PCM with a nominal range of -1 -> +1 (Web Audio API - Audio Buffer)
params | Object | optional default: {} | parameters
params.bufferSize | Number | optional default: 2048 | FFT windows size
params.hopSize | Number | optional default: 441 | spacing of audio frames in samples
params.decayRate | Number | optional default: 0.84 | how quickly previous peaks are forgotten
params.peakFindingWindow | Number | optional default: 6 | minimum distance between peaks
params.meanWndMultiplier | Number | optional default: 3 | multiplier for peak finding window
params.peakThreshold | Number | optional default: 0.35 | minimum value of peaks
params.widthTreshold | Number | optional default: 0.025 | the maximum difference in IOIs which are in the same cluster
params.maxIOI | Number | optional default: 2.5 | the maximum IOI for inclusion in a cluster
params.minIOI | Number | optional default: 0.07 | the minimum IOI for inclusion in a cluster
params.maxTempos | Number | optional default: 10 | initial amount of tempo hypotheses
params.minBeatInterval | Number | optional default: 0.3 | the minimum inter-beat interval (IBI) (0.30 seconds == 200 BPM)
params.maxBeatInterval | Number | optional default: 1 | the maximum inter-beat interval (IBI) (1.00 seconds == 60 BPM)
params.initPeriod | Number | optional default: 5 | duration of the initial section
params.thresholdBI | Number | optional default: 0.02 | for the purpose of removing duplicate agents, the default JND of IBI
params.thresholdBT | Number | optional default: 0.04 | for the purpose of removing duplicate agents, the default JND of phase
params.expiryTime | Number | optional default: 10 | the time after which an Agent that has not accepted any beat will be destroyed
params.toleranceWndInner | Number | optional default: 0.04 | the maximum time that a beat can deviate from the predicted beat time without a fork occurring
params.toleranceWndPre | Number | optional default: 0.15 | the maximum amount by which a beat can be earlier than the predicted beat time, expressed as a fraction of the beat period
params.toleranceWndPost | Number | optional default: 0.3 | the maximum amount by which a beat can be later than the predicted beat time, expressed as a fraction of the beat period
params.correctionFactor | Number | optional default: 50 | correction factor for updating beat period
params.maxChange | Number | optional default: 0.2 | the maximum allowed deviation from the initial tempo, expressed as a fraction of the initial beat period
params.penaltyFactor | Number | optional default: 0.5 | factor for correcting score, if onset do not coincide precisely with predicted beat time

## Public Members

### public agents: Array source

Agents array

### public beatInterval: Number source

Inter-beat interval

### public beats: Array source

Beat times array

### public bestAgent: Agent source

The agent with the highest score

### public events: Array source

Onsets times array

### public peaks: Array source

Spectral flux peaks indexes

### public spectralFlux: Array source

Spectral flux

### public tempo: Number source

The tempo value in beats per minute

### public tempoList: Array source

Tempo hypotheses array