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) 2006-2013 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_FILEHANDLE_H
MikamiUitOpen 16:cbb726ac20d8 17 #define MBED_FILEHANDLE_H
MikamiUitOpen 16:cbb726ac20d8 18
MikamiUitOpen 16:cbb726ac20d8 19 typedef int FILEHANDLE;
MikamiUitOpen 16:cbb726ac20d8 20
MikamiUitOpen 16:cbb726ac20d8 21 #include <stdio.h>
MikamiUitOpen 16:cbb726ac20d8 22
MikamiUitOpen 16:cbb726ac20d8 23 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
MikamiUitOpen 16:cbb726ac20d8 24 typedef int ssize_t;
MikamiUitOpen 16:cbb726ac20d8 25 typedef long off_t;
MikamiUitOpen 16:cbb726ac20d8 26
MikamiUitOpen 16:cbb726ac20d8 27 #else
MikamiUitOpen 16:cbb726ac20d8 28 # include <sys/types.h>
MikamiUitOpen 16:cbb726ac20d8 29 #endif
MikamiUitOpen 16:cbb726ac20d8 30
MikamiUitOpen 16:cbb726ac20d8 31 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 32
MikamiUitOpen 16:cbb726ac20d8 33 /** An OO equivalent of the internal FILEHANDLE variable
MikamiUitOpen 16:cbb726ac20d8 34 * and associated _sys_* functions.
MikamiUitOpen 16:cbb726ac20d8 35 *
MikamiUitOpen 16:cbb726ac20d8 36 * FileHandle is an abstract class, needing at least sys_write and
MikamiUitOpen 16:cbb726ac20d8 37 * sys_read to be implmented for a simple interactive device.
MikamiUitOpen 16:cbb726ac20d8 38 *
MikamiUitOpen 16:cbb726ac20d8 39 * No one ever directly tals to/instanciates a FileHandle - it gets
MikamiUitOpen 16:cbb726ac20d8 40 * created by FileSystem, and wrapped up by stdio.
MikamiUitOpen 16:cbb726ac20d8 41 */
MikamiUitOpen 16:cbb726ac20d8 42 class FileHandle {
MikamiUitOpen 16:cbb726ac20d8 43
MikamiUitOpen 16:cbb726ac20d8 44 public:
MikamiUitOpen 16:cbb726ac20d8 45 /** Write the contents of a buffer to the file
MikamiUitOpen 16:cbb726ac20d8 46 *
MikamiUitOpen 16:cbb726ac20d8 47 * @param buffer the buffer to write from
MikamiUitOpen 16:cbb726ac20d8 48 * @param length the number of characters to write
MikamiUitOpen 16:cbb726ac20d8 49 *
MikamiUitOpen 16:cbb726ac20d8 50 * @returns
MikamiUitOpen 16:cbb726ac20d8 51 * The number of characters written (possibly 0) on success, -1 on error.
MikamiUitOpen 16:cbb726ac20d8 52 */
MikamiUitOpen 16:cbb726ac20d8 53 virtual ssize_t write(const void* buffer, size_t length) = 0;
MikamiUitOpen 16:cbb726ac20d8 54
MikamiUitOpen 16:cbb726ac20d8 55 /** Close the file
MikamiUitOpen 16:cbb726ac20d8 56 *
MikamiUitOpen 16:cbb726ac20d8 57 * @returns
MikamiUitOpen 16:cbb726ac20d8 58 * Zero on success, -1 on error.
MikamiUitOpen 16:cbb726ac20d8 59 */
MikamiUitOpen 16:cbb726ac20d8 60 virtual int close() = 0;
MikamiUitOpen 16:cbb726ac20d8 61
MikamiUitOpen 16:cbb726ac20d8 62 /** Function read
MikamiUitOpen 16:cbb726ac20d8 63 * Reads the contents of the file into a buffer
MikamiUitOpen 16:cbb726ac20d8 64 *
MikamiUitOpen 16:cbb726ac20d8 65 * @param buffer the buffer to read in to
MikamiUitOpen 16:cbb726ac20d8 66 * @param length the number of characters to read
MikamiUitOpen 16:cbb726ac20d8 67 *
MikamiUitOpen 16:cbb726ac20d8 68 * @returns
MikamiUitOpen 16:cbb726ac20d8 69 * The number of characters read (zero at end of file) on success, -1 on error.
MikamiUitOpen 16:cbb726ac20d8 70 */
MikamiUitOpen 16:cbb726ac20d8 71 virtual ssize_t read(void* buffer, size_t length) = 0;
MikamiUitOpen 16:cbb726ac20d8 72
MikamiUitOpen 16:cbb726ac20d8 73 /** Check if the handle is for a interactive terminal device.
MikamiUitOpen 16:cbb726ac20d8 74 * If so, line buffered behaviour is used by default
MikamiUitOpen 16:cbb726ac20d8 75 *
MikamiUitOpen 16:cbb726ac20d8 76 * @returns
MikamiUitOpen 16:cbb726ac20d8 77 * 1 if it is a terminal,
MikamiUitOpen 16:cbb726ac20d8 78 * 0 otherwise
MikamiUitOpen 16:cbb726ac20d8 79 */
MikamiUitOpen 16:cbb726ac20d8 80 virtual int isatty() = 0;
MikamiUitOpen 16:cbb726ac20d8 81
MikamiUitOpen 16:cbb726ac20d8 82 /** Move the file position to a given offset from a given location.
MikamiUitOpen 16:cbb726ac20d8 83 *
MikamiUitOpen 16:cbb726ac20d8 84 * @param offset The offset from whence to move to
MikamiUitOpen 16:cbb726ac20d8 85 * @param whence SEEK_SET for the start of the file, SEEK_CUR for the
MikamiUitOpen 16:cbb726ac20d8 86 * current file position, or SEEK_END for the end of the file.
MikamiUitOpen 16:cbb726ac20d8 87 *
MikamiUitOpen 16:cbb726ac20d8 88 * @returns
MikamiUitOpen 16:cbb726ac20d8 89 * new file position on success,
MikamiUitOpen 16:cbb726ac20d8 90 * -1 on failure or unsupported
MikamiUitOpen 16:cbb726ac20d8 91 */
MikamiUitOpen 16:cbb726ac20d8 92 virtual off_t lseek(off_t offset, int whence) = 0;
MikamiUitOpen 16:cbb726ac20d8 93
MikamiUitOpen 16:cbb726ac20d8 94 /** Flush any buffers associated with the FileHandle, ensuring it
MikamiUitOpen 16:cbb726ac20d8 95 * is up to date on disk
MikamiUitOpen 16:cbb726ac20d8 96 *
MikamiUitOpen 16:cbb726ac20d8 97 * @returns
MikamiUitOpen 16:cbb726ac20d8 98 * 0 on success or un-needed,
MikamiUitOpen 16:cbb726ac20d8 99 * -1 on error
MikamiUitOpen 16:cbb726ac20d8 100 */
MikamiUitOpen 16:cbb726ac20d8 101 virtual int fsync() = 0;
MikamiUitOpen 16:cbb726ac20d8 102
MikamiUitOpen 16:cbb726ac20d8 103 virtual off_t flen() {
MikamiUitOpen 16:cbb726ac20d8 104 /* remember our current position */
MikamiUitOpen 16:cbb726ac20d8 105 off_t pos = lseek(0, SEEK_CUR);
MikamiUitOpen 16:cbb726ac20d8 106 if(pos == -1) return -1;
MikamiUitOpen 16:cbb726ac20d8 107 /* seek to the end to get the file length */
MikamiUitOpen 16:cbb726ac20d8 108 off_t res = lseek(0, SEEK_END);
MikamiUitOpen 16:cbb726ac20d8 109 /* return to our old position */
MikamiUitOpen 16:cbb726ac20d8 110 lseek(pos, SEEK_SET);
MikamiUitOpen 16:cbb726ac20d8 111 return res;
MikamiUitOpen 16:cbb726ac20d8 112 }
MikamiUitOpen 16:cbb726ac20d8 113
MikamiUitOpen 16:cbb726ac20d8 114 virtual ~FileHandle();
MikamiUitOpen 16:cbb726ac20d8 115 };
MikamiUitOpen 16:cbb726ac20d8 116
MikamiUitOpen 16:cbb726ac20d8 117 } // namespace mbed
MikamiUitOpen 16:cbb726ac20d8 118
MikamiUitOpen 16:cbb726ac20d8 119 #endif