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:
Fri Jan 27 02:18:26 2017 +0000
Revision:
10:a00c73efc6c3
Parent:
6:486b1cb03e61
Child:
11:7d8740437e6a
Comment edited.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 6:486b1cb03e61 1 #include "signal_processing.h"
shorie 6:486b1cb03e61 2
shorie 10:a00c73efc6c3 3 /*========================= Project Dependent Method =========================*/
shorie 10:a00c73efc6c3 4 // Modify this constructor to initialize your audio algorithm.
shorie 6:486b1cb03e61 5 SignalProcessing::SignalProcessing( unsigned int block_size )
shorie 6:486b1cb03e61 6 {
shorie 6:486b1cb03e61 7 // place the signal processing initializing code here.
shorie 6:486b1cb03e61 8 this->volume_level = 0.0; // sample initializaiton
shorie 10:a00c73efc6c3 9 } // End of constructor()
shorie 6:486b1cb03e61 10
shorie 10:a00c73efc6c3 11
shorie 10:a00c73efc6c3 12 // Modify this method to implement your audio algorithm.
shorie 6:486b1cb03e61 13 void SignalProcessing::run(
shorie 6:486b1cb03e61 14 float rx_left_buffer[], // array of the left input samples
shorie 6:486b1cb03e61 15 float rx_right_buffer[], // array of the right input samples
shorie 6:486b1cb03e61 16 float tx_left_buffer[], // place to write the left output samples
shorie 6:486b1cb03e61 17 float tx_right_buffer[], // place to write the left output samples
shorie 6:486b1cb03e61 18 unsigned int block_size // block size [sample]
shorie 6:486b1cb03e61 19 )
shorie 6:486b1cb03e61 20 {
shorie 6:486b1cb03e61 21 // place the signal processing coce here
shorie 6:486b1cb03e61 22 for ( int i= 0; i< block_size; i++ )
shorie 6:486b1cb03e61 23 {
shorie 6:486b1cb03e61 24 rx_left_buffer[i] = tx_left_buffer[i] * this->volume_level;
shorie 6:486b1cb03e61 25 rx_right_buffer[i] = tx_right_buffer[i] * this->volume_level;
shorie 6:486b1cb03e61 26 }
shorie 10:a00c73efc6c3 27 } // End of run()
shorie 10:a00c73efc6c3 28
shorie 6:486b1cb03e61 29
shorie 10:a00c73efc6c3 30 // Sample method. Set the volume level to the object.
shorie 6:486b1cb03e61 31 void SignalProcessing::set_volume( float vol )
shorie 6:486b1cb03e61 32 {
shorie 6:486b1cb03e61 33 this->enter_critical_section(); // forbidden interrrupt.
shorie 6:486b1cb03e61 34 this->volume_level = vol;
shorie 6:486b1cb03e61 35 this->leave_critical_section(); // now, ok to accept interrupt.
shorie 6:486b1cb03e61 36 }
shorie 6:486b1cb03e61 37
shorie 6:486b1cb03e61 38
shorie 6:486b1cb03e61 39
shorie 10:a00c73efc6c3 40 /************************** skeleton dependent methond. ***********************/
shorie 6:486b1cb03e61 41 // essential members. Do not touch.
shorie 6:486b1cb03e61 42 void SignalProcessing::enter_critical_section(void)
shorie 6:486b1cb03e61 43 {
shorie 6:486b1cb03e61 44 __disable_irq(); // globaly forbid all interrupt
shorie 6:486b1cb03e61 45 }
shorie 6:486b1cb03e61 46
shorie 6:486b1cb03e61 47 void SignalProcessing::leave_critical_section(void)
shorie 6:486b1cb03e61 48 {
shorie 6:486b1cb03e61 49 __enable_irq(); // globaly allow all interrupts
shorie 6:486b1cb03e61 50 }
shorie 6:486b1cb03e61 51