| @@ -8,6 +8,7 @@ · 7 unmodified lines |
| 8 | | 8 | |
| 9 | struct smoother_n { | 9 | struct smoother_n { |
| 10 | pw_cable *in; | 10 | pw_cable *in; |
| | 11 | pw_cable *trig; |
| 11 | pw_cable *smooth; | 12 | pw_cable *smooth; |
| 12 | pw_cable *out; | 13 | pw_cable *out; |
| 13 | sk_smoother smoother; | 14 | sk_smoother smoother; |
| @@ -35,6 +36,34 @@ static void compute(pw_node *node) · 21 unmodified lines |
| 35 | } | 36 | } |
| 36 | } | 37 | } |
| 37 | | 38 | |
| | 39 | static void compute_withtrig(pw_node *node) |
| | 40 | { |
| | 41 | int blksize; |
| | 42 | int n; |
| | 43 | struct smoother_n *smoother; |
| | 44 | |
| | 45 | blksize = pw_node_blksize(node); |
| | 46 | |
| | 47 | smoother = (struct smoother_n *)pw_node_get_data(node); |
| | 48 | |
| | 49 | for (n = 0; n < blksize; n++) { |
| | 50 | PWFLT out, smooth, in, trig; |
| | 51 | in = pw_cable_get(smoother->in, n); |
| | 52 | trig = pw_cable_get(smoother->trig, n); |
| | 53 | smooth = pw_cable_get(smoother->smooth, n); |
| | 54 | |
| | 55 | sk_smoother_time(&smoother->smoother, smooth); |
| | 56 | |
| | 57 | if (trig != 0) { |
| | 58 | sk_smoother_reset(&smoother->smoother, in); |
| | 59 | } |
| | 60 | |
| | 61 | out = sk_smoother_tick(&smoother->smoother, in); |
| | 62 | |
| | 63 | pw_cable_set(smoother->out, n, out); |
| | 64 | } |
| | 65 | } |
| | 66 | |
| 38 | static void destroy(pw_node *node) | 67 | static void destroy(pw_node *node) |
| 39 | { | 68 | { |
| 40 | pw_patch *patch; | 69 | pw_patch *patch; |
| @@ -94,3 +123,57 @@ int sk_node_smoother(sk_core *core) · 53 unmodified lines |
| 94 | sk_param_out(core, node, 2); | 123 | sk_param_out(core, node, 2); |
| 95 | return 0; | 124 | return 0; |
| 96 | } | 125 | } |
| | 126 | |
| | 127 | int sk_node_tsmoother(sk_core *core) |
| | 128 | { |
| | 129 | pw_patch *patch; |
| | 130 | pw_node *node; |
| | 131 | int rc; |
| | 132 | sk_param in; |
| | 133 | sk_param trig; |
| | 134 | sk_param smooth; |
| | 135 | void *ud; |
| | 136 | struct smoother_n *smoother; |
| | 137 | int sr; |
| | 138 | |
| | 139 | rc = sk_param_get(core, &smooth); |
| | 140 | SK_ERROR_CHECK(rc); |
| | 141 | |
| | 142 | rc = sk_param_get(core, &trig); |
| | 143 | SK_ERROR_CHECK(rc); |
| | 144 | |
| | 145 | rc = sk_param_get(core, &in); |
| | 146 | SK_ERROR_CHECK(rc); |
| | 147 | |
| | 148 | patch = sk_core_patch(core); |
| | 149 | |
| | 150 | rc = pw_memory_alloc(patch, sizeof(struct smoother_n), &ud); |
| | 151 | SK_PW_ERROR_CHECK(rc); |
| | 152 | smoother = (struct smoother_n *)ud; |
| | 153 | |
| | 154 | sr = pw_patch_srate_get(patch); |
| | 155 | sk_smoother_init(&smoother->smoother, sr); |
| | 156 | |
| | 157 | rc = pw_patch_new_node(patch, &node); |
| | 158 | SK_PW_ERROR_CHECK(rc); |
| | 159 | |
| | 160 | rc = pw_node_cables_alloc(node, 4); |
| | 161 | SK_PW_ERROR_CHECK(rc); |
| | 162 | |
| | 163 | pw_node_set_block(node, 3); |
| | 164 | |
| | 165 | pw_node_get_cable(node, 0, &smoother->in); |
| | 166 | pw_node_get_cable(node, 1, &smoother->trig); |
| | 167 | pw_node_get_cable(node, 2, &smoother->smooth); |
| | 168 | pw_node_get_cable(node, 3, &smoother->out); |
| | 169 | |
| | 170 | pw_node_set_data(node, smoother); |
| | 171 | pw_node_set_compute(node, compute_withtrig); |
| | 172 | pw_node_set_destroy(node, destroy); |
| | 173 | |
| | 174 | sk_param_set(core, node, &in, 0); |
| | 175 | sk_param_set(core, node, &trig, 1); |
| | 176 | sk_param_set(core, node, &smooth, 2); |
| | 177 | sk_param_out(core, node, 3); |
| | 178 | return 0; |
| | 179 | } |