Easy playback library for AUDIO_GRBoard.
Dependents: GR-PEACH_Audio_WAV_PwmOut GR-Boards_Audio_WAV
EasyPlayback.h@1:fdd79b99ba73, 2018-07-03 (annotated)
- Committer:
- dkato
- Date:
- Tue Jul 03 05:12:29 2018 +0000
- Revision:
- 1:fdd79b99ba73
- Parent:
- 0:9956e2ed09da
- Child:
- 2:6c46c61630b3
Add decoder EasyDec_Mov
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:9956e2ed09da | 1 | /* mbed EasyPlayback 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 | #ifndef __EASY_PLAYBACK_H__ |
dkato | 0:9956e2ed09da | 18 | #define __EASY_PLAYBACK_H__ |
dkato | 0:9956e2ed09da | 19 | |
dkato | 0:9956e2ed09da | 20 | #include <string> |
dkato | 0:9956e2ed09da | 21 | #include <map> |
dkato | 0:9956e2ed09da | 22 | #include "EasyDecoder.h" |
dkato | 0:9956e2ed09da | 23 | #include "AUDIO_GRBoard.h" |
dkato | 1:fdd79b99ba73 | 24 | #include "FATFileSystem.h" |
dkato | 0:9956e2ed09da | 25 | |
dkato | 0:9956e2ed09da | 26 | class EasyPlayback |
dkato | 0:9956e2ed09da | 27 | { |
dkato | 0:9956e2ed09da | 28 | public: |
dkato | 1:fdd79b99ba73 | 29 | typedef enum { |
dkato | 1:fdd79b99ba73 | 30 | AUDIO_TPYE_SSIF, |
dkato | 1:fdd79b99ba73 | 31 | AUDIO_TPYE_SPDIF |
dkato | 1:fdd79b99ba73 | 32 | } audio_type_t; |
dkato | 1:fdd79b99ba73 | 33 | |
dkato | 1:fdd79b99ba73 | 34 | EasyPlayback(audio_type_t type = AUDIO_TPYE_SSIF); |
dkato | 0:9956e2ed09da | 35 | ~EasyPlayback(); |
dkato | 0:9956e2ed09da | 36 | bool get_tag(const char* filename, char* p_title, char* p_artist, char* p_album, uint16_t tag_size); |
dkato | 0:9956e2ed09da | 37 | bool play(const char* filename); |
dkato | 0:9956e2ed09da | 38 | bool is_paused(void); |
dkato | 0:9956e2ed09da | 39 | void pause(void); |
dkato | 0:9956e2ed09da | 40 | void pause(bool type); |
dkato | 0:9956e2ed09da | 41 | void skip(void); |
dkato | 0:9956e2ed09da | 42 | bool outputVolume(float VolumeOut); |
dkato | 0:9956e2ed09da | 43 | |
dkato | 0:9956e2ed09da | 44 | template<typename T> |
dkato | 0:9956e2ed09da | 45 | void add_decoder(const string& extension) { |
dkato | 0:9956e2ed09da | 46 | m_lpDecoders[extension] = &T::inst; |
dkato | 0:9956e2ed09da | 47 | } |
dkato | 0:9956e2ed09da | 48 | |
dkato | 0:9956e2ed09da | 49 | private: |
dkato | 0:9956e2ed09da | 50 | #define AUDIO_WRITE_BUFF_NUM (8) |
dkato | 0:9956e2ed09da | 51 | #define AUDIO_MSK_RING_BUFF (AUDIO_WRITE_BUFF_NUM - 1) |
dkato | 1:fdd79b99ba73 | 52 | AUDIO_GRBoard * _audio_ssif; |
dkato | 1:fdd79b99ba73 | 53 | AUDIO_RBSP * _audio; |
dkato | 0:9956e2ed09da | 54 | int _buff_index; |
dkato | 1:fdd79b99ba73 | 55 | audio_type_t _type; |
dkato | 0:9956e2ed09da | 56 | bool _skip; |
dkato | 0:9956e2ed09da | 57 | bool _pause; |
dkato | 0:9956e2ed09da | 58 | bool _init_end; |
dkato | 1:fdd79b99ba73 | 59 | uint32_t _audio_buff_size; |
dkato | 0:9956e2ed09da | 60 | uint8_t *_heap_buf; |
dkato | 1:fdd79b99ba73 | 61 | uint8_t *_audio_buf; |
dkato | 0:9956e2ed09da | 62 | std::map<std::string, EasyDecoder*(*)()> m_lpDecoders; |
dkato | 0:9956e2ed09da | 63 | |
dkato | 0:9956e2ed09da | 64 | EasyDecoder * create_decoer_class(const char* filename); |
dkato | 0:9956e2ed09da | 65 | }; |
dkato | 0:9956e2ed09da | 66 | |
dkato | 0:9956e2ed09da | 67 | #endif |