tomusic_ai_1

Crates.iotomusic_ai_1
lib.rstomusic_ai_1
version67.0.37
created_at2025-12-30 08:24:23.761724+00
updated_at2025-12-30 08:49:23.41968+00
descriptionHigh-quality integration for https://tomusic.ai/
homepagehttps://tomusic.ai/
repositoryhttps://github.com/qy-upup/tomusic.ai-1
max_upload_size
id2012267
size10,007
(qy-upup)

documentation

README

tomusic.ai-1

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.

Installation

Add the following to your Cargo.toml file under the [dependencies] section: toml tomusic.ai-1 = "0.1.0"

Usage Examples

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(&note1, &note2);

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 = vec![/* Your audio data here */]; let sample_rate: u32 = 44100;

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);

}

Feature Summary

This crate includes the following key features:

  • Music Theory: Data structures and functions for representing notes, intervals, chords, scales, and keys. Provides methods for calculating intervals, transposing notes, and identifying chord qualities.
  • Audio Processing: Basic audio analysis tools, including fundamental frequency detection. Designed to be extensible for more advanced audio processing tasks.
  • MIDI Manipulation: Data structures for representing MIDI events and messages. Enables the creation and manipulation of MIDI data.

License

MIT

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

Commit count: 0

cargo fmt