use tunes::prelude::*;
fn main() -> anyhow::Result<()> {
println!("\n🔁 Example: Pattern Repeat\n");
let engine = AudioEngine::new()?;
let mut comp = Composition::new(Tempo::new(120.0));
comp.instrument("simple_repeat", &Instrument::pluck())
.at(0.0)
.pattern_start()
.notes(&[C4, E4, G4], 0.2)
.repeat(3);
comp.instrument("chord_loop", &Instrument::warm_pad())
.at(2.5)
.pattern_start()
.chords(&[C4_MAJOR, F4_MAJOR, G4_MAJOR, C4_MAJOR], 0.5)
.repeat(2);
comp.instrument("nested", &Instrument::pluck())
.at(7.0)
.pattern_start()
.note(&[C4], 0.2)
.note(&[E4], 0.2)
.repeat(1) .pattern_start()
.note(&[G4], 0.4)
.repeat(3);
comp.instrument("buildup", &Instrument::arp_lead())
.at(9.0)
.pattern_start()
.note(&[C4], 0.2)
.note(&[D4], 0.2)
.note(&[E4], 0.2)
.note(&[F4], 0.2)
.repeat(2);
println!("✓ .pattern_start() marks the beginning of a repeatable section");
println!("✓ .repeat(n) repeats the pattern n more times");
println!("✓ Patterns can be nested");
println!("✓ All note properties (waveform, envelope, etc) are preserved\n");
engine.play_mixer(&comp.into_mixer())?;
Ok(())
}