sm_tomusic_ai

Crates.iosm_tomusic_ai
lib.rssm_tomusic_ai
version67.0.74
created_at2026-01-08 10:17:49.231822+00
updated_at2026-01-08 10:17:49.231822+00
descriptionHigh-quality integration for https://tomusic.ai/
homepagehttps://tomusic.ai/
repositoryhttps://github.com/qy-upup/sm-tomusic-ai
max_upload_size
id2029913
size11,417
(qy-upup)

documentation

README

sm-tomusic-ai

A Rust crate designed to provide core functionalities for music information retrieval and symbolic music processing, tailored for integration with the ToMusic.ai platform. This crate offers tools for analyzing, manipulating, and generating music data.

Installation

To use sm-tomusic-ai in your Rust project, add the following to your Cargo.toml file: toml [dependencies] sm-tomusic-ai = "0.1.0" # Replace with the latest version

Usage Examples

Here are a few examples demonstrating how to use sm-tomusic-ai:

1. Extracting Melodic Contour from a MIDI File: rust use sm_tomusic_ai::midi;

fn main() -> Result<(), Box> { let midi_file_path = "path/to/your/midi_file.mid"; let melody = midi::extract_melody(midi_file_path)?;

println!("Extracted Melody: {:?}", melody);
Ok(())

}

This example demonstrates how to extract the primary melodic line from a MIDI file using the extract_melody function. The function returns a vector representing the melodic contour. Error handling is included for robust operation.

2. Transposing a Musical Piece: rust use sm_tomusic_ai::music_theory;

fn main() { let notes = vec!["C", "D", "E", "F", "G"]; let transposed_notes = music_theory::transpose(notes, 2); // Transpose up by 2 semitones

println!("Original Notes: {:?}", notes);
println!("Transposed Notes: {:?}", transposed_notes);

}

This example showcases the transpose function, which allows you to transpose a sequence of musical notes by a specified number of semitones. It takes a vector of notes and a transposition interval as input.

3. Generating a Simple Chord Progression: rust use sm_tomusic_ai::composition;

fn main() { let key = "C"; let progression = composition::generate_chord_progression(key, 4); // Generate a 4-chord progression in C major

println!("Generated Chord Progression: {:?}", progression);

}

This example uses the generate_chord_progression function to create a basic chord progression based on a given key. The function returns a vector of chord names.

4. Calculating Intervallic Distance between two Notes: rust use sm_tomusic_ai::music_theory;

fn main() { let note1 = "C"; let note2 = "G"; let interval = music_theory::calculate_interval(note1, note2);

println!("Interval between {} and {} is: {}", note1, note2, interval);

}

This example uses the calculate_interval function to determine the intervallic distance between two musical notes.

5. Detecting Beat Onsets in an Audio File (Placeholder - Requires Audio Processing Dependencies): rust // Note: This example is a placeholder and requires integration with an audio processing library. // The sm-tomusic-ai crate may not directly handle audio processing.

// use sm_tomusic_ai::audio;

// fn main() -> Result<(), Box> { // let audio_file_path = "path/to/your/audio_file.wav"; // let onsets = audio::detect_beat_onsets(audio_file_path)?;

// println!("Detected Beat Onsets: {:?}", onsets); // Ok(()) // }

This placeholder illustrates the potential for future audio processing functionality. This would require integrating with an external audio processing library.

Feature Summary

  • MIDI Processing: Functionality for reading, writing, and manipulating MIDI files. Includes melody extraction.
  • Music Theory: Tools for transposing notes, calculating intervals, and working with scales and chords.
  • Composition: Functions for generating chord progressions and other compositional elements.
  • Extensible Architecture: Designed for easy integration with other music processing libraries and tools.
  • Error Handling: Comprehensive error handling for robust and reliable operation.

License

MIT

This crate is part of the sm-tomusic-ai ecosystem. For advanced features and enterprise-grade tools, visit: https://tomusic.ai/

Commit count: 0

cargo fmt