不韋 呂 / Mbed 2 deprecated F746_SD_WavPlayer

Dependencies:   BSP_DISCO_F746NG F746_GUI LCD_DISCO_F746NG SDFileSystem_Warning_Fixed TS_DISCO_F746NG mbed FrequencyResponseDrawer F746_SAI_IO Array_Matrix

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Wed Apr 20 12:10:17 2016 +0000
Parent:
0:04b43b777fae
Child:
2:2478e7a8e8d5
Commit message:
2

Changed in this revision

MyClasses_Functions/BSP_AudioOut_Overwrite.hpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/MyFunctions.hpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/SAI_Output.cpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/SAI_Output.hpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/sai_io_o.cpp Show diff for this revision Revisions of this file
MyClasses_Functions/sai_io_o.hpp Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MyClasses_Functions/BSP_AudioOut_Overwrite.hpp	Tue Apr 19 09:46:11 2016 +0000
+++ b/MyClasses_Functions/BSP_AudioOut_Overwrite.hpp	Wed Apr 20 12:10:17 2016 +0000
@@ -7,7 +7,7 @@
 #define F746_AUDIO_OUT_OVERWRITE_HPP
 
 #include "stm32746g_discovery_audio.h"
-#include "sai_io_o.hpp"
+#include "SAI_Output.hpp"
 
 void AUDIO_OUT_SAIx_DMAx_IRQHandler();
 
--- a/MyClasses_Functions/MyFunctions.hpp	Tue Apr 19 09:46:11 2016 +0000
+++ b/MyClasses_Functions/MyFunctions.hpp	Wed Apr 20 12:10:17 2016 +0000
@@ -1,13 +1,13 @@
 //--------------------------------------------------------------
 //  フィルタ処理付き SD オーディオプレーヤーで使う大域関数(ヘッダ)
 //
-//  2016/04/19, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/20, Copyright (c) 2016 MIKAMI, Naoki
 //--------------------------------------------------------------
 
 #ifndef F746_MY_FUNCTIONS_HPP
 #define F746_MY_FUNCTIONS_HPP
 
-#include "sai_io_o.hpp"
+#include "SAI_Output.hpp"
 #include "ButtonGroup.hpp"
 #include "FileSelectorWav.hpp"
 #include "DesignerDrawer.hpp"
@@ -35,4 +35,3 @@
                   float &g0, bool &filterOn);
 
 #endif  // F746_MY_FUNCTIONS_HPP
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyClasses_Functions/SAI_Output.cpp	Wed Apr 20 12:10:17 2016 +0000
@@ -0,0 +1,82 @@
+//-----------------------------------------------------------
+//  SiaIO class for output
+//  2016/04/20, Copyright (c) 2016 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#include "SAI_Output.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;
+    }
+    SaiIO_O::~SaiIO_O()
+    {
+        delete[] tmp_;
+        delete[] outBuffer_;
+    }
+
+    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_;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MyClasses_Functions/SAI_Output.hpp	Wed Apr 20 12:10:17 2016 +0000
@@ -0,0 +1,60 @@
+//-----------------------------------------------------------
+//  SiaIO class for output (Header)
+//  2016/04/20, Copyright (c) 2016 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#ifndef F746_SAI_IO_HPP
+#define F746_SAI_IO_HPP
+
+#include "mbed.h"
+#include "stm32746g_discovery_audio.h"
+#include "BSP_AudioOut_Overwrite.hpp"
+
+namespace Mikami
+{
+    class SaiIO_O
+    {
+    public:
+        SaiIO_O(int size, int fs);
+        ~SaiIO_O();
+
+        void InitCodecOut();
+        
+        bool IsXferred();
+        void Output(int16_t xL, int16_t xR);
+        
+        void ResetXferred() { xferred_ = false; }
+        int32_t GetLength() { return nData_; }
+        void Stop()   { BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW); }
+        void Pause()  { BSP_AUDIO_OUT_Pause(); }
+        void Resume() { BSP_AUDIO_OUT_Resume(); }
+
+        
+        // These three member functions are called from
+        // callback functions in "BSP_AudioOut_Overwrite.cpp"
+
+        // Called form BSP_AUDIO_OUT_HalfTransfer_CallBack()
+        static void FillBuffer1st() { FillBuffer(0); }
+        // Called form BSP_AUDIO_OUT_TransferComplete_CallBack()
+        static void FillBuffer2nd() { FillBuffer(bufferSize_/2); }
+        // Also called form BSP_AUDIO_OUT_Error_CallBack()
+        static void ErrorTrap();
+
+    private:
+        const int FS_;
+        static const uint8_t VOLUME_OUT_ = 90;
+
+        static int32_t nData_;
+        static int32_t bufferSize_;
+
+        static int16_t* outBuffer_;
+        static int16_t* tmp_;       
+
+        static __IO bool xferred_;
+        
+        __IO int32_t tmpIndex_;
+
+        static void FillBuffer(uint32_t offset);
+    };
+}
+#endif  // F746_SAI_IO_HPP
--- a/MyClasses_Functions/sai_io_o.cpp	Tue Apr 19 09:46:11 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-//-----------------------------------------------------------
-//  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;
-    }
-    SaiIO_O::~SaiIO_O()
-    {
-        delete[] tmp_;
-        delete[] outBuffer_;
-    }
-
-    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_;
-}
--- a/MyClasses_Functions/sai_io_o.hpp	Tue Apr 19 09:46:11 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-//-----------------------------------------------------------
-//  SiaIO class for output (Header)
-//  2016/04/17, Copyright (c) 2016 MIKAMI, Naoki
-//-----------------------------------------------------------
-
-#ifndef F746_SAI_IO_HPP
-#define F746_SAI_IO_HPP
-
-#include "mbed.h"
-#include "stm32746g_discovery_audio.h"
-#include "BSP_AudioOut_Overwrite.hpp"
-
-namespace Mikami
-{
-    class SaiIO_O
-    {
-    public:
-        SaiIO_O(int size, int fs);
-        ~SaiIO_O();
-
-        void InitCodecOut();
-        
-        bool IsXferred();
-        void Output(int16_t xL, int16_t xR);
-        
-        void ResetXferred() { xferred_ = false; }
-        int32_t GetLength() { return nData_; }
-        void Stop()   { BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW); }
-        void Pause()  { BSP_AUDIO_OUT_Pause(); }
-        void Resume() { BSP_AUDIO_OUT_Resume(); }
-
-        
-        // These three member functions are called from
-        // callback functions in "BSP_AudioOut_Overwrite.cpp"
-
-        // Called form BSP_AUDIO_OUT_HalfTransfer_CallBack()
-        static void FillBuffer1st() { FillBuffer(0); }
-        // Called form BSP_AUDIO_OUT_TransferComplete_CallBack()
-        static void FillBuffer2nd() { FillBuffer(bufferSize_/2); }
-        // Also called form BSP_AUDIO_OUT_Error_CallBack()
-        static void ErrorTrap();
-
-    private:
-        const int FS_;
-        static const uint8_t VOLUME_OUT_ = 90;
-
-        static int32_t nData_;
-        static int32_t bufferSize_;
-
-        static int16_t* outBuffer_;
-        static int16_t* tmp_;       
-
-        static __IO bool xferred_;
-        
-        __IO int32_t tmpIndex_;
-
-        static void FillBuffer(uint32_t offset);
-    };
-}
-#endif  // F746_SAI_IO_HPP
--- a/main.cpp	Tue Apr 19 09:46:11 2016 +0000
+++ b/main.cpp	Wed Apr 20 12:10:17 2016 +0000
@@ -4,7 +4,7 @@
 //                   PCM,16 ビットステレオ,標本化周波数 44.1 kHz
 //      IIR フィルタ ---- 低域通過および高域通過フィルタ
 //
-//  2016/04/19, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/20, Copyright (c) 2016 MIKAMI, Naoki
 //--------------------------------------------------------------
 
 #include "MyFunctions.hpp"
@@ -164,3 +164,4 @@
         sdReader.Close();   // SD のファイルのクローズ
     }
 }
+