CW Decoder (Morse code decoder) 1st release version. Only run on Nucleo-F446RE mbed board.

Dependencies:   Array_Matrix F446_AD_DA ST7565_SPI_LCD TextLCD UIT_FFT_Real

Fork of F446_MySoundMachine by 不韋 呂

Base on F446_MySoundMachine program created by 不韋 呂-san.
Thanks to 不韋 呂-san making fundamental part such as FFT and ADC high speed interrupt driven program.
I just combined LCD and show CW code.

Committer:
MikamiUitOpen
Date:
Sun Jan 29 09:11:30 2017 +0000
Revision:
0:fa74b1130cc3
Child:
5:503bd366fd73
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:fa74b1130cc3 1 //--------------------------------------------------------------
MikamiUitOpen 0:fa74b1130cc3 2 // Reverb unit
MikamiUitOpen 0:fa74b1130cc3 3 // 2017/01/28, Copyright (c) 2017 MIKAMI, Naoki
MikamiUitOpen 0:fa74b1130cc3 4 //--------------------------------------------------------------
MikamiUitOpen 0:fa74b1130cc3 5
MikamiUitOpen 0:fa74b1130cc3 6 #ifndef REVERB_UNIT_HPP
MikamiUitOpen 0:fa74b1130cc3 7 #define REVERB_UNIT_HPP
MikamiUitOpen 0:fa74b1130cc3 8
MikamiUitOpen 0:fa74b1130cc3 9 #include "mbed.h"
MikamiUitOpen 0:fa74b1130cc3 10 #include "Array.hpp"
MikamiUitOpen 0:fa74b1130cc3 11 namespace Mikami
MikamiUitOpen 0:fa74b1130cc3 12 {
MikamiUitOpen 0:fa74b1130cc3 13 // Base class for reverb unit
MikamiUitOpen 0:fa74b1130cc3 14 class Reverb
MikamiUitOpen 0:fa74b1130cc3 15 {
MikamiUitOpen 0:fa74b1130cc3 16 public:
MikamiUitOpen 0:fa74b1130cc3 17 // Constructor
MikamiUitOpen 0:fa74b1130cc3 18 Reverb(int delay) : DELAY_(delay), un_(delay)
MikamiUitOpen 0:fa74b1130cc3 19 {
MikamiUitOpen 0:fa74b1130cc3 20 ptr_ = 0;
MikamiUitOpen 0:fa74b1130cc3 21 Clear();
MikamiUitOpen 0:fa74b1130cc3 22 }
MikamiUitOpen 0:fa74b1130cc3 23
MikamiUitOpen 0:fa74b1130cc3 24 ~Reverb() {}
MikamiUitOpen 0:fa74b1130cc3 25
MikamiUitOpen 0:fa74b1130cc3 26 // Execute of filter (pure virtual function)
MikamiUitOpen 0:fa74b1130cc3 27 virtual float Execute(float x) = 0;
MikamiUitOpen 0:fa74b1130cc3 28
MikamiUitOpen 0:fa74b1130cc3 29 // Clear internal delay elements
MikamiUitOpen 0:fa74b1130cc3 30 void Clear()
MikamiUitOpen 0:fa74b1130cc3 31 { for (int n=0; n<DELAY_; n++) un_[n] = 0; }
MikamiUitOpen 0:fa74b1130cc3 32
MikamiUitOpen 0:fa74b1130cc3 33 protected:
MikamiUitOpen 0:fa74b1130cc3 34 float Get() { return un_[ptr_]; }
MikamiUitOpen 0:fa74b1130cc3 35
MikamiUitOpen 0:fa74b1130cc3 36 float Get(int n)
MikamiUitOpen 0:fa74b1130cc3 37 {
MikamiUitOpen 0:fa74b1130cc3 38 int k = ptr_ + n;
MikamiUitOpen 0:fa74b1130cc3 39 if (k > DELAY_) k -= DELAY_;
MikamiUitOpen 0:fa74b1130cc3 40 if (k < 0) k += DELAY_;
MikamiUitOpen 0:fa74b1130cc3 41 return un_[k];
MikamiUitOpen 0:fa74b1130cc3 42 }
MikamiUitOpen 0:fa74b1130cc3 43
MikamiUitOpen 0:fa74b1130cc3 44 void Set(float x)
MikamiUitOpen 0:fa74b1130cc3 45 {
MikamiUitOpen 0:fa74b1130cc3 46 un_[ptr_] = x;
MikamiUitOpen 0:fa74b1130cc3 47 if (++ptr_ >= DELAY_) ptr_ = 0;
MikamiUitOpen 0:fa74b1130cc3 48 }
MikamiUitOpen 0:fa74b1130cc3 49 private:
MikamiUitOpen 0:fa74b1130cc3 50 const int DELAY_;
MikamiUitOpen 0:fa74b1130cc3 51 Array<float> un_; // for delay
MikamiUitOpen 0:fa74b1130cc3 52 int ptr_;
MikamiUitOpen 0:fa74b1130cc3 53
MikamiUitOpen 0:fa74b1130cc3 54 // disallow copy constructor and assignment operator
MikamiUitOpen 0:fa74b1130cc3 55 Reverb(const Reverb&);
MikamiUitOpen 0:fa74b1130cc3 56 Reverb& operator=(const Reverb&);
MikamiUitOpen 0:fa74b1130cc3 57 };
MikamiUitOpen 0:fa74b1130cc3 58
MikamiUitOpen 0:fa74b1130cc3 59 // Reverb unit using comb filter
MikamiUitOpen 0:fa74b1130cc3 60 class CombFilter : public Reverb
MikamiUitOpen 0:fa74b1130cc3 61 {
MikamiUitOpen 0:fa74b1130cc3 62 public:
MikamiUitOpen 0:fa74b1130cc3 63 // Constructor
MikamiUitOpen 0:fa74b1130cc3 64 CombFilter(float g, int delay)
MikamiUitOpen 0:fa74b1130cc3 65 : Reverb(delay), G0_(g) {}
MikamiUitOpen 0:fa74b1130cc3 66
MikamiUitOpen 0:fa74b1130cc3 67 // Execute comb filter
MikamiUitOpen 0:fa74b1130cc3 68 virtual float Execute(float x)
MikamiUitOpen 0:fa74b1130cc3 69 {
MikamiUitOpen 0:fa74b1130cc3 70 float yn = Reverb::Get();
MikamiUitOpen 0:fa74b1130cc3 71 Reverb::Set(x + G0_*yn);
MikamiUitOpen 0:fa74b1130cc3 72 return yn;
MikamiUitOpen 0:fa74b1130cc3 73 }
MikamiUitOpen 0:fa74b1130cc3 74
MikamiUitOpen 0:fa74b1130cc3 75 // Execute comb filter with variable delay
MikamiUitOpen 0:fa74b1130cc3 76 float Execute(float x, int n)
MikamiUitOpen 0:fa74b1130cc3 77 {
MikamiUitOpen 0:fa74b1130cc3 78 float yn = Reverb::Get(n);
MikamiUitOpen 0:fa74b1130cc3 79 Reverb::Set(x + G0_*yn);
MikamiUitOpen 0:fa74b1130cc3 80 return yn;
MikamiUitOpen 0:fa74b1130cc3 81 }
MikamiUitOpen 0:fa74b1130cc3 82
MikamiUitOpen 0:fa74b1130cc3 83 private:
MikamiUitOpen 0:fa74b1130cc3 84 const float G0_;
MikamiUitOpen 0:fa74b1130cc3 85 };
MikamiUitOpen 0:fa74b1130cc3 86
MikamiUitOpen 0:fa74b1130cc3 87 // Reverb unit using allpass filter
MikamiUitOpen 0:fa74b1130cc3 88 class AllPassFilter : public Reverb
MikamiUitOpen 0:fa74b1130cc3 89 {
MikamiUitOpen 0:fa74b1130cc3 90 public:
MikamiUitOpen 0:fa74b1130cc3 91 // Constructor
MikamiUitOpen 0:fa74b1130cc3 92 AllPassFilter(float g, int delay)
MikamiUitOpen 0:fa74b1130cc3 93 : Reverb(delay), G0_(g) {}
MikamiUitOpen 0:fa74b1130cc3 94
MikamiUitOpen 0:fa74b1130cc3 95 // Execute allpass filter
MikamiUitOpen 0:fa74b1130cc3 96 virtual float Execute(float x)
MikamiUitOpen 0:fa74b1130cc3 97 {
MikamiUitOpen 0:fa74b1130cc3 98 float un = x + G0_*Reverb::Get();
MikamiUitOpen 0:fa74b1130cc3 99 float yn = -G0_*un + Reverb::Get();
MikamiUitOpen 0:fa74b1130cc3 100 Reverb::Set(un);
MikamiUitOpen 0:fa74b1130cc3 101 return yn;
MikamiUitOpen 0:fa74b1130cc3 102 }
MikamiUitOpen 0:fa74b1130cc3 103 private:
MikamiUitOpen 0:fa74b1130cc3 104 const float G0_;
MikamiUitOpen 0:fa74b1130cc3 105 };
MikamiUitOpen 0:fa74b1130cc3 106 }
MikamiUitOpen 0:fa74b1130cc3 107 #endif // REVERB_UNIT_HPP
MikamiUitOpen 0:fa74b1130cc3 108