Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
2.1 kB · 72 lines
Rust
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273use std::num::NonZero;
use torque_tracker_engine::{ PlaybackSettings, audio_processing::{Interpolation, playback::PlaybackState}, project::{ event_command::NoteCommand, note_event::{Note, NoteEvent, VolumeEffect}, pattern::InPatternPosition, song::{PatternOrder, Song}, }, sample::{Sample, SampleMetaData, VibratoWave},};
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::<i16>() .map(|result| <f32 as dasp_sample::Sample>::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); }}