Synthesizer based on the Unzen / Nucleo F746ZG
Dependencies: amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746
Fork of skeleton_unzen_nucleo_f746 by
雲仙フレームワークのテストとして作っているプロジェクトです。中身はどんどん変っていきます。 説明はDSP空挺団の「シンセサイザー」カテゴリーを参照してください。初回は「ドッグフードを食べる」です。
signal_processing.cpp@6:486b1cb03e61, 2017-01-27 (annotated)
- Committer:
- shorie
- Date:
- Fri Jan 27 01:53:43 2017 +0000
- Revision:
- 6:486b1cb03e61
- Child:
- 10:a00c73efc6c3
Skeleton build successful. Need to test.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shorie | 6:486b1cb03e61 | 1 | #include "signal_processing.h" |
shorie | 6:486b1cb03e61 | 2 | |
shorie | 6:486b1cb03e61 | 3 | SignalProcessing::SignalProcessing( unsigned int block_size ) |
shorie | 6:486b1cb03e61 | 4 | { |
shorie | 6:486b1cb03e61 | 5 | // place the signal processing initializing code here. |
shorie | 6:486b1cb03e61 | 6 | this->volume_level = 0.0; // sample initializaiton |
shorie | 6:486b1cb03e61 | 7 | } |
shorie | 6:486b1cb03e61 | 8 | |
shorie | 6:486b1cb03e61 | 9 | void SignalProcessing::run( |
shorie | 6:486b1cb03e61 | 10 | float rx_left_buffer[], // array of the left input samples |
shorie | 6:486b1cb03e61 | 11 | float rx_right_buffer[], // array of the right input samples |
shorie | 6:486b1cb03e61 | 12 | float tx_left_buffer[], // place to write the left output samples |
shorie | 6:486b1cb03e61 | 13 | float tx_right_buffer[], // place to write the left output samples |
shorie | 6:486b1cb03e61 | 14 | unsigned int block_size // block size [sample] |
shorie | 6:486b1cb03e61 | 15 | ) |
shorie | 6:486b1cb03e61 | 16 | { |
shorie | 6:486b1cb03e61 | 17 | // place the signal processing coce here |
shorie | 6:486b1cb03e61 | 18 | for ( int i= 0; i< block_size; i++ ) |
shorie | 6:486b1cb03e61 | 19 | { |
shorie | 6:486b1cb03e61 | 20 | rx_left_buffer[i] = tx_left_buffer[i] * this->volume_level; |
shorie | 6:486b1cb03e61 | 21 | rx_right_buffer[i] = tx_right_buffer[i] * this->volume_level; |
shorie | 6:486b1cb03e61 | 22 | } |
shorie | 6:486b1cb03e61 | 23 | } |
shorie | 6:486b1cb03e61 | 24 | |
shorie | 6:486b1cb03e61 | 25 | // project depenedent members. |
shorie | 6:486b1cb03e61 | 26 | void SignalProcessing::set_volume( float vol ) |
shorie | 6:486b1cb03e61 | 27 | { |
shorie | 6:486b1cb03e61 | 28 | this->enter_critical_section(); // forbidden interrrupt. |
shorie | 6:486b1cb03e61 | 29 | this->volume_level = vol; |
shorie | 6:486b1cb03e61 | 30 | this->leave_critical_section(); // now, ok to accept interrupt. |
shorie | 6:486b1cb03e61 | 31 | } |
shorie | 6:486b1cb03e61 | 32 | |
shorie | 6:486b1cb03e61 | 33 | |
shorie | 6:486b1cb03e61 | 34 | |
shorie | 6:486b1cb03e61 | 35 | |
shorie | 6:486b1cb03e61 | 36 | // essential members. Do not touch. |
shorie | 6:486b1cb03e61 | 37 | void SignalProcessing::enter_critical_section(void) |
shorie | 6:486b1cb03e61 | 38 | { |
shorie | 6:486b1cb03e61 | 39 | __disable_irq(); // globaly forbid all interrupt |
shorie | 6:486b1cb03e61 | 40 | } |
shorie | 6:486b1cb03e61 | 41 | |
shorie | 6:486b1cb03e61 | 42 | void SignalProcessing::leave_critical_section(void) |
shorie | 6:486b1cb03e61 | 43 | { |
shorie | 6:486b1cb03e61 | 44 | __enable_irq(); // globaly allow all interrupts |
shorie | 6:486b1cb03e61 | 45 | } |
shorie | 6:486b1cb03e61 | 46 |