From 991849b32acf83dd14a5096540bb053d2572502a Mon Sep 17 00:00:00 2001 From: Wavy Harp Date: Sun, 7 May 2023 23:04:53 -0600 Subject: initial import currently everything is very tied to alsa and my system, for the moment you'll need to manually change the device names and maybe channels/period_size in src/main.rs, src/bin/smolguitar.rs and src/bin/loopbacker.rs, i'll fix that and add runtime period size/updater allocation soon, (and probably make a cpal backend as well so it can work on other platforms), but doing this initial commit to play around with stereo for now~ --- src/bin/smolguitar.rs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/bin/smolguitar.rs (limited to 'src/bin/smolguitar.rs') diff --git a/src/bin/smolguitar.rs b/src/bin/smolguitar.rs new file mode 100644 index 0000000..bb36b64 --- /dev/null +++ b/src/bin/smolguitar.rs @@ -0,0 +1,44 @@ +use rustynotes::notes::{Notes, note_range, ProcerNotes}; +use rustynotes::proc::{Procer, ProcerData}; +use rustynotes::rfft::RFftProcer; +use rustynotes::buf::{StaticBuffer, Procers}; +use rustynotes::outputers::{Outputers, SimpleOutputer, LineLayout}; +use rustynotes::args::SimpleArgs; +use clap::Parser; + +fn main() { + const CHANNELS: u32 = 1; + const PERIOD_SIZE: usize = 480; + const PROC_SIZE: usize = 1 << 13; // 8k + //let disp_threshold = 0.00372314453125; + //let disp_threshold = 0.00526532149076897; + //let disp_threshold = 0.05; + let sample_rate = 48000; + let notes = note_range((Notes::C, 2), (Notes::E, 7)); + let rfproc: RFftProcer = RFftProcer::new(sample_rate); + let pnotes = rfproc.make_pnotes(¬es); + for pnote in &pnotes { + println!("{}", pnote); + } + println!("{}", rfproc); + //let outputer = Outputers::Simple(SimpleOutputer); + //(2f32).sqrt() + //let outputer = Outputers::LineLayout(LineLayout::new(0.25, true, (60., 255., 220.), ¬es)); + let args = SimpleArgs::parse(); + let disp_threshold = args.threshold; + let outputer = args.get_outputer(¬es); + let rfpdata = ProcerData::new(&rfproc, ProcerNotes(pnotes, disp_threshold)); + let mut buf: StaticBuffer = StaticBuffer::new(48000, CHANNELS, + vec![(Procers::Rfft(rfproc), rfpdata)], "guitar_c".to_string(), args.get_outdev(), + outputer); + println!("{}", buf); + let mut aout = alsa::Output::buffer_open().unwrap(); + buf.adev.dump(&mut aout); + //buf.outdev.dump(&mut aout); + match &buf.outdev { + Some(outdev) => { outdev.dump(&mut aout); }, + None => {}, + } + println!("{}", aout); + buf.capture_loop(); +} -- cgit v1.1