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_ANALOGOUT_H
MikamiUitOpen 16:cbb726ac20d8 17 #define MBED_ANALOGOUT_H
MikamiUitOpen 16:cbb726ac20d8 18
MikamiUitOpen 16:cbb726ac20d8 19 #include "platform.h"
MikamiUitOpen 16:cbb726ac20d8 20
MikamiUitOpen 16:cbb726ac20d8 21 #if DEVICE_ANALOGOUT
MikamiUitOpen 16:cbb726ac20d8 22
MikamiUitOpen 16:cbb726ac20d8 23 #include "analogout_api.h"
MikamiUitOpen 16:cbb726ac20d8 24
MikamiUitOpen 16:cbb726ac20d8 25 namespace mbed {
MikamiUitOpen 16:cbb726ac20d8 26
MikamiUitOpen 16:cbb726ac20d8 27 /** An analog output, used for setting the voltage on a pin
MikamiUitOpen 16:cbb726ac20d8 28 *
MikamiUitOpen 16:cbb726ac20d8 29 * Example:
MikamiUitOpen 16:cbb726ac20d8 30 * @code
MikamiUitOpen 16:cbb726ac20d8 31 * // Make a sawtooth output
MikamiUitOpen 16:cbb726ac20d8 32 *
MikamiUitOpen 16:cbb726ac20d8 33 * #include "mbed.h"
MikamiUitOpen 16:cbb726ac20d8 34 *
MikamiUitOpen 16:cbb726ac20d8 35 * AnalogOut tri(p18);
MikamiUitOpen 16:cbb726ac20d8 36 * int main() {
MikamiUitOpen 16:cbb726ac20d8 37 * while(1) {
MikamiUitOpen 16:cbb726ac20d8 38 * tri = tri + 0.01;
MikamiUitOpen 16:cbb726ac20d8 39 * wait_us(1);
MikamiUitOpen 16:cbb726ac20d8 40 * if(tri == 1) {
MikamiUitOpen 16:cbb726ac20d8 41 * tri = 0;
MikamiUitOpen 16:cbb726ac20d8 42 * }
MikamiUitOpen 16:cbb726ac20d8 43 * }
MikamiUitOpen 16:cbb726ac20d8 44 * }
MikamiUitOpen 16:cbb726ac20d8 45 * @endcode
MikamiUitOpen 16:cbb726ac20d8 46 */
MikamiUitOpen 16:cbb726ac20d8 47 class AnalogOut {
MikamiUitOpen 16:cbb726ac20d8 48
MikamiUitOpen 16:cbb726ac20d8 49 public:
MikamiUitOpen 16:cbb726ac20d8 50
MikamiUitOpen 16:cbb726ac20d8 51 /** Create an AnalogOut connected to the specified pin
MikamiUitOpen 16:cbb726ac20d8 52 *
MikamiUitOpen 16:cbb726ac20d8 53 * @param AnalogOut pin to connect to (18)
MikamiUitOpen 16:cbb726ac20d8 54 */
MikamiUitOpen 16:cbb726ac20d8 55 AnalogOut(PinName pin) {
MikamiUitOpen 16:cbb726ac20d8 56 analogout_init(&_dac, pin);
MikamiUitOpen 16:cbb726ac20d8 57 }
MikamiUitOpen 16:cbb726ac20d8 58
MikamiUitOpen 16:cbb726ac20d8 59 /** Set the output voltage, specified as a percentage (float)
MikamiUitOpen 16:cbb726ac20d8 60 *
MikamiUitOpen 16:cbb726ac20d8 61 * @param value A floating-point value representing the output voltage,
MikamiUitOpen 16:cbb726ac20d8 62 * specified as a percentage. The value should lie between
MikamiUitOpen 16:cbb726ac20d8 63 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
MikamiUitOpen 16:cbb726ac20d8 64 * Values outside this range will be saturated to 0.0f or 1.0f.
MikamiUitOpen 16:cbb726ac20d8 65 */
MikamiUitOpen 16:cbb726ac20d8 66 void write(float value) {
MikamiUitOpen 16:cbb726ac20d8 67 analogout_write(&_dac, value);
MikamiUitOpen 16:cbb726ac20d8 68 }
MikamiUitOpen 16:cbb726ac20d8 69
MikamiUitOpen 16:cbb726ac20d8 70 /** Set the output voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
MikamiUitOpen 16:cbb726ac20d8 71 *
MikamiUitOpen 16:cbb726ac20d8 72 * @param value 16-bit unsigned short representing the output voltage,
MikamiUitOpen 16:cbb726ac20d8 73 * normalised to a 16-bit value (0x0000 = 0v, 0xFFFF = 3.3v)
MikamiUitOpen 16:cbb726ac20d8 74 */
MikamiUitOpen 16:cbb726ac20d8 75 void write_u16(unsigned short value) {
MikamiUitOpen 16:cbb726ac20d8 76 analogout_write_u16(&_dac, value);
MikamiUitOpen 16:cbb726ac20d8 77 }
MikamiUitOpen 16:cbb726ac20d8 78
MikamiUitOpen 16:cbb726ac20d8 79 /** Return the current output voltage setting, measured as a percentage (float)
MikamiUitOpen 16:cbb726ac20d8 80 *
MikamiUitOpen 16:cbb726ac20d8 81 * @returns
MikamiUitOpen 16:cbb726ac20d8 82 * A floating-point value representing the current voltage being output on the pin,
MikamiUitOpen 16:cbb726ac20d8 83 * measured as a percentage. The returned value will lie between
MikamiUitOpen 16:cbb726ac20d8 84 * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%).
MikamiUitOpen 16:cbb726ac20d8 85 *
MikamiUitOpen 16:cbb726ac20d8 86 * @note
MikamiUitOpen 16:cbb726ac20d8 87 * This value may not match exactly the value set by a previous write().
MikamiUitOpen 16:cbb726ac20d8 88 */
MikamiUitOpen 16:cbb726ac20d8 89 float read() {
MikamiUitOpen 16:cbb726ac20d8 90 return analogout_read(&_dac);
MikamiUitOpen 16:cbb726ac20d8 91 }
MikamiUitOpen 16:cbb726ac20d8 92
MikamiUitOpen 16:cbb726ac20d8 93 #ifdef MBED_OPERATORS
MikamiUitOpen 16:cbb726ac20d8 94 /** An operator shorthand for write()
MikamiUitOpen 16:cbb726ac20d8 95 */
MikamiUitOpen 16:cbb726ac20d8 96 AnalogOut& operator= (float percent) {
MikamiUitOpen 16:cbb726ac20d8 97 write(percent);
MikamiUitOpen 16:cbb726ac20d8 98 return *this;
MikamiUitOpen 16:cbb726ac20d8 99 }
MikamiUitOpen 16:cbb726ac20d8 100
MikamiUitOpen 16:cbb726ac20d8 101 AnalogOut& operator= (AnalogOut& rhs) {
MikamiUitOpen 16:cbb726ac20d8 102 write(rhs.read());
MikamiUitOpen 16:cbb726ac20d8 103 return *this;
MikamiUitOpen 16:cbb726ac20d8 104 }
MikamiUitOpen 16:cbb726ac20d8 105
MikamiUitOpen 16:cbb726ac20d8 106 /** An operator shorthand for read()
MikamiUitOpen 16:cbb726ac20d8 107 */
MikamiUitOpen 16:cbb726ac20d8 108 operator float() {
MikamiUitOpen 16:cbb726ac20d8 109 return read();
MikamiUitOpen 16:cbb726ac20d8 110 }
MikamiUitOpen 16:cbb726ac20d8 111 #endif
MikamiUitOpen 16:cbb726ac20d8 112
MikamiUitOpen 16:cbb726ac20d8 113 protected:
MikamiUitOpen 16:cbb726ac20d8 114 dac_t _dac;
MikamiUitOpen 16:cbb726ac20d8 115 };
MikamiUitOpen 16:cbb726ac20d8 116
MikamiUitOpen 16:cbb726ac20d8 117 } // namespace mbed
MikamiUitOpen 16:cbb726ac20d8 118
MikamiUitOpen 16:cbb726ac20d8 119 #endif
MikamiUitOpen 16:cbb726ac20d8 120
MikamiUitOpen 16:cbb726ac20d8 121 #endif