Skip to main content

vibe_analysis 0.1.1 copy "vibe_analysis: ^0.1.1" to clipboard
vibe_analysis: ^0.1.1 copied to clipboard

Pure-Dart audio analysis from PCM samples. Estimates tempo (BPM), musical key, energy, timbre and mood. No native code.

example/vibe_analysis_example.dart

import 'dart:math' as math;
import 'dart:typed_data';

import 'package:vibe_analysis/vibe_analysis.dart';

/// Builds a 30 second click track at 120 BPM so the example runs anywhere.
/// In a real app, decode your file to mono samples instead (see the README).
Float32List demoTrack() {
  const sr = 8000;
  final x = Float32List(sr * 30);
  final rnd = math.Random(1);
  const step = sr ~/ 2; // 120 BPM
  for (var s = 0; s < x.length; s += step) {
    for (var i = 0; i < 240 && s + i < x.length; i++) {
      x[s + i] = (rnd.nextDouble() * 2 - 1) * math.exp(-i / 50);
    }
  }
  return x;
}

void main() {
  final report = analyzeTrack(demoTrack(), sampleRate: 8000);
  print('BPM: ${report.analysis.bpm}');
  print('Energy: ${report.analysis.energy}');
  print(
      'Key: ${report.analysis.keyLabel.isEmpty ? 'unclear' : report.analysis.keyLabel}');
  print('Mood estimate: ${report.features.mood}');
}
1
likes
160
points
0
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Pure-Dart audio analysis from PCM samples. Estimates tempo (BPM), musical key, energy, timbre and mood. No native code.

Repository (GitHub)
View/report issues

Topics

#audio #music #dsp #bpm

License

MIT (license)

More

Packages that depend on vibe_analysis