use tunes::prelude::*;
fn main() -> anyhow::Result<()> {
let mut comp = Composition::new(Tempo::new(120.0));
let engine = AudioEngine::new()?;
println!("🎯 Transform Namespace Demo\n");
println!("📜 Old syntax (direct calls - still works!):");
comp.instrument("old_way", &Instrument::synth_lead())
.pattern_start()
.notes(&[C4, E4, G4, C5], 0.25)
.shift(7) .humanize(0.01, 0.05)
.rotate(1);
println!("✨ New syntax (scoped with closure):");
comp.instrument("new_way", &Instrument::synth_lead())
.wait(2.0)
.pattern_start()
.notes(&[C4, E4, G4, C5], 0.25)
.transform(|t| t .shift(7)
.humanize(0.01, 0.05)
.rotate(1)
) .wait(1.0);
println!("🔗 Chaining multiple transform blocks:");
comp.instrument("chained", &Instrument::electric_piano())
.wait(4.0)
.pattern_start()
.notes(&[C4, D4, E4, F4, G4], 0.25)
.transform(|t| t .stretch(0.5)
.quantize(0.125)
)
.transform(|t| t .shift(12)
.mutate(2)
)
.transform(|t| t .humanize(0.01, 0.05)
.shuffle()
);
println!("🌀 Complex generative transformation:");
comp.instrument("generative", &Instrument::synth_lead())
.wait(6.0)
.pattern_start()
.note(&[C4], 1.0)
.transform(|t| t
.granularize(16) .mutate(4) .thin(0.7) .magnetize(&[C4, D4, E4, G4, A4]) .gravity(E4, 0.3) .ripple(0.02) .shuffle() .humanize(0.01, 0.08) );
println!("\n▶️ Playing transform namespace demo...\n");
let mixer = comp.into_mixer();
engine.play_mixer(&mixer)?;
println!("✅ Demo complete!\n");
println!("💡 Benefits of the new syntax:");
println!(" ✨ Cleaner autocomplete - only see transforms when in .transform()");
println!(" 📦 Organized namespace - all 18 transforms grouped together");
println!(" 🔍 Better discoverability - easy to explore what's available");
println!(" 📖 More readable - clear boundaries for transform operations");
println!(" 🔄 Backward compatible - old direct-call syntax still works!");
println!("\n Both syntaxes are valid - use whichever fits your workflow!");
Ok(())
}