Easy playback library for AUDIO_GRBoard.

Dependents:   GR-PEACH_Audio_WAV_PwmOut GR-Boards_Audio_WAV

Committer:
dkato
Date:
Tue Jul 24 08:45:30 2018 +0000
Revision:
2:6c46c61630b3
Parent:
1:fdd79b99ba73
Add PwmOutSpeaker to output

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:9956e2ed09da 1 /* mbed EasyDec_WavCnv2ch Library
dkato 0:9956e2ed09da 2 * Copyright (C) 2017 dkato
dkato 0:9956e2ed09da 3 *
dkato 0:9956e2ed09da 4 * Licensed under the Apache License, Version 2.0 (the "License");
dkato 0:9956e2ed09da 5 * you may not use this file except in compliance with the License.
dkato 0:9956e2ed09da 6 * You may obtain a copy of the License at
dkato 0:9956e2ed09da 7 *
dkato 0:9956e2ed09da 8 * http://www.apache.org/licenses/LICENSE-2.0
dkato 0:9956e2ed09da 9 *
dkato 0:9956e2ed09da 10 * Unless required by applicable law or agreed to in writing, software
dkato 0:9956e2ed09da 11 * distributed under the License is distributed on an "AS IS" BASIS,
dkato 0:9956e2ed09da 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dkato 0:9956e2ed09da 13 * See the License for the specific language governing permissions and
dkato 0:9956e2ed09da 14 * limitations under the License.
dkato 0:9956e2ed09da 15 */
dkato 0:9956e2ed09da 16
dkato 0:9956e2ed09da 17 /**************************************************************************//**
dkato 0:9956e2ed09da 18 * @file EasyDec_WavCnv2ch.h
dkato 0:9956e2ed09da 19 * @brief wav
dkato 0:9956e2ed09da 20 ******************************************************************************/
dkato 0:9956e2ed09da 21 #ifndef __EASY_DEC_WAV_CNV_2CH_H__
dkato 0:9956e2ed09da 22 #define __EASY_DEC_WAV_CNV_2CH_H__
dkato 0:9956e2ed09da 23
dkato 0:9956e2ed09da 24 #include "EasyDecoder.h"
dkato 0:9956e2ed09da 25
dkato 0:9956e2ed09da 26 /** A class to communicate a EasyDec_WavCnv2ch
dkato 0:9956e2ed09da 27 *
dkato 0:9956e2ed09da 28 */
dkato 0:9956e2ed09da 29 class EasyDec_WavCnv2ch : public EasyDecoder {
dkato 0:9956e2ed09da 30 public:
dkato 0:9956e2ed09da 31
dkato 0:9956e2ed09da 32 static inline EasyDecoder* inst() { return new EasyDec_WavCnv2ch; }
dkato 0:9956e2ed09da 33
dkato 0:9956e2ed09da 34 /** analyze header
dkato 0:9956e2ed09da 35 *
dkato 0:9956e2ed09da 36 * @param p_title title tag buffer
dkato 0:9956e2ed09da 37 * @param p_artist artist tag buffer
dkato 0:9956e2ed09da 38 * @param p_album album tag buffer
dkato 0:9956e2ed09da 39 * @param tag_size tag buffer size
dkato 0:9956e2ed09da 40 * @param fp file pointer
dkato 0:9956e2ed09da 41 * @return true = success, false = failure
dkato 0:9956e2ed09da 42 */
dkato 1:fdd79b99ba73 43 virtual bool AnalyzeHeder(char* p_title, char* p_artist, char* p_album, uint16_t tag_size, FILE* fp);
dkato 0:9956e2ed09da 44
dkato 0:9956e2ed09da 45 /** get next data
dkato 0:9956e2ed09da 46 *
dkato 0:9956e2ed09da 47 * @param buf data buffer address
dkato 0:9956e2ed09da 48 * @param len data buffer length
dkato 0:9956e2ed09da 49 * @return get data size
dkato 0:9956e2ed09da 50 */
dkato 1:fdd79b99ba73 51 virtual size_t GetNextData(void *buf, size_t len);
dkato 0:9956e2ed09da 52
dkato 0:9956e2ed09da 53 /** get channel
dkato 0:9956e2ed09da 54 *
dkato 0:9956e2ed09da 55 * @return channel
dkato 0:9956e2ed09da 56 */
dkato 1:fdd79b99ba73 57 virtual uint16_t GetChannel();
dkato 0:9956e2ed09da 58
dkato 0:9956e2ed09da 59 /** get block size
dkato 0:9956e2ed09da 60 *
dkato 0:9956e2ed09da 61 * @return block size
dkato 0:9956e2ed09da 62 */
dkato 1:fdd79b99ba73 63 virtual uint16_t GetBlockSize();
dkato 0:9956e2ed09da 64
dkato 0:9956e2ed09da 65 /** get sampling rate
dkato 0:9956e2ed09da 66 *
dkato 0:9956e2ed09da 67 * @return sampling rate
dkato 0:9956e2ed09da 68 */
dkato 1:fdd79b99ba73 69 virtual uint32_t GetSamplingRate();
dkato 0:9956e2ed09da 70
dkato 0:9956e2ed09da 71 private:
dkato 0:9956e2ed09da 72 FILE * wav_fp;
dkato 0:9956e2ed09da 73 uint32_t music_data_size;
dkato 0:9956e2ed09da 74 uint32_t music_data_index;
dkato 0:9956e2ed09da 75 uint16_t channel;
dkato 0:9956e2ed09da 76 uint16_t block_size;
dkato 0:9956e2ed09da 77 uint32_t sampling_rate;
dkato 0:9956e2ed09da 78 };
dkato 0:9956e2ed09da 79
dkato 0:9956e2ed09da 80 #endif