Synthesizer based on the Unzen / Nucleo F746ZG
Dependencies: amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746
Fork of skeleton_unzen_nucleo_f746 by
monophonic.cpp
00001 #include "signal_processing.h" 00002 00003 00004 // constructor. 00005 Monophonic::Monophonic( unsigned int a_block_size ) 00006 { 00007 this->block_size = a_block_size; 00008 00009 // initializing the subm-odules. 00010 this->vfo = new VFO(block_size); // allocate VFO 00011 this->dc_blocker = new DCBlocker( this->block_size ); 00012 this->sv_filter = new SVFilter( this->block_size ); 00013 this->eg = new EG( this->block_size ); 00014 this->limitter = new amakusa::LimitterLinAtan( this->block_size ); 00015 00016 work_buf_a = new float32_t[block_size]; 00017 work_buf_b = new float32_t[block_size]; 00018 00019 } // End of constructor() 00020 00021 Monophonic::~Monophonic( void ) 00022 { 00023 // initializing the subm-odules. 00024 delete this->vfo; 00025 delete this->dc_blocker; 00026 delete this->sv_filter; 00027 delete this->eg; 00028 delete this->limitter; 00029 00030 delete[] work_buf_a; 00031 delete[] work_buf_b; 00032 } // End of constructor() 00033 00034 00035 00036 // Run all signal processing. 00037 void Monophonic::run( 00038 float out_buffer[] // place to write the right output samples 00039 ) 00040 { 00041 // place the signal processing coce here 00042 this->vfo->run( work_buf_a ); 00043 00044 // blocking DC. 00045 this->dc_blocker->run( work_buf_a, work_buf_b ); 00046 00047 // applying filter. 00048 this->sv_filter->run( work_buf_b, work_buf_a ); 00049 00050 // generate envelope 00051 this->eg->run( work_buf_b ); 00052 00053 // apply envelope 00054 for ( int i= 0; i< this->block_size; i++ ) 00055 work_buf_b[ i ] *= work_buf_a[ i ]; 00056 00057 // apply amplitude limitter 00058 this->limitter->run( work_buf_b, out_buffer ); 00059 00060 } // End of run() 00061 00062 00063 // Sampling Frequency 00064 void Monophonic::set_Fs( int Fs ) 00065 { 00066 this->vfo->set_Fs( Fs ); 00067 this->sv_filter->set_Fs( Fs ); 00068 } 00069 00070 // Oscillation Frequency 00071 void Monophonic::set_vfo_frequency( float freq ) 00072 { 00073 this->vfo->set_frequency( freq ); 00074 this->sv_filter->set_fc( freq ); 00075 } 00076 00077 // Duty Cycle of VFO 00078 void Monophonic::set_vfo_duty_cycle( float duty ) 00079 { 00080 this->vfo->set_duty_cycle( duty ); 00081 } 00082 00083 // VFO wave form 00084 void Monophonic::set_vfo_wave_form( wave_form form ) 00085 { 00086 this->vfo->set_wave_form( form ); 00087 } 00088 00089 // SVF filter mode. 00090 void Monophonic::set_filter_mode( svf_mode mode ) 00091 { 00092 this->sv_filter->set_mode( mode ); 00093 } 00094 00095 // SVF Q factor 00096 void Monophonic::set_filter_Q( float Q ) 00097 { 00098 this->sv_filter->set_Q( Q ); 00099 } 00100 00101 // Set the f_factor value. 00102 void Monophonic::set_filter_f_factor( float f_factor ) 00103 { 00104 this->sv_filter->set_f_factor( f_factor ); 00105 } 00106 00107 // Turn note on 00108 void Monophonic::eg_on(void) 00109 { 00110 this->eg->on(); 00111 } 00112 00113 // Turn note off 00114 void Monophonic::eg_off(void) 00115 { 00116 this->eg->off(); 00117 } 00118 00119 void Monophonic::set_eg_attack( float32_t attack ) 00120 { 00121 this->eg->set_attack( attack ); 00122 } 00123 void Monophonic::set_eg_decay( float32_t decay ) 00124 { 00125 this->eg->set_decay( decay ); 00126 } 00127 00128 void Monophonic::set_eg_sustain( float32_t sustain ) 00129 { 00130 this->eg->set_sustain( sustain ); 00131 } 00132 00133 void Monophonic::set_eg_release ( float32_t release ) 00134 { 00135 this->eg->set_release( release ); 00136 } 00137
Generated on Wed Jul 13 2022 23:24:36 by 1.7.2