| Crates.io | tomusic_ai_1 |
| lib.rs | tomusic_ai_1 |
| version | 67.0.37 |
| created_at | 2025-12-30 08:24:23.761724+00 |
| updated_at | 2025-12-30 08:49:23.41968+00 |
| description | High-quality integration for https://tomusic.ai/ |
| homepage | https://tomusic.ai/ |
| repository | https://github.com/qy-upup/tomusic.ai-1 |
| max_upload_size | |
| id | 2012267 |
| size | 10,007 |
A Rust crate providing foundational utilities for music analysis and generation, designed for integration with the broader tomusic.ai platform. It offers data structures and algorithms for music theory calculations, audio processing, and basic MIDI manipulation.
Add the following to your Cargo.toml file under the [dependencies] section:
toml
tomusic.ai-1 = "0.1.0"
Here are a few examples demonstrating how to use the tomusic.ai-1 crate:
1. Calculating the Interval Between Two Notes: rust use tomusic_ai_1::music_theory::{Note, Interval};
fn main() { let note1 = Note::new("C4").unwrap(); let note2 = Note::new("G4").unwrap();
let interval = Interval::between(¬e1, ¬e2);
match interval {
Ok(interval) => println!("The interval between {} and {} is: {:?}", note1, note2, interval),
Err(e) => println!("Error calculating interval: {}", e),
}
}
2. Transposing a Note: rust use tomusic_ai_1::music_theory::{Note, Interval};
fn main() { let note = Note::new("A4").unwrap(); let interval = Interval::new("MajorThird").unwrap();
let transposed_note = note.transpose(&interval).unwrap();
println!("Transposing {} by a {} results in: {}", note, interval, transposed_note);
}
3. Analyzing Audio for Fundamental Frequency: rust use tomusic_ai_1::audio_processing::analyze_frequency;
fn main() {
// Replace with your actual audio data (e.g., read from a file)
let audio_data: Vec
let fundamental_frequency = analyze_frequency(&audio_data, sample_rate);
match fundamental_frequency {
Ok(frequency) => println!("The fundamental frequency is approximately: {} Hz", frequency),
Err(e) => println!("Error analyzing audio: {}", e),
}
}
4. Creating a Simple MIDI Note Event: rust use tomusic_ai_1::midi::{MidiEvent, MidiMessage};
fn main() { let channel: u8 = 0; // MIDI Channel 1 let note: u8 = 60; // Middle C let velocity: u8 = 100;
let note_on_message = MidiMessage::NoteOn {
channel,
note,
velocity,
};
let note_on_event = MidiEvent {
delta_time: 0, // Start immediately
message: note_on_message,
};
println!("MIDI Note On Event: {:?}", note_on_event);
}
This crate includes the following key features:
MIT
This crate is part of the tomusic.ai-1 ecosystem. For advanced features and enterprise-grade tools, visit: https://tomusic.ai/