Skip to content

API Reference


API Reference / analyzeFullBuffer

Function: analyzeFullBuffer()

ts
function analyzeFullBuffer(originalBuffer, options?): Promise<Tempo[]>;

Defined in: core/analyzer.ts:460

Analyzes a complete audio buffer to detect the BPM (tempo) synchronously.

This function performs offline analysis of an entire audio file to detect its tempo. It's ideal for analyzing pre-recorded audio files where you have the complete audio data available.

Parameters

ParameterTypeDescription
originalBufferAudioBufferThe AudioBuffer containing the complete audio to analyze
options?BiquadFilterOptionsOptional filter configuration to customize bass detection

Returns

Promise<Tempo[]>

A promise that resolves to an array of tempo candidates sorted by confidence

Examples

Analyze an uploaded audio file

typescript
const audioContext = new AudioContext();

// Load audio file
const response = await fetch('song.mp3');
const arrayBuffer = await response.arrayBuffer();
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);

// Analyze BPM
const tempos = await analyzeFullBuffer(audioBuffer);

console.log('Detected BPM:', tempos[0].tempo);
console.log('Confidence:', tempos[0].count);
console.log('Top 5 candidates:', tempos);

With custom filter settings

typescript
const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);

const tempos = await analyzeFullBuffer(audioBuffer, {
  frequencyValue: 150,  // Focus on bass frequencies
  qualityValue: 1       // Filter steepness
});

// Get the most likely BPM
const mostLikelyBPM = tempos[0].tempo;

Analyze from file input

typescript
const fileInput = document.querySelector('input[type="file"]');

fileInput.addEventListener('change', async (e) => {
  const file = e.target.files[0];
  const arrayBuffer = await file.arrayBuffer();
  const audioBuffer = await audioContext.decodeAudioData(arrayBuffer);

  const tempos = await analyzeFullBuffer(audioBuffer);

  if (tempos.length > 0) {
    console.log(`Detected BPM: ${tempos[0].tempo} with ${tempos[0].count} matching intervals`);
  }
});

Remarks

  • This is a synchronous/offline analysis method (analyzes complete audio at once)
  • For real-time streaming audio, use createRealtimeBpmAnalyzer instead
  • The function returns multiple candidates sorted by confidence (count)
  • Analysis applies a lowpass filter to isolate bass frequencies for better beat detection
  • BPM values are normalized to the 90-180 range (doubles/halves if outside this range)
  • Higher count values indicate more confidence in the detected tempo

See

Released under the Apache License 2.0