aboutsummaryrefslogtreecommitdiffstats
path: root/src/cw-example
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-12-07 22:19:22 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-12-07 22:19:22 +0100
commitb804bdb641f4738cd05e664cae469f408f6fae08 (patch)
tree5aaca101634c7c204d789814aaa84c32ea7e037f /src/cw-example
parent0863817096a1f1c1deff7e39c86a4c0da8623442 (diff)
downloadglutte-o-matic-b804bdb641f4738cd05e664cae469f408f6fae08.tar.gz
glutte-o-matic-b804bdb641f4738cd05e664cae469f408f6fae08.tar.bz2
glutte-o-matic-b804bdb641f4738cd05e664cae469f408f6fae08.zip
Reduce CW clicks
Diffstat (limited to 'src/cw-example')
-rw-r--r--src/cw-example/cw.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/cw-example/cw.c b/src/cw-example/cw.c
index 3b9df43..1e42469 100644
--- a/src/cw-example/cw.c
+++ b/src/cw-example/cw.c
@@ -251,19 +251,28 @@ static void cw_task(void *pvParameters)
const float omega = 2.0f * FLOAT_PI * cw_fill_msg_current.freq /
(float)cw_samplerate;
+ float ampl = 0.0f;
+
for (int i = 0; i < cw_fill_msg_current.on_buffer_end; i++) {
for (int t = 0; t < samples_per_dit; t++) {
int16_t s = 0;
+ // Remove clicks from CW
if (cw_fill_msg_current.on_buffer[i]) {
- nco_phase += omega;
- if (nco_phase > FLOAT_PI) {
- nco_phase -= 2.0f * FLOAT_PI;
- }
+ const float remaining = 32768.0f - ampl;
+ ampl += remaining / 16.0f;
+ }
+ else {
+ ampl *= 0.8f;
+ }
- s = 32768.0f * arm_sin_f32(nco_phase);
+ nco_phase += omega;
+ if (nco_phase > FLOAT_PI) {
+ nco_phase -= 2.0f * FLOAT_PI;
}
+ s = ampl * arm_sin_f32(nco_phase);
+
if (buf_pos == AUDIO_BUF_LEN) {
xQueueSendToBack(cw_audio_queue, &cw_audio_buf, portMAX_DELAY);
buf_pos = 0;