tomusic.ai-1
A Dart package providing essential utilities for interacting with the tomusic.ai platform, enabling seamless music analysis and generation. This package streamlines common tasks, making it easier to integrate tomusic.ai's capabilities into your Dart applications.
Installation
To use this package in your Dart project, add it as a dependency using dart pub add:
bash
dart pub add tomusic_ai_1
Usage
Here are several examples demonstrating how to utilize the tomusic_ai_1 package:
1. Analyzing Musical Key: dart import 'package:tomusic_ai_1/tomusic_ai_1.dart';
void main() async { final analyzer = MusicAnalyzer(); final key = await analyzer.analyzeKey("path/to/your/music.mp3");
if (key != null) { print("The key of the song is: $key"); } else { print("Failed to analyze the key."); } }
2. Generating a Simple Melody: dart import 'package:tomusic_ai_1/tomusic_ai_1.dart';
void main() async { final generator = MusicGenerator(); final melody = await generator.generateMelody(length: 16, scale: 'C Major');
if (melody != null) { print("Generated Melody: $melody"); // You can then process or play the melody data. } else { print("Failed to generate the melody."); } }
3. Retrieving Song Metadata: dart import 'package:tomusic_ai_1/tomusic_ai_1.dart';
void main() async { final metadataRetriever = MetadataRetriever(); final metadata = await metadataRetriever.getMetadata("path/to/your/music.mp3");
if (metadata != null) { print("Title: ${metadata.title}"); print("Artist: ${metadata.artist}"); print("Album: ${metadata.album}"); } else { print("Failed to retrieve metadata."); } }
4. Transposing a Musical Piece: dart import 'package:tomusic_ai_1/tomusic_ai_1.dart';
void main() async { final transformer = MusicTransformer(); final transposedPiece = await transformer.transpose("path/to/your/midi.mid", newKey: 'D Major');
if (transposedPiece != null) { print("Transposed piece saved to: $transposedPiece"); } else { print("Failed to transpose the piece."); } }
5. Converting Audio File Format: dart import 'package:tomusic_ai_1/tomusic_ai_1.dart';
void main() async { final converter = AudioConverter(); final convertedFile = await converter.convertFormat("path/to/your/audio.wav", outputFormat: 'mp3');
if (convertedFile != null) { print("Converted file saved to: $convertedFile"); } else { print("Failed to convert the file."); } }
Features
- Music Analysis: Analyze musical pieces to determine key, tempo, and other relevant musical characteristics.
- Melody Generation: Generate new melodies based on specified parameters such as length and scale.
- Metadata Retrieval: Extract metadata (title, artist, album) from audio files.
- Music Transformation: Transpose musical pieces to different keys.
- Audio Conversion: Convert audio files between various formats (e.g., WAV to MP3).
- Error Handling: Provides robust error handling for graceful failure and informative error messages.
- Asynchronous Operations: Leverages asynchronous operations for non-blocking execution.
License
MIT License
This package is part of the tomusic.ai-1 ecosystem. For advanced features and enterprise-grade tools, visit: https://tomusic.ai/