Synthesizer based on the Unzen / Nucleo F746ZG

Dependencies:   amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746

Fork of skeleton_unzen_nucleo_f746 by seiichi horie

雲仙フレームワークのテストとして作っているプロジェクトです。中身はどんどん変っていきます。 説明はDSP空挺団の「シンセサイザー」カテゴリーを参照してください。初回は「ドッグフードを食べる」です。

Committer:
shorie
Date:
Sun Feb 05 06:16:49 2017 +0000
Revision:
22:dc2cbe8db9d9
Parent:
20:53021b2c424d
Child:
26:e99f71165e19
Integrated filter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 18:b9b1116f8768 1 #include "signal_processing.h"
shorie 18:b9b1116f8768 2
shorie 18:b9b1116f8768 3
shorie 18:b9b1116f8768 4 // constructor.
shorie 18:b9b1116f8768 5 Monophonic::Monophonic( unsigned int block_size )
shorie 18:b9b1116f8768 6 {
shorie 18:b9b1116f8768 7 // initializing the subm-odules.
shorie 18:b9b1116f8768 8 this->vfo = new VFO(); // allocate VFO
shorie 20:53021b2c424d 9 this->dc_blocker = new DCBlocker( block_size );
shorie 20:53021b2c424d 10 this->sv_filter = new SVFilter( block_size );
shorie 20:53021b2c424d 11
shorie 20:53021b2c424d 12 work_buf_a = new float32_t[block_size];
shorie 20:53021b2c424d 13 work_buf_b = new float32_t[block_size];
shorie 18:b9b1116f8768 14 } // End of constructor()
shorie 18:b9b1116f8768 15
shorie 18:b9b1116f8768 16 Monophonic::~Monophonic( void )
shorie 18:b9b1116f8768 17 {
shorie 18:b9b1116f8768 18 // initializing the subm-odules.
shorie 18:b9b1116f8768 19 delete this->vfo;
shorie 20:53021b2c424d 20 delete this->dc_blocker;
shorie 20:53021b2c424d 21 delete this->sv_filter;
shorie 20:53021b2c424d 22
shorie 20:53021b2c424d 23 delete[] work_buf_a;
shorie 20:53021b2c424d 24 delete[] work_buf_b;
shorie 18:b9b1116f8768 25 } // End of constructor()
shorie 18:b9b1116f8768 26
shorie 18:b9b1116f8768 27
shorie 18:b9b1116f8768 28
shorie 18:b9b1116f8768 29 // Run all signal processing.
shorie 18:b9b1116f8768 30 void Monophonic::run(
shorie 18:b9b1116f8768 31 float out_buffer[], // place to write the right output samples
shorie 18:b9b1116f8768 32 unsigned int block_size // block size [sample]
shorie 18:b9b1116f8768 33 )
shorie 18:b9b1116f8768 34 {
shorie 18:b9b1116f8768 35 // place the signal processing coce here
shorie 22:dc2cbe8db9d9 36 this->vfo->run( work_buf_a, block_size );
shorie 22:dc2cbe8db9d9 37
shorie 22:dc2cbe8db9d9 38 // blocking DC.
shorie 22:dc2cbe8db9d9 39 this->dc_blocker->run( work_buf_a, work_buf_b );
shorie 18:b9b1116f8768 40
shorie 22:dc2cbe8db9d9 41 // applying filter.
shorie 22:dc2cbe8db9d9 42 this->sv_filter->run( work_buf_b, out_buffer );
shorie 18:b9b1116f8768 43
shorie 18:b9b1116f8768 44 } // End of run()
shorie 18:b9b1116f8768 45
shorie 18:b9b1116f8768 46
shorie 18:b9b1116f8768 47 // Sampling Frequency
shorie 18:b9b1116f8768 48 void Monophonic::set_Fs( int Fs )
shorie 18:b9b1116f8768 49 {
shorie 18:b9b1116f8768 50 this->vfo->set_Fs( Fs );
shorie 22:dc2cbe8db9d9 51 this->sv_filter->set_Fs( Fs );
shorie 18:b9b1116f8768 52 }
shorie 18:b9b1116f8768 53
shorie 18:b9b1116f8768 54 // Oscillation Frequency
shorie 18:b9b1116f8768 55 void Monophonic::set_vfo_frequency( int freq )
shorie 18:b9b1116f8768 56 {
shorie 18:b9b1116f8768 57 this->vfo->set_frequency( freq );
shorie 22:dc2cbe8db9d9 58 this->sv_filter->set_fc( freq );
shorie 18:b9b1116f8768 59 }
shorie 18:b9b1116f8768 60
shorie 18:b9b1116f8768 61 // Duty Cycle of VFO
shorie 18:b9b1116f8768 62 void Monophonic::set_vfo_duty_cycle( float duty )
shorie 18:b9b1116f8768 63 {
shorie 18:b9b1116f8768 64 this->vfo->set_duty_cycle( duty );
shorie 18:b9b1116f8768 65 }
shorie 18:b9b1116f8768 66
shorie 18:b9b1116f8768 67 // VFO wave form
shorie 18:b9b1116f8768 68 void Monophonic::set_vfo_wave_form( wave_form form )
shorie 18:b9b1116f8768 69 {
shorie 18:b9b1116f8768 70 this->vfo->set_wave_form( form );
shorie 18:b9b1116f8768 71 }
shorie 22:dc2cbe8db9d9 72
shorie 22:dc2cbe8db9d9 73 // SVF filter mode.
shorie 22:dc2cbe8db9d9 74 void Monophonic::set_filter_mode( svf_mode mode )
shorie 22:dc2cbe8db9d9 75 {
shorie 22:dc2cbe8db9d9 76 this->sv_filter->set_mode( mode );
shorie 22:dc2cbe8db9d9 77 }
shorie 22:dc2cbe8db9d9 78
shorie 22:dc2cbe8db9d9 79 // SVF Q factor
shorie 22:dc2cbe8db9d9 80 void Monophonic::set_filter_Q( float Q )
shorie 22:dc2cbe8db9d9 81 {
shorie 22:dc2cbe8db9d9 82 this->sv_filter->set_Q( Q );
shorie 22:dc2cbe8db9d9 83 }
shorie 22:dc2cbe8db9d9 84
shorie 22:dc2cbe8db9d9 85 // Set the f_factor value.
shorie 22:dc2cbe8db9d9 86 void Monophonic::set_filter_f_factor( float f_factor )
shorie 22:dc2cbe8db9d9 87 {
shorie 22:dc2cbe8db9d9 88 this->sv_filter->set_f_factor( f_factor );
shorie 22:dc2cbe8db9d9 89 }