use std::num::NonZero; use torque_tracker_engine::{ PlaybackSettings, audio_processing::{Interpolation, playback::PlaybackState}, file::impulse_format::{header::PatternOrder, sample::VibratoWave}, project::{ event_command::NoteCommand, note_event::{Note, NoteEvent, VolumeEffect}, pattern::InPatternPosition, song::Song, }, sample::{Sample, SampleMetaData}, }; fn main() { let mut reader = hound::WavReader::open("test-files/770_Hz_Tone.wav").unwrap(); let spec = reader.spec(); println!("sample specs: {spec:?}"); assert!(spec.channels == 1); let sample_data = reader .samples::() .map(|result| ::from_sample(result.unwrap())); let sample = Sample::new_mono(sample_data); let meta = SampleMetaData { sample_rate: NonZero::new(spec.sample_rate).unwrap(), default_volume: 200, global_volume: 200, default_pan: None, vibrato_speed: 0, vibrato_depth: 0, vibrato_rate: 0, vibrato_waveform: VibratoWave::Sine, base_note: Note::new(20).unwrap(), }; let mut song: Song = Song::default(); song.pattern_order[0] = PatternOrder::Number(0); song.samples[0] = Some((meta, sample)); song.patterns[0].set_event( InPatternPosition { row: 0, channel: 0 }, NoteEvent { note: Note::default(), sample_instr: 0, vol: VolumeEffect::None, command: NoteCommand::None, }, ); song.patterns[0].set_event( InPatternPosition { row: 0, channel: 2 }, NoteEvent { note: Note::default(), sample_instr: 0, vol: VolumeEffect::None, command: NoteCommand::None, }, ); let mut playback = PlaybackState::new( &song, NonZero::new(44100).unwrap(), PlaybackSettings::Order { idx: 0, should_loop: true, }, ) .unwrap(); let iter = playback.iter::<{ Interpolation::Nearest as u8 }>(&song); for _ in iter.take(50) { // dbg!(frame); } }