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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SD_BinaryReader.hpp Source File

SD_BinaryReader.hpp

00001 //--------------------------------------------------------------
00002 //  SD_BinaryReader class
00003 //      SD カードの内容を読み出す
00004 //          最初の4バイト:データサイズ
00005 //          それ以降: int16_t のデータ
00006 //
00007 //  2016/04/07, Copyright (c) 2016 MIKAMI, Naoki
00008 //--------------------------------------------------------------
00009 
00010 #ifndef SD_BINARY_READER_HPP
00011 #define SD_BINARY_READER_HPP
00012 
00013 #include "SDFileSystem.h"
00014 #include "BlinkLabel.hpp"
00015 #include <string>
00016 
00017 namespace Mikami
00018 {
00019     class SD_BinaryReader
00020     {
00021     public:
00022         SD_BinaryReader() : STR_("sd"), ok_(false)
00023         {
00024             sd_ = new SDFileSystem(STR_.c_str());
00025             sd_->mount();
00026         }
00027 
00028         ~SD_BinaryReader()
00029         {
00030             sd_->unmount();
00031             delete sd_;
00032         }
00033         
00034         void Open(const string fileName)
00035         {
00036             string name = (string)"/" + STR_ + "/" + fileName;
00037             fp_ = fopen(name.c_str(), "rb");
00038             if (fp_ == NULL) ErrorMsg("open error!!");
00039         }
00040         
00041         void Close() { fclose(fp_); }
00042         
00043         // ファイルからデータサイズの読み出し
00044         //      戻り値: int16_t 型のデータサイズ
00045         int32_t ReadSize()
00046         {
00047             fread(&size_, sizeof(int), 1, fp_);
00048             ok_ = true;
00049             return size_;
00050         }
00051 
00052         // ファイルからデータの取得
00053         void Read(int16_t data[], uint32_t size)
00054         {
00055             if (!ok_) ErrorMsg("Get data FAILED");
00056             fread(data, sizeof(int16_t), size, fp_);
00057         }        
00058 
00059         // データサイズの取得
00060         //      戻り値: int16_t 型のデータサイズ
00061         int32_t GetSize()
00062         {
00063             if (!ok_) ErrorMsg("Get data size FAILED");
00064             return size_;
00065         }
00066 
00067     private:
00068         const string STR_;
00069         
00070         SDFileSystem *sd_;
00071         FILE *fp_;
00072         
00073         bool ok_;
00074         int32_t size_;  // word count, word = int16_t
00075         
00076         void ErrorMsg(char msg[])
00077         {
00078             BlinkLabel errLabel(240, 100, msg, Label::CENTER);
00079         }
00080 
00081         // disallow copy constructor and assignment operator
00082         SD_BinaryReader(const SD_BinaryReader&);
00083         SD_BinaryReader& operator=(const SD_BinaryReader&);
00084     };
00085 }
00086 #endif  // SD_BINARY_READER_HPP