renamed Quant to CQnt, because it's more specialized than just a simple quantizer
This commit is contained in:
parent
a631240e64
commit
42553cc800
3 changed files with 43 additions and 39 deletions
|
@ -2135,7 +2135,7 @@ impl<F: Flt> TriSawLFO<F> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Quantizer {
|
pub struct CtrlPitchQuantizer {
|
||||||
/// All keys, containing the min/max octave!
|
/// All keys, containing the min/max octave!
|
||||||
keys: Vec<f32>,
|
keys: Vec<f32>,
|
||||||
/// Only the used keys with their pitches from the UI
|
/// Only the used keys with their pitches from the UI
|
||||||
|
@ -2150,7 +2150,7 @@ pub struct Quantizer {
|
||||||
|
|
||||||
const QUANT_TUNE_TO_A4 : f32 = (9.0 / 12.0) * 0.1;
|
const QUANT_TUNE_TO_A4 : f32 = (9.0 / 12.0) * 0.1;
|
||||||
|
|
||||||
impl Quantizer {
|
impl CtrlPitchQuantizer {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
keys: vec![0.0; 12 * 10],
|
keys: vec![0.0; 12 * 10],
|
||||||
|
|
|
@ -49,7 +49,7 @@ mod node_rndwk;
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
mod node_mux9;
|
mod node_mux9;
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
mod node_quant;
|
mod node_cqnt;
|
||||||
|
|
||||||
pub mod biquad;
|
pub mod biquad;
|
||||||
pub mod tracker;
|
pub mod tracker;
|
||||||
|
@ -88,9 +88,9 @@ use crate::fa_vosc_ovrsmpl;
|
||||||
use crate::fa_distort;
|
use crate::fa_distort;
|
||||||
use crate::fa_comb_mode;
|
use crate::fa_comb_mode;
|
||||||
use crate::fa_mux9_in_cnt;
|
use crate::fa_mux9_in_cnt;
|
||||||
use crate::fa_quant;
|
use crate::fa_cqnt;
|
||||||
use crate::fa_quant_omin;
|
use crate::fa_cqnt_omin;
|
||||||
use crate::fa_quant_omax;
|
use crate::fa_cqnt_omax;
|
||||||
|
|
||||||
use node_amp::Amp;
|
use node_amp::Amp;
|
||||||
use node_sin::Sin;
|
use node_sin::Sin;
|
||||||
|
@ -116,7 +116,7 @@ use node_tslfo::TsLFO;
|
||||||
use node_pverb::PVerb;
|
use node_pverb::PVerb;
|
||||||
use node_rndwk::RndWk;
|
use node_rndwk::RndWk;
|
||||||
use node_mux9::Mux9;
|
use node_mux9::Mux9;
|
||||||
use node_quant::Quant;
|
use node_cqnt::CQnt;
|
||||||
|
|
||||||
pub const MIDI_MAX_FREQ : f32 = 13289.75;
|
pub const MIDI_MAX_FREQ : f32 = 13289.75;
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ macro_rules! define_exp6 {
|
||||||
|
|
||||||
|
|
||||||
macro_rules! n_pit { ($x: expr) => {
|
macro_rules! n_pit { ($x: expr) => {
|
||||||
((($x as f32).max(0.01) / 440.0).log2() / 10.0)
|
0.1 * (($x as f32).max(0.01) / 440.0).log2()
|
||||||
} }
|
} }
|
||||||
|
|
||||||
macro_rules! d_pit { ($x: expr) => {
|
macro_rules! d_pit { ($x: expr) => {
|
||||||
|
@ -737,12 +737,12 @@ macro_rules! node_list {
|
||||||
(6 max n_id d_id r_s f_def stp_d -1.0, 1.0, 1.0)
|
(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}
|
{7 0 clip setting(0) fa_map_clip 0 1}
|
||||||
[0 sig],
|
[0 sig],
|
||||||
quant => Quant UIType::Generic UICategory::CV
|
cqnt => CQnt UIType::Generic UICategory::CV
|
||||||
(0 inp n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
(0 inp n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
||||||
(1 oct n_id d_id r_s f_def stp_d -1.0, 1.0, 0.0)
|
(1 oct n_id d_id r_s f_def stp_d -1.0, 1.0, 0.0)
|
||||||
{2 0 keys setting(0) fa_quant 0 0}
|
{2 0 keys setting(0) fa_cqnt 0 0}
|
||||||
{3 1 omin setting(0) fa_quant_omin 0 4}
|
{3 1 omin setting(0) fa_cqnt_omin 0 4}
|
||||||
{4 2 omax setting(0) fa_quant_omax 0 4}
|
{4 2 omax setting(0) fa_cqnt_omax 0 4}
|
||||||
[0 sig],
|
[0 sig],
|
||||||
tseq => TSeq UIType::Generic UICategory::Mod
|
tseq => TSeq UIType::Generic UICategory::Mod
|
||||||
(0 clock n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
(0 clock n_id d_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
|
|
||||||
use crate::nodes::{NodeAudioContext, NodeExecContext};
|
use crate::nodes::{NodeAudioContext, NodeExecContext};
|
||||||
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals, NodeContext};
|
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals, NodeContext};
|
||||||
use crate::dsp::helpers::Quantizer;
|
use crate::dsp::helpers::CtrlPitchQuantizer;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! fa_quant { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
macro_rules! fa_cqnt { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||||
write!($formatter, "?")
|
write!($formatter, "?")
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! fa_quant_omin { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
macro_rules! fa_cqnt_omin { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||||
let s =
|
let s =
|
||||||
match ($v.round() as usize) {
|
match ($v.round() as usize) {
|
||||||
0 => "-0",
|
0 => "-0",
|
||||||
|
@ -26,7 +26,7 @@ macro_rules! fa_quant_omin { ($formatter: expr, $v: expr, $denorm_v: expr) => {
|
||||||
} } }
|
} } }
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! fa_quant_omax { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
macro_rules! fa_cqnt_omax { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||||
let s =
|
let s =
|
||||||
match ($v.round() as usize) {
|
match ($v.round() as usize) {
|
||||||
0 => "+0",
|
0 => "+0",
|
||||||
|
@ -41,39 +41,43 @@ macro_rules! fa_quant_omax { ($formatter: expr, $v: expr, $denorm_v: expr) => {
|
||||||
|
|
||||||
/// A 9 channel signal multiplexer
|
/// A 9 channel signal multiplexer
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Quant {
|
pub struct CQnt {
|
||||||
quant: Quantizer,
|
quant: Box<CtrlPitchQuantizer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Quant {
|
impl CQnt {
|
||||||
pub fn new(_nid: &NodeId) -> Self {
|
pub fn new(_nid: &NodeId) -> Self {
|
||||||
Self {
|
Self {
|
||||||
quant: Quantizer::new(),
|
quant: Box::new(CtrlPitchQuantizer::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub const inp : &'static str =
|
pub const inp : &'static str =
|
||||||
"Quant inp\n\nRange: (0..1)";
|
"CQnt inp\n\nRange: (0..1)";
|
||||||
pub const oct : &'static str =
|
pub const oct : &'static str =
|
||||||
"Quant oct\n\nRange: (-1..1)";
|
"CQnt oct\n\nRange: (-1..1)";
|
||||||
pub const omin : &'static str =
|
pub const omin : &'static str =
|
||||||
"Quant omin\n\nRange: (-1..1)";
|
"CQnt omin\n\nRange: (-1..1)";
|
||||||
pub const omax : &'static str =
|
pub const omax : &'static str =
|
||||||
"Quant omax\n\nRange: (-1..1)";
|
"CQnt omax\n\nRange: (-1..1)";
|
||||||
pub const sig : &'static str =
|
pub const sig : &'static str =
|
||||||
"Quant sig\n\nRange: (-1..1)";
|
"CQnt sig\n\nRange: (-1..1)";
|
||||||
pub const keys : &'static str =
|
pub const keys : &'static str =
|
||||||
"Quant keys\n";
|
"CQnt keys\n";
|
||||||
pub const DESC : &'static str =
|
pub const DESC : &'static str =
|
||||||
r#"Pitch/Note Quantizer
|
r#"Control Pitch Quantizer
|
||||||
|
|
||||||
|
This special quantizer maps the 0..1 input range on 'inp' evenly to the selected keys and octaves.
|
||||||
"#;
|
"#;
|
||||||
pub const HELP : &'static str =
|
pub const HELP : &'static str =
|
||||||
r#"Quant - A pitch quantizer
|
r#"CQnt - A control signal to pitch quantizer
|
||||||
|
|
||||||
|
This is a specialized quantizer to generate a pitch/frequency from a signal
|
||||||
|
within the 0..1 range. It does not quantize a typical -1..1 frequency signal
|
||||||
|
like the 'Quant' node.
|
||||||
"#;
|
"#;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DspNode for Quant {
|
impl DspNode for CQnt {
|
||||||
fn outputs() -> usize { 1 }
|
fn outputs() -> usize { 1 }
|
||||||
|
|
||||||
fn set_sample_rate(&mut self, _srate: f32) { }
|
fn set_sample_rate(&mut self, _srate: f32) { }
|
||||||
|
@ -88,12 +92,12 @@ impl DspNode for Quant {
|
||||||
{
|
{
|
||||||
use crate::dsp::{at, out, inp, denorm};
|
use crate::dsp::{at, out, inp, denorm};
|
||||||
|
|
||||||
let inp = inp::Quant::inp(inputs);
|
let inp = inp::CQnt::inp(inputs);
|
||||||
let oct = inp::Quant::oct(inputs);
|
let oct = inp::CQnt::oct(inputs);
|
||||||
let out = out::Quant::sig(outputs);
|
let out = out::CQnt::sig(outputs);
|
||||||
let keys = at::Quant::keys(atoms);
|
let keys = at::CQnt::keys(atoms);
|
||||||
let omin = at::Quant::omin(atoms);
|
let omin = at::CQnt::omin(atoms);
|
||||||
let omax = at::Quant::omax(atoms);
|
let omax = at::CQnt::omax(atoms);
|
||||||
|
|
||||||
self.quant.update_keys(keys.i(), omin.i(), omax.i());
|
self.quant.update_keys(keys.i(), omin.i(), omax.i());
|
||||||
|
|
||||||
|
@ -101,8 +105,8 @@ impl DspNode for Quant {
|
||||||
for frame in 0..ctx.nframes() {
|
for frame in 0..ctx.nframes() {
|
||||||
out.write(
|
out.write(
|
||||||
frame,
|
frame,
|
||||||
denorm::Quant::inp(inp, frame)
|
denorm::CQnt::inp(inp, frame)
|
||||||
+ denorm::Quant::oct(oct, frame));
|
+ denorm::CQnt::oct(oct, frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx_vals[1].set(100.0); // some unreachable value for Keys widget
|
ctx_vals[1].set(100.0); // some unreachable value for Keys widget
|
||||||
|
@ -114,8 +118,8 @@ impl DspNode for Quant {
|
||||||
for frame in 0..ctx.nframes() {
|
for frame in 0..ctx.nframes() {
|
||||||
let pitch =
|
let pitch =
|
||||||
self.quant.signal_to_pitch(
|
self.quant.signal_to_pitch(
|
||||||
denorm::Quant::inp(inp, frame));
|
denorm::CQnt::inp(inp, frame));
|
||||||
out.write(frame, pitch + denorm::Quant::oct(oct, frame));
|
out.write(frame, pitch + denorm::CQnt::oct(oct, frame));
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_pitch = self.quant.last_key_pitch();
|
let last_pitch = self.quant.last_key_pitch();
|
Loading…
Reference in a new issue