Output the audio signal (*.bin) with filtering by IIR filter in the SD card using onboard CODEC. For *.wav file, F746_SD_WavPlayer and F746_SD_GraphicEqualiser are published on mbed. SD カードのオーディオ信号 (*.bin) を遮断周波数可変の IIR フィルタを通して,ボードに搭載されているCODEC で出力する.*.wav 形式のファイル用には,F746_SD_WavPlayer と F746_SD_GraphicEqualiser を mbed で公開している.
Dependencies: BSP_DISCO_F746NG_patch_fixed F746_GUI LCD_DISCO_F746NG SDFileSystem_Warning_Fixed TS_DISCO_F746NG mbed
Diff: MyClasses_Functions/sai_io_o.cpp
- Revision:
- 0:6748e3332e85
- Child:
- 5:4a99dabc9180
diff -r 000000000000 -r 6748e3332e85 MyClasses_Functions/sai_io_o.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyClasses_Functions/sai_io_o.cpp Fri Apr 08 13:11:53 2016 +0000 @@ -0,0 +1,77 @@ +//----------------------------------------------------------- +// SiaIO class for output +// 2016/02/16, Copyright (c) 2016 MIKAMI, Naoki +//----------------------------------------------------------- + +#include "sai_io_o.hpp" + +namespace Mikami +{ + SaiIO_O::SaiIO_O(int size, int fs) : FS_(fs), tmpIndex_(0) + { + nData_ = size; + bufferSize_ = (size*2)*2; + outBuffer_ = new int16_t[(size*2)*2]; + tmp_ = new int16_t[size*2]; + xferred_ = false; + } + + void SaiIO_O::InitCodecOut() + { + if (BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE, VOLUME_OUT_, FS_) == AUDIO_ERROR) + ErrorTrap(); + for (int n=0; n<bufferSize_; n++) outBuffer_[n] = 0; + for (int n=0; n<nData_*2; n++) tmp_[n] = 0; + + NVIC_SetVector(AUDIO_OUT_SAIx_DMAx_IRQ, (uint32_t)AUDIO_OUT_SAIx_DMAx_IRQHandler); + BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02); + + if (BSP_AUDIO_OUT_Play((uint16_t *)outBuffer_, + bufferSize_*AUDIODATA_SIZE) == AUDIO_ERROR) + ErrorTrap(); + } + + bool SaiIO_O::IsXferred() + { + if (xferred_) + { + tmpIndex_ = 0; + return true; + } + else + return false; + } + + void SaiIO_O::Output(int16_t xL, int16_t xR) + { + tmp_[tmpIndex_++] = xL; // Left + tmp_[tmpIndex_++] = xR; // Right + } + + void SaiIO_O::ErrorTrap() + { + DigitalOut led1(LED1); + fprintf(stderr, "\r\n### ERROR\r\n"); + while(true) + { + led1 = !led1; + wait_ms(250); + } + } + + void SaiIO_O::FillBuffer(uint32_t offset) + { + int k = offset; + for (int n=0; n<nData_*2; n++) + outBuffer_[k++] = tmp_[n]; + xferred_ = true; + } + + // Instances for static variables + int32_t SaiIO_O::nData_; + int32_t SaiIO_O::bufferSize_; + int16_t* SaiIO_O::outBuffer_; + int16_t* SaiIO_O::tmp_; + __IO bool SaiIO_O::xferred_; +} +