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 #include "Stream.h"
MikamiUitOpen 16:cbb726ac20d8 17
MikamiUitOpen 16:cbb726ac20d8 18 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 19
MikamiUitOpen 16:cbb726ac20d8 20 Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
MikamiUitOpen 16:cbb726ac20d8 21 /* open ourselves */
MikamiUitOpen 16:cbb726ac20d8 22 char buf[12]; /* :0x12345678 + null byte */
MikamiUitOpen 16:cbb726ac20d8 23 std::sprintf(buf, ":%p", this);
MikamiUitOpen 16:cbb726ac20d8 24 _file = std::fopen(buf, "w+");
MikamiUitOpen 16:cbb726ac20d8 25 mbed_set_unbuffered_stream(_file);
MikamiUitOpen 16:cbb726ac20d8 26 }
MikamiUitOpen 16:cbb726ac20d8 27
MikamiUitOpen 16:cbb726ac20d8 28 Stream::~Stream() {
MikamiUitOpen 16:cbb726ac20d8 29 fclose(_file);
MikamiUitOpen 16:cbb726ac20d8 30 }
MikamiUitOpen 16:cbb726ac20d8 31
MikamiUitOpen 16:cbb726ac20d8 32 int Stream::putc(int c) {
MikamiUitOpen 16:cbb726ac20d8 33 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 34 return std::fputc(c, _file);
MikamiUitOpen 16:cbb726ac20d8 35 }
MikamiUitOpen 16:cbb726ac20d8 36 int Stream::puts(const char *s) {
MikamiUitOpen 16:cbb726ac20d8 37 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 38 return std::fputs(s, _file);
MikamiUitOpen 16:cbb726ac20d8 39 }
MikamiUitOpen 16:cbb726ac20d8 40 int Stream::getc() {
MikamiUitOpen 16:cbb726ac20d8 41 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 42 return mbed_getc(_file);
MikamiUitOpen 16:cbb726ac20d8 43 }
MikamiUitOpen 16:cbb726ac20d8 44 char* Stream::gets(char *s, int size) {
MikamiUitOpen 16:cbb726ac20d8 45 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 46 return mbed_gets(s,size,_file);
MikamiUitOpen 16:cbb726ac20d8 47 }
MikamiUitOpen 16:cbb726ac20d8 48
MikamiUitOpen 16:cbb726ac20d8 49 int Stream::close() {
MikamiUitOpen 16:cbb726ac20d8 50 return 0;
MikamiUitOpen 16:cbb726ac20d8 51 }
MikamiUitOpen 16:cbb726ac20d8 52
MikamiUitOpen 16:cbb726ac20d8 53 ssize_t Stream::write(const void* buffer, size_t length) {
MikamiUitOpen 16:cbb726ac20d8 54 const char* ptr = (const char*)buffer;
MikamiUitOpen 16:cbb726ac20d8 55 const char* end = ptr + length;
MikamiUitOpen 16:cbb726ac20d8 56 while (ptr != end) {
MikamiUitOpen 16:cbb726ac20d8 57 if (_putc(*ptr++) == EOF) {
MikamiUitOpen 16:cbb726ac20d8 58 break;
MikamiUitOpen 16:cbb726ac20d8 59 }
MikamiUitOpen 16:cbb726ac20d8 60 }
MikamiUitOpen 16:cbb726ac20d8 61 return ptr - (const char*)buffer;
MikamiUitOpen 16:cbb726ac20d8 62 }
MikamiUitOpen 16:cbb726ac20d8 63
MikamiUitOpen 16:cbb726ac20d8 64 ssize_t Stream::read(void* buffer, size_t length) {
MikamiUitOpen 16:cbb726ac20d8 65 char* ptr = (char*)buffer;
MikamiUitOpen 16:cbb726ac20d8 66 char* end = ptr + length;
MikamiUitOpen 16:cbb726ac20d8 67 while (ptr != end) {
MikamiUitOpen 16:cbb726ac20d8 68 int c = _getc();
MikamiUitOpen 16:cbb726ac20d8 69 if (c==EOF) break;
MikamiUitOpen 16:cbb726ac20d8 70 *ptr++ = c;
MikamiUitOpen 16:cbb726ac20d8 71 }
MikamiUitOpen 16:cbb726ac20d8 72 return ptr - (const char*)buffer;
MikamiUitOpen 16:cbb726ac20d8 73 }
MikamiUitOpen 16:cbb726ac20d8 74
MikamiUitOpen 16:cbb726ac20d8 75 off_t Stream::lseek(off_t offset, int whence) {
MikamiUitOpen 16:cbb726ac20d8 76 return 0;
MikamiUitOpen 16:cbb726ac20d8 77 }
MikamiUitOpen 16:cbb726ac20d8 78
MikamiUitOpen 16:cbb726ac20d8 79 int Stream::isatty() {
MikamiUitOpen 16:cbb726ac20d8 80 return 0;
MikamiUitOpen 16:cbb726ac20d8 81 }
MikamiUitOpen 16:cbb726ac20d8 82
MikamiUitOpen 16:cbb726ac20d8 83 int Stream::fsync() {
MikamiUitOpen 16:cbb726ac20d8 84 return 0;
MikamiUitOpen 16:cbb726ac20d8 85 }
MikamiUitOpen 16:cbb726ac20d8 86
MikamiUitOpen 16:cbb726ac20d8 87 off_t Stream::flen() {
MikamiUitOpen 16:cbb726ac20d8 88 return 0;
MikamiUitOpen 16:cbb726ac20d8 89 }
MikamiUitOpen 16:cbb726ac20d8 90
MikamiUitOpen 16:cbb726ac20d8 91 int Stream::printf(const char* format, ...) {
MikamiUitOpen 16:cbb726ac20d8 92 std::va_list arg;
MikamiUitOpen 16:cbb726ac20d8 93 va_start(arg, format);
MikamiUitOpen 16:cbb726ac20d8 94 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 95 int r = vfprintf(_file, format, arg);
MikamiUitOpen 16:cbb726ac20d8 96 va_end(arg);
MikamiUitOpen 16:cbb726ac20d8 97 return r;
MikamiUitOpen 16:cbb726ac20d8 98 }
MikamiUitOpen 16:cbb726ac20d8 99
MikamiUitOpen 16:cbb726ac20d8 100 int Stream::scanf(const char* format, ...) {
MikamiUitOpen 16:cbb726ac20d8 101 std::va_list arg;
MikamiUitOpen 16:cbb726ac20d8 102 va_start(arg, format);
MikamiUitOpen 16:cbb726ac20d8 103 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 104 int r = vfscanf(_file, format, arg);
MikamiUitOpen 16:cbb726ac20d8 105 va_end(arg);
MikamiUitOpen 16:cbb726ac20d8 106 return r;
MikamiUitOpen 16:cbb726ac20d8 107 }
MikamiUitOpen 16:cbb726ac20d8 108
MikamiUitOpen 16:cbb726ac20d8 109 int Stream::vprintf(const char* format, std::va_list args) {
MikamiUitOpen 16:cbb726ac20d8 110 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 111 int r = vfprintf(_file, format, args);
MikamiUitOpen 16:cbb726ac20d8 112 return r;
MikamiUitOpen 16:cbb726ac20d8 113 }
MikamiUitOpen 16:cbb726ac20d8 114
MikamiUitOpen 16:cbb726ac20d8 115 int Stream::vscanf(const char* format, std::va_list args) {
MikamiUitOpen 16:cbb726ac20d8 116 fflush(_file);
MikamiUitOpen 16:cbb726ac20d8 117 int r = vfscanf(_file, format, args);
MikamiUitOpen 16:cbb726ac20d8 118 return r;
MikamiUitOpen 16:cbb726ac20d8 119 }
MikamiUitOpen 16:cbb726ac20d8 120
MikamiUitOpen 16:cbb726ac20d8 121 } // namespace mbed