music_feature_analyzer 1.0.1-beta-01
music_feature_analyzer: ^1.0.1-beta-01 copied to clipboard
A comprehensive music feature analysis package using YAMNet AI and signal processing. Supports Android and iOS only.
🎵 Music Feature Analyzer #
Extract metadata and AI-powered features from audio files
⚠️ Beta Version: This is a beta release (
1.0.1-beta-01) and may have issues. Not recommended for production use. Please wait for a stable version.
✨ Features #
- 📊 Metadata Extraction: Title, Artist, Album, Album Art, Duration, Genre, Year, Bitrate, and more
- 🤖 AI Analysis: Genre, Instruments, Mood, Vocals detection using YAMNet
- 🎵 Signal Processing: Tempo (BPM), Energy, Danceability, Spectral features
- ⚡ Background Processing: Process multiple files with progress tracking
🚀 Quick Start #
Installation #
dependencies:
music_feature_analyzer: ^1.0.1-beta-01
flutter pub get
Note: For local path dependencies, see BUILD_COMPATIBILITY.md
Basic Usage #
import 'package:music_feature_analyzer/music_feature_analyzer.dart';
// Extract metadata (no initialization needed)
final song = await MusicFeatureAnalyzer.metadata('/path/to/song.mp3');
print('Title: ${song?.title}');
print('Artist: ${song?.artist}');
// Extract AI features (requires initialization)
await MusicFeatureAnalyzer.initialize();
final features = await MusicFeatureAnalyzer.analyzeSong(song!);
print('Genre: ${features?.estimatedGenre}');
print('Tempo: ${features?.tempoBpm} BPM');
📊 Extracted Data #
Metadata #
| Field | Type | Description |
|---|---|---|
title, artist, album |
String |
Basic song information |
albumArt |
String? |
Path to album art image |
duration |
int |
Duration in milliseconds |
genre, year |
String?, int? |
Genre and release year |
bitrate, fileSize |
int? |
Audio quality and file size |
trackNumber, discNumber |
int? |
Track position in album |
composer, writer |
String? |
Credits information |
AI Features #
| Field | Type | Description |
|---|---|---|
estimatedGenre |
String |
Genre classification (Rock, Pop, Jazz, etc.) |
yamnetInstruments |
List<String> |
Detected instruments |
hasVocals |
bool |
Whether vocals are detected |
tempoBpm |
double |
Tempo in beats per minute (60-200) |
danceability |
double |
Danceability score (0.0-1.0) |
overallEnergy |
double |
Energy level (0.0-1.0) |
mood |
String |
Mood classification (Happy, Sad, Energetic, etc.) |
moodTags |
List<String> |
Multiple mood tags |
Signal Processing #
| Field | Type | Range |
|---|---|---|
tempoBpm |
double |
60-200 BPM |
beatStrength |
double |
0.0-1.0 |
spectralCentroid |
double |
0-5000 Hz |
danceability |
double |
0.0-1.0 |
valence, arousal |
double |
0.0-1.0 |
📚 API Reference #
Metadata Extraction #
// Single file
final song = await MusicFeatureAnalyzer.metadata('/path/to/song.mp3');
// Multiple files
final songs = await MusicFeatureAnalyzer.extractMetadataBatch([
'/path/to/song1.mp3',
'/path/to/song2.mp3',
]);
Feature Extraction #
// Initialize (required once)
await MusicFeatureAnalyzer.initialize();
// Analyze single song
final features = await MusicFeatureAnalyzer.analyzeSong(song);
// Batch analysis
final featuresList = await MusicFeatureAnalyzer.analyzeSongs(songs);
// Background processing with progress
final results = await MusicFeatureAnalyzer.extractFeaturesInBackground(
filePaths,
onProgress: (current, total) {
print('Progress: $current/$total');
},
);
Utility Functions #
// Verify setup
final setup = await MusicFeatureAnalyzer.verifyPlatformSetup();
// Get progress
final progress = MusicFeatureAnalyzer.getExtractionProgress(filePaths);
// Clean up
await MusicFeatureAnalyzer.dispose();
⚙️ Platform Setup #
Android #
Add to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
Request permissions:
import 'package:permission_handler/permission_handler.dart';
await Permission.audio.request(); // Android 13+
await Permission.storage.request(); // Android 12-
iOS #
Add to ios/Runner/Info.plist:
<key>NSAppleMusicUsageDescription</key>
<string>This app needs access to your music library.</string>
<key>NSMediaLibraryUsageDescription</key>
<string>This app needs access to your media library.</string>
Request permissions:
import 'package:permission_handler/permission_handler.dart';
await Permission.mediaLibrary.request();
🎯 Supported Formats #
MP3, WAV, FLAC, AAC, M4A, OGG, WMA, OPUS, AIFF, ALAC
📋 Requirements #
- Flutter: 3.0.0+
- Dart: 3.8.1+
- iOS: 12.0+
- Android: API 21+
📚 Documentation #
- Build Compatibility - Local path dependency setup
- Changelog - Version history
🤝 Contributing #
Contributions are welcome! Please open an issue or submit a pull request.
📄 License #
MIT License - see LICENSE file for details.