started work on the mapper node
This commit is contained in:
parent
fb3bb7dab2
commit
f99bcfc348
2 changed files with 116 additions and 0 deletions
|
@ -24,6 +24,8 @@ mod node_delay;
|
||||||
mod node_allp;
|
mod node_allp;
|
||||||
#[allow(non_upper_case_globals)]
|
#[allow(non_upper_case_globals)]
|
||||||
mod node_noise;
|
mod node_noise;
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
|
mod node_map;
|
||||||
|
|
||||||
pub mod tracker;
|
pub mod tracker;
|
||||||
mod satom;
|
mod satom;
|
||||||
|
@ -49,6 +51,7 @@ use crate::fa_sampl_dir;
|
||||||
use crate::fa_ad_mult;
|
use crate::fa_ad_mult;
|
||||||
use crate::fa_delay_mode;
|
use crate::fa_delay_mode;
|
||||||
use crate::fa_noise_mode;
|
use crate::fa_noise_mode;
|
||||||
|
use crate::fa_map_k;
|
||||||
|
|
||||||
use node_amp::Amp;
|
use node_amp::Amp;
|
||||||
use node_sin::Sin;
|
use node_sin::Sin;
|
||||||
|
@ -62,6 +65,7 @@ use node_ad::Ad;
|
||||||
use node_delay::Delay;
|
use node_delay::Delay;
|
||||||
use node_allp::AllP;
|
use node_allp::AllP;
|
||||||
use node_noise::Noise;
|
use node_noise::Noise;
|
||||||
|
use node_map::Map;
|
||||||
|
|
||||||
pub const MIDI_MAX_FREQ : f32 = 13289.75;
|
pub const MIDI_MAX_FREQ : f32 = 13289.75;
|
||||||
|
|
||||||
|
@ -425,6 +429,14 @@ macro_rules! node_list {
|
||||||
(2 att n_att d_att r_id f_def stp_d 0.0, 1.0, 1.0)
|
(2 att n_att d_att r_id f_def stp_d 0.0, 1.0, 1.0)
|
||||||
{3 0 neg_att setting(1) fa_amp_neg_att 0 1}
|
{3 0 neg_att setting(1) fa_amp_neg_att 0 1}
|
||||||
[0 sig],
|
[0 sig],
|
||||||
|
map => Map UIType::Generic UICategory::CV
|
||||||
|
(0 inp n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
(1 atv n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
(2 imin n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
(3 imax n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
(4 omin n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
(5 omax n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
[0 sig],
|
||||||
tseq => TSeq UIType::Generic UICategory::CV
|
tseq => TSeq UIType::Generic UICategory::CV
|
||||||
(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)
|
||||||
(1 trig n_id n_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
(1 trig n_id n_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
||||||
|
|
104
src/dsp/node_map.rs
Normal file
104
src/dsp/node_map.rs
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
// Copyright (c) 2021 Weird Constructor <weirdconstructor@gmail.com>
|
||||||
|
// This is a part of HexoDSP. Released under (A)GPLv3 or any later.
|
||||||
|
// See README.md and COPYING for details.
|
||||||
|
|
||||||
|
use crate::nodes::{NodeAudioContext, NodeExecContext};
|
||||||
|
use crate::dsp::{NodeId, SAtom, ProcBuf, DspNode, LedPhaseVals};
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! fa_map_k { ($formatter: expr, $v: expr, $denorm_v: expr) => { {
|
||||||
|
write!($formatter, "{}", $v)
|
||||||
|
} } }
|
||||||
|
|
||||||
|
/// A simple amplifier
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Map {
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Map {
|
||||||
|
pub fn new(_nid: &NodeId) -> Self {
|
||||||
|
Self {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub const inp : &'static str =
|
||||||
|
"Map inp\nSignal input\nRange: (-1..1)\n";
|
||||||
|
pub const atv : &'static str =
|
||||||
|
"Map atv\n\nRange: (0..1)\n";
|
||||||
|
pub const imin : &'static str =
|
||||||
|
"Map imin\n\nRange: (0..1)\n";
|
||||||
|
pub const imax : &'static str =
|
||||||
|
"Map imax\n\nRange: (0..1)\n";
|
||||||
|
pub const omin : &'static str =
|
||||||
|
"Map omin\n\nRange: (0..1)\n";
|
||||||
|
pub const omax : &'static str =
|
||||||
|
"Map omax\n\nRange: (0..1)\n";
|
||||||
|
pub const sig : &'static str =
|
||||||
|
"Map sig\nMapped signal output\nRange: (-1..1)\n";
|
||||||
|
pub const DESC : &'static str =
|
||||||
|
r#"Signal Range Mapper
|
||||||
|
|
||||||
|
"#;
|
||||||
|
pub const HELP : &'static str =
|
||||||
|
r#"Map - Signal Range Mapper
|
||||||
|
|
||||||
|
"#;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DspNode for Map {
|
||||||
|
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,
|
||||||
|
atoms: &[SAtom], _params: &[ProcBuf], inputs: &[ProcBuf],
|
||||||
|
outputs: &mut [ProcBuf], ctx_vals: LedPhaseVals)
|
||||||
|
{
|
||||||
|
use crate::dsp::{out, inp, denorm, denorm_v, inp_dir, at};
|
||||||
|
|
||||||
|
// let gain = inp::Amp::gain(inputs);
|
||||||
|
// let att = inp::Amp::att(inputs);
|
||||||
|
// let inp = inp::Amp::inp(inputs);
|
||||||
|
// let out = out::Amp::sig(outputs);
|
||||||
|
// let neg = at::Amp::neg_att(atoms);
|
||||||
|
//
|
||||||
|
// let last_frame = ctx.nframes() - 1;
|
||||||
|
//
|
||||||
|
// let last_val =
|
||||||
|
// if neg.i() > 0 {
|
||||||
|
// for frame in 0..ctx.nframes() {
|
||||||
|
// out.write(frame,
|
||||||
|
// inp.read(frame)
|
||||||
|
// * denorm_v::Amp::att(
|
||||||
|
// inp_dir::Amp::att(att, frame)
|
||||||
|
// .max(0.0))
|
||||||
|
// * denorm::Amp::gain(gain, frame));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// inp.read(last_frame)
|
||||||
|
// * denorm_v::Amp::att(
|
||||||
|
// inp_dir::Amp::att(att, last_frame)
|
||||||
|
// .max(0.0))
|
||||||
|
// * denorm::Amp::gain(gain, last_frame)
|
||||||
|
//
|
||||||
|
// } else {
|
||||||
|
// for frame in 0..ctx.nframes() {
|
||||||
|
// out.write(frame,
|
||||||
|
// inp.read(frame)
|
||||||
|
// * denorm_v::Amp::att(
|
||||||
|
// inp_dir::Amp::att(att, frame).abs())
|
||||||
|
// * denorm::Amp::gain(gain, frame));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// inp.read(last_frame)
|
||||||
|
// * denorm_v::Amp::att(
|
||||||
|
// inp_dir::Amp::att(att, last_frame).abs())
|
||||||
|
// * denorm::Amp::gain(gain, last_frame)
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// ctx_vals[0].set(last_val);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue