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 18:b9b1116f8768, committed 2017-02-01
- Comitter:
- shorie
- Date:
- Wed Feb 01 15:00:31 2017 +0000
- Parent:
- 17:728ffc633179
- Child:
- 19:f5e785fe50b1
- Commit message:
- Update ciomment
Changed in this revision
--- a/main.cpp Tue Jan 31 14:19:16 2017 +0000 +++ b/main.cpp Wed Feb 01 15:00:31 2017 +0000 @@ -43,14 +43,14 @@ { uint32_t pushing, releasing, holding; - // VFO style - wave_style style = triangle; + // VFO form + wave_form form = triangle; // start audio. Do not touch initialize_system(); process->set_vfo_frequency( 440 ); - process->set_vfo_wave_style( style ); + process->set_vfo_wave_form( form ); ukifune::turn_led_off( ukifune::led1_1 ); ukifune::turn_led_on( ukifune::led1_2 ); @@ -67,17 +67,17 @@ // pushing detection demo if ( pushing & (1 << ukifune::swm1 ) ) // is SWM1 switch pusshing down? - if ( style == triangle ) + if ( form == triangle ) { - style = square; - process->set_vfo_wave_style( style ); + form = square; + process->set_vfo_wave_form( form ); ukifune::turn_led_on( ukifune::led1_1 ); ukifune::turn_led_off( ukifune::led1_2 ); } else { - style = triangle; - process->set_vfo_wave_style( style ); + form = triangle; + process->set_vfo_wave_form( form ); ukifune::turn_led_off( ukifune::led1_1 ); ukifune::turn_led_on( ukifune::led1_2 ); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/monophonic.cpp Wed Feb 01 15:00:31 2017 +0000 @@ -0,0 +1,55 @@ +#include "signal_processing.h" + + + // constructor. +Monophonic::Monophonic( unsigned int block_size ) +{ + // initializing the subm-odules. + this->vfo = new VFO(); // allocate VFO +} // End of constructor() + +Monophonic::~Monophonic( void ) +{ + // initializing the subm-odules. + delete this->vfo; +} // End of constructor() + + + + // Run all signal processing. +void Monophonic::run( + float out_buffer[], // place to write the right output samples + unsigned int block_size // block size [sample] + ) +{ + // place the signal processing coce here + + // VFO + this->vfo->run( out_buffer, block_size); + +} // End of run() + + + // Sampling Frequency +void Monophonic::set_Fs( int Fs ) +{ + this->vfo->set_Fs( Fs ); +} + + // Oscillation Frequency +void Monophonic::set_vfo_frequency( int freq ) +{ + this->vfo->set_frequency( freq ); +} + + // Duty Cycle of VFO +void Monophonic::set_vfo_duty_cycle( float duty ) +{ + this->vfo->set_duty_cycle( duty ); +} + + // VFO wave form +void Monophonic::set_vfo_wave_form( wave_form form ) +{ + this->vfo->set_wave_form( form ); +}
--- a/signal_processing.cpp Tue Jan 31 14:19:16 2017 +0000 +++ b/signal_processing.cpp Wed Feb 01 15:00:31 2017 +0000 @@ -6,7 +6,10 @@ { // place the signal processing initializing code here. this->volume_level = 0.0; // sample initializaiton - this->vfo = new VFO(); // allocate VFO + this->note = new Monophonic(block_size); // allocate VFO + note->set_Fs( SAMPLING_FREQUENCY ); + note->set_vfo_frequency( 440 ); + note->set_vfo_wave_form( triangle ); } // End of constructor() @@ -22,7 +25,7 @@ // place the signal processing coce here // VFO - this->vfo->run( tx_left_buffer, block_size); + this->note->run( tx_left_buffer, block_size); // apply gain and copy to right ch. for ( int i= 0; i< block_size; i++ ) @@ -36,7 +39,7 @@ void SignalProcessing::set_Fs( int Fs ) { this->enter_critical_section(); // forbidden interrrupt. - this->vfo->set_Fs( Fs ); + this->note->set_Fs( Fs ); this->leave_critical_section(); // now, ok to accept interrupt. } @@ -44,7 +47,7 @@ void SignalProcessing::set_vfo_frequency( int freq ) { this->enter_critical_section(); // forbidden interrrupt. - this->vfo->set_frequency( freq ); + this->note->set_vfo_frequency( freq ); this->leave_critical_section(); // now, ok to accept interrupt. } @@ -52,15 +55,15 @@ void SignalProcessing::set_vfo_duty_cycle( float duty ) { this->enter_critical_section(); // forbidden interrrupt. - this->vfo->set_duty_cycle( duty ); + this->note->set_vfo_duty_cycle( duty ); this->leave_critical_section(); // now, ok to accept interrupt. } - // VFO wave style -void SignalProcessing::set_vfo_wave_style( wave_style style ) + // VFO wave form +void SignalProcessing::set_vfo_wave_form( wave_form form ) { this->enter_critical_section(); // forbidden interrrupt. - this->vfo->set_wave_style( style ); + this->note->set_vfo_wave_form( form ); this->leave_critical_section(); // now, ok to accept interrupt. }
--- a/signal_processing.h Tue Jan 31 14:19:16 2017 +0000 +++ b/signal_processing.h Wed Feb 01 15:00:31 2017 +0000 @@ -3,30 +3,32 @@ #include "amakusa.h" -enum wave_style { triangle, square }; +#define SAMPLING_FREQUENCY 48000 - // User Signal processing Class +enum wave_form { triangle, square }; + + // Variable Frequency Oscillator. Only square and triangle class VFO { public: - // essential members. Do not touch VFO( void ); + virtual ~VFO(void); void run( - float out_buffer[], // place to write the right output samples + 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_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 ); + void set_wave_form( wave_form form ); 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. + wave_form form; // form of the wave form. int current_phase; // internal variable of VFO. // internal variable. @@ -37,6 +39,23 @@ void update_parameters(void); // call one of the parameter is changed. }; + // Monophonic synthsizer class +class Monophonic { +public: + Monophonic( unsigned int block_size ); + virtual ~Monophonic(void); + void run( + float out_buffer[], // place to write the right output samples + unsigned int block_size // block size [sample] + ); + 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_form( wave_form form ); +private: + VFO *vfo; +}; + // User Signal processing Class class SignalProcessing { @@ -56,7 +75,7 @@ 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 ); + void set_vfo_wave_form( wave_form form ); private: // essential members. Do not touch. void enter_critical_section(void); @@ -64,7 +83,7 @@ // project dependent members. float volume_level; // 0 ... 1.0 - VFO *vfo; + Monophonic * note; }; #endif
--- a/vfo.cpp Tue Jan 31 14:19:16 2017 +0000 +++ b/vfo.cpp Wed Feb 01 15:00:31 2017 +0000 @@ -1,19 +1,24 @@ #include "signal_processing.h" - // Modify this constructor to initialize your audio algorithm. + VFO::VFO( void ) { // initial parameter setting. - this->style = triangle; + this->form = triangle; this->Fs = 48000; this->frequency = 440; this->duty_cycle = 0.5; this->update_parameters(); } // End of constructor() + +VFO::~VFO( void ) +{ + // do nothing +} - // Modify this method to implement your audio algorithm. + void VFO::run( float out_buffer[], // vfo output buffer unsigned int block_size // block size [sample] @@ -23,14 +28,14 @@ for ( int i= 0; i< block_size; i++ ) { // 1 : if phase < half_way; 0 : others. - if ( this->style == square ) + if ( this->form == square ) { if ( this->current_phase < this->half_way ) out_buffer[i] = 1.0; else out_buffer[i] = 0.0; } - else // style == triangle + else // form == triangle { if ( this->current_phase < this->half_way ) out_buffer[i] = this->rising_rate * this->current_phase; @@ -77,9 +82,9 @@ this->update_parameters(); } -void VFO::set_wave_style( wave_style style ) +void VFO::set_wave_form( wave_form form ) { - this->style = style; + this->form = form; }