music_analysis 0.1.0 copy "music_analysis: ^0.1.0" to clipboard
music_analysis: ^0.1.0 copied to clipboard

A Dart package allowing music processing and analysis BPM, Key, and more.

Music analysis

A music analysis package for Dart & Flutter.

The music_analysis package provides a set of tools for analyzing music data in Dart and Flutter applications. It offers features such as audio feature extraction, tempo detection, key detection, and more. The package is designed to be easy to use and efficient, making it suitable for a wide range of music analysis applications.

pub package


Contents #

Features #

  1. File data extraction such as sample size, sample rate, bit depth, number of channels, duration, and more.
  2. Audio feature extraction such as tempo, key, time signature, and more.
  3. Support for WAV formats.
  4. Upcoming support for MP3, FLAC, and other audio formats.

Getting started #

Installation #

Install/import the package by running the following command in your project folder terminal:

flutter pub add music_analysis

Detecting audio features #

The package features one simple command: Music.analyzeFile() that takes in a file path and returns an AnalysisResult object containing the extracted audio features:

AnalysisResult result  = await Music.analyzeFile("path-to-file");

To obtain analysis data like BPM and Key:

BPM (tempo) data #

double bpm = result.musicData.bpm;

Tip

BPM data is very rarely an integer value, however, in your applications you can round it to the nearest integer if you wish.

Key (pitch) data #

Key (pitch) data is represented by the CamelotKeyPrediction class, which contains information about the detected key of the audio file. You can access the best prediction for the key using bestPrediction:

CamelotKeyPrediction camelotKeyPrediction = result.musicData.key.bestPrediction;

You can also access all predictions for the key using predictions:

List<CamelotKeyPrediction> predictions = result.musicData.key.predictions;

Note

Key predictions are sometimes not 100% accurate, especially for songs with complex harmonies or modulations. It is recommended to use the best prediction as a reference and verify it with your own musical knowledge. This is also why the package provides a list of predictions, so you can choose the one that best fits your needs. You can also use the confidence property of the CamelotKeyPrediction class to determine how confident the algorithm is in its prediction.

Detecting file features #

The package also provides file data extraction features such as sample size, sample rate, bit depth, number of channels, duration, and more. You can access these features through the fileData property of the AnalysisResult object:

FileData fileData = result.fileData;

From this you can get the file name, path, size, sample rate, bit depth, number of channels, duration, and more:

String fileName = fileData.fileName;
String filePath = fileData.path;
int fileSize = fileData.sizeInBytes;
int sampleRate = fileData.sampleRate;
int channels = fileData.channels;
Duration duration = fileData.duration;

Helper methods allow you also obtain the file size in kilobytes, megabytes, or gigabytes:

double sizeInKB = fileData.sizeInKB;
double sizeInMB = fileData.sizeInMB;
double sizeInGB = fileData.sizeInGB;

Information #

Requirements #

  • Dart 3.2 or higher
  • The package is compatible with both plain Dart applications or Flutter applications.
  • The package has no dependencies and does not use Flutter FFI.

Known issues and feature requests #

No known issues. If you find a bug or have a feature request, please report it on our GitHub repository.

View the change log for the latest updates and changes to Firestorm.

License #

Music analysis is open-source and is released under the Apache 2.0 License. See the LICENSE file for more information.

1
likes
150
points
71
downloads

Documentation

API reference

Publisher

verified publisherraylabz.com

Weekly Downloads

A Dart package allowing music processing and analysis BPM, Key, and more.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

buymeacoffee.com

License

Apache-2.0 (license)

More

Packages that depend on music_analysis