Easy playback library for PwmOutSpeaker.

Committer:
dkato
Date:
Thu Jul 06 04:42:29 2017 +0000
Revision:
0:41ab76b22961
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:41ab76b22961 1 /* mbed EasyPlaybackPWM Library
dkato 0:41ab76b22961 2 * Copyright (C) 2017 dkato
dkato 0:41ab76b22961 3 *
dkato 0:41ab76b22961 4 * Licensed under the Apache License, Version 2.0 (the "License");
dkato 0:41ab76b22961 5 * you may not use this file except in compliance with the License.
dkato 0:41ab76b22961 6 * You may obtain a copy of the License at
dkato 0:41ab76b22961 7 *
dkato 0:41ab76b22961 8 * http://www.apache.org/licenses/LICENSE-2.0
dkato 0:41ab76b22961 9 *
dkato 0:41ab76b22961 10 * Unless required by applicable law or agreed to in writing, software
dkato 0:41ab76b22961 11 * distributed under the License is distributed on an "AS IS" BASIS,
dkato 0:41ab76b22961 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dkato 0:41ab76b22961 13 * See the License for the specific language governing permissions and
dkato 0:41ab76b22961 14 * limitations under the License.
dkato 0:41ab76b22961 15 */
dkato 0:41ab76b22961 16
dkato 0:41ab76b22961 17 #ifndef __EASY_PLAYBACK_PWM_H__
dkato 0:41ab76b22961 18 #define __EASY_PLAYBACK_PWM_H__
dkato 0:41ab76b22961 19
dkato 0:41ab76b22961 20 #include <string>
dkato 0:41ab76b22961 21 #include <map>
dkato 0:41ab76b22961 22 #include "EasyDecoder.h"
dkato 0:41ab76b22961 23 #include "PwmOutSpeaker.h"
dkato 0:41ab76b22961 24
dkato 0:41ab76b22961 25 class EasyPlaybackPWM
dkato 0:41ab76b22961 26 {
dkato 0:41ab76b22961 27 public:
dkato 0:41ab76b22961 28 EasyPlaybackPWM(PinName pwm_l, PinName pwm_r);
dkato 0:41ab76b22961 29 ~EasyPlaybackPWM();
dkato 0:41ab76b22961 30 bool get_tag(const char* filename, char* p_title, char* p_artist, char* p_album, uint16_t tag_size);
dkato 0:41ab76b22961 31 bool play(const char* filename);
dkato 0:41ab76b22961 32 bool is_paused(void);
dkato 0:41ab76b22961 33 void pause(void);
dkato 0:41ab76b22961 34 void pause(bool type);
dkato 0:41ab76b22961 35 void skip(void);
dkato 0:41ab76b22961 36 bool outputVolume(float VolumeOut);
dkato 0:41ab76b22961 37
dkato 0:41ab76b22961 38 template<typename T>
dkato 0:41ab76b22961 39 void add_decoder(const string& extension) {
dkato 0:41ab76b22961 40 m_lpDecoders[extension] = &T::inst;
dkato 0:41ab76b22961 41 }
dkato 0:41ab76b22961 42
dkato 0:41ab76b22961 43 private:
dkato 0:41ab76b22961 44 #define AUDIO_WRITE_BUFF_SIZE (4096)
dkato 0:41ab76b22961 45 PwmOutSpeaker audio;
dkato 0:41ab76b22961 46 bool _skip;
dkato 0:41ab76b22961 47 bool _pause;
dkato 0:41ab76b22961 48 uint8_t *_audio_buf;
dkato 0:41ab76b22961 49 std::map<std::string, EasyDecoder*(*)()> m_lpDecoders;
dkato 0:41ab76b22961 50
dkato 0:41ab76b22961 51 EasyDecoder * create_decoer_class(const char* filename);
dkato 0:41ab76b22961 52 };
dkato 0:41ab76b22961 53
dkato 0:41ab76b22961 54 #endif