Implemented most of the Quant node
This commit is contained in:
parent
f6c17121ab
commit
c5f70252e3
2 changed files with 46 additions and 21 deletions
|
@ -738,7 +738,7 @@ macro_rules! node_list {
|
||||||
quant => Quant UIType::Generic UICategory::CV
|
quant => Quant UIType::Generic UICategory::CV
|
||||||
(0 inp n_id d_id r_id f_def stp_d -1.0, 1.0, 0.0)
|
(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)
|
(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}
|
{2 0 keys setting(0) fa_quant 0 0}
|
||||||
[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)
|
||||||
|
|
|
@ -58,28 +58,53 @@ impl DspNode for Quant {
|
||||||
let inp = inp::Quant::inp(inputs);
|
let inp = inp::Quant::inp(inputs);
|
||||||
let oct = inp::Quant::oct(inputs);
|
let oct = inp::Quant::oct(inputs);
|
||||||
let out = out::Quant::sig(outputs);
|
let out = out::Quant::sig(outputs);
|
||||||
let max = at::Quant::keys(atoms);
|
let keys = at::Quant::keys(atoms);
|
||||||
|
|
||||||
|
let mut key_count = 0;
|
||||||
|
let mut used_keys = [0.0; 12];
|
||||||
|
|
||||||
|
let mask = keys.i();
|
||||||
|
let tune_to_a4 = (9.0 / 12.0) * 0.1;
|
||||||
|
for i in 0..9 {
|
||||||
|
if mask & (0x1 << i) > 0 {
|
||||||
|
used_keys[key_count] = ((i as f32 / 12.0) * 0.1) - tune_to_a4;
|
||||||
|
key_count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i in 9..12 {
|
||||||
|
let key_pitch_idx = (i + 9 + 12) % 12;
|
||||||
|
if mask & (0x1 << i) > 0 {
|
||||||
|
used_keys[key_count] = (i as f32 / 12.0) * 0.1 - tune_to_a4;
|
||||||
|
key_count += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if key_count == 0 {
|
||||||
|
for frame in 0..ctx.nframes() {
|
||||||
|
out.write(
|
||||||
|
frame,
|
||||||
|
denorm::Quant::inp(inp, frame)
|
||||||
|
+ denorm::Quant::oct(oct, frame));
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx_vals[1].set(100.0); // some unreachable value for Keys widget
|
||||||
|
ctx_vals[0].set(out.read(ctx.nframes() - 1));
|
||||||
|
} else {
|
||||||
|
let mut last_pitch = 0.0;
|
||||||
|
|
||||||
for frame in 0..ctx.nframes() {
|
for frame in 0..ctx.nframes() {
|
||||||
// self.idx =
|
let key =
|
||||||
// (max as f32 * denorm::Mux9::slct(slct, frame))
|
(denorm::Quant::inp(inp, frame) * (key_count as f32))
|
||||||
// .floor() as u8
|
.floor();
|
||||||
// % max;
|
let key = key as usize % key_count;
|
||||||
//
|
let pitch = used_keys[key];
|
||||||
// out.write(frame, match self.idx {
|
last_pitch = pitch;
|
||||||
// 0 => denorm::Mux9::in_1(in_1, frame),
|
out.write(frame, pitch + denorm::Quant::oct(oct, 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((last_pitch + tune_to_a4) * 10.0 + 0.0001);
|
||||||
ctx_vals[1].set(0.5);
|
ctx_vals[0].set(((last_pitch + tune_to_a4) * 10.0 - 0.5) * 2.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue