Output the audio signal with filtering by graphic equalizer in the *.wav file on the SD card using onboard CODEC. SD カードの *.wav ファイルのオーディオ信号をグラフィック・イコライザを通して,ボードに搭載されているCODEC で出力する.

Dependencies:   F746_GUI F746_SAI_IO SD_PlayerSkeleton FrequencyResponseDrawer

Committer:
MikamiUitOpen
Date:
Sun Oct 02 06:33:59 2016 +0000
Revision:
16:cbb726ac20d8
17

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 16:cbb726ac20d8 1 /* mbed Microcontroller Library
MikamiUitOpen 16:cbb726ac20d8 2 * Copyright (c) 2015 ARM Limited
MikamiUitOpen 16:cbb726ac20d8 3 *
MikamiUitOpen 16:cbb726ac20d8 4 * Licensed under the Apache License, Version 2.0 (the "License");
MikamiUitOpen 16:cbb726ac20d8 5 * you may not use this file except in compliance with the License.
MikamiUitOpen 16:cbb726ac20d8 6 * You may obtain a copy of the License at
MikamiUitOpen 16:cbb726ac20d8 7 *
MikamiUitOpen 16:cbb726ac20d8 8 * http://www.apache.org/licenses/LICENSE-2.0
MikamiUitOpen 16:cbb726ac20d8 9 *
MikamiUitOpen 16:cbb726ac20d8 10 * Unless required by applicable law or agreed to in writing, software
MikamiUitOpen 16:cbb726ac20d8 11 * distributed under the License is distributed on an "AS IS" BASIS,
MikamiUitOpen 16:cbb726ac20d8 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikamiUitOpen 16:cbb726ac20d8 13 * See the License for the specific language governing permissions and
MikamiUitOpen 16:cbb726ac20d8 14 * limitations under the License.
MikamiUitOpen 16:cbb726ac20d8 15 */
MikamiUitOpen 16:cbb726ac20d8 16 #ifndef MBED_CIRCULARBUFFER_H
MikamiUitOpen 16:cbb726ac20d8 17 #define MBED_CIRCULARBUFFER_H
MikamiUitOpen 16:cbb726ac20d8 18
MikamiUitOpen 16:cbb726ac20d8 19 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 20
MikamiUitOpen 16:cbb726ac20d8 21 /** Templated Circular buffer class
MikamiUitOpen 16:cbb726ac20d8 22 */
MikamiUitOpen 16:cbb726ac20d8 23 template<typename T, uint32_t BufferSize, typename CounterType = uint32_t>
MikamiUitOpen 16:cbb726ac20d8 24 class CircularBuffer {
MikamiUitOpen 16:cbb726ac20d8 25 public:
MikamiUitOpen 16:cbb726ac20d8 26 CircularBuffer() : _head(0), _tail(0), _full(false) {
MikamiUitOpen 16:cbb726ac20d8 27 }
MikamiUitOpen 16:cbb726ac20d8 28
MikamiUitOpen 16:cbb726ac20d8 29 ~CircularBuffer() {
MikamiUitOpen 16:cbb726ac20d8 30 }
MikamiUitOpen 16:cbb726ac20d8 31
MikamiUitOpen 16:cbb726ac20d8 32 /** Push the transaction to the buffer. This overwrites the buffer if it's
MikamiUitOpen 16:cbb726ac20d8 33 * full
MikamiUitOpen 16:cbb726ac20d8 34 *
MikamiUitOpen 16:cbb726ac20d8 35 * @param data Data to be pushed to the buffer
MikamiUitOpen 16:cbb726ac20d8 36 */
MikamiUitOpen 16:cbb726ac20d8 37 void push(const T& data) {
MikamiUitOpen 16:cbb726ac20d8 38 if (full()) {
MikamiUitOpen 16:cbb726ac20d8 39 _tail++;
MikamiUitOpen 16:cbb726ac20d8 40 _tail %= BufferSize;
MikamiUitOpen 16:cbb726ac20d8 41 }
MikamiUitOpen 16:cbb726ac20d8 42 _pool[_head++] = data;
MikamiUitOpen 16:cbb726ac20d8 43 _head %= BufferSize;
MikamiUitOpen 16:cbb726ac20d8 44 if (_head == _tail) {
MikamiUitOpen 16:cbb726ac20d8 45 _full = true;
MikamiUitOpen 16:cbb726ac20d8 46 }
MikamiUitOpen 16:cbb726ac20d8 47 }
MikamiUitOpen 16:cbb726ac20d8 48
MikamiUitOpen 16:cbb726ac20d8 49 /** Pop the transaction from the buffer
MikamiUitOpen 16:cbb726ac20d8 50 *
MikamiUitOpen 16:cbb726ac20d8 51 * @param data Data to be pushed to the buffer
MikamiUitOpen 16:cbb726ac20d8 52 * @return True if the buffer is not empty and data contains a transaction, false otherwise
MikamiUitOpen 16:cbb726ac20d8 53 */
MikamiUitOpen 16:cbb726ac20d8 54 bool pop(T& data) {
MikamiUitOpen 16:cbb726ac20d8 55 if (!empty()) {
MikamiUitOpen 16:cbb726ac20d8 56 data = _pool[_tail++];
MikamiUitOpen 16:cbb726ac20d8 57 _tail %= BufferSize;
MikamiUitOpen 16:cbb726ac20d8 58 _full = false;
MikamiUitOpen 16:cbb726ac20d8 59 return true;
MikamiUitOpen 16:cbb726ac20d8 60 }
MikamiUitOpen 16:cbb726ac20d8 61 return false;
MikamiUitOpen 16:cbb726ac20d8 62 }
MikamiUitOpen 16:cbb726ac20d8 63
MikamiUitOpen 16:cbb726ac20d8 64 /** Check if the buffer is empty
MikamiUitOpen 16:cbb726ac20d8 65 *
MikamiUitOpen 16:cbb726ac20d8 66 * @return True if the buffer is empty, false if not
MikamiUitOpen 16:cbb726ac20d8 67 */
MikamiUitOpen 16:cbb726ac20d8 68 bool empty() {
MikamiUitOpen 16:cbb726ac20d8 69 return (_head == _tail) && !_full;
MikamiUitOpen 16:cbb726ac20d8 70 }
MikamiUitOpen 16:cbb726ac20d8 71
MikamiUitOpen 16:cbb726ac20d8 72 /** Check if the buffer is full
MikamiUitOpen 16:cbb726ac20d8 73 *
MikamiUitOpen 16:cbb726ac20d8 74 * @return True if the buffer is full, false if not
MikamiUitOpen 16:cbb726ac20d8 75 */
MikamiUitOpen 16:cbb726ac20d8 76 bool full() {
MikamiUitOpen 16:cbb726ac20d8 77 return _full;
MikamiUitOpen 16:cbb726ac20d8 78 }
MikamiUitOpen 16:cbb726ac20d8 79
MikamiUitOpen 16:cbb726ac20d8 80 /** Reset the buffer
MikamiUitOpen 16:cbb726ac20d8 81 *
MikamiUitOpen 16:cbb726ac20d8 82 */
MikamiUitOpen 16:cbb726ac20d8 83 void reset() {
MikamiUitOpen 16:cbb726ac20d8 84 _head = 0;
MikamiUitOpen 16:cbb726ac20d8 85 _tail = 0;
MikamiUitOpen 16:cbb726ac20d8 86 _full = false;
MikamiUitOpen 16:cbb726ac20d8 87 }
MikamiUitOpen 16:cbb726ac20d8 88
MikamiUitOpen 16:cbb726ac20d8 89 private:
MikamiUitOpen 16:cbb726ac20d8 90 T _pool[BufferSize];
MikamiUitOpen 16:cbb726ac20d8 91 volatile CounterType _head;
MikamiUitOpen 16:cbb726ac20d8 92 volatile CounterType _tail;
MikamiUitOpen 16:cbb726ac20d8 93 volatile bool _full;
MikamiUitOpen 16:cbb726ac20d8 94 };
MikamiUitOpen 16:cbb726ac20d8 95
MikamiUitOpen 16:cbb726ac20d8 96 }
MikamiUitOpen 16:cbb726ac20d8 97
MikamiUitOpen 16:cbb726ac20d8 98 #endif