Synthesizer based on the Unzen / Nucleo F746ZG
Dependencies: amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746
Fork of skeleton_unzen_nucleo_f746 by
雲仙フレームワークのテストとして作っているプロジェクトです。中身はどんどん変っていきます。 説明はDSP空挺団の「シンセサイザー」カテゴリーを参照してください。初回は「ドッグフードを食べる」です。
signal_processing.h@16:d4ea3e6a0bce, 2017-01-31 (annotated)
- Committer:
- shorie
- Date:
- Tue Jan 31 12:52:59 2017 +0000
- Revision:
- 16:d4ea3e6a0bce
- Parent:
- 15:de22b9d147e0
- Child:
- 18:b9b1116f8768
update the VFO.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shorie | 6:486b1cb03e61 | 1 | #ifndef _SIGNAL_PROCESSING_H_ |
shorie | 6:486b1cb03e61 | 2 | #define _SIGNAL_PROCESSING_H_ |
shorie | 6:486b1cb03e61 | 3 | |
shorie | 6:486b1cb03e61 | 4 | #include "amakusa.h" |
shorie | 6:486b1cb03e61 | 5 | |
shorie | 14:cec63d8da48c | 6 | enum wave_style { triangle, square }; |
shorie | 14:cec63d8da48c | 7 | |
shorie | 14:cec63d8da48c | 8 | // User Signal processing Class |
shorie | 14:cec63d8da48c | 9 | class VFO { |
shorie | 14:cec63d8da48c | 10 | public: |
shorie | 14:cec63d8da48c | 11 | // essential members. Do not touch |
shorie | 14:cec63d8da48c | 12 | VFO( void ); |
shorie | 14:cec63d8da48c | 13 | void run( |
shorie | 14:cec63d8da48c | 14 | float out_buffer[], // place to write the right output samples |
shorie | 14:cec63d8da48c | 15 | unsigned int block_size // block size [sample] |
shorie | 14:cec63d8da48c | 16 | ); |
shorie | 14:cec63d8da48c | 17 | |
shorie | 14:cec63d8da48c | 18 | // parameter settings |
shorie | 14:cec63d8da48c | 19 | void set_frequency( int freq ); // unit is Hz. |
shorie | 14:cec63d8da48c | 20 | void set_Fs( int Fs ); // unit is Hz. |
shorie | 14:cec63d8da48c | 21 | void set_duty_cycle( float duty ); // 0 ... 0.5 |
shorie | 14:cec63d8da48c | 22 | void set_wave_style( wave_style style ); |
shorie | 14:cec63d8da48c | 23 | private: |
shorie | 14:cec63d8da48c | 24 | |
shorie | 16:d4ea3e6a0bce | 25 | // control variables. |
shorie | 14:cec63d8da48c | 26 | int frequency; // VFO frequency [Hz] |
shorie | 14:cec63d8da48c | 27 | int Fs; // sampling Frequency [Hz] |
shorie | 14:cec63d8da48c | 28 | float duty_cycle; // VFO duty cycle. 0 ... 0.5 |
shorie | 14:cec63d8da48c | 29 | wave_style style; // style of the wave form. |
shorie | 15:de22b9d147e0 | 30 | int current_phase; // internal variable of VFO. |
shorie | 15:de22b9d147e0 | 31 | |
shorie | 16:d4ea3e6a0bce | 32 | // internal variable. |
shorie | 16:d4ea3e6a0bce | 33 | int half_way; // change point by duty cycle. ( period * duty_cycle ). |
shorie | 16:d4ea3e6a0bce | 34 | float rising_rate; |
shorie | 16:d4ea3e6a0bce | 35 | float falling_rate; |
shorie | 16:d4ea3e6a0bce | 36 | |
shorie | 16:d4ea3e6a0bce | 37 | void update_parameters(void); // call one of the parameter is changed. |
shorie | 14:cec63d8da48c | 38 | }; |
shorie | 14:cec63d8da48c | 39 | |
shorie | 14:cec63d8da48c | 40 | |
shorie | 6:486b1cb03e61 | 41 | // User Signal processing Class |
shorie | 6:486b1cb03e61 | 42 | class SignalProcessing { |
shorie | 6:486b1cb03e61 | 43 | public: |
shorie | 6:486b1cb03e61 | 44 | // essential members. Do not touch |
shorie | 6:486b1cb03e61 | 45 | SignalProcessing( unsigned int block_size ); |
shorie | 6:486b1cb03e61 | 46 | void run( |
shorie | 6:486b1cb03e61 | 47 | float rx_left_buffer[], // array of the left input samples |
shorie | 6:486b1cb03e61 | 48 | float rx_right_buffer[], // array of the right input samples |
shorie | 6:486b1cb03e61 | 49 | float tx_left_buffer[], // place to write the left output samples |
shorie | 13:b33cb5925113 | 50 | float tx_right_buffer[], // place to write the right output samples |
shorie | 6:486b1cb03e61 | 51 | unsigned int block_size // block size [sample] |
shorie | 6:486b1cb03e61 | 52 | ); |
shorie | 6:486b1cb03e61 | 53 | |
shorie | 6:486b1cb03e61 | 54 | // project depenedent members. |
shorie | 6:486b1cb03e61 | 55 | void set_volume( float vol ); |
shorie | 14:cec63d8da48c | 56 | void set_Fs( int Fs ); // unit is Hz. |
shorie | 15:de22b9d147e0 | 57 | void set_vfo_frequency( int freq ); // unit is Hz. |
shorie | 15:de22b9d147e0 | 58 | void set_vfo_duty_cycle( float duty ); // 0 ... 0.5 |
shorie | 15:de22b9d147e0 | 59 | void set_vfo_wave_style( wave_style style ); |
shorie | 6:486b1cb03e61 | 60 | private: |
shorie | 6:486b1cb03e61 | 61 | // essential members. Do not touch. |
shorie | 6:486b1cb03e61 | 62 | void enter_critical_section(void); |
shorie | 6:486b1cb03e61 | 63 | void leave_critical_section(void); |
shorie | 6:486b1cb03e61 | 64 | |
shorie | 6:486b1cb03e61 | 65 | // project dependent members. |
shorie | 14:cec63d8da48c | 66 | float volume_level; // 0 ... 1.0 |
shorie | 14:cec63d8da48c | 67 | VFO *vfo; |
shorie | 6:486b1cb03e61 | 68 | }; |
shorie | 6:486b1cb03e61 | 69 | |
shorie | 6:486b1cb03e61 | 70 | #endif |