sin now has a detune UI parameter (not yet handled in DSP)

This commit is contained in:
Weird Constructor 2021-06-05 09:13:42 +02:00
parent 1b22ab623a
commit 79c3e36eab
2 changed files with 29 additions and 0 deletions

View file

@ -249,6 +249,14 @@ macro_rules! d_pit { ($x: expr) => {
}
} }
// 5.0 for mapping -0.2-0.2 range to -1.0 to 1.0
// 5.0 * 0.2 => 24.0
// 5.0 * 0.1 => 12.0
// 5.0 * 0.008333333 => 1.0
// 5.0 * 0.000083333 => 0.001
macro_rules! n_det { ($x: expr) => { ($x * 5.0 * 0.1) / 12.0 } }
macro_rules! d_det { ($x: expr) => { $x * 0.2 * 120.0 } }
// Rounding function that does nothing
macro_rules! r_id { ($x: expr) => { $x } }
@ -267,6 +275,20 @@ macro_rules! f_freq { ($formatter: expr, $v: expr, $denorm_v: expr) => {
}
} }
macro_rules! f_det { ($formatter: expr, $v: expr, $denorm_v: expr) => {
{
let sign = if $denorm_v < 0.0 { -1.0 } else { 1.0 };
let semitones = $denorm_v.floor().abs();
let cents = ($denorm_v.fract() * 100.0).floor().abs();
if (cents > 1.0) {
write!($formatter, "{:2.0}s {:3.0}c", sign * semitones, cents)
} else {
write!($formatter, "{:2.0}s", sign * semitones)
}
}
} }
// norm-fun denorm-min
// denorm-fun denorm-max
define_exp!{n_gain d_gain 0.0, 2.0}
@ -328,6 +350,7 @@ macro_rules! node_list {
[0 sig],
sin => Sin UIType::Generic UICategory::Osc
(0 freq n_pit d_pit r_id f_freq -1.0, 1.0, 440.0)
(1 det n_det d_det r_id f_det -1.0, 1.0, 0.0)
[0 sig],
out => Out UIType::Generic UICategory::IOUtil
(0 ch1 n_id d_id r_id f_def -1.0, 1.0, 0.0)

View file

@ -27,6 +27,12 @@ impl Sin {
}
pub const freq : &'static str =
"Sin freq\nFrequency of the oscillator.\n\nRange: (-1..1)\n";
pub const det : &'static str =
"Sin det\nDetune the oscillator in semitones and cents. \
the input of this value is rounded to semitones on coarse input. \
Fine input lets you detune in cents (rounded). \
A signal sent to this port is not rounded.\
\n\nRange: (-1..1)\n";
pub const sig : &'static str =
"Sin sig\nOscillator signal output.\n\nRange: (-1..1)\n";
}