stuff
This commit is contained in:
parent
67e4b2382b
commit
37bb77bc88
7 changed files with 78 additions and 49 deletions
|
@ -1,7 +1,10 @@
|
|||
#include "audioc.hpp"
|
||||
#include "scope.hpp"
|
||||
#include "osclsk.hpp"
|
||||
|
||||
#define AUDIOC_DEBUG
|
||||
#include "audioc.hpp"
|
||||
|
||||
|
||||
#define _HUUUGE_FLOAT (std::numeric_limits<float>::infinity())
|
||||
|
||||
int
|
||||
|
@ -166,15 +169,14 @@ osclsk_scope::sample(const float *sig, size_t num)
|
|||
trig_lkb_num = 0;
|
||||
sample_trigger(&sig[i], num - i);
|
||||
}
|
||||
|
||||
break;
|
||||
return;
|
||||
case osc_state::TRIGGER:
|
||||
case osc_state::SAMPLE_DONE:
|
||||
case osc_state::RENDER:
|
||||
case osc_state::RENDER_DONE:
|
||||
case osc_state::READY:
|
||||
sample_trigger(sig, num);
|
||||
break;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -200,21 +202,39 @@ osclsk_scope::is_triggering(float sample)
|
|||
void
|
||||
osclsk_scope::trig_lkb_wr_block(void)
|
||||
{
|
||||
size_t lkb_i, n;
|
||||
size_t lkb_start, n;
|
||||
size_t lkb_cpy, lkb_cpy_part;
|
||||
|
||||
lkb_i = trig_lkb_idx >= trig_lkb_amount ?
|
||||
trig_lkb_idx - (trig_lkb_amount) :
|
||||
OSCLSK_TRIG_LOOKBACK + trig_lkb_idx - (trig_lkb_amount);
|
||||
if (trig_mode == osc_trig_mode::INSTANT)
|
||||
lkb_cpy = trig_lkb_num;
|
||||
else
|
||||
lkb_cpy = std::min(trig_lkb_num, trig_lkb_amount);
|
||||
|
||||
lkb_start = trig_lkb_idx >= lkb_cpy ? trig_lkb_idx - lkb_cpy :
|
||||
OSCLSK_TRIG_LOOKBACK + trig_lkb_idx - lkb_cpy;
|
||||
|
||||
lkb_cpy_part = OSCLSK_TRIG_LOOKBACK - lkb_start >= lkb_cpy ? lkb_cpy :
|
||||
OSCLSK_TRIG_LOOKBACK - lkb_start;
|
||||
|
||||
block_fill = 0;
|
||||
for (n = 0; n < trig_lkb_amount; n++) {
|
||||
block_y_max[block_fill] = trig_lkb_y_max[lkb_i];
|
||||
block_y_min[block_fill] = trig_lkb_y_min[lkb_i];
|
||||
|
||||
block_fill++;
|
||||
lkb_i = (lkb_i + 1) & (OSCLSK_TRIG_LOOKBACK - 1);
|
||||
std::copy(trig_lkb_y_max + lkb_start,
|
||||
trig_lkb_y_max + lkb_start + lkb_cpy_part, block_y_max);
|
||||
std::copy(trig_lkb_y_min + lkb_start,
|
||||
trig_lkb_y_min + lkb_start + lkb_cpy_part, block_y_min);
|
||||
|
||||
block_fill += lkb_cpy_part;
|
||||
|
||||
lkb_cpy -= lkb_cpy_part;
|
||||
if (lkb_cpy > 0) {
|
||||
std::copy(trig_lkb_y_max, trig_lkb_y_max + lkb_cpy,
|
||||
block_y_max + lkb_cpy_part);
|
||||
std::copy(trig_lkb_y_min, trig_lkb_y_min + lkb_cpy,
|
||||
block_y_min + lkb_cpy_part);
|
||||
}
|
||||
|
||||
block_fill += lkb_cpy;
|
||||
|
||||
/* we wanna resume sampling from right after the lookback data,
|
||||
* so we write partial data points to block as well */
|
||||
block_y_max[block_fill] = trig_lkb_y_max[trig_lkb_idx];
|
||||
|
@ -247,21 +267,22 @@ osclsk_scope::sample_trigger(const float *sig, size_t num)
|
|||
trig_lkb_idx_nsamp++;
|
||||
if (trig_lkb_idx_nsamp >= OSCLSK_RATE_DIV) {
|
||||
trig_lkb_idx++;
|
||||
trig_lkb_idx = trig_lkb_idx &
|
||||
(OSCLSK_TRIG_LOOKBACK - 1);
|
||||
trig_lkb_idx_nsamp = 0;
|
||||
trig_lkb_num = std::min(trig_lkb_num + 1,
|
||||
OSCLSK_TRIG_LOOKBACK);
|
||||
}
|
||||
|
||||
trig_lkb_num = std::min(trig_lkb_num + 1,
|
||||
OSCLSK_TRIG_LOOKBACK);
|
||||
|
||||
trig_lkb_idx =
|
||||
trig_lkb_idx & (OSCLSK_TRIG_LOOKBACK - 1);
|
||||
}
|
||||
|
||||
|
||||
/* only do triggering checks in TRIGGER state and out lookback buffer is
|
||||
* full enough */
|
||||
if (st != osc_state::TRIGGER || trig_lkb_num < trig_lkb_amount)
|
||||
/* only do triggering checks in TRIGGER state and if out lookback buffer
|
||||
* is full enough */
|
||||
if (st != osc_state::TRIGGER ||
|
||||
(trig_mode != osc_trig_mode::INSTANT &&
|
||||
trig_lkb_num < trig_lkb_amount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* trigger needs to be in NO_TRIG before TRIG state for e.g.
|
||||
* RISING_EDGE trigger mode */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue