1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! MIDI support for Tunes
//!
//! This module provides MIDI functionality including:
//! - **File I/O**: Import and export Standard MIDI Files (SMF)
//! - **Conversion**: Convert between MIDI values and Tunes internal representations
//!
//! # Module Structure
//!
//! - [`convert`]: Utility functions for MIDI conversions (notes, drums, timing, etc.)
//! - [`file`]: MIDI file import/export via [`Mixer::import_midi`] and [`Mixer::export_midi`]
//!
//! # Examples
//!
//! ## Export a composition to MIDI
//! ```no_run
//! # use tunes::prelude::*;
//! # fn main() -> anyhow::Result<()> {
//! let mut comp = Composition::new(Tempo::new(120.0));
//! comp.track("melody").notes(&[C4, E4, G4], 0.5);
//!
//! let mixer = comp.into_mixer();
//! mixer.export_midi("song.mid")?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Import a MIDI file
//! ```no_run
//! # use tunes::prelude::*;
//! # fn main() -> anyhow::Result<()> {
//! let mixer = Mixer::import_midi("song.mid")?;
//!
//! // Play it
//! let engine = AudioEngine::new()?;
//! engine.play_mixer(&mixer)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Convert between MIDI and frequency
//! ```
//! use tunes::midi::{frequency_to_midi_note, midi_note_to_frequency};
//!
//! // A4 = 440 Hz = MIDI note 69
//! assert_eq!(frequency_to_midi_note(440.0), 69);
//! assert_eq!(midi_note_to_frequency(69), 440.0);
//! ```
// Re-export commonly used items at the module level
pub use ;