Started work on a quantizer node
This commit is contained in:
parent
a7e64b802d
commit
f6c17121ab
2 changed files with 94 additions and 0 deletions
|
@ -48,6 +48,8 @@ mod node_pverb;
|
|||
mod node_rndwk;
|
||||
#[allow(non_upper_case_globals)]
|
||||
mod node_mux9;
|
||||
#[allow(non_upper_case_globals)]
|
||||
mod node_quant;
|
||||
|
||||
pub mod biquad;
|
||||
pub mod tracker;
|
||||
|
@ -86,6 +88,7 @@ use crate::fa_vosc_ovrsmpl;
|
|||
use crate::fa_distort;
|
||||
use crate::fa_comb_mode;
|
||||
use crate::fa_mux9_in_cnt;
|
||||
use crate::fa_quant;
|
||||
|
||||
use node_amp::Amp;
|
||||
use node_sin::Sin;
|
||||
|
@ -111,6 +114,7 @@ use node_tslfo::TsLFO;
|
|||
use node_pverb::PVerb;
|
||||
use node_rndwk::RndWk;
|
||||
use node_mux9::Mux9;
|
||||
use node_quant::Quant;
|
||||
|
||||
pub const MIDI_MAX_FREQ : f32 = 13289.75;
|
||||
|
||||
|
@ -731,6 +735,11 @@ macro_rules! node_list {
|
|||
(6 max n_id d_id r_s f_def stp_d -1.0, 1.0, 1.0)
|
||||
{7 0 clip setting(0) fa_map_clip 0 1}
|
||||
[0 sig],
|
||||
quant => Quant UIType::Generic UICategory::CV
|
||||
(0 inp n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
(1 oct n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
{2 0 keys micro(&[0.0; 12]) fa_quant 0 1}
|
||||
[0 sig],
|
||||
tseq => TSeq UIType::Generic UICategory::Mod
|
||||
(0 clock n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
||||
(1 trig n_id n_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||
|
|
85
src/dsp/node_quant.rs
Normal file
85
src/dsp/node_quant.rs
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Copyright (c) 2021 Weird Constructor <weirdconstructor@gmail.com>
|
||||
// This file is a part of HexoDSP. Released under GPL-3.0-or-later.
|
||||
// See README.md and COPYING for details.
|
||||
|
||||
use crate::nodes::{NodeAudioContext, NodeExecContext};
|
||||
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals, NodeContext};
|
||||
use crate::dsp::helpers::{Trigger};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! fa_quant { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||
write!($formatter, "?")
|
||||
} } }
|
||||
|
||||
/// A 9 channel signal multiplexer
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Quant {
|
||||
}
|
||||
|
||||
impl Quant {
|
||||
pub fn new(_nid: &NodeId) -> Self {
|
||||
Self {
|
||||
}
|
||||
}
|
||||
pub const inp : &'static str =
|
||||
"Quant inp\n\nRange: (0..1)";
|
||||
pub const oct : &'static str =
|
||||
"Quant oct\n\nRange: (-1..1)";
|
||||
pub const sig : &'static str =
|
||||
"Quant sig\n\nRange: (-1..1)";
|
||||
pub const keys : &'static str =
|
||||
"Quant keys\n";
|
||||
pub const DESC : &'static str =
|
||||
r#"Pitch/Note Quantizer
|
||||
|
||||
"#;
|
||||
pub const HELP : &'static str =
|
||||
r#"Quant - A pitch quantizer
|
||||
|
||||
"#;
|
||||
|
||||
}
|
||||
|
||||
impl DspNode for Quant {
|
||||
fn outputs() -> usize { 1 }
|
||||
|
||||
fn set_sample_rate(&mut self, _srate: f32) { }
|
||||
fn reset(&mut self) { }
|
||||
|
||||
#[inline]
|
||||
fn process<T: NodeAudioContext>(
|
||||
&mut self, ctx: &mut T, _ectx: &mut NodeExecContext,
|
||||
nctx: &NodeContext,
|
||||
atoms: &[SAtom], inputs: &[ProcBuf],
|
||||
outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
|
||||
{
|
||||
use crate::dsp::{at, out, inp, denorm};
|
||||
|
||||
let inp = inp::Quant::inp(inputs);
|
||||
let oct = inp::Quant::oct(inputs);
|
||||
let out = out::Quant::sig(outputs);
|
||||
let max = at::Quant::keys(atoms);
|
||||
|
||||
for frame in 0..ctx.nframes() {
|
||||
// self.idx =
|
||||
// (max as f32 * denorm::Mux9::slct(slct, frame))
|
||||
// .floor() as u8
|
||||
// % max;
|
||||
//
|
||||
// out.write(frame, match self.idx {
|
||||
// 0 => denorm::Mux9::in_1(in_1, frame),
|
||||
// 1 => denorm::Mux9::in_2(in_2, frame),
|
||||
// 2 => denorm::Mux9::in_3(in_3, frame),
|
||||
// 3 => denorm::Mux9::in_4(in_4, frame),
|
||||
// 4 => denorm::Mux9::in_5(in_5, frame),
|
||||
// 5 => denorm::Mux9::in_6(in_6, frame),
|
||||
// 6 => denorm::Mux9::in_7(in_7, frame),
|
||||
// 7 => denorm::Mux9::in_8(in_8, frame),
|
||||
// _ => denorm::Mux9::in_9(in_9, frame),
|
||||
// });
|
||||
}
|
||||
|
||||
ctx_vals[0].set(out.read(ctx.nframes() - 1));
|
||||
ctx_vals[1].set(0.5);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue