Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: GR-PEACH_Audio_WAV_PwmOut GR-Boards_Audio_WAV
Revision 2:6c46c61630b3, committed 2018-07-24
- Comitter:
- dkato
- Date:
- Tue Jul 24 08:45:30 2018 +0000
- Parent:
- 1:fdd79b99ba73
- Commit message:
- Add PwmOutSpeaker to output
Changed in this revision
| EasyPlayback.cpp | Show annotated file Show diff for this revision Revisions of this file |
| EasyPlayback.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/EasyPlayback.cpp Tue Jul 03 05:12:29 2018 +0000
+++ b/EasyPlayback.cpp Tue Jul 24 08:45:30 2018 +0000
@@ -18,14 +18,19 @@
#include "dcache-control.h"
#include "EasyPlayback.h"
-EasyPlayback::EasyPlayback(audio_type_t type) :
+EasyPlayback::EasyPlayback(audio_type_t type, PinName pin1, PinName pin2) :
_buff_index(0), _type(type), _skip(false), _pause(false), _init_end(false)
{
_audio_ssif = NULL;
+ _audio_pwm = NULL;
if (_type == AUDIO_TPYE_SSIF) {
_audio_buff_size = 4096;
_audio_ssif = new AUDIO_GRBoard(0x80, (AUDIO_WRITE_BUFF_NUM - 1), 0);
_audio = _audio_ssif;
+ } else if (_type == AUDIO_TPYE_PWM) {
+ _audio_buff_size = 4096;
+ _audio_pwm = new PwmOutSpeaker(pin1, pin2);
+ _audio = _audio_pwm;
} else if (_type == AUDIO_TPYE_SPDIF) {
MBED_ASSERT(false);
} else {
@@ -40,11 +45,9 @@
if (_audio_ssif != NULL) {
delete _audio_ssif;
}
-#if (R_BSP_SPDIF_ENABLE == 1)
- if (_audio_spdif != NULL) {
- delete _audio_spdif;
+ if (_audio_pwm != NULL) {
+ delete _audio_pwm;
}
-#endif
delete [] _heap_buf;
}
--- a/EasyPlayback.h Tue Jul 03 05:12:29 2018 +0000
+++ b/EasyPlayback.h Tue Jul 24 08:45:30 2018 +0000
@@ -21,6 +21,7 @@
#include <map>
#include "EasyDecoder.h"
#include "AUDIO_GRBoard.h"
+#include "PwmOutSpeaker.h"
#include "FATFileSystem.h"
class EasyPlayback
@@ -28,10 +29,11 @@
public:
typedef enum {
AUDIO_TPYE_SSIF,
+ AUDIO_TPYE_PWM,
AUDIO_TPYE_SPDIF
} audio_type_t;
- EasyPlayback(audio_type_t type = AUDIO_TPYE_SSIF);
+ EasyPlayback(audio_type_t type = AUDIO_TPYE_SSIF, PinName pin1 = NC, PinName pin2 = NC);
~EasyPlayback();
bool get_tag(const char* filename, char* p_title, char* p_artist, char* p_album, uint16_t tag_size);
bool play(const char* filename);
@@ -50,6 +52,7 @@
#define AUDIO_WRITE_BUFF_NUM (8)
#define AUDIO_MSK_RING_BUFF (AUDIO_WRITE_BUFF_NUM - 1)
AUDIO_GRBoard * _audio_ssif;
+ PwmOutSpeaker * _audio_pwm;
AUDIO_RBSP * _audio;
int _buff_index;
audio_type_t _type;