replace len with mxlen instead
This commit is contained in:
parent
e6df5039ef
commit
30b67efe70
3 changed files with 17 additions and 79 deletions
|
@ -372,12 +372,11 @@ macro_rules! node_list {
|
||||||
(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)
|
||||||
(2 offs n_id n_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
(2 offs n_id n_id r_id f_def stp_d 0.0, 1.0, 0.0)
|
||||||
(3 len n_id n_id r_id f_def stp_d 0.0, 1.0, 1.0)
|
(3 len n_id n_id r_id f_def stp_d 0.0, 1.0, 1.0)
|
||||||
(4 mxlen n_id n_id r_id f_def stp_d 0.0, 1.0, 1.0)
|
(4 dcms n_declick d_declick r_ms f_ms stp_m 0.0, 1.0, 3.0)
|
||||||
(5 dcms n_declick d_declick r_ms f_ms stp_m 0.0, 1.0, 3.0)
|
(5 det n_det d_det r_det f_det stp_f -0.2, 0.2, 0.0)
|
||||||
(6 det n_det d_det r_det f_det stp_f -0.2, 0.2, 0.0)
|
{6 0 sample audio_unloaded("") f_def 0 0}
|
||||||
{7 0 sample audio_unloaded("") f_def 0 0}
|
{7 1 pmode setting(0) fa_sampl_pmode 0 1}
|
||||||
{8 1 pmode setting(0) fa_sampl_pmode 0 1}
|
{8 2 dclick setting(0) fa_sampl_dclick 0 1}
|
||||||
{9 2 dclick setting(0) fa_sampl_dclick 0 1}
|
|
||||||
[0 sig],
|
[0 sig],
|
||||||
// node_param_idx
|
// node_param_idx
|
||||||
// name denorm round format steps norm norm denorm
|
// name denorm round format steps norm norm denorm
|
||||||
|
|
|
@ -61,15 +61,8 @@ impl Sampl {
|
||||||
pub const offs : &'static str =
|
pub const offs : &'static str =
|
||||||
"Sampl offs\nStart position offset.\nRange: (0..1)\n";
|
"Sampl offs\nStart position offset.\nRange: (0..1)\n";
|
||||||
pub const len : &'static str =
|
pub const len : &'static str =
|
||||||
"Sampl len\nAdjusts the remaining length of the sample, after the \
|
"Sampl len\nAdjusts the playback length of the sample in relation \
|
||||||
offset has been applied. This means the absolute length in seconds \
|
to the original length of the sample.\nRange: (0..1)\n";
|
||||||
depends on the offset and this ratio.\
|
|
||||||
\nRange: (0..1)\n";
|
|
||||||
pub const mxlen : &'static str =
|
|
||||||
"Sampl mxlen\nLimits the remaining length of the sample relative to the \
|
|
||||||
original length of the sample. In constrast to 'len' this paramter \
|
|
||||||
modifies the length independently to the 'offs' parameter. \
|
|
||||||
\nRange: (0..1)\n";
|
|
||||||
pub const dcms : &'static str =
|
pub const dcms : &'static str =
|
||||||
"Sampl dcms\nDeclick fade time in milliseconds.\nNot audio rate!\nRange: (0..1)\n";
|
"Sampl dcms\nDeclick fade time in milliseconds.\nNot audio rate!\nRange: (0..1)\n";
|
||||||
pub const det : &'static str =
|
pub const det : &'static str =
|
||||||
|
@ -117,13 +110,8 @@ in the 'Samples' tab.
|
||||||
|
|
||||||
You can adjust the playback speed of the sample either by the 'freq' parameter
|
You can adjust the playback speed of the sample either by the 'freq' parameter
|
||||||
or the 'det' parameter. You can offset into the sample using the 'offs'
|
or the 'det' parameter. You can offset into the sample using the 'offs'
|
||||||
parameter and modify the remaining length using the 'len' parameter.
|
parameter and modify the playback length relative to the original
|
||||||
|
sample length using the 'len' parameter.
|
||||||
The maximum length can be modified using the 'mxlen' parameter.
|
|
||||||
It limits the maximum of the remaining length, but relative to the original
|
|
||||||
length of the sample and not to the length after the offset has been applied.
|
|
||||||
If you apply length modification using the 'len' parameter,
|
|
||||||
then the playback length of the sample will change with the 'offs' parameter.
|
|
||||||
|
|
||||||
Even though you are advised to use an envelope for controlling the playback
|
Even though you are advised to use an envelope for controlling the playback
|
||||||
volume of the sample to prevent clicks a simple in and out ramp is provided
|
volume of the sample to prevent clicks a simple in and out ramp is provided
|
||||||
|
@ -186,7 +174,6 @@ impl Sampl {
|
||||||
let trig = inp::Sampl::trig(inputs);
|
let trig = inp::Sampl::trig(inputs);
|
||||||
let offs = inp::Sampl::offs(inputs);
|
let offs = inp::Sampl::offs(inputs);
|
||||||
let len = inp::Sampl::len(inputs);
|
let len = inp::Sampl::len(inputs);
|
||||||
let mxlen = inp::Sampl::mxlen(inputs);
|
|
||||||
let dcms = inp::Sampl::dcms(inputs);
|
let dcms = inp::Sampl::dcms(inputs);
|
||||||
let det = inp::Sampl::det(inputs);
|
let det = inp::Sampl::det(inputs);
|
||||||
|
|
||||||
|
@ -206,7 +193,6 @@ impl Sampl {
|
||||||
|
|
||||||
let mut prev_offs = -10.0;
|
let mut prev_offs = -10.0;
|
||||||
let mut prev_len = -10.0;
|
let mut prev_len = -10.0;
|
||||||
let mut prev_mxlen = -10.0;
|
|
||||||
|
|
||||||
let mut start_idx = 0;
|
let mut start_idx = 0;
|
||||||
let mut end_idx_plus1 = sample_data.len();
|
let mut end_idx_plus1 = sample_data.len();
|
||||||
|
@ -246,30 +232,19 @@ impl Sampl {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
let cur_mxlen =
|
|
||||||
denorm::Sampl::mxlen(mxlen, frame).abs().min(1.0)
|
|
||||||
as f64;
|
|
||||||
let cur_len =
|
let cur_len =
|
||||||
denorm::Sampl::len(len, frame).abs().min(0.999999)
|
denorm::Sampl::len(len, frame).abs().min(1.0) as f64;
|
||||||
as f64;
|
if recalc_end || prev_len != cur_len {
|
||||||
if recalc_end
|
|
||||||
|| prev_len != cur_len
|
|
||||||
|| prev_mxlen != cur_mxlen
|
|
||||||
{
|
|
||||||
let max_sd_len =
|
let max_sd_len =
|
||||||
((sd_len as f64 * cur_mxlen as f64)
|
(sd_len as f64 * cur_len as f64).round() as usize;
|
||||||
as usize).max(1);
|
|
||||||
|
|
||||||
let remain_s_len =
|
let remain_s_len =
|
||||||
if start_idx <= sd_len {
|
if start_idx <= sd_len {
|
||||||
(sd_len - start_idx).min(max_sd_len)
|
(sd_len - start_idx).min(max_sd_len)
|
||||||
} else { 0 };
|
} else { 0 };
|
||||||
|
|
||||||
end_idx_plus1 =
|
end_idx_plus1 = remain_s_len;
|
||||||
((remain_s_len as f64 * cur_len)
|
|
||||||
.ceil() as usize).min(remain_s_len);
|
|
||||||
|
|
||||||
prev_mxlen = cur_mxlen;
|
|
||||||
prev_len = cur_len;
|
prev_len = cur_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,7 +355,7 @@ fn check_node_sampl_offs_len() {
|
||||||
|
|
||||||
// Select part 0.5 to 0.75 of the sample:
|
// Select part 0.5 to 0.75 of the sample:
|
||||||
matrix.set_param(offs_p, SAtom::param(0.5));
|
matrix.set_param(offs_p, SAtom::param(0.5));
|
||||||
matrix.set_param(len_p, SAtom::param(0.5));
|
matrix.set_param(len_p, SAtom::param(0.25));
|
||||||
|
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.001113, 0.54999));
|
assert_minmax_of_rms!(rmsvec[0], (0.001113, 0.54999));
|
||||||
|
@ -367,42 +367,6 @@ fn check_node_sampl_offs_len() {
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.5, 0.55));
|
assert_minmax_of_rms!(rmsvec[2], (0.5, 0.55));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn check_node_sampl_offs_mxlen() {
|
|
||||||
let (node_conf, mut node_exec) = new_node_engine();
|
|
||||||
let mut matrix = Matrix::new(node_conf, 3, 3);
|
|
||||||
|
|
||||||
let smpl = NodeId::Sampl(0);
|
|
||||||
let out = NodeId::Out(0);
|
|
||||||
matrix.place(0, 0, Cell::empty(smpl)
|
|
||||||
.out(None, None, smpl.out("sig")));
|
|
||||||
matrix.place(0, 1, Cell::empty(out)
|
|
||||||
.input(out.inp("ch1"), None, None));
|
|
||||||
matrix.sync().unwrap();
|
|
||||||
|
|
||||||
let sample_p = smpl.inp_param("sample").unwrap();
|
|
||||||
let pmode_p = smpl.inp_param("pmode").unwrap();
|
|
||||||
let offs_p = smpl.inp_param("offs").unwrap();
|
|
||||||
let mxlen_p = smpl.inp_param("mxlen").unwrap();
|
|
||||||
|
|
||||||
matrix.set_param(sample_p, create_1sec_ramp());
|
|
||||||
matrix.set_param(pmode_p, SAtom::setting(0));
|
|
||||||
|
|
||||||
// Select part 0.5 to 0.75 of the sample:
|
|
||||||
matrix.set_param(offs_p, SAtom::param(0.5));
|
|
||||||
matrix.set_param(mxlen_p, SAtom::param(0.25));
|
|
||||||
|
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.001113, 0.54999));
|
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.6, 0.65));
|
|
||||||
|
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.65, 0.6999));
|
|
||||||
assert_minmax_of_rms!(rmsvec[1], (0.70, 0.75));
|
|
||||||
assert_minmax_of_rms!(rmsvec[2], (0.5, 0.55));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn check_node_sampl_offs_len_zero_crash() {
|
fn check_node_sampl_offs_len_zero_crash() {
|
||||||
let (node_conf, mut node_exec) = new_node_engine();
|
let (node_conf, mut node_exec) = new_node_engine();
|
||||||
|
@ -431,7 +395,7 @@ fn check_node_sampl_offs_len_zero_crash() {
|
||||||
|
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
let rmsvec = run_and_get_each_rms_mimax(&mut node_exec, 50.0);
|
||||||
assert_minmax_of_rms!(rmsvec[0], (0.0, 1.0));
|
assert_minmax_of_rms!(rmsvec[0], (0.0, 0.9979));
|
||||||
|
|
||||||
// Select part 0.5 to 0.75 of the sample:
|
// Select part 0.5 to 0.75 of the sample:
|
||||||
matrix.set_param(offs_p, SAtom::param(0.9));
|
matrix.set_param(offs_p, SAtom::param(0.9));
|
||||||
|
@ -554,7 +518,7 @@ fn check_node_sampl_declick_offs_len() {
|
||||||
matrix.set_param(dcms_p, SAtom::param(dcms_p.norm(3.14)));
|
matrix.set_param(dcms_p, SAtom::param(dcms_p.norm(3.14)));
|
||||||
matrix.set_param(trig_p, (1.0).into());
|
matrix.set_param(trig_p, (1.0).into());
|
||||||
matrix.set_param(offs_p, SAtom::param(0.9));
|
matrix.set_param(offs_p, SAtom::param(0.9));
|
||||||
matrix.set_param(len_p, SAtom::param(0.08));
|
matrix.set_param(len_p, SAtom::param(0.008));
|
||||||
|
|
||||||
// trigger:
|
// trigger:
|
||||||
run_for_ms(&mut node_exec, 7.5);
|
run_for_ms(&mut node_exec, 7.5);
|
||||||
|
|
Loading…
Reference in a new issue