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:
Mon Jan 30 14:48:42 2017 +0000
Revision:
14:cec63d8da48c
Child:
15:de22b9d147e0
VFO added.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 14:cec63d8da48c 1 #include "signal_processing.h"
shorie 14:cec63d8da48c 2
shorie 14:cec63d8da48c 3 // Modify this constructor to initialize your audio algorithm.
shorie 14:cec63d8da48c 4 VFO::VFO( void )
shorie 14:cec63d8da48c 5 {
shorie 14:cec63d8da48c 6 // initial parameter setting.
shorie 14:cec63d8da48c 7 this->style = triangle;
shorie 14:cec63d8da48c 8 this->Fs = 48000;
shorie 14:cec63d8da48c 9 this->frequency = 440;
shorie 14:cec63d8da48c 10 this->duty_cycle = 0.5;
shorie 14:cec63d8da48c 11 } // End of constructor()
shorie 14:cec63d8da48c 12
shorie 14:cec63d8da48c 13
shorie 14:cec63d8da48c 14 // Modify this method to implement your audio algorithm.
shorie 14:cec63d8da48c 15 void VFO::run(
shorie 14:cec63d8da48c 16 float out_buffer[], // vfo output buffer
shorie 14:cec63d8da48c 17 unsigned int block_size // block size [sample]
shorie 14:cec63d8da48c 18 )
shorie 14:cec63d8da48c 19 {
shorie 14:cec63d8da48c 20 // place the signal processing coce here
shorie 14:cec63d8da48c 21 for ( int i= 0; i< block_size; i++ )
shorie 14:cec63d8da48c 22 {
shorie 14:cec63d8da48c 23 }
shorie 14:cec63d8da48c 24 } // End of run()
shorie 14:cec63d8da48c 25
shorie 14:cec63d8da48c 26
shorie 14:cec63d8da48c 27 void VFO::set_Fs( int Fs )
shorie 14:cec63d8da48c 28 {
shorie 14:cec63d8da48c 29 // regulate the Fs.
shorie 14:cec63d8da48c 30 if ( Fs != 32000 && Fs != 44100 && Fs != 96000 && Fs != 48000 )
shorie 14:cec63d8da48c 31 Fs = 48000;
shorie 14:cec63d8da48c 32 this->Fs = Fs;
shorie 14:cec63d8da48c 33 }
shorie 14:cec63d8da48c 34
shorie 14:cec63d8da48c 35 void VFO::set_frequency( int freq )
shorie 14:cec63d8da48c 36 {
shorie 14:cec63d8da48c 37 if ( freq > this->Fs / 4 )
shorie 14:cec63d8da48c 38 freq = Fs/4;
shorie 14:cec63d8da48c 39 this->frequency = freq;
shorie 14:cec63d8da48c 40 }
shorie 14:cec63d8da48c 41
shorie 14:cec63d8da48c 42 void VFO::set_duty_cycle( float duty )
shorie 14:cec63d8da48c 43 {
shorie 14:cec63d8da48c 44 if ( duty > 0.5f ) // high limit
shorie 14:cec63d8da48c 45 duty = 0.5f;
shorie 14:cec63d8da48c 46 if ( duty < 0.01f ) // low limit
shorie 14:cec63d8da48c 47 duty = 0.01f;
shorie 14:cec63d8da48c 48 this->duty_cycle = duty;
shorie 14:cec63d8da48c 49 }
shorie 14:cec63d8da48c 50
shorie 14:cec63d8da48c 51 void VFO::set_wave_style( wave_style style )
shorie 14:cec63d8da48c 52 {
shorie 14:cec63d8da48c 53 this->style = style;
shorie 14:cec63d8da48c 54 }
shorie 14:cec63d8da48c 55
shorie 14:cec63d8da48c 56
shorie 14:cec63d8da48c 57