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
ハードウェアおよびソフトウェアはskelton_unzen_nucleo_f746を基本にしています。
Revision 14:cec63d8da48c, committed 2017-01-30
- Comitter:
- shorie
- Date:
- Mon Jan 30 14:48:42 2017 +0000
- Parent:
- 13:b33cb5925113
- Child:
- 15:de22b9d147e0
- Commit message:
- VFO added.
Changed in this revision
--- a/signal_processing.cpp Sun Jan 29 03:05:56 2017 +0000 +++ b/signal_processing.cpp Mon Jan 30 14:48:42 2017 +0000 @@ -6,6 +6,7 @@ { // place the signal processing initializing code here. this->volume_level = 0.0; // sample initializaiton + this->vfo = new VFO(); // allocate VFO } // End of constructor() @@ -19,13 +20,39 @@ ) { // place the signal processing coce here + + // VFO + this->vfo->run( tx_left_buffer, block_size); + + // apply gain and copy to right ch. for ( int i= 0; i< block_size; i++ ) { - tx_left_buffer[i] = rx_left_buffer[i] * this->volume_level; - tx_right_buffer[i] = rx_right_buffer[i] * this->volume_level; + tx_right_buffer[i] = tx_left_buffer[i] *= this->volume_level; } } // End of run() + +void SignalProcessing::set_Fs( int Fs ) +{ + this->vfo->set_Fs( Fs ); +} + +void SignalProcessing::set_frequency( int freq ) +{ + this->vfo->set_frequency( freq ); +} + +void SignalProcessing::set_duty_cycle( float duty ) +{ + this->vfo->set_duty_cycle( duty ); +} + +void SignalProcessing::set_wave_style( wave_style style ) +{ + this->vfo->set_wave_style( style ); +} + + // Sample method. Set the volume level to the object. void SignalProcessing::set_volume( float vol )
--- a/signal_processing.h Sun Jan 29 03:05:56 2017 +0000 +++ b/signal_processing.h Mon Jan 30 14:48:42 2017 +0000 @@ -3,6 +3,34 @@ #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: + + // internal 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. +}; + + // User Signal processing Class class SignalProcessing { public: @@ -18,13 +46,18 @@ // project depenedent members. void set_volume( float vol ); + 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: // essential members. Do not touch. void enter_critical_section(void); void leave_critical_section(void); // project dependent members. - float volume_level; + float volume_level; // 0 ... 1.0 + VFO *vfo; }; #endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vfo.cpp Mon Jan 30 14:48:42 2017 +0000 @@ -0,0 +1,57 @@ +#include "signal_processing.h" + + // Modify this constructor to initialize your audio algorithm. +VFO::VFO( void ) +{ + // initial parameter setting. + this->style = triangle; + this->Fs = 48000; + this->frequency = 440; + this->duty_cycle = 0.5; +} // End of constructor() + + + // Modify this method to implement your audio algorithm. +void VFO::run( + float out_buffer[], // vfo output buffer + unsigned int block_size // block size [sample] + ) +{ + // place the signal processing coce here + for ( int i= 0; i< block_size; i++ ) + { + } +} // End of run() + + +void VFO::set_Fs( int Fs ) +{ + // regulate the Fs. + if ( Fs != 32000 && Fs != 44100 && Fs != 96000 && Fs != 48000 ) + Fs = 48000; + this->Fs = Fs; +} + +void VFO::set_frequency( int freq ) +{ + if ( freq > this->Fs / 4 ) + freq = Fs/4; + this->frequency = freq; +} + +void VFO::set_duty_cycle( float duty ) +{ + if ( duty > 0.5f ) // high limit + duty = 0.5f; + if ( duty < 0.01f ) // low limit + duty = 0.01f; + this->duty_cycle = duty; +} + +void VFO::set_wave_style( wave_style style ) +{ + this->style = style; +} + + +