Experimental implementation of the adaptive filter of "Interface" magazine in 2016-2017

Dependencies:   amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746

Fork of skeleton_unzen_nucleo_f746 by seiichi horie

ハードウェアおよびソフトウェアはskelton_unzen_nucleo_f746を基本にしています。

signal_processing.h

Committer:
shorie
Date:
2017-01-31
Revision:
16:d4ea3e6a0bce
Parent:
15:de22b9d147e0
Child:
18:b9b1116f8768

File content as of revision 16:d4ea3e6a0bce:

#ifndef _SIGNAL_PROCESSING_H_
#define _SIGNAL_PROCESSING_H_

#include "amakusa.h"

enum wave_style { triangle, square };

    // User Signal processing Class 
class VFO {
public:
        // essential members. Do not touch
    VFO( void );
    void run(           
        float out_buffer[],    // place to write the right output samples
        unsigned int block_size     // block size [sample]
        );
           
        // parameter settings
    void set_frequency( int freq );  // unit is Hz.
    void set_Fs( int Fs );          // unit is Hz.
    void set_duty_cycle( float duty );  // 0 ... 0.5
    void set_wave_style( wave_style style );
private:

        // control variables.
    int frequency;          // VFO frequency [Hz]
    int Fs;                 // sampling Frequency [Hz]
    float duty_cycle;       // VFO duty cycle. 0 ... 0.5
    wave_style style;       // style of the wave form.
    int current_phase;      // internal variable of VFO.
    
        // internal variable.
    int half_way;           // change point by duty cycle. ( period * duty_cycle ).
    float rising_rate;
    float falling_rate;
    
    void update_parameters(void);    // call one of the parameter is changed.
};


    // User Signal processing Class 
class SignalProcessing {
public:
        // essential members. Do not touch
    SignalProcessing( unsigned int  block_size );
    void run(           
        float rx_left_buffer[],     // array of the left input samples
        float rx_right_buffer[],    // array of the right input samples
        float tx_left_buffer[],     // place to write the left output samples
        float tx_right_buffer[],    // place to write the right output samples
        unsigned int block_size     // block size [sample]
        );
           
        // project depenedent members.
    void set_volume( float vol );
    void set_Fs( int Fs );          // unit is Hz.
    void set_vfo_frequency( int freq );  // unit is Hz.
    void set_vfo_duty_cycle( float duty );  // 0 ... 0.5
    void set_vfo_wave_style( wave_style style );
private:
        // essential members. Do not touch.
    void enter_critical_section(void);
    void leave_critical_section(void);

        // project dependent members.
    float volume_level;     // 0 ... 1.0
    VFO *vfo;
};

#endif