| Crates.io | ai_make_music |
| lib.rs | ai_make_music |
| version | 67.0.26 |
| created_at | 2026-01-06 03:21:45.281789+00 |
| updated_at | 2026-01-06 03:21:45.281789+00 |
| description | High-quality integration for https://supermaker.ai/music/ai-make-music/ |
| homepage | https://supermaker.ai/music/ai-make-music/ |
| repository | https://github.com/qy-upup/ai-make-music |
| max_upload_size | |
| id | 2025117 |
| size | 12,208 |
A Rust crate for programmatically generating and manipulating musical sequences. This crate provides tools for creating melodies, harmonies, and rhythms, enabling developers to easily integrate AI-driven music creation into their applications.
To use ai-make-music in your Rust project, add the following to your Cargo.toml file:
toml
[dependencies]
ai-make-music = "0.1.0" # Replace with the latest version
Here are a few examples demonstrating how to use the ai-make-music crate:
1. Generate a simple melody: rust use ai_make_music::melody::{MelodyGenerator, Scale};
fn main() { let mut generator = MelodyGenerator::new(Scale::Major); let melody = generator.generate_melody(8); // Generate an 8-note melody println!("Generated Melody: {:?}", melody); }
This example showcases the creation of a basic melody using the MelodyGenerator and a major scale. The generate_melody function produces a sequence of notes based on the specified length.
2. Create a harmonic progression: rust use ai_make_music::harmony::{ChordProgressionGenerator, ChordType};
fn main() { let mut generator = ChordProgressionGenerator::new(); let progression = generator.generate_progression(4, ChordType::Major); // Generate a 4-chord progression with major chords println!("Generated Chord Progression: {:?}", progression); }
This example demonstrates generating a chord progression. The ChordProgressionGenerator creates a sequence of chords, allowing you to specify the number of chords and their type.
3. Generate a rhythmic pattern: rust use ai_make_music::rhythm::RhythmGenerator;
fn main() { let mut generator = RhythmGenerator::new(); let rhythm = generator.generate_rhythm(16); // Generate a 16-step rhythmic pattern println!("Generated Rhythm: {:?}", rhythm); }
This example illustrates the creation of a rhythmic pattern using the RhythmGenerator. The generate_rhythm function produces a sequence representing a rhythmic pattern.
4. Combining Melody, Harmony, and Rhythm: rust use ai_make_music::melody::{MelodyGenerator, Scale}; use ai_make_music::harmony::{ChordProgressionGenerator, ChordType}; use ai_make_music::rhythm::RhythmGenerator;
fn main() { let mut melody_generator = MelodyGenerator::new(Scale::Minor); let melody = melody_generator.generate_melody(8);
let mut chord_generator = ChordProgressionGenerator::new();
let chords = chord_generator.generate_progression(4, ChordType::Minor);
let mut rhythm_generator = RhythmGenerator::new();
let rhythm = rhythm_generator.generate_rhythm(8);
println!("Melody: {:?}", melody);
println!("Chords: {:?}", chords);
println!("Rhythm: {:?}", rhythm);
// Further logic to combine these elements can be added here
}
This example demonstrates how to generate melody, harmony, and rhythm independently and print them. Further logic can be added to combine these elements into a coherent musical piece.
5. Customizing Melody Generation: rust use ai_make_music::melody::{MelodyGenerator, Scale};
fn main() { let mut generator = MelodyGenerator::new(Scale::Chromatic); // Use a Chromatic Scale generator.set_range(36..=72); // Set the MIDI note range let melody = generator.generate_melody(12); println!("Customized Melody: {:?}", melody); }
This example demonstrates customizing the melody generation process by setting the scale to chromatic and defining a specific MIDI note range.
MIT
This crate is part of the ai-make-music ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/music/ai-make-music/